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.
51 DumpSratApicProximity (
52 IN CONST CHAR16
* Format
,
57 An ACPI_PARSER array describing the SRAT Table.
59 STATIC CONST ACPI_PARSER SratParser
[] = {
60 PARSE_ACPI_HEADER (&AcpiHdrInfo
),
61 {L
"Reserved", 4, 36, L
"0x%x", NULL
, NULL
, ValidateSratReserved
, NULL
},
62 {L
"Reserved", 8, 40, L
"0x%lx", NULL
, NULL
, NULL
, NULL
}
66 An ACPI_PARSER array describing the Resource Allocation structure header.
68 STATIC CONST ACPI_PARSER SratResourceAllocationParser
[] = {
69 {L
"Type", 1, 0, NULL
, NULL
, (VOID
**)&SratRAType
, NULL
, NULL
},
70 {L
"Length", 1, 1, NULL
, NULL
, (VOID
**)&SratRALength
, NULL
, NULL
}
74 An ACPI_PARSER array describing the GICC Affinity structure.
76 STATIC CONST ACPI_PARSER SratGicCAffinityParser
[] = {
77 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
78 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
80 {L
"Proximity Domain", 4, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
81 {L
"ACPI Processor UID", 4, 6, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
82 {L
"Flags", 4, 10, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
83 {L
"Clock Domain", 4, 14, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
87 An ACPI_PARSER array describing the GIC ITS Affinity structure.
89 STATIC CONST ACPI_PARSER SratGicITSAffinityParser
[] = {
90 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
91 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
93 {L
"Proximity Domain", 4, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
94 {L
"Reserved", 2, 6, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
95 {L
"ITS Id", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
99 An ACPI_PARSER array describing the Memory Affinity structure.
101 STATIC CONST ACPI_PARSER SratMemAffinityParser
[] = {
102 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
103 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
105 {L
"Proximity Domain", 4, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
106 {L
"Reserved", 2, 6, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
107 {L
"Base Address Low", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
108 {L
"Base Address High", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
109 {L
"Length Low", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
110 {L
"Length High", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
111 {L
"Reserved", 4, 24, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
112 {L
"Flags", 4, 28, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
113 {L
"Reserved", 8, 32, L
"0x%lx", NULL
, NULL
, NULL
, NULL
}
117 An ACPI_PARSER array describing the APIC/SAPIC Affinity structure.
119 STATIC CONST ACPI_PARSER SratApciSapicAffinityParser
[] = {
120 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
121 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
123 {L
"Proximity Domain [7:0]", 1, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
124 {L
"APIC ID", 1, 3, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
125 {L
"Flags", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
126 {L
"Local SAPIC EID", 1, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
127 {L
"Proximity Domain [31:8]", 3, 9, L
"0x%x", DumpSratApicProximity
,
129 {L
"Clock Domain", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
133 An ACPI_PARSER array describing the Processor Local x2APIC Affinity structure.
135 STATIC CONST ACPI_PARSER SratX2ApciAffinityParser
[] = {
136 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
137 {L
"Length", 1, 1, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
139 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
140 {L
"Proximity Domain", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
141 {L
"X2APIC ID", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
142 {L
"Flags", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
143 {L
"Clock Domain", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
144 {L
"Reserved", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
147 /** This function validates the Reserved field in the SRAT table header.
149 @param [in] Ptr Pointer to the start of the field data.
150 @param [in] Context Pointer to context specific information e.g. this
151 could be a pointer to the ACPI table header.
156 ValidateSratReserved (
161 if (*(UINT32
*)Ptr
!= 1) {
162 IncrementErrorCount ();
163 Print (L
"\nERROR: Reserved should be 1 for backward compatibility.\n");
168 This function traces the APIC Proximity Domain field.
170 @param [in] Format Format string for tracing the data.
171 @param [in] Ptr Pointer to the start of the buffer.
175 DumpSratApicProximity (
176 IN CONST CHAR16
* Format
,
180 UINT32 ProximityDomain
;
182 ProximityDomain
= Ptr
[0] | (Ptr
[1] << 8) | (Ptr
[2] << 16);
184 Print (Format
, ProximityDomain
);
188 This function parses the ACPI SRAT table.
189 When trace is enabled this function parses the SRAT table and
190 traces the ACPI table fields.
192 This function parses the following Resource Allocation Structures:
193 - Processor Local APIC/SAPIC Affinity Structure
194 - Memory Affinity Structure
195 - Processor Local x2APIC Affinity Structure
196 - GICC Affinity Structure
198 This function also performs validation of the ACPI table fields.
200 @param [in] Trace If TRUE, trace the ACPI fields.
201 @param [in] Ptr Pointer to the start of the buffer.
202 @param [in] AcpiTableLength Length of the ACPI table.
203 @param [in] AcpiTableRevision Revision of the ACPI table.
210 IN UINT32 AcpiTableLength
,
211 IN UINT8 AcpiTableRevision
216 UINT32 GicCAffinityIndex
;
217 UINT32 GicITSAffinityIndex
;
218 UINT32 MemoryAffinityIndex
;
219 UINT32 ApicSapicAffinityIndex
;
220 UINT32 X2ApicAffinityIndex
;
221 CHAR8 Buffer
[80]; // Used for AsciiName param of ParseAcpi
223 GicCAffinityIndex
= 0;
224 GicITSAffinityIndex
= 0;
225 MemoryAffinityIndex
= 0;
226 ApicSapicAffinityIndex
= 0;
227 X2ApicAffinityIndex
= 0;
239 PARSER_PARAMS (SratParser
)
241 ResourcePtr
= Ptr
+ Offset
;
243 while (Offset
< AcpiTableLength
) {
249 2, // The length is 1 byte at offset 1
250 PARSER_PARAMS (SratResourceAllocationParser
)
253 switch (*SratRAType
) {
254 case EFI_ACPI_6_2_GICC_AFFINITY
:
258 "GICC Affinity Structure [%d]",
267 PARSER_PARAMS (SratGicCAffinityParser
)
271 case EFI_ACPI_6_2_GIC_ITS_AFFINITY
:
275 "GIC ITS Affinity Structure [%d]",
276 GicITSAffinityIndex
++
284 PARSER_PARAMS (SratGicITSAffinityParser
)
288 case EFI_ACPI_6_2_MEMORY_AFFINITY
:
292 "Memory Affinity Structure [%d]",
293 MemoryAffinityIndex
++
301 PARSER_PARAMS (SratMemAffinityParser
)
305 case EFI_ACPI_6_2_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY
:
309 "APIC/SAPIC Affinity Structure [%d]",
310 ApicSapicAffinityIndex
++
318 PARSER_PARAMS (SratApciSapicAffinityParser
)
322 case EFI_ACPI_6_2_PROCESSOR_LOCAL_X2APIC_AFFINITY
:
326 "X2APIC Affinity Structure [%d]",
327 X2ApicAffinityIndex
++
335 PARSER_PARAMS (SratX2ApciAffinityParser
)
340 IncrementErrorCount ();
341 Print (L
"ERROR: Unknown SRAT Affinity type = 0x%x\n", *SratRAType
);
345 ResourcePtr
+= (*SratRALength
);
346 Offset
+= (*SratRALength
);