4 Copyright (c) 2019, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 - ACPI 6.2 Specification - Errata A, September 2017
11 #include <Library/PrintLib.h>
12 #include <Library/UefiLib.h>
13 #include "AcpiParser.h"
16 STATIC CONST UINT8
* ProcessorTopologyStructureType
;
17 STATIC CONST UINT8
* ProcessorTopologyStructureLength
;
18 STATIC CONST UINT32
* NumberOfPrivateResources
;
19 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
;
22 An ACPI_PARSER array describing the ACPI PPTT Table.
24 STATIC CONST ACPI_PARSER PpttParser
[] = {
25 PARSE_ACPI_HEADER (&AcpiHdrInfo
)
29 This function validates the Cache Type Structure (Type 1) Line size field.
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 ValidateCacheLineSize (
43 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
44 // Reference: ARM Architecture Reference Manual ARMv8 (D.a)
45 // Section D12.2.25: CCSIDR_EL1, Current Cache Size ID Register
46 // LineSize, bits [2:0]
47 // (Log2(Number of bytes in cache line)) - 4.
50 LineSize
= *(UINT16
*)Ptr
;
52 if ((LineSize
< 16) || (LineSize
> 2048)) {
53 IncrementErrorCount ();
55 L
"\nERROR: The cache line size must be between 16 and 2048 bytes"
61 if ((LineSize
& (LineSize
- 1)) != 0) {
62 IncrementErrorCount ();
63 Print (L
"\nERROR: The cache line size is not a power of 2.");
69 This function validates the Cache Type Structure (Type 1) Attributes field.
71 @param [in] Ptr Pointer to the start of the field data.
72 @param [in] Context Pointer to context specific information e.g. this
73 could be a pointer to the ACPI table header.
78 ValidateCacheAttributes (
83 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
84 // Reference: Advanced Configuration and Power Interface (ACPI) Specification
85 // Version 6.2 Errata A, September 2017
86 // Table 5-153: Cache Type Structure
89 Attributes
= *(UINT8
*)Ptr
;
91 if ((Attributes
& 0xE0) != 0) {
92 IncrementErrorCount ();
94 L
"\nERROR: Attributes bits [7:5] are reserved and must be zero.",
103 An ACPI_PARSER array describing the processor topology structure header.
105 STATIC CONST ACPI_PARSER ProcessorTopologyStructureHeaderParser
[] = {
106 {L
"Type", 1, 0, NULL
, NULL
, (VOID
**)&ProcessorTopologyStructureType
,
108 {L
"Length", 1, 1, NULL
, NULL
, (VOID
**)&ProcessorTopologyStructureLength
,
110 {L
"Reserved", 2, 2, NULL
, NULL
, NULL
, NULL
, NULL
}
114 An ACPI_PARSER array describing the Processor Hierarchy Node Structure - Type 0.
116 STATIC CONST ACPI_PARSER ProcessorHierarchyNodeStructureParser
[] = {
117 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
118 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
119 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
121 {L
"Flags", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
122 {L
"Parent", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
123 {L
"ACPI Processor ID", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
124 {L
"Number of private resources", 4, 16, L
"%d", NULL
,
125 (VOID
**)&NumberOfPrivateResources
, NULL
, NULL
}
129 An ACPI_PARSER array describing the Cache Type Structure - Type 1.
131 STATIC CONST ACPI_PARSER CacheTypeStructureParser
[] = {
132 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
133 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
134 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
136 {L
"Flags", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
137 {L
"Next Level of Cache", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
138 {L
"Size", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
139 {L
"Number of sets", 4, 16, L
"%d", NULL
, NULL
, NULL
, NULL
},
140 {L
"Associativity", 1, 20, L
"%d", NULL
, NULL
, NULL
, NULL
},
141 {L
"Attributes", 1, 21, L
"0x%x", NULL
, NULL
, ValidateCacheAttributes
, NULL
},
142 {L
"Line size", 2, 22, L
"%d", NULL
, NULL
, ValidateCacheLineSize
, NULL
}
146 An ACPI_PARSER array describing the ID Type Structure - Type 2.
148 STATIC CONST ACPI_PARSER IdStructureParser
[] = {
149 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
150 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
151 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
153 {L
"VENDOR_ID", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
154 {L
"LEVEL_1_ID", 8, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
155 {L
"LEVEL_2_ID", 8, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
156 {L
"MAJOR_REV", 2, 24, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
157 {L
"MINOR_REV", 2, 26, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
158 {L
"SPIN_REV", 2, 28, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
162 This function parses the Processor Hierarchy Node Structure (Type 0).
164 @param [in] Ptr Pointer to the start of the Processor Hierarchy Node
166 @param [in] Length Length of the Processor Hierarchy Node Structure.
170 DumpProcessorHierarchyNodeStructure (
176 UINT8
* PrivateResourcePtr
;
178 CHAR16 Buffer
[OUTPUT_FIELD_COLUMN_WIDTH
];
183 "Processor Hierarchy Node Structure",
186 PARSER_PARAMS (ProcessorHierarchyNodeStructureParser
)
189 PrivateResourcePtr
= Ptr
+ Offset
;
191 while (Index
< *NumberOfPrivateResources
) {
195 L
"Private resources [%d]",
199 PrintFieldName (4, Buffer
);
202 *((UINT32
*) PrivateResourcePtr
)
205 PrivateResourcePtr
+= sizeof(UINT32
);
211 This function parses the Cache Type Structure (Type 1).
213 @param [in] Ptr Pointer to the start of the Cache Type Structure data.
214 @param [in] Length Length of the Cache Type Structure.
218 DumpCacheTypeStructure (
226 "Cache Type Structure",
229 PARSER_PARAMS (CacheTypeStructureParser
)
234 This function parses the ID Structure (Type 2).
236 @param [in] Ptr Pointer to the start of the ID Structure data.
237 @param [in] Length Length of the ID Structure.
252 PARSER_PARAMS (IdStructureParser
)
257 This function parses the ACPI PPTT table.
258 When trace is enabled this function parses the PPTT table and
259 traces the ACPI table fields.
261 This function parses the following processor topology structures:
262 - Processor hierarchy node structure (Type 0)
263 - Cache Type Structure (Type 1)
264 - ID structure (Type 2)
266 This function also performs validation of the ACPI table fields.
268 @param [in] Trace If TRUE, trace the ACPI fields.
269 @param [in] Ptr Pointer to the start of the buffer.
270 @param [in] AcpiTableLength Length of the ACPI table.
271 @param [in] AcpiTableRevision Revision of the ACPI table.
278 IN UINT32 AcpiTableLength
,
279 IN UINT8 AcpiTableRevision
283 UINT8
* ProcessorTopologyStructurePtr
;
295 PARSER_PARAMS (PpttParser
)
297 ProcessorTopologyStructurePtr
= Ptr
+ Offset
;
299 while (Offset
< AcpiTableLength
) {
300 // Parse Processor Hierarchy Node Structure to obtain Type and Length.
305 ProcessorTopologyStructurePtr
,
306 4, // Length of the processor topology structure header is 4 bytes
307 PARSER_PARAMS (ProcessorTopologyStructureHeaderParser
)
310 if ((Offset
+ (*ProcessorTopologyStructureLength
)) > AcpiTableLength
) {
311 IncrementErrorCount ();
313 L
"ERROR: Invalid processor topology structure length:"
314 L
" Type = %d, Length = %d\n",
315 *ProcessorTopologyStructureType
,
316 *ProcessorTopologyStructureLength
321 PrintFieldName (2, L
"* Structure Offset *");
322 Print (L
"0x%x\n", Offset
);
324 switch (*ProcessorTopologyStructureType
) {
325 case EFI_ACPI_6_2_PPTT_TYPE_PROCESSOR
:
326 DumpProcessorHierarchyNodeStructure (
327 ProcessorTopologyStructurePtr
,
328 *ProcessorTopologyStructureLength
331 case EFI_ACPI_6_2_PPTT_TYPE_CACHE
:
332 DumpCacheTypeStructure (
333 ProcessorTopologyStructurePtr
,
334 *ProcessorTopologyStructureLength
337 case EFI_ACPI_6_2_PPTT_TYPE_ID
:
339 ProcessorTopologyStructurePtr
,
340 *ProcessorTopologyStructureLength
344 IncrementErrorCount ();
346 L
"ERROR: Unknown processor topology structure:"
347 L
" Type = %d, Length = %d\n",
348 *ProcessorTopologyStructureType
,
349 *ProcessorTopologyStructureLength
353 ProcessorTopologyStructurePtr
+= *ProcessorTopologyStructureLength
;
354 Offset
+= *ProcessorTopologyStructureLength
;