[edk2-devel] [PATCH v1 2/7] DynamicTablesPkg: AML Code generation to create a named Package()

PierreGondois posted 7 patches 4 years, 7 months ago
There is a newer version of this series
[edk2-devel] [PATCH v1 2/7] DynamicTablesPkg: AML Code generation to create a named Package()
Posted by PierreGondois 4 years, 7 months ago
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 () {})

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
 .../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 cbbbb7a478f7..412db886e1f2 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -852,6 +852,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 f0861040191f..f9175c623622 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -747,6 +747,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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76960): https://edk2.groups.io/g/devel/message/76960
Mute This Topic: https://groups.io/mt/83735872/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v1 2/7] DynamicTablesPkg: AML Code generation to create a named Package()
Posted by Sami Mujawar 4 years, 4 months ago
Hi Pierre,

Thank you for this patch. These changes look good to me.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar


On 23/06/2021 12:58 PM, Pierre.Gondois@arm.com wrote:
> 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 () {})
>
> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
> ---
>   .../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 cbbbb7a478f7..412db886e1f2 100644
> --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
> @@ -852,6 +852,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 f0861040191f..f9175c623622 100644
> --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
> @@ -747,6 +747,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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81557): https://edk2.groups.io/g/devel/message/81557
Mute This Topic: https://groups.io/mt/83735872/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-