From nobody Tue Feb 10 17:30:52 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+81592+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+81592+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633620774; cv=none; d=zohomail.com; s=zohoarc; b=cimB1mnXGe8dUncUyAC1OE5TxoAbNkFpDP6lIEkjmgPHfSfL7OCLUtNug5kBtG2LVCvSa+pBlXD/ut4jL6s9M+fX30xfaiNp2sEG2OTGsPeL25iSFw+zKAKncw3Mq4vephllQhfo8H1wIwFUEeps7EA8ztfP9il7BFx0VZzHhk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633620774; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=lXHfMHdU10pwyYfip8BPK5ViUe4rwEdezuWcwlvS8I8=; b=TS0CJpjeMfMuRBOUdP2johF9uvwXyjpQWfmfXuRt7P9gr2crcObh1gljNyBNGN7OHAjlrvZdE8xFBMMIDTMJDFeav341BdI2uCd9n3H8V9cGxQVeVVOpPSP+BUlgGf0y1njBhP4/Veu/fb+pQ9qmXVMpFotk1R95aFEP0BlpIVQ= 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+81592+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 1633620774226803.4854149681044; Thu, 7 Oct 2021 08:32:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id jsWWYY1788612xDpv2bkVO2a; Thu, 07 Oct 2021 08:32:53 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.13846.1633620772885488324 for ; Thu, 07 Oct 2021 08:32:53 -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 8D9911FB; Thu, 7 Oct 2021 08:32:52 -0700 (PDT) X-Received: from e120189.arm.com (unknown [10.57.72.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B65DE3F66F; Thu, 7 Oct 2021 08:32:51 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v2 11/21] DynamicTablesPkg: AML Code generation for Resource data EndTag Date: Thu, 7 Oct 2021 16:32:00 +0100 Message-Id: <20211007153210.26608-12-Pierre.Gondois@arm.com> In-Reply-To: <20211007153210.26608-1-Pierre.Gondois@arm.com> References: <20211007153210.26608-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: PMn3qhRPFXopYQ6nr24cn6snx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633620773; bh=+fyIre/mOM79VkSY0krc7T1CLEy7umKVrFbb1oJq2JI=; h=Date:From:Reply-To:Subject:To; b=R4RzUWFLcUu5d0tmTpvpNsrzX2bhV6Is0ti5kCx0KpChnTCTs+eTbTk+KMRRu20kXGT 5SS9xKMrg6+fTc8BxrUmgqZTVYmjF+F0AkqJu0ax7qM7uDv+KKl4W9q9UCuPN05TLGbjx eSBJYFSFlbgjD/b+RF+2snS4DlfN5oMCamI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633620778230100020 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Add a helper function AmlCodeGenEndTag() to generate AML Resource Data EndTag. The EndTag resource data is automatically generated by the ASL compiler at the end of a list of resource data elements. Therefore, an equivalent function is not present in ASL. However, AmlCodeGenEndTag() is useful when generating AML code for the ResourceTemplate() macro. Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../AmlLib/CodeGen/AmlResourceDataCodeGen.c | 113 ++++++++++++++++++ .../AmlLib/CodeGen/AmlResourceDataCodeGen.h | 43 +++++++ 2 files changed, 156 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceData= CodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC= odeGen.c index 20b745f27a2b..0bdb6c24c5bb 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .c @@ -280,6 +280,119 @@ AmlCodeGenRdRegister ( return LinkRdNode (RdNode, NameOpNode, NewRdNode); } =20 +/** Code generation for the EndTag resource data. + + The EndTag resource data is automatically generated by the ASL compiler + at the end of a list of resource data elements. Thus, it doesn't have + a corresponding ASL function. + + This function allocates memory to create a data node. It is the caller's + responsibility to either: + - attach this node to an AML tree; + - delete this node. + + ACPI 6.4, s6.4.2.9 "End Tag": + "This checksum is generated such that adding it to the sum of all the da= ta + bytes will produce a zero sum." + "If the checksum field is zero, the resource data is treated as if the + checksum operation succeeded. Configuration proceeds normally." + + To avoid re-computing checksums, if a new resource data elements is + added/removed/modified in a list of resource data elements, the AmlLib + resets the checksum to 0. + + @param [in] CheckSum CheckSum to store in the EndTag. + To ignore/avoid computing the checksum, + give 0. + @param [in] ParentNode If not NULL, add the generated node + to the end of the variable list of + argument of the ParentNode. + The ParentNode must not initially contain + an EndTag resource data element. + @param [out] NewRdNode If success, contains the generated node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenEndTag ( + IN UINT8 CheckSum, OPTIONAL + IN AML_OBJECT_NODE * ParentNode, OPTIONAL + OUT AML_DATA_NODE ** NewRdNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_DATA_NODE * RdNode; + EFI_ACPI_END_TAG_DESCRIPTOR EndTag; + ACPI_SMALL_RESOURCE_HEADER SmallResHdr; + + if ((ParentNode =3D=3D NULL) && (NewRdNode =3D=3D NULL)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + RdNode =3D NULL; + + // Header + SmallResHdr.Bits.Length =3D sizeof (EFI_ACPI_END_TAG_DESCRIPTOR) - + sizeof (ACPI_SMALL_RESOURCE_HEADER); + SmallResHdr.Bits.Name =3D ACPI_SMALL_END_TAG_DESCRIPTOR_NAME; + SmallResHdr.Bits.Type =3D ACPI_SMALL_ITEM_FLAG; + + // Body + EndTag.Desc =3D SmallResHdr.Byte; + EndTag.Checksum =3D CheckSum; + + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeResourceData, + (UINT8*)&EndTag, + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR), + &RdNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + if (NewRdNode !=3D NULL) { + *NewRdNode =3D RdNode; + } + + if (ParentNode !=3D NULL) { + // Check the BufferOp doesn't contain any resource data yet. + // This is a hard check: do not allow to add an EndTag if the BufferNo= de + // already has resource data elements attached. Indeed, the EndTag sho= uld + // have already been added. + if (AmlGetNextVariableArgument ((AML_NODE_HEADER*)ParentNode, NULL) != =3D + NULL) { + ASSERT (0); + Status =3D EFI_INVALID_PARAMETER; + goto error_handler; + } + + // Add the EndTag RdNode. Indeed, the AmlAppendRdNode function + // is looking for an EndTag, which we are adding here. + Status =3D AmlVarListAddTail ( + (AML_NODE_HEADER*)ParentNode, + (AML_NODE_HEADER*)RdNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + } + + return Status; + +error_handler: + if (RdNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HEADER*)RdNode); + } + return Status; +} + // DEPRECATED APIS #ifndef DISABLE_NEW_DEPRECATED_INTERFACES =20 diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceData= CodeGen.h b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataC= odeGen.h index 831d6a7462ae..102340495933 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .h +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen= .h @@ -104,4 +104,47 @@ AmlCodeGenRdRegister ( OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL ); =20 +/** Code generation for the EndTag resource data. + + The EndTag resource data is automatically generated by the ASL compiler + at the end of a list of resource data elements. Thus, it doesn't have + a corresponding ASL function. + + This function allocates memory to create a data node. It is the caller's + responsibility to either: + - attach this node to an AML tree; + - delete this node. + + ACPI 6.4, s6.4.2.9 "End Tag": + "This checksum is generated such that adding it to the sum of all the da= ta + bytes will produce a zero sum." + "If the checksum field is zero, the resource data is treated as if the + checksum operation succeeded. Configuration proceeds normally." + + To avoid re-computing checksums, if a new resource data elements is + added/removed/modified in a list of resource data elements, the AmlLib + resets the checksum to 0. + + @param [in] CheckSum CheckSum to store in the EndTag. + To ignore/avoid computing the checksum, + give 0. + @param [in] ParentNode If not NULL, add the generated node + to the end of the variable list of + argument of the ParentNode. + The ParentNode must not initially contain + an EndTag resource data element. + @param [out] NewRdNode If success, contains the generated node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenEndTag ( + IN UINT8 CheckSum, OPTIONAL + IN AML_OBJECT_NODE * ParentNode, OPTIONAL + OUT AML_DATA_NODE ** NewRdNode OPTIONAL + ); + #endif // AML_RESOURCE_DATA_CODE_GEN_H_ --=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 (#81592): https://edk2.groups.io/g/devel/message/81592 Mute This Topic: https://groups.io/mt/86148202/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-