From nobody Mon Feb 9 20:31:50 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+81583+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+81583+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1633620767; cv=none; d=zohomail.com; s=zohoarc; b=QUO2/FpRT8Dpo20bGLbGVJU7XxxSJIfrGoNpfza2NvbfFPJqW6O7EGO85Vnh+amWg51xUyV9GtRZpqLOsO+7JCh35CWnkM9cLRwoA0tgcmyEpIAo+Ir6wc2dN3LQYqNidYIGWDj8w/6CuewRLF/pIqI7obYEEKmrt7hdql9jbS4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633620767; h=Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=UYvRnykkC4aGZJ+rA/fAtR0kLQylq2L/WDQ9JyCtrVk=; b=b5dJ8ezvsj65hcPTKb/LBBf1vsIIb95VuHhGQZY5oUQo2vCPhtYRWVAOTO7+MBsRuxsWf6hM3Jp/pnLBhw+RNfak5q8V7b9/qUk7h0dD49CSJxpvvLCBM1OmSG77Nu4WQ3AhRaioSQUxDeYZWAU2evDSolZ8igtNOAODAPT1fZ4= 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+81583+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 1633620767236398.32994300291546; Thu, 7 Oct 2021 08:32:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id oe7YYY1788612xi8QLHRUjyr; Thu, 07 Oct 2021 08:32:46 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.13671.1633620765798166748 for ; Thu, 07 Oct 2021 08:32:46 -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 DC88411FB; Thu, 7 Oct 2021 08:32:44 -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 19C9E3F66F; Thu, 7 Oct 2021 08:32:43 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [edk2-devel] [PATCH v2 05/21] DynamicTablesPkg: Add AmlSetRdListCheckSum() Date: Thu, 7 Oct 2021 16:31:54 +0100 Message-Id: <20211007153210.26608-6-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: JdBYAB0oXSTWn6xGp9Niw2L4x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1633620766; bh=wJ9t3ksII8Gr+m46N3XCRqd55t6fz44W9cfmjzNZ+nY=; h=Date:From:Reply-To:Subject:To; b=lUZl4oNBtHZ6JcaIppvrhW0kpkVXkwtWrW58+BQc7cdheNY2sYMcoHah1oV3OKN+Tjj tA/uiAmckkoxEFdIkWtpUbrxDqjec2TBohK7EDdAFM24+HlPVTLRNr0cnBMDUAI1rQEoT XC17LTOPwSe8N1PZrjbRoIN1+tz/+W8+VlY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1633620768233100010 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Lists of Resource Data elements end with an EndTag (most of the time). This function finds the EndTag (if present) in a list of Resource Data elements and sets the checksum. ACPI 6.4, s6.4.2.9 "End Tag": "This checksum is generated such that adding it to the sum of all the data 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." Signed-off-by: Pierre Gondois Reviewed-by: Sami Mujawar --- .../Library/Common/AmlLib/Utils/AmlUtility.c | 76 +++++++++++++++++++ .../Library/Common/AmlLib/Utils/AmlUtility.h | 32 ++++++++ 2 files changed, 108 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c b/Dy= namicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c index 7ebd08f945c0..ef159e3b831e 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.c @@ -904,3 +904,79 @@ AmlPropagateInformation ( =20 return EFI_SUCCESS; } + +/** Find and set the EndTag's Checksum of a list of Resource Data elements. + + Lists of Resource Data elements end with an EndTag (most of the time). T= his + function finds the EndTag (if present) in a list of Resource Data elemen= ts + and sets the checksum. + + 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] BufferOpNode Node having a list of Resource Data elements. + @param [in] CheckSum CheckSum to store in the EndTag. + To ignore/avoid computing the checksum, + give 0. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_NOT_FOUND No EndTag found. +**/ +EFI_STATUS +EFIAPI +AmlSetRdListCheckSum ( + IN AML_OBJECT_NODE * BufferOpNode, + IN UINT8 CheckSum + ) +{ + EFI_STATUS Status; + AML_DATA_NODE * LastRdNode; + AML_RD_HEADER RdDataType; + + if (!AmlNodeCompareOpCode (BufferOpNode, AML_BUFFER_OP, 0)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // Get the last Resource data node in the variable list of + // argument of the BufferOp node. + LastRdNode =3D (AML_DATA_NODE*)AmlGetPreviousVariableArgument ( + (AML_NODE_HEADER*)BufferOpNode, + NULL + ); + if ((LastRdNode =3D=3D NULL) || + !IS_AML_DATA_NODE (LastRdNode) || + (LastRdNode->DataType !=3D EAmlNodeDataTypeResourceData)) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + Status =3D AmlGetResourceDataType (LastRdNode, &RdDataType); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Check the LastRdNode is an EndTag. + // It is possible to have only one Resource Data in a BufferOp with + // no EndTag. Return EFI_NOT_FOUND is such case. + if (!AmlRdCompareDescId ( + &RdDataType, + AML_RD_BUILD_SMALL_DESC_ID (ACPI_SMALL_END_TAG_DESCRIPTOR_NAME))) { + ASSERT (0); + return EFI_NOT_FOUND; + } + + Status =3D AmlRdSetEndTagChecksum (LastRdNode->Buffer, CheckSum); + ASSERT_EFI_ERROR (Status); + + return Status; +} diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h b/Dy= namicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h index c57d780140d4..4667f57d7f08 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h +++ b/DynamicTablesPkg/Library/Common/AmlLib/Utils/AmlUtility.h @@ -91,5 +91,37 @@ AmlPropagateInformation ( IN UINT8 NodeCount ); =20 +/** Find and set the EndTag's Checksum of a list of Resource Data elements. + + Lists of Resource Data elements end with an EndTag (most of the time). T= his + function finds the EndTag (if present) in a list of Resource Data elemen= ts + and sets the checksum. + + 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] BufferOpNode Node having a list of Resource Data elements. + @param [in] CheckSum CheckSum to store in the EndTag. + To ignore/avoid computing the checksum, + give 0. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_NOT_FOUND No EndTag found. +**/ +EFI_STATUS +EFIAPI +AmlSetRdListCheckSum ( + IN AML_OBJECT_NODE * BufferOpNode, + IN UINT8 CheckSum + ); + #endif // AML_UTILITY_H_ =20 --=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 (#81583): https://edk2.groups.io/g/devel/message/81583 Mute This Topic: https://groups.io/mt/86148193/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-