From nobody Sat Feb 7 05:56:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+84577+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+84577+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1639041925; cv=none; d=zohomail.com; s=zohoarc; b=R8yycyhP8gh7L87T/ERCiECSn3jtF/8bdtQS2X0xhMkzBW6NpVfPAL3oYXlXae62Dt2PelaaW8XKksz9PydKM+NzXaEv04U4ruoNnjqTrB3O2X0htRu32OsTMAu1P9edHQRTBwcu6wSS4TKImBZ+JYp0KUMnxmJIx82pUzcNE6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639041925; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=1qNFPFn3DNRdn423oRkpQ3BrZ86GgcRnePuh5H5raJ8=; b=GWysmhTDz80mFVJHHvnDOWn5wAKq96ZGWFFo02Rs6y0tBaOtOABR+NWhnBZHp8Mrma1/aa2IhuIuo3rBJ1/JoOBwT4HIkSnY1FB0mYfCZktBXDtoH0Ule6jIAPIWjs92nB8YmX2MoIlc6YmwZ4KuAeJXQ+/l93ovkJz4kqgGTgs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+84577+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1639041925240557.6928404466744; Thu, 9 Dec 2021 01:25:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id SIGsYY1788612xGT349wRccv; Thu, 09 Dec 2021 01:25:24 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.9251.1639041923166905377 for ; Thu, 09 Dec 2021 01:25:23 -0800 X-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 C5849147A; Thu, 9 Dec 2021 01:25:18 -0800 (PST) X-Received: from e126645.nice.arm.com (unknown [10.34.129.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DB6F13F73B; Thu, 9 Dec 2021 01:25:17 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [edk2-devel] [PATCH v4 3/8] DynamicTablesPkg: AML Code generation to create a named ResourceTemplate() Date: Thu, 9 Dec 2021 10:25:00 +0100 Message-Id: <20211209092505.1248326-4-Pierre.Gondois@arm.com> In-Reply-To: <20211209092505.1248326-1-Pierre.Gondois@arm.com> References: <20211209092505.1248326-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: 2mCCKPnVOeAd1kcx7P9yESm3x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1639041924; bh=x8ODGFy8vNM8VIn4SD2HQz3dA3GnVckagNqnxfc78Go=; h=Cc:Date:From:Reply-To:Subject:To; b=TAErVChhTOs68bnfNrp9tG2KVWI27Tx+O/6AwhkGV8wLdbkoPaYKAml3mP+5qdRsT7c K7Mdj9pbzEmg8gvYaAHZoQ6spAR/mVldhfOrr/97+bwBVESFszdH5FOb/MzvWEPGtWEx3 omkLsw0XkBRrO6Ek+nKq6vBW0RDMOG/PFa0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1639041927059100001 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add AmlCodeGenNameResourceTemplate() to generate code for a ResourceTemplate(). AmlCodeGenNameResourceTemplate ("REST", ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(REST, ResourceTemplate () {}) To: Sami Mujawar To: Alexei Fedorov Reviewed-by: Sami Mujawar Signed-off-by: Pierre Gondois --- .../Include/Library/AmlLib/AmlLib.h | 28 ++++++++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 56 +++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index 183f565f47c0..8949cf4d932a 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -863,6 +863,34 @@ AmlCodeGenNamePackage ( OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL ); =20 +/** AML code generation for a Name object node, containing a ResourceTempl= ate. + + AmlCodeGenNameResourceTemplate ("PRS0", ParentNode, NewObjectNode) is + equivalent of the following ASL code: + Name(PRS0, ResourceTemplate () {}) + + @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 +AmlCodeGenNameResourceTemplate ( + 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. =20 AmlCodeGenDevice ("COM0", ParentNode, NewObjectNode) is diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 40095fe1fd0a..778e3c5ffaf0 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -812,6 +812,62 @@ AmlCodeGenNamePackage ( return Status; } =20 +/** AML code generation for a Name object node, containing a ResourceTempl= ate. + + AmlCodeGenNameResourceTemplate ("PRS0", ParentNode, NewObjectNode) is + equivalent of the following ASL code: + Name(PRS0, ResourceTemplate () {}) + + @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 +AmlCodeGenNameResourceTemplate ( + IN CONST CHAR8 *NameString, + IN AML_NODE_HEADER *ParentNode, OPTIONAL + OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE *ResourceTemplateNode; + + if ((NameString =3D=3D NULL) || + ((ParentNode =3D=3D NULL) && (NewObjectNode =3D=3D NULL))) + { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Status =3D AmlCodeGenResourceTemplate (&ResourceTemplateNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlCodeGenName ( + NameString, + ResourceTemplateNode, + ParentNode, + NewObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + AmlDeleteTree ((AML_NODE_HEADER *)ResourceTemplateNode); + } + + return Status; +} + /** AML code generation for a Device object node. =20 AmlCodeGenDevice ("COM0", ParentNode, NewObjectNode) is --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#84577): https://edk2.groups.io/g/devel/message/84577 Mute This Topic: https://groups.io/mt/87608844/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-