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 // Reference: Advanced Configuration and Power Interface (ACPI) Specification
84 // Version 6.2 Errata A, September 2017
85 // Table 5-153: Cache Type Structure
87 Attributes
= *(UINT8
*)Ptr
;
89 if ((Attributes
& 0xE0) != 0) {
90 IncrementErrorCount ();
92 L
"\nERROR: Attributes bits [7:5] are reserved and must be zero.",
100 An ACPI_PARSER array describing the processor topology structure header.
102 STATIC CONST ACPI_PARSER ProcessorTopologyStructureHeaderParser
[] = {
103 {L
"Type", 1, 0, NULL
, NULL
, (VOID
**)&ProcessorTopologyStructureType
,
105 {L
"Length", 1, 1, NULL
, NULL
, (VOID
**)&ProcessorTopologyStructureLength
,
107 {L
"Reserved", 2, 2, NULL
, NULL
, NULL
, NULL
, NULL
}
111 An ACPI_PARSER array describing the Processor Hierarchy Node Structure - Type 0.
113 STATIC CONST ACPI_PARSER ProcessorHierarchyNodeStructureParser
[] = {
114 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
115 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
116 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
118 {L
"Flags", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
119 {L
"Parent", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
120 {L
"ACPI Processor ID", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
121 {L
"Number of private resources", 4, 16, L
"%d", NULL
,
122 (VOID
**)&NumberOfPrivateResources
, NULL
, NULL
}
126 An ACPI_PARSER array describing the Cache Type Structure - Type 1.
128 STATIC CONST ACPI_PARSER CacheTypeStructureParser
[] = {
129 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
130 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
131 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
133 {L
"Flags", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
134 {L
"Next Level of Cache", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
135 {L
"Size", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
136 {L
"Number of sets", 4, 16, L
"%d", NULL
, NULL
, NULL
, NULL
},
137 {L
"Associativity", 1, 20, L
"%d", NULL
, NULL
, NULL
, NULL
},
138 {L
"Attributes", 1, 21, L
"0x%x", NULL
, NULL
, ValidateCacheAttributes
, NULL
},
139 {L
"Line size", 2, 22, L
"%d", NULL
, NULL
, ValidateCacheLineSize
, NULL
}
143 An ACPI_PARSER array describing the ID Type Structure - Type 2.
145 STATIC CONST ACPI_PARSER IdStructureParser
[] = {
146 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
147 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
148 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
150 {L
"VENDOR_ID", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
151 {L
"LEVEL_1_ID", 8, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
152 {L
"LEVEL_2_ID", 8, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
153 {L
"MAJOR_REV", 2, 24, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
154 {L
"MINOR_REV", 2, 26, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
155 {L
"SPIN_REV", 2, 28, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
159 This function parses the Processor Hierarchy Node Structure (Type 0).
161 @param [in] Ptr Pointer to the start of the Processor Hierarchy Node
163 @param [in] Length Length of the Processor Hierarchy Node Structure.
167 DumpProcessorHierarchyNodeStructure (
173 UINT8
* PrivateResourcePtr
;
175 CHAR16 Buffer
[OUTPUT_FIELD_COLUMN_WIDTH
];
180 "Processor Hierarchy Node Structure",
183 PARSER_PARAMS (ProcessorHierarchyNodeStructureParser
)
186 PrivateResourcePtr
= Ptr
+ Offset
;
188 while (Index
< *NumberOfPrivateResources
) {
192 L
"Private resources [%d]",
196 PrintFieldName (4, Buffer
);
199 *((UINT32
*) PrivateResourcePtr
)
202 PrivateResourcePtr
+= sizeof(UINT32
);
208 This function parses the Cache Type Structure (Type 1).
210 @param [in] Ptr Pointer to the start of the Cache Type Structure data.
211 @param [in] Length Length of the Cache Type Structure.
215 DumpCacheTypeStructure (
223 "Cache Type Structure",
226 PARSER_PARAMS (CacheTypeStructureParser
)
231 This function parses the ID Structure (Type 2).
233 @param [in] Ptr Pointer to the start of the ID Structure data.
234 @param [in] Length Length of the ID Structure.
249 PARSER_PARAMS (IdStructureParser
)
254 This function parses the ACPI PPTT table.
255 When trace is enabled this function parses the PPTT table and
256 traces the ACPI table fields.
258 This function parses the following processor topology structures:
259 - Processor hierarchy node structure (Type 0)
260 - Cache Type Structure (Type 1)
261 - ID structure (Type 2)
263 This function also performs validation of the ACPI table fields.
265 @param [in] Trace If TRUE, trace the ACPI fields.
266 @param [in] Ptr Pointer to the start of the buffer.
267 @param [in] AcpiTableLength Length of the ACPI table.
268 @param [in] AcpiTableRevision Revision of the ACPI table.
275 IN UINT32 AcpiTableLength
,
276 IN UINT8 AcpiTableRevision
280 UINT8
* ProcessorTopologyStructurePtr
;
292 PARSER_PARAMS (PpttParser
)
294 ProcessorTopologyStructurePtr
= Ptr
+ Offset
;
296 while (Offset
< AcpiTableLength
) {
297 // Parse Processor Hierarchy Node Structure to obtain Type and Length.
302 ProcessorTopologyStructurePtr
,
303 4, // Length of the processor topology structure header is 4 bytes
304 PARSER_PARAMS (ProcessorTopologyStructureHeaderParser
)
307 if ((Offset
+ (*ProcessorTopologyStructureLength
)) > AcpiTableLength
) {
308 IncrementErrorCount ();
310 L
"ERROR: Invalid processor topology structure length:"
311 L
" Type = %d, Length = %d\n",
312 *ProcessorTopologyStructureType
,
313 *ProcessorTopologyStructureLength
318 PrintFieldName (2, L
"* Structure Offset *");
319 Print (L
"0x%x\n", Offset
);
321 switch (*ProcessorTopologyStructureType
) {
322 case EFI_ACPI_6_2_PPTT_TYPE_PROCESSOR
:
323 DumpProcessorHierarchyNodeStructure (
324 ProcessorTopologyStructurePtr
,
325 *ProcessorTopologyStructureLength
328 case EFI_ACPI_6_2_PPTT_TYPE_CACHE
:
329 DumpCacheTypeStructure (
330 ProcessorTopologyStructurePtr
,
331 *ProcessorTopologyStructureLength
334 case EFI_ACPI_6_2_PPTT_TYPE_ID
:
336 ProcessorTopologyStructurePtr
,
337 *ProcessorTopologyStructureLength
341 IncrementErrorCount ();
343 L
"ERROR: Unknown processor topology structure:"
344 L
" Type = %d, Length = %d\n",
345 *ProcessorTopologyStructureType
,
346 *ProcessorTopologyStructureLength
350 ProcessorTopologyStructurePtr
+= *ProcessorTopologyStructureLength
;
351 Offset
+= *ProcessorTopologyStructureLength
;