From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.56]) by mx.groups.io with SMTP id smtpd.web10.211.1689027979020438932 for ; Mon, 10 Jul 2023 15:26:19 -0700 Authentication-Results: mx.groups.io; dkim=fail, err=malformed MIME header line: Subject: [PATCH v2 3/4] DynamicTablesPkg: Add support to add Strings to package; 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.237.56, mailfrom: jbrasen@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HRz8vUIAp4L7yY9NCJmNFuXALcNPM7YCOPOhOc8cqFsMYSZHUJQynk/41+9sMMDFD2XsRnloYV2NeNwTTC9jzifMqJqwrBeobO1qiUwoRs0TBMYOUlz4U4bNEL2jfeq01yyrAAiFAL3oHA4jCjGWdi1qYAYEycVX/UnRqUxHpwJBqGBhVFoGXsUdpLXZdJAd2PqFwS1HKci7nPQxqP7J0r2NXKn8VVtbR5+syh/QvnOuiW+3arLNd/3d8C5oHOZU6lVvxKghot1oCmZ8Ewk1DJ9HmoHOeyFbBExIjMzVRAMI6igo1dSEGS8q3GRAaXt/KSEP/eNs9rSEFrak5yI3eQ== 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=hYTVUL6k+vBPBalXA5Wo5iYZ2AGsEzfpQ4/nafeMnVY=; b=dQ6W0rQ4r/4t24cYNLyTCYQItlZb1dbmdcXppoF3n1BLVNZCzcTUgqp2kXxGxNMl2S3TQnR9uXhJ7Iw5LYL8+kOG/7qNJ11UZRmoTFY/lOUeWsNxCIXyMp9wWCoEAA+aTtX0+uAHXB6KaTr7Ohb7VmoIhRk4graF+6uzx1qS1OxEXveHM1H1wX2MJEefoJtBb/YoletjMvPvHfYzwqnXzLrZVfgs5lfhvMtIbXMy+7Ym3qsnpgTM5tJQ9Mg12XxEgnVob7x65aFddSPKPTvZkdnxpgcqYiwdhC7yFNYW91fGEUCjCALQPkQIToZxJCYq5MH8RTULBYDiVUxil0rmPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) 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=hYTVUL6k+vBPBalXA5Wo5iYZ2AGsEzfpQ4/nafeMnVY=; b=SQSJYc9zOr0xWxG1rYnqvWg+Hj+PqfJC6lfqbKC2nX+FkZAHd8JlJkH+1+dGNBKCP1JLeNf3gY1nY2jE4lDfMO3u2GadElBPv8CeFZ3JgqMEpAZEgdrxToAajw/P9y8z8kNXlGxzThxncZjvXbMbivWgaSqimhAhtxy9SRmDeCd/slkG/3Dk6FjUaKBuxjy94HWexdXOQHZ8CYrsuVW1cEqi2S7gFl7FAC39zcTqeLoGYHi52wHm/WdnP+YJq/fZNG645XhDag5G0Z4Pwr/quI5rDZ/8MeSdzSpwU9izfF3M4RP1DRk3OO86GuvzP+WSrqoSt8DFpZPsaBQa5ibggA== Received: from MW4PR03CA0223.namprd03.prod.outlook.com (2603:10b6:303:b9::18) by DS0PR12MB8218.namprd12.prod.outlook.com (2603:10b6:8:f2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Mon, 10 Jul 2023 22:26:16 +0000 Received: from CO1NAM11FT085.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b9:cafe::44) by MW4PR03CA0223.outlook.office365.com (2603:10b6:303:b9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30 via Frontend Transport; Mon, 10 Jul 2023 22:26:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT085.mail.protection.outlook.com (10.13.174.137) 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:16 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.67) 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:03 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) 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:03 -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:02 -0700 From: "Jeff Brasen" To: CC: , , , Jeff Brasen , "Swatisri Kantamsetti" , Ashish Singhal Subject: [PATCH v2 3/4] DynamicTablesPkg: Add support to add Strings to package Date: Mon, 10 Jul 2023 22:25:58 +0000 Message-ID: <722520ae73c9581ce3cf45fd0cc8ca1fd54c62fa.1689027745.git.jbrasen@nvidia.com> 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: CO1NAM11FT085:EE_|DS0PR12MB8218:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f1c8908-d1c3-4d44-fb49-08db8194ad22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bbX2FyL8tdjvmEZzZSDiRTRoUT0a4A2H7eQ/6mDM7hAu58k4mN0W4gTqWKdpDPtqy20g0BikIBWezACVR6EGQ24lQLvUJr2j3YHfKwvDzt6nR1nZ26vCsHWuIiIrRIQxX4Roe/4t9zb7Jc7wK3F+XbDZ9Qchhzt+7WrUAqL7S5vyDUXGioPMEQiYNKhf/etAvKLc7JHHhcgdpCpciYVOntjnaCQvnzFmJR4OwRv6VWNOGn80I8LVV3KUci5S60dfH+rRYUVYopJl6udQB+ZDHd3T9S88+HoCjl/Mgwz3v+WtrUKjv3iZ9coGB30C9lGxQPs4I6zIidZ+0sel4H61gasA3Lg6q0aB34+pFYfXwLRr2wEve7xJ85hJTovyAIAPoFJcjNlcXyI9Sl8iBLFia9F24uE3lztlfUWlLD68IsyJyVjBjdMbioRT710WxR/y6ZT/lsrRafh2nkDKA04Fy8hcKwByoQ60XbZ7og2kbKrXovg499WpCuG2cjswRzO6dexRyqvian5kB6g6dHnIUvHEfg7QXUbZpwhER9yto+6RS//JjXSj8B8kGMlD75h0uMR8kT/nXsNgVKjESxLTY6iH1cruuUG5bnLCC983Er0/rG1H9qx68vd4pmS3ryB2vjPeHw0B/5DZ/W6X/OPzR4NVAeLzH5Z6OCTq+NJ2YjfH/d/sbLAquMfQUS+i2TmGQcHJUdPhNd8Sag2Za2kWF7wo+bzfYckxF9oR1fJX/sE= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(396003)(136003)(346002)(376002)(451199021)(36840700001)(46966006)(40470700004)(7696005)(478600001)(6666004)(54906003)(19627235002)(36860700001)(47076005)(426003)(83380400001)(36756003)(40460700003)(86362001)(40480700001)(2616005)(2906002)(70206006)(82310400005)(336012)(70586007)(26005)(107886003)(186003)(8676002)(82740400003)(7636003)(356005)(5660300002)(4326008)(316002)(6916009)(41300700001)(8936002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 22:26:16.1388 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f1c8908-d1c3-4d44-fb49-08db8194ad22 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.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT085.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8218 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Add API to add a String to a package created with NamedPackage API. Signed-off-by: Jeff Brasen Reviewed-by: Swatisri Kantamsetti Reviewed-by: Ashish Singhal --- .../Include/Library/AmlLib/AmlLib.h | 17 ++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 82 +++++++++++++++++++ 2 files changed, 99 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index b82c7a3ce874..f4a490875365 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -1472,4 +1472,21 @@ AmlCreateCpcNode ( OUT AML_OBJECT_NODE_HANDLE *NewCpcNode OPTIONAL ); =20 +/** AML code generation to add a NameString to the package in a named node= . + + + @param [in] NameString NameString to add + @param [in] NamedNode Node to add the string to the included packa= ge. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlAddNameStringToNamedPackage ( + IN CHAR8 *NameString, + IN AML_OBJECT_NODE_HANDLE NamedNode + ); + #endif // AML_LIB_H_ diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index d31a86e98c4c..a2009d9805b5 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -3665,3 +3665,85 @@ AmlCreateCpcNode ( AmlDeleteTree ((AML_NODE_HANDLE)CpcNode); return Status; } + +/** AML code generation to add a NameString to the package in a named node= . + + + @param [in] NameString NameString to add + @param [in] NamedNode Node to add the string to the included packa= ge. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlAddNameStringToNamedPackage ( + IN CHAR8 *NameString, + IN AML_OBJECT_NODE_HANDLE NamedNode + ) +{ + EFI_STATUS Status; + AML_DATA_NODE *DataNode; + CHAR8 *AmlNameString; + UINT32 AmlNameStringSize; + AML_OBJECT_NODE_HANDLE PackageNode; + + DataNode =3D NULL; + + if ((NamedNode =3D=3D NULL) = || + (AmlGetNodeType ((AML_NODE_HANDLE)NamedNode) !=3D EAmlNodeObject) |= | + (!AmlNodeHasOpCode (NamedNode, AML_NAME_OP, 0))) + { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + PackageNode =3D (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( + NamedNode, + EAmlParseIndexTerm1 + ); + if ((PackageNode =3D=3D NULL) = || + (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) !=3D EAmlNodeObject) = || + (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0))) + { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Status =3D ConvertAslNameToAmlName (NameString, &AmlNameString); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeNameString, + (UINT8 *)AmlNameString, + AmlNameStringSize, + &DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)PackageNode, + (AML_NODE_HANDLE)DataNode + ); + ASSERT_EFI_ERROR (Status); + +exit_handler: + if (AmlNameString !=3D NULL) { + FreePool (AmlNameString); + } + + return Status; +} --=20 2.25.1