summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg
diff options
context:
space:
mode:
authorJeff Brasen <jbrasen@nvidia.com>2023-09-18 15:46:59 +0000
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-09-22 09:06:21 +0000
commitfd0ccccb4263f1cca92e3e561ca380b7e2f1bbf3 (patch)
tree399e2fd9c97e891a9bc73d126eeaf82a45e37763 /DynamicTablesPkg
parentb2df3ee17f376b37e6c2e1eede9163727c74702e (diff)
downloadedk2-fd0ccccb4263f1cca92e3e561ca380b7e2f1bbf3.tar.gz
edk2-fd0ccccb4263f1cca92e3e561ca380b7e2f1bbf3.tar.bz2
edk2-fd0ccccb4263f1cca92e3e561ca380b7e2f1bbf3.zip
DynamicTablesPkg: Add support to add Strings to package
Add API to add a String to a package created with NamedPackage API. Signed-off-by: Jeff Brasen <jbrasen@nvidia.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Diffstat (limited to 'DynamicTablesPkg')
-rw-r--r--DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h17
-rw-r--r--DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c84
2 files changed, 101 insertions, 0 deletions
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 cd6d349c44..9ab1a3e1a1 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -3679,3 +3679,87 @@ 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
+ );
+ if (EFI_ERROR (Status)) {
+ AmlDeleteTree ((AML_NODE_HANDLE)DataNode);
+ }
+
+exit_handler:
+ if (AmlNameString != NULL) {
+ FreePool (AmlNameString);
+ }
+
+ return Status;
+}