4 Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 - ACPI 6.2 Specification - Errata A, September 2017
17 #include <IndustryStandard/Acpi.h>
18 #include <Library/PrintLib.h>
19 #include <Library/UefiLib.h>
20 #include "AcpiParser.h"
21 #include "AcpiTableParser.h"
24 STATIC CONST UINT8
* SratRAType
;
25 STATIC CONST UINT8
* SratRALength
;
26 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
;
29 This function validates the Reserved field in the SRAT table header.
31 @param [in] Ptr Pointer to the start of the field data.
32 @param [in] Context Pointer to context specific information e.g. this
33 could be a pointer to the ACPI table header.
38 ValidateSratReserved (
44 This function traces the APIC Proximity Domain field.
46 @param [in] Format Format string for tracing the data.
47 @param [in] Ptr Pointer to the start of the buffer.
52 DumpSratApicProximity (
53 IN CONST CHAR16
* Format
,
58 An ACPI_PARSER array describing the SRAT Table.
60 STATIC CONST ACPI_PARSER SratParser
[] = {
61 PARSE_ACPI_HEADER (&AcpiHdrInfo
),
62 {L
"Reserved", 4, 36, L
"0x%x", NULL
, NULL
, ValidateSratReserved
, NULL
},
63 {L
"Reserved", 8, 40, L
"0x%lx", NULL
, NULL
, NULL
, NULL
}
67 An ACPI_PARSER array describing the Resource Allocation structure header.
69 STATIC CONST ACPI_PARSER SratResourceAllocationParser
[] = {
70 {L
"Type", 1, 0, NULL
, NULL
, (VOID
**)&SratRAType
, NULL
, NULL
},
71 {L
"Length", 1, 1, NULL
, NULL
, (VOID
**)&SratRALength
, NULL
, NULL
}
75 An ACPI_PARSER array describing the GICC Affinity structure.
77 STATIC CONST ACPI_PARSER SratGicCAffinityParser
[] = {
78 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
79 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
81 {L
"Proximity Domain", 4, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
82 {L
"ACPI Processor UID", 4, 6, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
83 {L
"Flags", 4, 10, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
84 {L
"Clock Domain", 4, 14, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
88 An ACPI_PARSER array describing the GIC ITS Affinity structure.
90 STATIC CONST ACPI_PARSER SratGicITSAffinityParser
[] = {
91 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
92 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
94 {L
"Proximity Domain", 4, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
95 {L
"Reserved", 2, 6, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
96 {L
"ITS Id", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
100 An ACPI_PARSER array describing the Memory Affinity structure.
102 STATIC CONST ACPI_PARSER SratMemAffinityParser
[] = {
103 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
104 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
106 {L
"Proximity Domain", 4, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
107 {L
"Reserved", 2, 6, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
108 {L
"Base Address Low", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
109 {L
"Base Address High", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
110 {L
"Length Low", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
111 {L
"Length High", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
112 {L
"Reserved", 4, 24, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
113 {L
"Flags", 4, 28, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
114 {L
"Reserved", 8, 32, L
"0x%lx", NULL
, NULL
, NULL
, NULL
}
118 An ACPI_PARSER array describing the APIC/SAPIC Affinity structure.
120 STATIC CONST ACPI_PARSER SratApciSapicAffinityParser
[] = {
121 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
122 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
124 {L
"Proximity Domain [7:0]", 1, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
125 {L
"APIC ID", 1, 3, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
126 {L
"Flags", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
127 {L
"Local SAPIC EID", 1, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
128 {L
"Proximity Domain [31:8]", 3, 9, L
"0x%x", DumpSratApicProximity
,
130 {L
"Clock Domain", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
134 An ACPI_PARSER array describing the Processor Local x2APIC Affinity structure.
136 STATIC CONST ACPI_PARSER SratX2ApciAffinityParser
[] = {
137 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
138 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
140 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
141 {L
"Proximity Domain", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
142 {L
"X2APIC ID", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
143 {L
"Flags", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
144 {L
"Clock Domain", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
145 {L
"Reserved", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
148 /** This function validates the Reserved field in the SRAT table header.
150 @param [in] Ptr Pointer to the start of the field data.
151 @param [in] Context Pointer to context specific information e.g. this
152 could be a pointer to the ACPI table header.
157 ValidateSratReserved (
162 if (*(UINT32
*)Ptr
!= 1) {
163 IncrementErrorCount ();
164 Print (L
"\nERROR: Reserved should be 1 for backward compatibility.\n");
169 This function traces the APIC Proximity Domain field.
171 @param [in] Format Format string for tracing the data.
172 @param [in] Ptr Pointer to the start of the buffer.
177 DumpSratApicProximity (
178 IN CONST CHAR16
* Format
,
182 UINT32 ProximityDomain
;
184 ProximityDomain
= Ptr
[0] | (Ptr
[1] << 8) | (Ptr
[2] << 16);
186 Print (Format
, ProximityDomain
);
190 This function parses the ACPI SRAT table.
191 When trace is enabled this function parses the SRAT table and
192 traces the ACPI table fields.
194 This function parses the following Resource Allocation Structures:
195 - Processor Local APIC/SAPIC Affinity Structure
196 - Memory Affinity Structure
197 - Processor Local x2APIC Affinity Structure
198 - GICC Affinity Structure
200 This function also performs validation of the ACPI table fields.
202 @param [in] Trace If TRUE, trace the ACPI fields.
203 @param [in] Ptr Pointer to the start of the buffer.
204 @param [in] AcpiTableLength Length of the ACPI table.
205 @param [in] AcpiTableRevision Revision of the ACPI table.
212 IN UINT32 AcpiTableLength
,
213 IN UINT8 AcpiTableRevision
218 UINT32 GicCAffinityIndex
;
219 UINT32 GicITSAffinityIndex
;
220 UINT32 MemoryAffinityIndex
;
221 UINT32 ApicSapicAffinityIndex
;
222 UINT32 X2ApicAffinityIndex
;
223 CHAR8 Buffer
[80]; // Used for AsciiName param of ParseAcpi
225 GicCAffinityIndex
= 0;
226 GicITSAffinityIndex
= 0;
227 MemoryAffinityIndex
= 0;
228 ApicSapicAffinityIndex
= 0;
229 X2ApicAffinityIndex
= 0;
241 PARSER_PARAMS (SratParser
)
243 ResourcePtr
= Ptr
+ Offset
;
245 while (Offset
< AcpiTableLength
) {
251 2, // The length is 1 byte at offset 1
252 PARSER_PARAMS (SratResourceAllocationParser
)
255 switch (*SratRAType
) {
256 case EFI_ACPI_6_2_GICC_AFFINITY
:
260 "GICC Affinity Structure [%d]",
269 PARSER_PARAMS (SratGicCAffinityParser
)
273 case EFI_ACPI_6_2_GIC_ITS_AFFINITY
:
277 "GIC ITS Affinity Structure [%d]",
278 GicITSAffinityIndex
++
286 PARSER_PARAMS (SratGicITSAffinityParser
)
290 case EFI_ACPI_6_2_MEMORY_AFFINITY
:
294 "Memory Affinity Structure [%d]",
295 MemoryAffinityIndex
++
303 PARSER_PARAMS (SratMemAffinityParser
)
307 case EFI_ACPI_6_2_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY
:
311 "APIC/SAPIC Affinity Structure [%d]",
312 ApicSapicAffinityIndex
++
320 PARSER_PARAMS (SratApciSapicAffinityParser
)
324 case EFI_ACPI_6_2_PROCESSOR_LOCAL_X2APIC_AFFINITY
:
328 "X2APIC Affinity Structure [%d]",
329 X2ApicAffinityIndex
++
337 PARSER_PARAMS (SratX2ApciAffinityParser
)
342 IncrementErrorCount ();
343 Print (L
"ERROR: Unknown SRAT Affinity type = 0x%x\n", *SratRAType
);
347 ResourcePtr
+= (*SratRALength
);
348 Offset
+= (*SratRALength
);