public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io, Sami Mujawar <sami.mujawar@arm.com>,
	Alexei Fedorov <Alexei.Fedorov@arm.com>
Subject: [PATCH v2 5/7] DynamicTablesPkg: Add AmlAttachNode()
Date: Mon, 11 Oct 2021 17:45:25 +0100	[thread overview]
Message-ID: <20211011164527.18660-6-Pierre.Gondois@arm.com> (raw)
In-Reply-To: <20211011164527.18660-1-Pierre.Gondois@arm.com>

From: Pierre Gondois <Pierre.Gondois@arm.com>

This function allows to add a node as the last node of a parent node
in an AML tree. For instance,
ASL code corresponding to NewNode:
  Name (_UID, 0)

ASL code corresponding to ParentNode:
  Device (PCI0) {
    Name(_HID, EISAID("PNP0A08"))
  }

"AmlAttachNode (ParentNode, NewNode)" will result in:
ASL code:
  Device (PCI0) {
    Name(_HID, EISAID("PNP0A08"))
    Name (_UID, 0)
  }

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           | 33 +++++++++++++++++
 .../Library/Common/AmlLib/Api/AmlApi.c        | 36 +++++++++++++++++++
 2 files changed, 69 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index aef5f55ce319..15517b5efac1 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -166,6 +166,39 @@ AmlDetachNode (
   IN  AML_NODE_HANDLE   Node
   );
 
+/** Attach a node in an AML tree.
+
+  The node will be added as the last statement of the ParentNode.
+  E.g.:
+  ASL code corresponding to NewNode:
+  Name (_UID, 0)
+
+  ASL code corresponding to ParentNode:
+  Device (PCI0) {
+    Name(_HID, EISAID("PNP0A08"))
+  }
+
+  "AmlAttachNode (ParentNode, NewNode)" will result in:
+  ASL code:
+  Device (PCI0) {
+    Name(_HID, EISAID("PNP0A08"))
+    Name (_UID, 0)
+  }
+
+  @param  [in]  ParentNode  Pointer to the parent node.
+                            Must be a root or an object node.
+  @param  [in]  NewNode     Pointer to the node to add.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+AmlAttachNode (
+  IN  AML_NODE_HANDLE   ParentNode,
+  IN  AML_NODE_HANDLE   NewNode
+  );
+
 /** Find a node in the AML namespace, given an ASL path and a reference Node.
 
    - The AslPath can be an absolute path, or a relative path from the
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Api/AmlApi.c b/DynamicTablesPkg/Library/Common/AmlLib/Api/AmlApi.c
index 6f9e3f6f2805..def581299f5c 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/Api/AmlApi.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/Api/AmlApi.c
@@ -379,6 +379,42 @@ AmlNameOpGetNextRdNode (
   return EFI_SUCCESS;
 }
 
+/** Attach a node in an AML tree.
+
+  The node will be added as the last statement of the ParentNode.
+  E.g.:
+  ASL code corresponding to NewNode:
+  Name (_UID, 0)
+
+  ASL code corresponding to ParentNode:
+  Device (PCI0) {
+    Name(_HID, EISAID("PNP0A08"))
+  }
+
+  "AmlAttachNode (ParentNode, NewNode)" will result in:
+  ASL code:
+  Device (PCI0) {
+    Name(_HID, EISAID("PNP0A08"))
+    Name (_UID, 0)
+  }
+
+  @param  [in]  ParentNode  Pointer to the parent node.
+                            Must be a root or an object node.
+  @param  [in]  NewNode     Pointer to the node to add.
+
+  @retval EFI_SUCCESS             The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+**/
+EFI_STATUS
+EFIAPI
+AmlAttachNode (
+  IN  AML_NODE_HANDLE   ParentNode,
+  IN  AML_NODE_HANDLE   NewNode
+  )
+{
+  return AmlVarListAddTail (ParentNode, NewNode);
+}
+
 // DEPRECATED APIS
 #ifndef DISABLE_NEW_DEPRECATED_INTERFACES
 
-- 
2.17.1


  parent reply	other threads:[~2021-10-11 16:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-11 16:45 [PATCH v2 0/7] Create a SSDT PCIe generator PierreGondois
2021-10-11 16:45 ` [PATCH v2 1/7] DynamicTablesPkg: AML Code generation for memory ranges PierreGondois
2021-10-11 16:45 ` [PATCH v2 2/7] DynamicTablesPkg: AML Code generation to create a named Package() PierreGondois
2021-10-11 16:45 ` [PATCH v2 3/7] DynamicTablesPkg: AML Code generation to create a named ResourceTemplate() PierreGondois
2021-10-11 16:45 ` [PATCH v2 4/7] DynamicTablesPkg: AML Code generation to add _PRT entries PierreGondois
2021-10-11 16:45 ` PierreGondois [this message]
2021-10-11 16:45 ` [PATCH v2 6/7] DynamicTablesPkg: Add Pci related objects PierreGondois
2021-10-11 16:45 ` [PATCH v2 7/7] DynamicTablesPkg: SSDT Pci express generator PierreGondois

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=20211011164527.18660-6-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