From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.56]) by mx.groups.io with SMTP id smtpd.web11.8127.1659712493987442406 for ; Fri, 05 Aug 2022 08:14:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nvidia.com header.s=selector2 header.b=crZtZj4n; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.93.56, mailfrom: jbrasen@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mB7DSRtxePxlwQ2u27oQynjCQRtFUGKctZbhf9jtKUVsEllHDZN5brkNK7mpDQseRAgtn1oPSFZxUAMVfWQkny8j/3MhsrXklIm2/zhHS2sHuclKXziqwN0czLHgUjNu/afnJ3sE0XtUw/U3GqPrjLzUIRhgFxJIq+G7Z3xIWT1VyrM+k0o0ziIvf7w2iwtKKb7lcT3LMvrYmob1KUO590SzLO5LBZIBQC7NAXD3KBEjXuocDcy7oUH063XTNMURDucrYfYS2T6UKWMVCP4ZD0we9tbGNd2qvlmn76CjCy03y4kVRDFNOP5UZWuDR1P07vEqL7XMTFf1eNJl/r77SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MzS+X3Xr+OX4EYobQtVw+O/8i5C50mU7bWthiqqgP1Y=; b=RK1HDQEh0H/5urgDaHp/sSiEO7oHtKYx1xqH97MUmzyT2R9LD2pkqml2SAfTDqMq3bcgV4HsRM1j0yKmJIQyjHOhtywe4uhnX94nWv/qE/78juNhML+pDFhey0arGfBEgesA7fq/0CZP2bHOWusip75xTZDi61CIx1wRoumvveRkjjesQOGy+a06RUAwhSWXzPKmq1HRccQdtW8uNYR6Bo68g5pMKpaxb7qYjTX8tvxw1MkJoXRdZe3RRK8VaMJiQfXpBCoP5V4Di5vV44Nbz2yN09RrbncCp5ny3dxo78dxaJOjRUCya0Glo1B1jyoompMIjSNYOi7+K3yXZjTw9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=arm.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MzS+X3Xr+OX4EYobQtVw+O/8i5C50mU7bWthiqqgP1Y=; b=crZtZj4noKiS8FIK6SHZv3srkyMTKMVGhXmXZmJlSq+qOt+L4B/au2geY3n6+yJ2wPUTYYX+x7O4MVUZq/Li+g6VQUY5YP8ID06l2aDGLJuaASr6MP+jVrRmN5DGboTWwOfGWXAfJDYDpTQqKzTex4eYHIdQ4WTPieD6YF0WUhu4k4AvMvMmT2kTE/ld10pxM6iYCHjIi21YaQSCZk6FE9I7tIcvPTbC+Gii6Wvp+j1sZgksD+Giz90w0zbV4NIPhQ0i5eYfgymrOdoepFhDqLc02SqnQtNaULyM5xKfkO7wmOD5FcOaX6qWTaDgwL0tT6a2rhpmg7ylv6XLwdg8vA== Received: from BN0PR03CA0019.namprd03.prod.outlook.com (2603:10b6:408:e6::24) by CH2PR12MB4922.namprd12.prod.outlook.com (2603:10b6:610:65::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Fri, 5 Aug 2022 15:14:52 +0000 Received: from BN8NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e6:cafe::cb) by BN0PR03CA0019.outlook.office365.com (2603:10b6:408:e6::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16 via Frontend Transport; Fri, 5 Aug 2022 15:14:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.238) by BN8NAM11FT006.mail.protection.outlook.com (10.13.177.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5504.14 via Frontend Transport; Fri, 5 Aug 2022 15:14:51 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 5 Aug 2022 15:14:48 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 5 Aug 2022 08:14:48 -0700 Received: from 455d231bdffa.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.26 via Frontend Transport; Fri, 5 Aug 2022 08:14:47 -0700 From: "Jeff Brasen" To: CC: , , Jeff Brasen Subject: [PATCH] DynamicTablesPkg: Add support to build _DSD Date: Fri, 5 Aug 2022 09:14:48 -0600 Message-ID: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-NVConfidentiality: public Return-Path: jbrasen@nvidia.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 35a1d7a2-a92b-4071-8f62-08da76f53e8b X-MS-TrafficTypeDiagnostic: CH2PR12MB4922:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vIqAcvhA8NXcRbz8F9UGr4myDl11purwVq4BRCe9zxjhh2GVkyIVbTmesIxHSrlJ4YBjP2Xxh+o7sTcLmUmSbPMdVER24FRNKf2kpASoTNkYyXFnJW9uhvyUZ9ILujLMo5mwJIkZXlqOCz1GoyATLyI/wy8x/enr4nawfZ19bC9U7ZOUE8cOuZCGiwakgLtDPBTqGMG9WraTnnTgPuL8vtmasknutdUm9rCfVfX2wlPgP56t/ob4n11V96fN24io7HMgz9sl2oAEi7+av6jYDdWOVrTwBzm4ivNLaN5mWXorpyJhNDy+LGtkL5MUrHZR+Wt25ozvBGGMDNSI3nku8t4qk3YDzSX4sbaS9oqB6XG3zIOmZ6yJlL90OQXYiYbkVwCNwX/BZaWKa8AePHC1i3B7hwMGG3kFvPPid5jnWM1kYje6khqe6a7drUCCdLSI209sUABWqqzOLs5CGg9DCCrpN3yfG5i0ukwklRKcCJYxJK8qcV5gBmiRY9iRjS1u1y75Mtu67LdjASI57iVwIL6W7CbCJDsn9ttohHaoxPM5cic8WdsCDy4VEM7qJUD9Zp1svQocDHJmhpHPYCjpcUiJA2tW7bivc5DyBHEnjjFy3SVj4FvMoB8DaQRLntGzlluXHX/NY5qL9fQqGeXGzV6bOu53M/qQnhnqfWWq1FFzGPmcMfFkjgks6AnLwOV8RNxwZfoQEeQpM+PMvSGUak7GpOrwlTMLlGwom0hx2rQaYubXb+JokQKtSKAxdBZF5qytGCqsj/2kfB9GqdBdgR3k7m52DoDS0NPwJrTlvc63wJtfS4226IeB2KhnM9DkEoVlNAQd+nIn98R7Vr9USw== X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230016)(4636009)(376002)(136003)(396003)(346002)(39860400002)(36840700001)(40470700004)(46966006)(316002)(6916009)(36860700001)(82310400005)(54906003)(478600001)(36756003)(70586007)(8936002)(5660300002)(19627235002)(70206006)(8676002)(2616005)(107886003)(7696005)(41300700001)(26005)(4326008)(40460700003)(47076005)(2906002)(426003)(81166007)(356005)(40480700001)(83380400001)(86362001)(82740400003)(336012)(186003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2022 15:14:51.3026 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35a1d7a2-a92b-4071-8f62-08da76f53e8b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4922 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Add APIs needed to build _DSD with different UUIDs.=0D This is per ACPI specification 6.4 s6.2.5.=0D =0D Adds support for building data packages with format=0D Package {"Name", Integer}=0D =0D Signed-off-by: Jeff Brasen =0D ---=0D .../Include/Library/AmlLib/AmlLib.h | 50 ++++=0D .../Common/AmlLib/CodeGen/AmlCodeGen.c | 236 ++++++++++++++++++=0D 2 files changed, 286 insertions(+)=0D =0D diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h=0D index 6f214c0dfa..30cab3f6bb 100644=0D --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h=0D +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h=0D @@ -1280,6 +1280,56 @@ AmlAddLpiState (=0D IN AML_OBJECT_NODE_HANDLE LpiNode=0D );=0D =0D +/** AML code generation for a _DSD device data object.=0D +=0D + AmlAddDeviceDataDescriptorPackage (Uuid, ParentNode, NewObjectNode) is=0D + equivalent of the following ASL code:=0D + ToUUID(Uuid),=0D + Package () {}=0D +=0D + @ingroup CodeGenApis=0D +=0D + @param [in] Uuid The Uuid of the descriptor to be created=0D + @param [in] DsdNode Node of the DSD Package.=0D + @param [out] PackageNode If success, contains the created package nod= e.=0D +=0D + @retval EFI_SUCCESS Success.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +AmlAddDeviceDataDescriptorPackage (=0D + IN CONST EFI_GUID *Uuid,=0D + IN AML_OBJECT_NODE_HANDLE DsdNode,=0D + OUT AML_OBJECT_NODE_HANDLE *PackageNode=0D + );=0D +=0D +/** AML code generation to add a package with a name and value,=0D + * to a parent package=0D +=0D + AmlAddNameValuePackage ("Name", Value, ParentNode) is=0D + equivalent of the following ASL code:=0D + Package (2) {"Name", Value}=0D +=0D + @ingroup CodeGenApis=0D +=0D + @param [in] Name String to place in first entry of package=0D + @param [in] Value Integer to place in second entry of package= =0D + @param [in] PackageNode Package to add new sub package to.=0D +=0D + @retval EFI_SUCCESS Success.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +AmlAddNameIntegerPackage (=0D + IN CHAR8 *Name,=0D + IN UINT64 Value,=0D + IN AML_OBJECT_NODE_HANDLE PackageNode=0D + );=0D +=0D // DEPRECATED APIS=0D #ifndef DISABLE_NEW_DEPRECATED_INTERFACES=0D =0D diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c=0D index e51d2dd7f0..80e43d0e62 100644=0D --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c=0D +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c=0D @@ -2600,3 +2600,239 @@ error_handler:=0D =0D return Status;=0D }=0D +=0D +/** AML code generation for a _DSD device data object.=0D +=0D + AmlAddDeviceDataDescriptorPackage (Uuid, ParentNode, NewObjectNode) is=0D + equivalent of the following ASL code:=0D + ToUUID(Uuid),=0D + Package () {}=0D +=0D + @ingroup CodeGenApis=0D +=0D + @param [in] Uuid The Uuid of the descriptor to be created=0D + @param [in] DsdNode Node of the DSD Package.=0D + @param [out] PackageNode If success, contains the created package nod= e.=0D +=0D + @retval EFI_SUCCESS Success.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +AmlAddDeviceDataDescriptorPackage (=0D + IN CONST EFI_GUID *Uuid,=0D + IN AML_OBJECT_NODE_HANDLE DsdNode,=0D + OUT AML_OBJECT_NODE_HANDLE *PackageNode=0D + )=0D +{=0D + EFI_STATUS Status;=0D + AML_OBJECT_NODE *UuidNode;=0D + AML_DATA_NODE *UuidDataNode;=0D + AML_OBJECT_NODE_HANDLE DsdEntryList;=0D +=0D + if ((Uuid =3D=3D NULL) ||=0D + (PackageNode =3D=3D NULL) ||=0D + (AmlGetNodeType ((AML_NODE_HANDLE)DsdNode) !=3D EAmlNodeObject) ||=0D + (!AmlNodeHasOpCode (DsdNode, AML_NAME_OP, 0)) ||=0D + !AmlNameOpCompareName (DsdNode, "_DSD"))=0D + {=0D + ASSERT (0);=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + // Get the Package object node of the _DSD node,=0D + // which is the 2nd fixed argument (i.e. index 1).=0D + DsdEntryList =3D (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (=0D + DsdNode,=0D + EAmlParseIndexTerm1=0D + );=0D + if ((DsdEntryList =3D=3D NULL) = ||=0D + (AmlGetNodeType ((AML_NODE_HANDLE)DsdEntryList) !=3D EAmlNodeObject)= ||=0D + (!AmlNodeHasOpCode (DsdEntryList, AML_PACKAGE_OP, 0)))=0D + {=0D + ASSERT (0);=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + *PackageNode =3D NULL;=0D + UuidNode =3D NULL;=0D +=0D + Status =3D AmlCodeGenBuffer (NULL, 0, &UuidNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlCreateDataNode (=0D + EAmlNodeDataTypeRaw,=0D + (CONST UINT8 *)Uuid,=0D + sizeof (EFI_GUID),=0D + &UuidDataNode=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlVarListAddTail (=0D + (AML_NODE_HEADER *)UuidNode,=0D + (AML_NODE_HEADER *)UuidDataNode=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + goto error_handler;=0D + }=0D + UuidDataNode =3D NULL;=0D +=0D + // Append to the the list of _DSD entries.=0D + Status =3D AmlVarListAddTail (=0D + (AML_NODE_HANDLE)DsdEntryList,=0D + (AML_NODE_HANDLE)UuidNode=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlCodeGenPackage (PackageNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + goto error_handler;=0D + }=0D +=0D + // Append to the the list of _DSD entries.=0D + Status =3D AmlVarListAddTail (=0D + (AML_NODE_HANDLE)DsdEntryList,=0D + (AML_NODE_HANDLE)*PackageNode=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + goto error_handler;=0D + }=0D +=0D + return Status;=0D +=0D +error_handler:=0D + if (UuidNode !=3D NULL) {=0D + //Need to check to detach as there is an error path that have=0D + //this attached to the DsdEntry=0D + if (AML_NODE_HAS_PARENT (UuidNode)) {=0D + AmlDetachNode ((AML_NODE_HANDLE)UuidNode);=0D + }=0D + AmlDeleteTree ((AML_NODE_HANDLE)UuidNode);=0D + }=0D +=0D + if (*PackageNode !=3D NULL) {=0D + AmlDeleteTree ((AML_NODE_HANDLE)*PackageNode);=0D + *PackageNode =3D NULL;=0D + }=0D + if (UuidDataNode !=3D NULL) {=0D + AmlDeleteTree ((AML_NODE_HANDLE)UuidDataNode);=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/** AML code generation to add a package with a name and value,=0D + * to a parent package=0D +=0D + AmlAddNameValuePackage ("Name", Value, ParentNode) is=0D + equivalent of the following ASL code:=0D + Package (2) {"Name", Value}=0D +=0D + @ingroup CodeGenApis=0D +=0D + @param [in] Name String to place in first entry of package=0D + @param [in] Value Integer to place in second entry of package= =0D + @param [in] PackageNode Package to add new sub package to.=0D +=0D + @retval EFI_SUCCESS Success.=0D + @retval EFI_INVALID_PARAMETER Invalid parameter.=0D + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +AmlAddNameIntegerPackage (=0D + IN CHAR8 *Name,=0D + IN UINT64 Value,=0D + IN AML_OBJECT_NODE_HANDLE PackageNode=0D + )=0D +{=0D + EFI_STATUS Status;=0D + AML_OBJECT_NODE *NameNode;=0D + AML_OBJECT_NODE *ValueNode;=0D + AML_OBJECT_NODE *NewPackageNode;=0D +=0D + if ((Name =3D=3D NULL) ||=0D + (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) !=3D EAmlNodeObject) = ||=0D + (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))=0D + {=0D + ASSERT (0);=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + NewPackageNode =3D NULL;=0D + // The new package entry.=0D + Status =3D AmlCodeGenPackage (&NewPackageNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + return Status;=0D + }=0D +=0D + Status =3D AmlCodeGenString (Name, &NameNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT_EFI_ERROR (Status);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlVarListAddTail (=0D + (AML_NODE_HANDLE)NewPackageNode,=0D + (AML_NODE_HANDLE)NameNode=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + goto error_handler;=0D + }=0D + NameNode =3D NULL;=0D +=0D + Status =3D AmlCodeGenInteger (Value, &ValueNode);=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + goto error_handler;=0D + }=0D +=0D + Status =3D AmlVarListAddTail (=0D + (AML_NODE_HANDLE)NewPackageNode,=0D + (AML_NODE_HANDLE)ValueNode=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + goto error_handler;=0D + }=0D + ValueNode =3D NULL;=0D +=0D + Status =3D AmlVarListAddTail (=0D + (AML_NODE_HANDLE)PackageNode,=0D + (AML_NODE_HANDLE)NewPackageNode=0D + );=0D + if (EFI_ERROR (Status)) {=0D + ASSERT (0);=0D + goto error_handler;=0D + }=0D +=0D + return Status;=0D +=0D +error_handler:=0D + if (NewPackageNode !=3D NULL) {=0D + AmlDeleteTree ((AML_NODE_HANDLE)NewPackageNode);=0D + }=0D + if (NameNode !=3D NULL) {=0D + AmlDeleteTree ((AML_NODE_HANDLE)NameNode);=0D + }=0D + if (ValueNode !=3D NULL) {=0D + AmlDeleteTree ((AML_NODE_HANDLE)ValueNode);=0D + }=0D +=0D + return Status;=0D +}=0D -- =0D 2.25.1=0D =0D