From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.4988.1637257383051358626 for ; Thu, 18 Nov 2021 09:43:03 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A51001042; Thu, 18 Nov 2021 09:43:02 -0800 (PST) Received: from e120189.home (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D48E43F5A1; Thu, 18 Nov 2021 09:43:01 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io, Sami.Mujawar@arm.com, Alexei.Fedorov@arm.com Subject: [PATCH v3 5/8] DynamicTablesPkg: Add AmlAttachNode() Date: Thu, 18 Nov 2021 17:42:44 +0000 Message-Id: <20211118174247.21075-6-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211118174247.21075-1-Pierre.Gondois@arm.com> References: <20211118174247.21075-1-Pierre.Gondois@arm.com> From: Pierre Gondois 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 To: Alexei Fedorov Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../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