summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Gondois <Pierre.Gondois@arm.com>2021-12-09 10:24:59 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-13 12:48:42 +0000
commit0e7147fe75e48862c236d11bcfc27dde8e3e8d89 (patch)
treec2497529f0860961135d27ff0abc944ccdac842b
parent7f1861be2b5e65a3dd840d77cd433f18992149c0 (diff)
downloadedk2-0e7147fe75e48862c236d11bcfc27dde8e3e8d89.tar.gz
edk2-0e7147fe75e48862c236d11bcfc27dde8e3e8d89.tar.bz2
edk2-0e7147fe75e48862c236d11bcfc27dde8e3e8d89.zip
DynamicTablesPkg: AML Code generation to create a named Package()
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> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
-rw-r--r--DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h28
-rw-r--r--DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c56
2 files changed, 84 insertions, 0 deletions
diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 385d2459d2..183f565f47 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 15cab832cb..40095fe1fd 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