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.web09.13578.1633620769174312210 for ; Thu, 07 Oct 2021 08:32:49 -0700 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 BD8A111D4; Thu, 7 Oct 2021 08:32:43 -0700 (PDT) Received: from e120189.arm.com (unknown [10.57.72.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B3DC63F66F; Thu, 7 Oct 2021 08:32:42 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [PATCH v2 04/21] DynamicTablesPkg: Add AmlRdSetEndTagChecksum() Date: Thu, 7 Oct 2021 16:31:53 +0100 Message-Id: <20211007153210.26608-5-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211007153210.26608-1-Pierre.Gondois@arm.com> References: <20211007153210.26608-1-Pierre.Gondois@arm.com> From: Pierre Gondois Add AmlRdSetEndTagChecksum(), setting the CheckSum value contained in a Resource Data element. 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 --- .../AmlLib/ResourceData/AmlResourceData.c | 33 +++++++++++++++++++ .../AmlLib/ResourceData/AmlResourceData.h | 21 ++++++++++++ 2 files changed, 54 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.c b/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.c index 8b46c7232df3..41cf0bc45314 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.c @@ -101,3 +101,36 @@ AmlRdGetSize ( return ((ACPI_SMALL_RESOURCE_HEADER*)Header)->Bits.Length + sizeof (ACPI_SMALL_RESOURCE_HEADER); } + +/** Set the Checksum of an EndTag resource data. + + 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." + + @param [in] Header Pointer to the first byte of a resource data. + @param [in] CheckSum Checksum value to set. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlRdSetEndTagChecksum ( + IN CONST AML_RD_HEADER * Header, + IN UINT8 CheckSum + ) +{ + if ((Header == NULL) || + !AmlRdCompareDescId ( + Header, + AML_RD_BUILD_SMALL_DESC_ID (ACPI_SMALL_END_TAG_DESCRIPTOR_NAME))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + ((EFI_ACPI_END_TAG_DESCRIPTOR*)Header)->Checksum = CheckSum; + return EFI_SUCCESS; +} diff --git a/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.h b/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.h index 48e4e2aaddb4..e478107dffbd 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.h +++ b/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.h @@ -171,4 +171,25 @@ AmlRdGetSize ( IN CONST AML_RD_HEADER * Header ); +/** Set the Checksum of an EndTag resource data. + + 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." + + @param [in] Header Pointer to the first byte of a resource data. + @param [in] CheckSum Checksum value to set. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +EFI_STATUS +EFIAPI +AmlRdSetEndTagChecksum ( + IN CONST AML_RD_HEADER * Header, + IN UINT8 CheckSum + ); + #endif // AML_RESOURCE_DATA_H_ -- 2.17.1