diff options
author | Pierre Gondois <Pierre.Gondois@arm.com> | 2021-10-08 15:46:15 +0100 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-10-08 15:39:42 +0000 |
commit | 28b2df475fb214d11ee50f5a924cedee671f0ba1 (patch) | |
tree | 405f67476c3df49ad78171521d9bf0c434afa546 | |
parent | bfaf7c8b9e4b89eb49c6357e50ba556e5fc47387 (diff) | |
download | edk2-28b2df475fb214d11ee50f5a924cedee671f0ba1.tar.gz edk2-28b2df475fb214d11ee50f5a924cedee671f0ba1.tar.bz2 edk2-28b2df475fb214d11ee50f5a924cedee671f0ba1.zip |
DynamicTablesPkg: Add AmlRdSetEndTagChecksum()
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 <sami.mujawar@arm.com>
Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
-rw-r--r-- | DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.c | 33 | ||||
-rw-r--r-- | DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.h | 21 |
2 files changed, 54 insertions, 0 deletions
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.c b/DynamicTablesPkg/Library/Common/AmlLib/ResourceData/AmlResourceData.c index 8b46c7232d..41cf0bc453 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 48e4e2aadd..e478107dff 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_
|