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
11 #include <IndustryStandard/Acpi.h>
12 #include <Library/UefiLib.h>
13 #include "AcpiParser.h"
14 #include "AcpiTableParser.h"
17 STATIC CONST UINT32
* GtdtPlatformTimerCount
;
18 STATIC CONST UINT32
* GtdtPlatformTimerOffset
;
19 STATIC CONST UINT8
* PlatformTimerType
;
20 STATIC CONST UINT16
* PlatformTimerLength
;
21 STATIC CONST UINT32
* GtBlockTimerCount
;
22 STATIC CONST UINT32
* GtBlockTimerOffset
;
23 STATIC CONST UINT16
* GtBlockLength
;
24 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
;
27 This function validates the GT Block timer count.
29 @param [in] Ptr Pointer to the start of the field data.
30 @param [in] Context Pointer to context specific information e.g. this
31 could be a pointer to the ACPI table header.
36 ValidateGtBlockTimerCount (
42 This function validates the GT Frame Number.
44 @param [in] Ptr Pointer to the start of the field data.
45 @param [in] Context Pointer to context specific information e.g. this
46 could be a pointer to the ACPI table header.
51 ValidateGtFrameNumber (
57 An ACPI_PARSER array describing the ACPI GTDT Table.
59 STATIC CONST ACPI_PARSER GtdtParser
[] = {
60 PARSE_ACPI_HEADER (&AcpiHdrInfo
),
61 {L
"CntControlBase Physical Address", 8, 36, L
"0x%lx", NULL
, NULL
,
63 {L
"Reserved", 4, 44, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
64 {L
"Secure EL1 timer GSIV", 4, 48, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
65 {L
"Secure EL1 timer FLAGS", 4, 52, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
67 {L
"Non-Secure EL1 timer GSIV", 4, 56, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
68 {L
"Non-Secure EL1 timer FLAGS", 4, 60, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
70 {L
"Virtual timer GSIV", 4, 64, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
71 {L
"Virtual timer FLAGS", 4, 68, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
73 {L
"Non-Secure EL2 timer GSIV", 4, 72, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
74 {L
"Non-Secure EL2 timer FLAGS", 4, 76, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
76 {L
"CntReadBase Physical address", 8, 80, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
77 {L
"Platform Timer Count", 4, 88, L
"%d", NULL
,
78 (VOID
**)&GtdtPlatformTimerCount
, NULL
, NULL
},
79 {L
"Platform Timer Offset", 4, 92, L
"0x%x", NULL
,
80 (VOID
**)&GtdtPlatformTimerOffset
, NULL
, NULL
},
81 {L
"Virtual EL2 Timer GSIV", 4, 96, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
82 {L
"Virtual EL2 Timer Flags", 4, 100, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
86 An ACPI_PARSER array describing the Platform timer header.
88 STATIC CONST ACPI_PARSER GtPlatformTimerHeaderParser
[] = {
89 {L
"Type", 1, 0, NULL
, NULL
, (VOID
**)&PlatformTimerType
, NULL
, NULL
},
90 {L
"Length", 2, 1, NULL
, NULL
, (VOID
**)&PlatformTimerLength
, NULL
, NULL
},
91 {L
"Reserved", 1, 3, NULL
, NULL
, NULL
, NULL
, NULL
}
95 An ACPI_PARSER array describing the Platform GT Block.
97 STATIC CONST ACPI_PARSER GtBlockParser
[] = {
98 {L
"Type", 1, 0, L
"%d", NULL
, NULL
, NULL
, NULL
},
99 {L
"Length", 2, 1, L
"%d", NULL
, (VOID
**)&GtBlockLength
, NULL
, NULL
},
100 {L
"Reserved", 1, 3, L
"%x", NULL
, NULL
, NULL
, NULL
},
101 {L
"Physical address (CntCtlBase)", 8, 4, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
102 {L
"Timer Count", 4, 12, L
"%d", NULL
, (VOID
**)&GtBlockTimerCount
,
103 ValidateGtBlockTimerCount
, NULL
},
104 {L
"Timer Offset", 4, 16, L
"%d", NULL
, (VOID
**)&GtBlockTimerOffset
, NULL
,
109 An ACPI_PARSER array describing the GT Block timer.
111 STATIC CONST ACPI_PARSER GtBlockTimerParser
[] = {
112 {L
"Frame Number", 1, 0, L
"%d", NULL
, NULL
, ValidateGtFrameNumber
, NULL
},
113 {L
"Reserved", 3, 1, L
"%x %x %x", Dump3Chars
, NULL
, NULL
, NULL
},
114 {L
"Physical address (CntBaseX)", 8, 4, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
115 {L
"Physical address (CntEL0BaseX)", 8, 12, L
"0x%lx", NULL
, NULL
, NULL
,
117 {L
"Physical Timer GSIV", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
118 {L
"Physical Timer Flags", 4, 24, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
119 {L
"Virtual Timer GSIV", 4, 28, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
120 {L
"Virtual Timer Flags", 4, 32, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
121 {L
"Common Flags", 4, 36, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
125 An ACPI_PARSER array describing the Platform Watchdog.
127 STATIC CONST ACPI_PARSER SBSAGenericWatchdogParser
[] = {
128 {L
"Type", 1, 0, L
"%d", NULL
, NULL
, NULL
, NULL
},
129 {L
"Length", 2, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
130 {L
"Reserved", 1, 3, L
"%x", NULL
, NULL
, NULL
, NULL
},
131 {L
"RefreshFrame Physical address", 8, 4, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
132 {L
"ControlFrame Physical address", 8, 12, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
133 {L
"Watchdog Timer GSIV", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
134 {L
"Watchdog Timer Flags", 4, 24, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
138 This function validates the GT Block timer count.
140 @param [in] Ptr Pointer to the start of the field data.
141 @param [in] Context Pointer to context specific information e.g. this
142 could be a pointer to the ACPI table header.
147 ValidateGtBlockTimerCount (
152 UINT32 BlockTimerCount
;
154 BlockTimerCount
= *(UINT32
*)Ptr
;
156 if (BlockTimerCount
> 8) {
157 IncrementErrorCount ();
159 L
"\nERROR: Timer Count = %d. Max Timer Count is 8.",
166 This function validates the GT Frame Number.
168 @param [in] Ptr Pointer to the start of the field data.
169 @param [in] Context Pointer to context specific information e.g. this
170 could be a pointer to the ACPI table header.
175 ValidateGtFrameNumber (
182 FrameNumber
= *(UINT8
*)Ptr
;
184 if (FrameNumber
> 7) {
185 IncrementErrorCount ();
187 L
"\nERROR: GT Frame Number = %d. GT Frame Number must be in range 0-7.",
194 This function parses the Platform GT Block.
196 @param [in] Ptr Pointer to the start of the GT Block data.
197 @param [in] Length Length of the GT Block structure.
208 UINT32 GTBlockTimerLength
;
216 PARSER_PARAMS (GtBlockParser
)
218 GTBlockTimerLength
= (*GtBlockLength
- Offset
) / (*GtBlockTimerCount
);
221 if (*GtBlockTimerCount
!= 0) {
222 Ptr
+= (*GtBlockTimerOffset
);
224 while ((Index
< (*GtBlockTimerCount
)) && (Length
>= GTBlockTimerLength
)) {
231 PARSER_PARAMS (GtBlockTimerParser
)
233 // Increment by GT Block Timer structure size
240 IncrementErrorCount ();
242 L
"ERROR:GT Block Timer length mismatch. Unparsed %d bytes.\n",
250 This function parses the Platform Watchdog timer.
252 @param [in] Ptr Pointer to the start of the watchdog timer data.
253 @param [in] Length Length of the watchdog timer structure.
265 "SBSA Generic Watchdog",
268 PARSER_PARAMS (SBSAGenericWatchdogParser
)
273 This function parses the ACPI GTDT table.
274 When trace is enabled this function parses the GTDT table and
275 traces the ACPI table fields.
277 This function also parses the following platform timer structures:
281 This function also performs validation of the ACPI table fields.
283 @param [in] Trace If TRUE, trace the ACPI fields.
284 @param [in] Ptr Pointer to the start of the buffer.
285 @param [in] AcpiTableLength Length of the ACPI table.
286 @param [in] AcpiTableRevision Revision of the ACPI table.
293 IN UINT32 AcpiTableLength
,
294 IN UINT8 AcpiTableRevision
310 PARSER_PARAMS (GtdtParser
)
313 if (*GtdtPlatformTimerCount
!= 0) {
314 TimerPtr
= Ptr
+ (*GtdtPlatformTimerOffset
);
317 // Parse the Platform Timer Header
323 4, // GT Platform Timer structure header length.
324 PARSER_PARAMS (GtPlatformTimerHeaderParser
)
326 switch (*PlatformTimerType
) {
327 case EFI_ACPI_6_2_GTDT_GT_BLOCK
:
328 DumpGTBlock (TimerPtr
, *PlatformTimerLength
);
330 case EFI_ACPI_6_2_GTDT_SBSA_GENERIC_WATCHDOG
:
331 DumpWatchdogTimer (TimerPtr
, *PlatformTimerLength
);
334 IncrementErrorCount ();
336 L
"ERROR: INVALID Platform Timer Type = %d\n",
341 TimerPtr
+= (*PlatformTimerLength
);
343 } while (Index
< *GtdtPlatformTimerCount
);