From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.50]) by mx.groups.io with SMTP id smtpd.web11.233.1689027981640748670 for ; Mon, 10 Jul 2023 15:26:21 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=J8c7sDYm; 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.92.50, mailfrom: jbrasen@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bLFpp01kr52vPc7FW+qkqW5zBAGlBS5TQqcWZYBWVMCZlhJDngFb2zkdAsdWziedBmtmnRyqs3wTWq3RSA6WISlMw0ozK1ze7NW6dx6SWvkNrTFXx+S/JyoG5V3ow9bWAccD2Z746RoLB45FyrNMwwERXrkifapjOUPaTiEsW5xZxAdbE8rElOL57cZLmhQNPijdBcKN4lALKjrDl3eOStu2deOLWAESmCRid1BVoIzVKXMEgHlnf1EJHT/6LQWFnWWFEYxUt8p1v6g7zaEmejlqDGvW20WjiXRW6aRfeM+/ijwjZqLYZU7xcjnAJGbEABRnndgWK79EP9bGdAolYQ== 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=04Jq2sRu3OADci19x3OybZO3FnYQjLlkfEOnf2qacmU=; b=N1aoOgZynxSFpd738L6RgrJ5Dqodw6/oLK9OkczEoQgWEZVEsLSu9f8ZpeT5pzCuPgapQW6JchcO9y0y/KtX71Aw+McIHULk8mC87IpxvBcTIhfKh1bufo0Ri+jX0BAkp7dzuhxpCUUotS+JLOFwqTR5z9jG0NleOPiyvHOO9ocCJP5wCsRQUAArKoA19hQb4OOGpizxjrrDXsQj3fQW2I4A27HfW95HHr9ij7wQmU8ZcAeaO8nmPWh0TD693vEzpZDkDHmxEUIoQZUeokP/ve4ugqsf5i1vCprPg8UJRugmAh3Eivqb989ntCBolGk244z3Da0nlxJtRhkxegdO/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=edk2.groups.io 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=04Jq2sRu3OADci19x3OybZO3FnYQjLlkfEOnf2qacmU=; b=J8c7sDYmcu/byz7j7SYNU4527b1D4G59ED4BaaJ0JaGGfAa+D1+CTR13SZImjIXnidHRPmpHEtXxwm2jPW9hkxeUrhtWehTiq0kFQJwT6PBj7KAe2mhaPA2mhU9WY1SUrsrtWo9w3rgT47YJuxiXc1EZPthqSlc5qMhUfqC1CAG4atEAPLtSxYvKpC4EXxvKRG3bJd6xCbuRdS1BjPprroKZzj6TdxGYbMjSp/N7oaf8YAT1RLCTLjJJyOVMuuL3DYJkseGJuXW4upDm5mAxQhNmUTQl8q8DWwyZpatN7g5XSdO+WK/u0wfsJR+weVqexCn6dFHFF43UwzM85g4BuQ== Received: from DM6PR03CA0042.namprd03.prod.outlook.com (2603:10b6:5:100::19) by BL1PR12MB5189.namprd12.prod.outlook.com (2603:10b6:208:308::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31; Mon, 10 Jul 2023 22:26:19 +0000 Received: from DM6NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::9e) by DM6PR03CA0042.outlook.office365.com (2603:10b6:5:100::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.31 via Frontend Transport; Mon, 10 Jul 2023 22:26:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT010.mail.protection.outlook.com (10.13.172.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.19 via Frontend Transport; Mon, 10 Jul 2023 22:26:18 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 10 Jul 2023 15:26:04 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 10 Jul 2023 15:26:04 -0700 Received: from 6cd8174ac25c.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Mon, 10 Jul 2023 15:26:03 -0700 From: "Jeff Brasen" To: CC: , , , Jeff Brasen , "Swatisri Kantamsetti" , Ashish Singhal Subject: [PATCH v2 4/4] DynamicTablesPkg: Add Aml NameUnicodeString API Date: Mon, 10 Jul 2023 22:25:59 +0000 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-NVConfidentiality: public Return-Path: jbrasen@nvidia.com X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT010:EE_|BL1PR12MB5189:EE_ X-MS-Office365-Filtering-Correlation-Id: cd2f64c8-72b9-430e-c78a-08db8194aea5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ur2R3Gw4Zto6od/oP8rJz6cE3Juqd7LU0NYxiGQBaw5Fg7WJEuFoF8/Nl516F+jeBA2bsEdk54xyfVJLtQZ5OaVdKQxOuydB6aL9uL3RZJcnpAXRigEtU4G4o4KE+FuQl3128xO5WbuDM8Fl3WxBu+oq8MEeW2MFSzPVnWYNIKV0cV5sw1bBHUrzK5MDVsf5vP+hYEnJfzuwkKJIpqO3JuwNq1CP/k2xMh023lue2+GT51B0eRFCoT/x0MnlA37So3mHHDwx7M97M/AVEU8WW7tKhdqH1oIfc/Jk7VNk/6G5kVUV04gOuSc5tiTq1QqO6opJ5hsr5M6vz2NE3YZ8v/WzWAnV23OGoZLurcsCptpnrFAktHWA3j8mxw+VHSW/To/DXCBlKYtb1NLZMDbOMMfzgHtw0VR2VpK+H264zsDsDyDVLrtrHLGT3GW27dp9KKQEw172uqQzXSO4xMYzn8I1w45KLWc1Jm6MA0vIWrcKhv4u/sqRi6jcxULVbl4bdSYgZnYmLdBKHj/uw9n8qgY6dTqOuggC+tRFJBMLsvBzMJ1mJieMB1bZ3RoUcXsQPvUp6uFVIcg/O+JJgW60G7Vu/vPzNVe03A51Xa2Lc1kDwZ/rDy2aD7MhKAI52eglG/rtlAd7EJW+0O0BOCJVVkpAnJ1tn7NIU9fkXk59GFmwbzqBLoayW677dn46dxBa0atRK2MFd5u4kc3zb4y7gbZLEOWpsE4MdS/I4RHn5xsNiTM2T/QO8RbnwbwhfvMQ X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(136003)(396003)(376002)(346002)(39860400002)(451199021)(40470700004)(46966006)(36840700001)(6666004)(7696005)(478600001)(54906003)(26005)(70586007)(186003)(107886003)(336012)(70206006)(2906002)(82310400005)(41300700001)(4326008)(316002)(5660300002)(6916009)(8936002)(8676002)(356005)(82740400003)(7636003)(86362001)(36756003)(47076005)(36860700001)(2616005)(83380400001)(426003)(40480700001)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 22:26:18.6737 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd2f64c8-72b9-430e-c78a-08db8194aea5 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5189 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Add API to generate a Name that contains a Unicode string buffer. Signed-off-by: Jeff Brasen Reviewed-by: Swatisri Kantamsetti Reviewed-by: Ashish Singhal --- .../Include/Library/AmlLib/AmlLib.h | 31 +++++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 86 +++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index f4a490875365..e0dc1340ab50 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -958,6 +958,37 @@ AmlCodeGenNameResourceTemplate ( OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL ); =20 +/** AML code generation for a Name object node, containing a String. + + AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNod= e) is + equivalent of the following ASL code: + Name(_STR, Unicode ("String")) + + @ingroup CodeGenApis + + @param [in] NameString The new variable name. + Must be a NULL-terminated ASL NameString + e.g.: "DEV0", "DV15.DEV0", etc. + The input string is copied. + @param [in] String NULL terminated Unicode String to associate = to the + NameString. + @param [in] ParentNode If provided, set ParentNode as the parent + of the node created. + @param [out] NewObjectNode If success, contains the created node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenNameUnicodeString ( + IN CONST CHAR8 *NameString, + IN CHAR16 *String, + IN AML_NODE_HANDLE ParentNode OPTIONAL, + OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL + ); + /** Add a _PRT entry. =20 AmlCodeGenPrtEntry (0x0FFFF, 0, "LNKA", 0, PrtNameNode) is diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index a2009d9805b5..ffc809ba1b0a 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -869,6 +869,92 @@ AmlCodeGenNameResourceTemplate ( return Status; } =20 +/** AML code generation for a Name object node, containing a String. + + AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode= ) is + equivalent of the following ASL code: + Name(_STR, Unicode ("String")) + + @ingroup CodeGenApis + + @param [in] NameString The new variable name. + Must be a NULL-terminated ASL NameString + e.g.: "DEV0", "DV15.DEV0", etc. + The input string is copied. + @param [in] String NULL terminated Unicode String to associate t= o the + NameString. + @param [in] ParentNode If provided, set ParentNode as the parent + of the node created. + @param [out] NewObjectNode If success, contains the created node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenNameUnicodeString ( + IN CONST CHAR8 *NameString, + IN CHAR16 *String, + IN AML_NODE_HANDLE ParentNode OPTIONAL, + OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE *ObjectNode; + AML_DATA_NODE *DataNode; + + if ((NameString =3D=3D NULL) || + (String =3D=3D NULL) || + ((ParentNode =3D=3D NULL) && (NewObjectNode =3D=3D NULL))) + { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Status =3D AmlCodeGenBuffer (NULL, 0, &ObjectNode); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeRaw, + (CONST UINT8 *)String, + StrSize (String), + &DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode); + return Status; + } + + Status =3D AmlVarListAddTail ( + (AML_NODE_HEADER *)ObjectNode, + (AML_NODE_HEADER *)DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode); + AmlDeleteTree ((AML_NODE_HANDLE)DataNode); + return Status; + } + + Status =3D AmlCodeGenName ( + NameString, + ObjectNode, + ParentNode, + NewObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + AmlDeleteTree ((AML_NODE_HEADER *)ObjectNode); + } + + return Status; +} + /** Add a _PRT entry. =20 AmlCodeGenPrtEntry (0x0FFFF, 0, "LNKA", 0, PrtNameNode) is --=20 2.25.1