4 Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 - ACPI 6.2 Specification - Errata A, September 2017
11 #include <IndustryStandard/Acpi.h>
12 #include <Library/PrintLib.h>
13 #include <Library/UefiLib.h>
14 #include "AcpiParser.h"
15 #include "AcpiTableParser.h"
18 STATIC CONST UINT8
* SratRAType
;
19 STATIC CONST UINT8
* SratRALength
;
20 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
;
23 This function validates the Reserved field in the SRAT table header.
25 @param [in] Ptr Pointer to the start of the field data.
26 @param [in] Context Pointer to context specific information e.g. this
27 could be a pointer to the ACPI table header.
32 ValidateSratReserved (
38 This function traces the APIC Proximity Domain field.
40 @param [in] Format Format string for tracing the data.
41 @param [in] Ptr Pointer to the start of the buffer.
46 DumpSratApicProximity (
47 IN CONST CHAR16
* Format
,
52 An ACPI_PARSER array describing the SRAT Table.
54 STATIC CONST ACPI_PARSER SratParser
[] = {
55 PARSE_ACPI_HEADER (&AcpiHdrInfo
),
56 {L
"Reserved", 4, 36, L
"0x%x", NULL
, NULL
, ValidateSratReserved
, NULL
},
57 {L
"Reserved", 8, 40, L
"0x%lx", NULL
, NULL
, NULL
, NULL
}
61 An ACPI_PARSER array describing the Resource Allocation structure header.
63 STATIC CONST ACPI_PARSER SratResourceAllocationParser
[] = {
64 {L
"Type", 1, 0, NULL
, NULL
, (VOID
**)&SratRAType
, NULL
, NULL
},
65 {L
"Length", 1, 1, NULL
, NULL
, (VOID
**)&SratRALength
, NULL
, NULL
}
69 An ACPI_PARSER array describing the GICC Affinity structure.
71 STATIC CONST ACPI_PARSER SratGicCAffinityParser
[] = {
72 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
73 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
75 {L
"Proximity Domain", 4, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
76 {L
"ACPI Processor UID", 4, 6, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
77 {L
"Flags", 4, 10, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
78 {L
"Clock Domain", 4, 14, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
82 An ACPI_PARSER array describing the GIC ITS Affinity structure.
84 STATIC CONST ACPI_PARSER SratGicITSAffinityParser
[] = {
85 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
86 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
88 {L
"Proximity Domain", 4, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
89 {L
"Reserved", 2, 6, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
90 {L
"ITS Id", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
94 An ACPI_PARSER array describing the Memory Affinity structure.
96 STATIC CONST ACPI_PARSER SratMemAffinityParser
[] = {
97 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
98 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
100 {L
"Proximity Domain", 4, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
101 {L
"Reserved", 2, 6, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
102 {L
"Base Address Low", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
103 {L
"Base Address High", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
104 {L
"Length Low", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
105 {L
"Length High", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
106 {L
"Reserved", 4, 24, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
107 {L
"Flags", 4, 28, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
108 {L
"Reserved", 8, 32, L
"0x%lx", NULL
, NULL
, NULL
, NULL
}
112 An ACPI_PARSER array describing the APIC/SAPIC Affinity structure.
114 STATIC CONST ACPI_PARSER SratApciSapicAffinityParser
[] = {
115 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
116 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
118 {L
"Proximity Domain [7:0]", 1, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
119 {L
"APIC ID", 1, 3, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
120 {L
"Flags", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
121 {L
"Local SAPIC EID", 1, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
122 {L
"Proximity Domain [31:8]", 3, 9, L
"0x%x", DumpSratApicProximity
,
124 {L
"Clock Domain", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
128 An ACPI_PARSER array describing the Processor Local x2APIC Affinity structure.
130 STATIC CONST ACPI_PARSER SratX2ApciAffinityParser
[] = {
131 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
132 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
134 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
135 {L
"Proximity Domain", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
136 {L
"X2APIC ID", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
137 {L
"Flags", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
138 {L
"Clock Domain", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
139 {L
"Reserved", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
142 /** This function validates the Reserved field in the SRAT table header.
144 @param [in] Ptr Pointer to the start of the field data.
145 @param [in] Context Pointer to context specific information e.g. this
146 could be a pointer to the ACPI table header.
151 ValidateSratReserved (
156 if (*(UINT32
*)Ptr
!= 1) {
157 IncrementErrorCount ();
158 Print (L
"\nERROR: Reserved should be 1 for backward compatibility.\n");
163 This function traces the APIC Proximity Domain field.
165 @param [in] Format Format string for tracing the data.
166 @param [in] Ptr Pointer to the start of the buffer.
171 DumpSratApicProximity (
172 IN CONST CHAR16
* Format
,
176 UINT32 ProximityDomain
;
178 ProximityDomain
= Ptr
[0] | (Ptr
[1] << 8) | (Ptr
[2] << 16);
180 Print (Format
, ProximityDomain
);
184 This function parses the ACPI SRAT table.
185 When trace is enabled this function parses the SRAT table and
186 traces the ACPI table fields.
188 This function parses the following Resource Allocation Structures:
189 - Processor Local APIC/SAPIC Affinity Structure
190 - Memory Affinity Structure
191 - Processor Local x2APIC Affinity Structure
192 - GICC Affinity Structure
194 This function also performs validation of the ACPI table fields.
196 @param [in] Trace If TRUE, trace the ACPI fields.
197 @param [in] Ptr Pointer to the start of the buffer.
198 @param [in] AcpiTableLength Length of the ACPI table.
199 @param [in] AcpiTableRevision Revision of the ACPI table.
206 IN UINT32 AcpiTableLength
,
207 IN UINT8 AcpiTableRevision
212 UINT32 GicCAffinityIndex
;
213 UINT32 GicITSAffinityIndex
;
214 UINT32 MemoryAffinityIndex
;
215 UINT32 ApicSapicAffinityIndex
;
216 UINT32 X2ApicAffinityIndex
;
217 CHAR8 Buffer
[80]; // Used for AsciiName param of ParseAcpi
219 GicCAffinityIndex
= 0;
220 GicITSAffinityIndex
= 0;
221 MemoryAffinityIndex
= 0;
222 ApicSapicAffinityIndex
= 0;
223 X2ApicAffinityIndex
= 0;
235 PARSER_PARAMS (SratParser
)
237 ResourcePtr
= Ptr
+ Offset
;
239 while (Offset
< AcpiTableLength
) {
245 2, // The length is 1 byte at offset 1
246 PARSER_PARAMS (SratResourceAllocationParser
)
249 switch (*SratRAType
) {
250 case EFI_ACPI_6_2_GICC_AFFINITY
:
254 "GICC Affinity Structure [%d]",
263 PARSER_PARAMS (SratGicCAffinityParser
)
267 case EFI_ACPI_6_2_GIC_ITS_AFFINITY
:
271 "GIC ITS Affinity Structure [%d]",
272 GicITSAffinityIndex
++
280 PARSER_PARAMS (SratGicITSAffinityParser
)
284 case EFI_ACPI_6_2_MEMORY_AFFINITY
:
288 "Memory Affinity Structure [%d]",
289 MemoryAffinityIndex
++
297 PARSER_PARAMS (SratMemAffinityParser
)
301 case EFI_ACPI_6_2_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY
:
305 "APIC/SAPIC Affinity Structure [%d]",
306 ApicSapicAffinityIndex
++
314 PARSER_PARAMS (SratApciSapicAffinityParser
)
318 case EFI_ACPI_6_2_PROCESSOR_LOCAL_X2APIC_AFFINITY
:
322 "X2APIC Affinity Structure [%d]",
323 X2ApicAffinityIndex
++
331 PARSER_PARAMS (SratX2ApciAffinityParser
)
336 IncrementErrorCount ();
337 Print (L
"ERROR: Unknown SRAT Affinity type = 0x%x\n", *SratRAType
);
341 ResourcePtr
+= (*SratRALength
);
342 Offset
+= (*SratRALength
);