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/UefiLib.h>
19 #include "AcpiParser.h"
20 #include "AcpiTableParser.h"
23 STATIC CONST UINT8
* MadtInterruptControllerType
;
24 STATIC CONST UINT8
* MadtInterruptControllerLength
;
25 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
;
28 This function validates the System Vector Base in the GICD.
30 @param [in] Ptr Pointer to the start of the field data.
31 @param [in] Context Pointer to context specific information e.g. this
32 could be a pointer to the ACPI table header.
37 ValidateGICDSystemVectorBase (
43 An ACPI_PARSER array describing the GICC Interrupt Controller Structure.
45 STATIC CONST ACPI_PARSER GicCParser
[] = {
46 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
47 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
48 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
50 {L
"CPU Interface Number", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
51 {L
"ACPI Processor UID", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
52 {L
"Flags", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
53 {L
"Parking Protocol Version", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
55 {L
"Performance Interrupt GSIV", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
56 {L
"Parked Address", 8, 24, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
57 {L
"Physical Base Address", 8, 32, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
58 {L
"GICV", 8, 40, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
59 {L
"GICH", 8, 48, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
60 {L
"VGIC Maintenance interrupt", 4, 56, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
61 {L
"GICR Base Address", 8, 60, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
62 {L
"MPIDR", 8, 68, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
63 {L
"Processor Power Efficiency Class", 1, 76, L
"0x%x", NULL
, NULL
, NULL
,
65 {L
"Reserved", 3, 77, L
"%x %x %x", Dump3Chars
, NULL
, NULL
, NULL
}
69 An ACPI_PARSER array describing the GICD Interrupt Controller Structure.
71 STATIC CONST ACPI_PARSER GicDParser
[] = {
72 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
73 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
74 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
76 {L
"GIC ID", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
77 {L
"Physical Base Address", 8, 8, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
78 {L
"System Vector Base", 4, 16, L
"0x%x", NULL
, NULL
,
79 ValidateGICDSystemVectorBase
, NULL
},
80 {L
"GIC Version", 1, 20, L
"%d", NULL
, NULL
, NULL
, NULL
},
81 {L
"Reserved", 3, 21, L
"%x %x %x", Dump3Chars
, NULL
, NULL
, NULL
}
85 An ACPI_PARSER array describing the MSI Frame Interrupt Controller Structure.
87 STATIC CONST ACPI_PARSER GicMSIFrameParser
[] = {
88 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
89 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
90 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
92 {L
"MSI Frame ID", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
93 {L
"Physical Base Address", 8, 8, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
94 {L
"Flags", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
96 {L
"SPI Count", 2, 20, L
"%d", NULL
, NULL
, NULL
, NULL
},
97 {L
"SPI Base", 2, 22, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
101 An ACPI_PARSER array describing the GICR Interrupt Controller Structure.
103 STATIC CONST ACPI_PARSER GicRParser
[] = {
104 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
105 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
106 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
108 {L
"Discovery Range Base Address", 8, 4, L
"0x%lx", NULL
, NULL
, NULL
,
110 {L
"Discovery Range Length", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
114 An ACPI_PARSER array describing the GIC ITS Interrupt Controller Structure.
116 STATIC CONST ACPI_PARSER GicITSParser
[] = {
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
"GIC ITS ID", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
122 {L
"Physical Base Address", 8, 8, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
123 {L
"Reserved", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
127 An ACPI_PARSER array describing the ACPI MADT Table.
129 STATIC CONST ACPI_PARSER MadtParser
[] = {
130 PARSE_ACPI_HEADER (&AcpiHdrInfo
),
131 {L
"Local Interrupt Controller Address", 4, 36, L
"0x%x", NULL
, NULL
, NULL
,
133 {L
"Flags", 4, 40, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
137 An ACPI_PARSER array describing the MADT Interrupt Controller Structure Header Structure.
139 STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser
[] = {
140 {NULL
, 1, 0, NULL
, NULL
, (VOID
**)&MadtInterruptControllerType
, NULL
, NULL
},
141 {L
"Length", 1, 1, NULL
, NULL
, (VOID
**)&MadtInterruptControllerLength
, NULL
,
143 {L
"Reserved", 2, 2, NULL
, NULL
, NULL
, NULL
, NULL
}
147 This function validates the System Vector Base in the GICD.
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 ValidateGICDSystemVectorBase (
161 if (*(UINT32
*)Ptr
!= 0) {
162 IncrementErrorCount ();
164 L
"\nERROR: System Vector Base must be zero."
170 This function parses the ACPI MADT table.
171 When trace is enabled this function parses the MADT table and
172 traces the ACPI table fields.
174 This function currently parses the following Interrupt Controller
182 This function also performs validation of the ACPI table fields.
184 @param [in] Trace If TRUE, trace the ACPI fields.
185 @param [in] Ptr Pointer to the start of the buffer.
186 @param [in] AcpiTableLength Length of the ACPI table.
187 @param [in] AcpiTableRevision Revision of the ACPI table.
194 IN UINT32 AcpiTableLength
,
195 IN UINT8 AcpiTableRevision
199 UINT8
* InterruptContollerPtr
;
214 PARSER_PARAMS (MadtParser
)
216 InterruptContollerPtr
= Ptr
+ Offset
;
218 while (Offset
< AcpiTableLength
) {
219 // Parse Interrupt Controller Structure to obtain Length.
224 InterruptContollerPtr
,
225 2, // Length is 1 byte at offset 1
226 PARSER_PARAMS (MadtInterruptControllerHeaderParser
)
229 if (((Offset
+ (*MadtInterruptControllerLength
)) > AcpiTableLength
) ||
230 (*MadtInterruptControllerLength
< 4)) {
231 IncrementErrorCount ();
233 L
"ERROR: Invalid Interrupt Controller Length,"
234 " Type = %d, Length = %d\n",
235 *MadtInterruptControllerType
,
236 *MadtInterruptControllerLength
241 switch (*MadtInterruptControllerType
) {
242 case EFI_ACPI_6_2_GIC
: {
247 InterruptContollerPtr
,
248 *MadtInterruptControllerLength
,
249 PARSER_PARAMS (GicCParser
)
254 case EFI_ACPI_6_2_GICD
: {
255 if (++GICDCount
> 1) {
256 IncrementErrorCount ();
258 L
"ERROR: Only one GICD must be present,"
267 InterruptContollerPtr
,
268 *MadtInterruptControllerLength
,
269 PARSER_PARAMS (GicDParser
)
274 case EFI_ACPI_6_2_GIC_MSI_FRAME
: {
279 InterruptContollerPtr
,
280 *MadtInterruptControllerLength
,
281 PARSER_PARAMS (GicMSIFrameParser
)
286 case EFI_ACPI_6_2_GICR
: {
291 InterruptContollerPtr
,
292 *MadtInterruptControllerLength
,
293 PARSER_PARAMS (GicRParser
)
298 case EFI_ACPI_6_2_GIC_ITS
: {
303 InterruptContollerPtr
,
304 *MadtInterruptControllerLength
,
305 PARSER_PARAMS (GicITSParser
)
311 IncrementErrorCount ();
313 L
"ERROR: Unknown Interrupt Controller Structure,"
314 " Type = %d, Length = %d\n",
315 *MadtInterruptControllerType
,
316 *MadtInterruptControllerLength
321 InterruptContollerPtr
+= *MadtInterruptControllerLength
;
322 Offset
+= *MadtInterruptControllerLength
;