[edk2-devel] [PATCH v2 04/21] DynamicTablesPkg: Add AmlRdSetEndTagChecksum()

PierreGondois posted 21 patches 4 years, 4 months ago
There is a newer version of this series
[edk2-devel] [PATCH v2 04/21] DynamicTablesPkg: Add AmlRdSetEndTagChecksum()
Posted by PierreGondois 4 years, 4 months ago
From: Pierre Gondois <Pierre.Gondois@arm.com>

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 <Pierre.Gondois@arm.com>
---
 .../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



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81589): https://edk2.groups.io/g/devel/message/81589
Mute This Topic: https://groups.io/mt/86148199/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v2 04/21] DynamicTablesPkg: Add AmlRdSetEndTagChecksum()
Posted by Sami Mujawar 4 years, 4 months ago
  Hi Pierre,

Thank you for this patch.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

On 07/10/2021 04:31 PM, Pierre.Gondois@arm.com wrote:
> From: Pierre Gondois <Pierre.Gondois@arm.com>
>
> 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 <Pierre.Gondois@arm.com>
> ---
>   .../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_

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81676): https://edk2.groups.io/g/devel/message/81676
Mute This Topic: https://groups.io/mt/86148199/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-