4 Copyright (c) 2019, 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 <Library/PrintLib.h>
18 #include <Library/UefiLib.h>
19 #include "AcpiParser.h"
22 STATIC CONST UINT8
* ProcessorTopologyStructureType
;
23 STATIC CONST UINT8
* ProcessorTopologyStructureLength
;
24 STATIC CONST UINT32
* NumberOfPrivateResources
;
25 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
;
28 An ACPI_PARSER array describing the ACPI PPTT Table.
30 STATIC CONST ACPI_PARSER PpttParser
[] = {
31 PARSE_ACPI_HEADER (&AcpiHdrInfo
)
35 This function validates the Cache Type Structure (Type 1) Line size field.
37 @param [in] Ptr Pointer to the start of the field data.
38 @param [in] Context Pointer to context specific information e.g. this
39 could be a pointer to the ACPI table header.
44 ValidateCacheLineSize (
49 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
50 // Reference: ARM Architecture Reference Manual ARMv8 (D.a)
51 // Section D12.2.25: CCSIDR_EL1, Current Cache Size ID Register
52 // LineSize, bits [2:0]
53 // (Log2(Number of bytes in cache line)) - 4.
56 LineSize
= *(UINT16
*)Ptr
;
58 if ((LineSize
< 16) || (LineSize
> 2048)) {
59 IncrementErrorCount ();
61 L
"\nERROR: The cache line size must be between 16 and 2048 bytes"
67 if ((LineSize
& (LineSize
- 1)) != 0) {
68 IncrementErrorCount ();
69 Print (L
"\nERROR: The cache line size is not a power of 2.");
75 This function validates the Cache Type Structure (Type 1) Attributes field.
77 @param [in] Ptr Pointer to the start of the field data.
78 @param [in] Context Pointer to context specific information e.g. this
79 could be a pointer to the ACPI table header.
84 ValidateCacheAttributes (
89 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
90 // Reference: Advanced Configuration and Power Interface (ACPI) Specification
91 // Version 6.2 Errata A, September 2017
92 // Table 5-153: Cache Type Structure
95 Attributes
= *(UINT8
*)Ptr
;
97 if ((Attributes
& 0xE0) != 0) {
98 IncrementErrorCount ();
100 L
"\nERROR: Attributes bits [7:5] are reserved and must be zero.",
109 An ACPI_PARSER array describing the processor topology structure header.
111 STATIC CONST ACPI_PARSER ProcessorTopologyStructureHeaderParser
[] = {
112 {L
"Type", 1, 0, NULL
, NULL
, (VOID
**)&ProcessorTopologyStructureType
,
114 {L
"Length", 1, 1, NULL
, NULL
, (VOID
**)&ProcessorTopologyStructureLength
,
116 {L
"Reserved", 2, 2, NULL
, NULL
, NULL
, NULL
, NULL
}
120 An ACPI_PARSER array describing the Processor Hierarchy Node Structure - Type 0.
122 STATIC CONST ACPI_PARSER ProcessorHierarchyNodeStructureParser
[] = {
123 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
124 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
125 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
127 {L
"Flags", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
128 {L
"Parent", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
129 {L
"ACPI Processor ID", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
130 {L
"Number of private resources", 4, 16, L
"%d", NULL
,
131 (VOID
**)&NumberOfPrivateResources
, NULL
, NULL
}
135 An ACPI_PARSER array describing the Cache Type Structure - Type 1.
137 STATIC CONST ACPI_PARSER CacheTypeStructureParser
[] = {
138 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
139 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
140 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
142 {L
"Flags", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
143 {L
"Next Level of Cache", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
144 {L
"Size", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
145 {L
"Number of sets", 4, 16, L
"%d", NULL
, NULL
, NULL
, NULL
},
146 {L
"Associativity", 1, 20, L
"%d", NULL
, NULL
, NULL
, NULL
},
147 {L
"Attributes", 1, 21, L
"0x%x", NULL
, NULL
, ValidateCacheAttributes
, NULL
},
148 {L
"Line size", 2, 22, L
"%d", NULL
, NULL
, ValidateCacheLineSize
, NULL
}
152 An ACPI_PARSER array describing the ID Type Structure - Type 2.
154 STATIC CONST ACPI_PARSER IdStructureParser
[] = {
155 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
156 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
157 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
159 {L
"VENDOR_ID", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
160 {L
"LEVEL_1_ID", 8, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
161 {L
"LEVEL_2_ID", 8, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
162 {L
"MAJOR_REV", 2, 24, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
163 {L
"MINOR_REV", 2, 26, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
164 {L
"SPIN_REV", 2, 28, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
168 This function parses the Processor Hierarchy Node Structure (Type 0).
170 @param [in] Ptr Pointer to the start of the Processor Hierarchy Node
172 @param [in] Length Length of the Processor Hierarchy Node Structure.
176 DumpProcessorHierarchyNodeStructure (
182 UINT8
* PrivateResourcePtr
;
184 CHAR16 Buffer
[OUTPUT_FIELD_COLUMN_WIDTH
];
189 "Processor Hierarchy Node Structure",
192 PARSER_PARAMS (ProcessorHierarchyNodeStructureParser
)
195 PrivateResourcePtr
= Ptr
+ Offset
;
197 while (Index
< *NumberOfPrivateResources
) {
201 L
"Private resources [%d]",
205 PrintFieldName (4, Buffer
);
208 *((UINT32
*) PrivateResourcePtr
)
211 PrivateResourcePtr
+= sizeof(UINT32
);
217 This function parses the Cache Type Structure (Type 1).
219 @param [in] Ptr Pointer to the start of the Cache Type Structure data.
220 @param [in] Length Length of the Cache Type Structure.
224 DumpCacheTypeStructure (
232 "Cache Type Structure",
235 PARSER_PARAMS (CacheTypeStructureParser
)
240 This function parses the ID Structure (Type 2).
242 @param [in] Ptr Pointer to the start of the ID Structure data.
243 @param [in] Length Length of the ID Structure.
258 PARSER_PARAMS (IdStructureParser
)
263 This function parses the ACPI PPTT table.
264 When trace is enabled this function parses the PPTT table and
265 traces the ACPI table fields.
267 This function parses the following processor topology structures:
268 - Processor hierarchy node structure (Type 0)
269 - Cache Type Structure (Type 1)
270 - ID structure (Type 2)
272 This function also performs validation of the ACPI table fields.
274 @param [in] Trace If TRUE, trace the ACPI fields.
275 @param [in] Ptr Pointer to the start of the buffer.
276 @param [in] AcpiTableLength Length of the ACPI table.
277 @param [in] AcpiTableRevision Revision of the ACPI table.
284 IN UINT32 AcpiTableLength
,
285 IN UINT8 AcpiTableRevision
289 UINT8
* ProcessorTopologyStructurePtr
;
301 PARSER_PARAMS (PpttParser
)
303 ProcessorTopologyStructurePtr
= Ptr
+ Offset
;
305 while (Offset
< AcpiTableLength
) {
306 // Parse Processor Hierarchy Node Structure to obtain Type and Length.
311 ProcessorTopologyStructurePtr
,
312 4, // Length of the processor topology structure header is 4 bytes
313 PARSER_PARAMS (ProcessorTopologyStructureHeaderParser
)
316 if ((Offset
+ (*ProcessorTopologyStructureLength
)) > AcpiTableLength
) {
317 IncrementErrorCount ();
319 L
"ERROR: Invalid processor topology structure length:"
320 L
" Type = %d, Length = %d\n",
321 *ProcessorTopologyStructureType
,
322 *ProcessorTopologyStructureLength
327 PrintFieldName (2, L
"* Structure Offset *");
328 Print (L
"0x%x\n", Offset
);
330 switch (*ProcessorTopologyStructureType
) {
331 case EFI_ACPI_6_2_PPTT_TYPE_PROCESSOR
:
332 DumpProcessorHierarchyNodeStructure (
333 ProcessorTopologyStructurePtr
,
334 *ProcessorTopologyStructureLength
337 case EFI_ACPI_6_2_PPTT_TYPE_CACHE
:
338 DumpCacheTypeStructure (
339 ProcessorTopologyStructurePtr
,
340 *ProcessorTopologyStructureLength
343 case EFI_ACPI_6_2_PPTT_TYPE_ID
:
345 ProcessorTopologyStructurePtr
,
346 *ProcessorTopologyStructureLength
350 IncrementErrorCount ();
352 L
"ERROR: Unknown processor topology structure:"
353 L
" Type = %d, Length = %d\n",
354 *ProcessorTopologyStructureType
,
355 *ProcessorTopologyStructureLength
359 ProcessorTopologyStructurePtr
+= *ProcessorTopologyStructureLength
;
360 Offset
+= *ProcessorTopologyStructureLength
;