From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web09.5020.1637257380253270620 for ; Thu, 18 Nov 2021 09:43:00 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D8CD8ED1; Thu, 18 Nov 2021 09:42:58 -0800 (PST) Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CEB623F5A1; Thu, 18 Nov 2021 09:42:57 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [PATCH v3 2/8] DynamicTablesPkg: AML Code generation to create a named Package() Date: Thu, 18 Nov 2021 17:42:41 +0000 Message-Id: <20211118174247.21075-3-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211118174247.21075-1-Pierre.Gondois@arm.com> References: <20211118174247.21075-1-Pierre.Gondois@arm.com> From: Pierre Gondois Add AmlCodeGenNamePackage() to generate code for a Package(). AmlCodeGenNamePackage ("PACK", ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(PACK, Package () {}) To: Sami Mujawar To: Alexei Fedorov Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Include/Library/AmlLib/AmlLib.h | 28 ++++++++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 55 +++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h index 59811379c597..d2e9cbe26d75 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -835,6 +835,34 @@ AmlCodeGenNameInteger ( OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL ); +/** AML code generation for a Name object node, containing a Package. + + AmlCodeGenNamePackage ("PKG0", ParentNode, NewObjectNode) is + equivalent of the following ASL code: + Name(PKG0, Package () {}) + + @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] 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 +AmlCodeGenNamePackage ( + IN CONST CHAR8 * NameString, + IN AML_NODE_HANDLE ParentNode, OPTIONAL + OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL + ); + /** AML code generation for a Device object node. AmlCodeGenDevice ("COM0", ParentNode, NewObjectNode) is diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 64064018aecb..1ba75fbd6f12 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -746,6 +746,61 @@ AmlCodeGenNameInteger ( return Status; } +/** AML code generation for a Name object node, containing a Package. + + AmlCodeGenNamePackage ("PKG0", ParentNode, NewObjectNode) is + equivalent of the following ASL code: + Name(PKG0, Package () {}) + + @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] 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 +AmlCodeGenNamePackage ( + IN CONST CHAR8 * NameString, + IN AML_NODE_HEADER * ParentNode, OPTIONAL + OUT AML_OBJECT_NODE ** NewObjectNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE * PackageNode; + + if ((NameString == NULL) || + ((ParentNode == NULL) && (NewObjectNode == NULL))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Status = AmlCodeGenPackage (&PackageNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status = AmlCodeGenName ( + NameString, + PackageNode, + ParentNode, + NewObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + AmlDeleteTree ((AML_NODE_HEADER*)PackageNode); + } + + return Status; +} + /** AML code generation for a Device object node. AmlCodeGenDevice ("COM0", ParentNode, NewObjectNode) is -- 2.17.1