From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io
Cc: Sami Mujawar <sami.mujawar@arm.com>,
Alexei Fedorov <Alexei.Fedorov@arm.com>
Subject: [PATCH v4 2/8] DynamicTablesPkg: AML Code generation to create a named Package()
Date: Thu, 9 Dec 2021 10:24:59 +0100 [thread overview]
Message-ID: <20211209092505.1248326-3-Pierre.Gondois@arm.com> (raw)
In-Reply-To: <20211209092505.1248326-1-Pierre.Gondois@arm.com>
From: Pierre Gondois <Pierre.Gondois@arm.com>
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 <sami.mujawar@arm.com>
To: Alexei Fedorov <Alexei.Fedorov@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
.../Include/Library/AmlLib/AmlLib.h | 28 ++++++++++
.../Common/AmlLib/CodeGen/AmlCodeGen.c | 56 +++++++++++++++++++
2 files changed, 84 insertions(+)
diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 385d2459d273..183f565f47c0 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 15cab832cbb7..40095fe1fd0a 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -756,6 +756,62 @@ 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.25.1
next prev parent reply other threads:[~2021-12-09 9:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 9:24 [PATCH v4 0/8] Create a SSDT PCIe generator PierreGondois
2021-12-09 9:24 ` [PATCH v4 1/8] DynamicTablesPkg: AML Code generation for memory ranges PierreGondois
2021-12-09 9:24 ` PierreGondois [this message]
2021-12-09 9:25 ` [PATCH v4 3/8] DynamicTablesPkg: AML Code generation to create a named ResourceTemplate() PierreGondois
2021-12-09 9:25 ` [PATCH v4 4/8] DynamicTablesPkg: AML Code generation to add _PRT entries PierreGondois
2021-12-09 9:25 ` [PATCH v4 5/8] DynamicTablesPkg: Add AmlAttachNode() PierreGondois
2021-12-09 9:25 ` [PATCH v4 6/8] DynamicTablesPkg: Add Pci related objects PierreGondois
2021-12-09 9:25 ` [PATCH v4 7/8] DynamicTablesPkg: SSDT Pci express generator PierreGondois
2021-12-09 9:25 ` [PATCH v4 8/8] DynamicTablesPkg: Fix multiple objects parsing PierreGondois
2021-12-13 12:24 ` [PATCH v4 0/8] Create a SSDT PCIe generator Sami Mujawar
2021-12-13 17:19 ` [edk2-devel] " Sami Mujawar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211209092505.1248326-3-Pierre.Gondois@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox