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.web10.10319.1633704407799675002 for ; Fri, 08 Oct 2021 07:46:48 -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 664C91396; Fri, 8 Oct 2021 07:46:42 -0700 (PDT) Received: from e120189.arm.com (unknown [10.57.73.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 541E63F66F; Fri, 8 Oct 2021 07:46:41 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io, Sami Mujawar , Alexei.Fedorov@arm.com Subject: [PATCH v3 04/21] DynamicTablesPkg: Add AmlRdSetEndTagChecksum() Date: Fri, 8 Oct 2021 15:46:15 +0100 Message-Id: <20211008144632.31894-5-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211008144632.31894-1-Pierre.Gondois@arm.com> References: <20211008144632.31894-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." Reviewed-by: Sami Mujawar 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