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
= Ptr
[0] | (Ptr
[1] << 8) | (Ptr
[2] << 16);
181 Print (Format
, ProximityDomain
);
185 This function parses the ACPI SRAT table.
186 When trace is enabled this function parses the SRAT table and
187 traces the ACPI table fields.
189 This function parses the following Resource Allocation Structures:
190 - Processor Local APIC/SAPIC Affinity Structure
191 - Memory Affinity Structure
192 - Processor Local x2APIC Affinity Structure
193 - GICC Affinity Structure
195 This function also performs validation of the ACPI table fields.
197 @param [in] Trace If TRUE, trace the ACPI fields.
198 @param [in] Ptr Pointer to the start of the buffer.
199 @param [in] AcpiTableLength Length of the ACPI table.
200 @param [in] AcpiTableRevision Revision of the ACPI table.
207 IN UINT32 AcpiTableLength
,
208 IN UINT8 AcpiTableRevision
213 UINT32 GicCAffinityIndex
= 0;
214 UINT32 GicITSAffinityIndex
= 0;
215 UINT32 MemoryAffinityIndex
= 0;
216 UINT32 ApicSapicAffinityIndex
= 0;
217 UINT32 X2ApicAffinityIndex
= 0;
218 CHAR8 Buffer
[80]; // Used for AsciiName param of ParseAcpi
230 PARSER_PARAMS (SratParser
)
232 ResourcePtr
= Ptr
+ Offset
;
234 while (Offset
< AcpiTableLength
) {
240 2, // The length is 1 byte at offset 1
241 PARSER_PARAMS (SratResourceAllocationParser
)
244 switch (*SratRAType
) {
245 case EFI_ACPI_6_2_GICC_AFFINITY
:
249 "GICC Affinity Structure [%d]",
258 PARSER_PARAMS (SratGicCAffinityParser
)
262 case EFI_ACPI_6_2_GIC_ITS_AFFINITY
:
266 "GIC ITS Affinity Structure [%d]",
267 GicITSAffinityIndex
++
275 PARSER_PARAMS (SratGicITSAffinityParser
)
279 case EFI_ACPI_6_2_MEMORY_AFFINITY
:
283 "Memory Affinity Structure [%d]",
284 MemoryAffinityIndex
++
292 PARSER_PARAMS (SratMemAffinityParser
)
296 case EFI_ACPI_6_2_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY
:
300 "APIC/SAPIC Affinity Structure [%d]",
301 ApicSapicAffinityIndex
++
309 PARSER_PARAMS (SratApciSapicAffinityParser
)
313 case EFI_ACPI_6_2_PROCESSOR_LOCAL_X2APIC_AFFINITY
:
317 "X2APIC Affinity Structure [%d]",
318 X2ApicAffinityIndex
++
326 PARSER_PARAMS (SratX2ApciAffinityParser
)
331 IncrementErrorCount ();
332 Print (L
"ERROR: Unknown SRAT Affinity type = 0x%x\n", *SratRAType
);
336 ResourcePtr
+= (*SratRALength
);
337 Offset
+= (*SratRALength
);