4 Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 - ACPI 6.3 Specification - January 2019
9 - Arm Generic Interrupt Controller Architecture Specification,
10 GIC architecture version 3 and version 4, issue E
11 - Arm Server Base System Architecture 5.0
14 #include <IndustryStandard/Acpi.h>
15 #include <Library/UefiLib.h>
16 #include "AcpiParser.h"
17 #include "AcpiTableParser.h"
18 #include "MadtParser.h"
21 STATIC CONST UINT8
* MadtInterruptControllerType
;
22 STATIC CONST UINT8
* MadtInterruptControllerLength
;
23 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
;
26 This function validates the System Vector Base in the GICD.
28 @param [in] Ptr Pointer to the start of the field data.
29 @param [in] Context Pointer to context specific information e.g. this
30 could be a pointer to the ACPI table header.
35 ValidateGICDSystemVectorBase (
41 This function validates the SPE Overflow Interrupt in the GICC.
43 @param [in] Ptr Pointer to the start of the field data.
44 @param [in] Context Pointer to context specific information e.g. this
45 could be a pointer to the ACPI table header.
50 ValidateSpeOverflowInterrupt (
56 An ACPI_PARSER array describing the GICC Interrupt Controller Structure.
58 STATIC CONST ACPI_PARSER GicCParser
[] = {
59 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
60 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
61 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
63 {L
"CPU Interface Number", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
64 {L
"ACPI Processor UID", 4, 8, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
65 {L
"Flags", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
66 {L
"Parking Protocol Version", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
68 {L
"Performance Interrupt GSIV", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
69 {L
"Parked Address", 8, 24, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
70 {L
"Physical Base Address", 8, 32, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
71 {L
"GICV", 8, 40, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
72 {L
"GICH", 8, 48, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
73 {L
"VGIC Maintenance interrupt", 4, 56, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
74 {L
"GICR Base Address", 8, 60, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
75 {L
"MPIDR", 8, 68, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
76 {L
"Processor Power Efficiency Class", 1, 76, L
"0x%x", NULL
, NULL
, NULL
,
78 {L
"Reserved", 1, 77, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
79 {L
"SPE overflow Interrupt", 2, 78, L
"0x%x", NULL
, NULL
,
80 ValidateSpeOverflowInterrupt
, NULL
}
84 An ACPI_PARSER array describing the GICD Interrupt Controller Structure.
86 STATIC CONST ACPI_PARSER GicDParser
[] = {
87 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
88 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
89 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
91 {L
"GIC ID", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
92 {L
"Physical Base Address", 8, 8, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
93 {L
"System Vector Base", 4, 16, L
"0x%x", NULL
, NULL
,
94 ValidateGICDSystemVectorBase
, NULL
},
95 {L
"GIC Version", 1, 20, L
"%d", NULL
, NULL
, NULL
, NULL
},
96 {L
"Reserved", 3, 21, L
"%x %x %x", Dump3Chars
, NULL
, NULL
, NULL
}
100 An ACPI_PARSER array describing the MSI Frame Interrupt Controller Structure.
102 STATIC CONST ACPI_PARSER GicMSIFrameParser
[] = {
103 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
104 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
105 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
107 {L
"MSI Frame ID", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
108 {L
"Physical Base Address", 8, 8, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
109 {L
"Flags", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
111 {L
"SPI Count", 2, 20, L
"%d", NULL
, NULL
, NULL
, NULL
},
112 {L
"SPI Base", 2, 22, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
116 An ACPI_PARSER array describing the GICR Interrupt Controller Structure.
118 STATIC CONST ACPI_PARSER GicRParser
[] = {
119 {L
"Type", 1, 0, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
120 {L
"Length", 1, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
121 {L
"Reserved", 2, 2, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
123 {L
"Discovery Range Base Address", 8, 4, L
"0x%lx", NULL
, NULL
, NULL
,
125 {L
"Discovery Range Length", 4, 12, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
129 An ACPI_PARSER array describing the GIC ITS Interrupt Controller Structure.
131 STATIC CONST ACPI_PARSER GicITSParser
[] = {
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
"GIC ITS ID", 4, 4, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
137 {L
"Physical Base Address", 8, 8, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
138 {L
"Reserved", 4, 16, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
142 An ACPI_PARSER array describing the ACPI MADT Table.
144 STATIC CONST ACPI_PARSER MadtParser
[] = {
145 PARSE_ACPI_HEADER (&AcpiHdrInfo
),
146 {L
"Local Interrupt Controller Address", 4, 36, L
"0x%x", NULL
, NULL
, NULL
,
148 {L
"Flags", 4, 40, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
152 An ACPI_PARSER array describing the MADT Interrupt Controller Structure Header Structure.
154 STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser
[] = {
155 {NULL
, 1, 0, NULL
, NULL
, (VOID
**)&MadtInterruptControllerType
, NULL
, NULL
},
156 {L
"Length", 1, 1, NULL
, NULL
, (VOID
**)&MadtInterruptControllerLength
, NULL
,
158 {L
"Reserved", 2, 2, NULL
, NULL
, NULL
, NULL
, NULL
}
162 This function validates the System Vector Base in the GICD.
164 @param [in] Ptr Pointer to the start of the field data.
165 @param [in] Context Pointer to context specific information e.g. this
166 could be a pointer to the ACPI table header.
171 ValidateGICDSystemVectorBase (
176 if (*(UINT32
*)Ptr
!= 0) {
177 IncrementErrorCount ();
179 L
"\nERROR: System Vector Base must be zero."
185 This function validates the SPE Overflow Interrupt in the GICC.
187 @param [in] Ptr Pointer to the start of the field data.
188 @param [in] Context Pointer to context specific information e.g. this
189 could be a pointer to the ACPI table header.
194 ValidateSpeOverflowInterrupt (
199 UINT16 SpeOverflowInterrupt
;
201 SpeOverflowInterrupt
= *(UINT16
*)Ptr
;
203 // SPE not supported by this processor
204 if (SpeOverflowInterrupt
== 0) {
208 if ((SpeOverflowInterrupt
< ARM_PPI_ID_MIN
) ||
209 ((SpeOverflowInterrupt
> ARM_PPI_ID_MAX
) &&
210 (SpeOverflowInterrupt
< ARM_PPI_ID_EXTENDED_MIN
)) ||
211 (SpeOverflowInterrupt
> ARM_PPI_ID_EXTENDED_MAX
)) {
212 IncrementErrorCount ();
214 L
"\nERROR: SPE Overflow Interrupt ID of %d is not in the allowed PPI ID "
215 L
"ranges of %d-%d or %d-%d (for GICv3.1 or later).",
216 SpeOverflowInterrupt
,
219 ARM_PPI_ID_EXTENDED_MIN
,
220 ARM_PPI_ID_EXTENDED_MAX
222 } else if (SpeOverflowInterrupt
!= ARM_PPI_ID_PMBIRQ
) {
223 IncrementWarningCount();
225 L
"\nWARNING: SPE Overflow Interrupt ID of %d is not compliant with SBSA "
226 L
"Level 3 PPI ID assignment: %d.",
227 SpeOverflowInterrupt
,
234 This function parses the ACPI MADT table.
235 When trace is enabled this function parses the MADT table and
236 traces the ACPI table fields.
238 This function currently parses the following Interrupt Controller
246 This function also performs validation of the ACPI table fields.
248 @param [in] Trace If TRUE, trace the ACPI fields.
249 @param [in] Ptr Pointer to the start of the buffer.
250 @param [in] AcpiTableLength Length of the ACPI table.
251 @param [in] AcpiTableRevision Revision of the ACPI table.
258 IN UINT32 AcpiTableLength
,
259 IN UINT8 AcpiTableRevision
263 UINT8
* InterruptContollerPtr
;
278 PARSER_PARAMS (MadtParser
)
280 InterruptContollerPtr
= Ptr
+ Offset
;
282 while (Offset
< AcpiTableLength
) {
283 // Parse Interrupt Controller Structure to obtain Length.
288 InterruptContollerPtr
,
289 2, // Length is 1 byte at offset 1
290 PARSER_PARAMS (MadtInterruptControllerHeaderParser
)
293 if (((Offset
+ (*MadtInterruptControllerLength
)) > AcpiTableLength
) ||
294 (*MadtInterruptControllerLength
< 4)) {
295 IncrementErrorCount ();
297 L
"ERROR: Invalid Interrupt Controller Length,"
298 L
" Type = %d, Length = %d\n",
299 *MadtInterruptControllerType
,
300 *MadtInterruptControllerLength
305 switch (*MadtInterruptControllerType
) {
306 case EFI_ACPI_6_3_GIC
: {
311 InterruptContollerPtr
,
312 *MadtInterruptControllerLength
,
313 PARSER_PARAMS (GicCParser
)
318 case EFI_ACPI_6_3_GICD
: {
319 if (++GICDCount
> 1) {
320 IncrementErrorCount ();
322 L
"ERROR: Only one GICD must be present,"
323 L
" GICDCount = %d\n",
331 InterruptContollerPtr
,
332 *MadtInterruptControllerLength
,
333 PARSER_PARAMS (GicDParser
)
338 case EFI_ACPI_6_3_GIC_MSI_FRAME
: {
343 InterruptContollerPtr
,
344 *MadtInterruptControllerLength
,
345 PARSER_PARAMS (GicMSIFrameParser
)
350 case EFI_ACPI_6_3_GICR
: {
355 InterruptContollerPtr
,
356 *MadtInterruptControllerLength
,
357 PARSER_PARAMS (GicRParser
)
362 case EFI_ACPI_6_3_GIC_ITS
: {
367 InterruptContollerPtr
,
368 *MadtInterruptControllerLength
,
369 PARSER_PARAMS (GicITSParser
)
375 IncrementErrorCount ();
377 L
"ERROR: Unknown Interrupt Controller Structure,"
378 L
" Type = %d, Length = %d\n",
379 *MadtInterruptControllerType
,
380 *MadtInterruptControllerLength
385 InterruptContollerPtr
+= *MadtInterruptControllerLength
;
386 Offset
+= *MadtInterruptControllerLength
;