4 Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 - Rd or RD - Resource Data
10 - Rds or RDS - Resource Data Small
11 - Rdl or RDL - Resource Data Large
14 #include <ResourceData/AmlResourceData.h>
16 /** Check whether the resource data has the input descriptor Id.
18 The small/large bit is included in the descriptor Id,
19 but the size bits are not included for small resource data elements.
21 @param [in] Header Pointer to the first byte of a resource data
23 @param [in] DescriptorId The descriptor to check against.
25 @retval TRUE The resource data has the descriptor Id.
26 @retval FALSE Otherwise.
31 IN CONST AML_RD_HEADER
*Header
,
32 IN AML_RD_HEADER DescriptorId
40 if (AML_RD_IS_LARGE (Header
)) {
41 return ((*Header
^ DescriptorId
) == 0);
43 return (((*Header
& AML_RD_SMALL_ID_MASK
) ^ DescriptorId
) == 0);
47 /** Get the descriptor Id of the resource data.
49 The small/large bit is included in the descriptor Id,
50 but the size bits are not included for small resource data elements.
52 @param [in] Header Pointer to the first byte of a resource data.
54 @return A descriptor Id.
59 IN CONST AML_RD_HEADER
*Header
67 if (AML_RD_IS_LARGE (Header
)) {
71 // Header is a small resource data element.
72 return *Header
& AML_RD_SMALL_ID_MASK
;
75 /** Get the size of a resource data element.
77 If the resource data element is of the large type, the Header
78 is expected to be at least 3 bytes long.
80 @param [in] Header Pointer to the first byte of a resource data.
82 @return The size of the resource data element.
87 IN CONST AML_RD_HEADER
*Header
95 if (AML_RD_IS_LARGE (Header
)) {
96 return ((ACPI_LARGE_RESOURCE_HEADER
*)Header
)->Length
+
97 sizeof (ACPI_LARGE_RESOURCE_HEADER
);
100 // Header is a small resource data element.
101 return ((ACPI_SMALL_RESOURCE_HEADER
*)Header
)->Bits
.Length
+
102 sizeof (ACPI_SMALL_RESOURCE_HEADER
);
105 /** Set the Checksum of an EndTag resource data.
107 ACPI 6.4, s6.4.2.9 "End Tag":
108 "This checksum is generated such that adding it to the sum of all the data
109 bytes will produce a zero sum."
110 "If the checksum field is zero, the resource data is treated as if the
111 checksum operation succeeded. Configuration proceeds normally."
113 @param [in] Header Pointer to the first byte of a resource data.
114 @param [in] CheckSum Checksum value to set.
116 @retval EFI_SUCCESS The function completed successfully.
117 @retval EFI_INVALID_PARAMETER Invalid parameter.
121 AmlRdSetEndTagChecksum (
122 IN CONST AML_RD_HEADER
*Header
,
126 if ((Header
== NULL
) ||
127 !AmlRdCompareDescId (
129 AML_RD_BUILD_SMALL_DESC_ID (ACPI_SMALL_END_TAG_DESCRIPTOR_NAME
)
133 return EFI_INVALID_PARAMETER
;
136 ((EFI_ACPI_END_TAG_DESCRIPTOR
*)Header
)->Checksum
= CheckSum
;