From nobody Mon Feb 9 20:32:20 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+76961+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+76961+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1624449553; cv=none; d=zohomail.com; s=zohoarc; b=fCsbldcWjMjXneMvHyk4Gv5D1BIhOwWv9bs9lp0zN5OyqMqfFvB7x6T1o91wy9FsMHA9A7yAXXQWM8UKWQ++bB2hRNguBsffXEmjPod2aYyZSTav170Tst4Rb4kgZkZYyJ5XTtWltSogiXPmng7pGmJwTizR0fTPCcYO4hC3d1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624449553; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=11RxDYBoSYOwE7J5RNwB4uhiTxFErQn//5/20BxN+tk=; b=H3EXKdmsLpYh5c1hVZ/stCfmZw8Ds3mfDCs4GpSbr64UmjJw9W6LsMtpgCwpJIsk+Ya9btHZnQ4qI1mC16iBB9eOmAvGD2iaLuUQYAz3xndGNkb3tEmMza9PJcwCi9QMQRze7x7SjdVwQC+Qwhvhw5pUHB7ng5Q+By0t4O8AUyE= 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+76961+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 1624449553430421.6209212541877; Wed, 23 Jun 2021 04:59:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id iHgyYY1788612x1GOYqiJYgD; Wed, 23 Jun 2021 04:59:13 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.6480.1624449546879975367 for ; Wed, 23 Jun 2021 04:59:07 -0700 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 7103FED1; Wed, 23 Jun 2021 04:59:06 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.78.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1B5543F718; Wed, 23 Jun 2021 04:59:04 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei Fedorov Cc: Akanksha Jain , Alexandru Elisei Subject: [edk2-devel] [PATCH v1 3/7] DynamicTablesPkg: AML Code generation to create a named ResourceTemplate() Date: Wed, 23 Jun 2021 12:58:30 +0100 Message-Id: <20210623115834.907-4-Pierre.Gondois@arm.com> In-Reply-To: <20210623115834.907-1-Pierre.Gondois@arm.com> References: <20210623115834.907-1-Pierre.Gondois@arm.com> 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: Q5LO7IbmPi92nulSM373y2aKx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1624449553; bh=r5yjdGHE1MboTJNuhZRITFQBFOGExNQ5ENnM04pKIps=; h=Cc:Date:From:Reply-To:Subject:To; b=Fg0Mnl79L8qrmjxQQer7iwFfC5T/hoXV/StAuTYQac+z3XiNR37MRK+02bFyc0NN0Ki N3FA0xuydamkSax06z90bo0byDUK9C0N5zY2EfJIrPi1CvbNqmkaVldEj9/+MbbHiSVLJ WLyvN960p3LqnnyRccNo/BBlLF+RraBA+sk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 () {}) Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../Include/Library/AmlLib/AmlLib.h | 28 ++++++++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 55 +++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index 412db886e1f2..544bc670c455 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -880,6 +880,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 f9175c623622..eaa49a5834c2 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -802,6 +802,61 @@ 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.17.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 (#76961): https://edk2.groups.io/g/devel/message/76961 Mute This Topic: https://groups.io/mt/83735874/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-