[edk2-devel] [PATCH v3 3/4] DynamicTablesPkg: Add support to add Strings to package

Jeff Brasen via groups.io posted 4 patches 8 months, 2 weeks ago
There is a newer version of this series
[edk2-devel] [PATCH v3 3/4] DynamicTablesPkg: Add support to add Strings to package
Posted by Jeff Brasen via groups.io 8 months, 2 weeks ago
Add API to add a String to a package created with NamedPackage API.



Bug 4063340



Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>

Reviewed-by: Swatisri Kantamsetti <swatisrik@nvidia.com>

Reviewed-by: Ashish Singhal <ashishsingha@nvidia.com>

---

 .../Include/Library/AmlLib/AmlLib.h           | 17 ++++

 .../Common/AmlLib/CodeGen/AmlCodeGen.c        | 88 +++++++++++++++++++

 2 files changed, 105 insertions(+)



diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h

index b82c7a3ce8..f4a4908753 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

   );

 

+/** 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 package.

+

+  @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 53c537e2d3..d7fec859ef 100644

--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c

@@ -3677,3 +3677,91 @@ error_handler:

   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 package.

+

+  @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 = NULL;

+

+  if ((NamedNode == NULL)                                              ||

+      (AmlGetNodeType ((AML_NODE_HANDLE)NamedNode) != EAmlNodeObject)  ||

+      (!AmlNodeHasOpCode (NamedNode, AML_NAME_OP, 0)))

+  {

+    ASSERT (0);

+    return EFI_INVALID_PARAMETER;

+  }

+

+  PackageNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument (

+                                          NamedNode,

+                                          EAmlParseIndexTerm1

+                                          );

+  if ((PackageNode == NULL)                                             ||

+      (AmlGetNodeType ((AML_NODE_HANDLE)PackageNode) != EAmlNodeObject) ||

+      (!AmlNodeHasOpCode (PackageNode, AML_PACKAGE_OP, 0)))

+  {

+    ASSERT (0);

+    return EFI_INVALID_PARAMETER;

+  }

+

+  Status = ConvertAslNameToAmlName (NameString, &AmlNameString);

+  if (EFI_ERROR (Status)) {

+    ASSERT (0);

+    return Status;

+  }

+

+  Status = AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);

+  if (EFI_ERROR (Status)) {

+    ASSERT (0);

+    goto exit_handler;

+  }

+

+  Status = AmlCreateDataNode (

+             EAmlNodeDataTypeNameString,

+             (UINT8 *)AmlNameString,

+             AmlNameStringSize,

+             &DataNode

+             );

+  if (EFI_ERROR (Status)) {

+    ASSERT (0);

+    goto exit_handler;

+  }

+

+  Status = AmlVarListAddTail (

+             (AML_NODE_HANDLE)PackageNode,

+             (AML_NODE_HANDLE)DataNode

+             );

+  ASSERT_EFI_ERROR (Status);

+

+exit_handler:

+  if (AmlNameString != NULL) {

+    FreePool (AmlNameString);

+  }

+

+  if (EFI_ERROR (Status)) {

+    if (DataNode != NULL) {

+      AmlDeleteTree ((AML_NODE_HANDLE)DataNode);

+    }

+  }

+

+  return Status;

+}

-- 

2.25.1





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