4 Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 - ACPI 6.2 Specification - Errata A, September 2017
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 An ACPI_PARSER array describing the ACPI GTDT Table.
44 STATIC CONST ACPI_PARSER GtdtParser
[] = {
45 PARSE_ACPI_HEADER (&AcpiHdrInfo
),
46 {L
"CntControlBase Physical Address", 8, 36, L
"0x%lx", NULL
, NULL
,
48 {L
"Reserved", 4, 44, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
49 {L
"Secure EL1 timer GSIV", 4, 48, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
50 {L
"Secure EL1 timer FLAGS", 4, 52, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
52 {L
"Non-Secure EL1 timer GSIV", 4, 56, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
53 {L
"Non-Secure EL1 timer FLAGS", 4, 60, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
55 {L
"Virtual timer GSIV", 4, 64, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
56 {L
"Virtual timer FLAGS", 4, 68, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
58 {L
"Non-Secure EL2 timer GSIV", 4, 72, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
59 {L
"Non-Secure EL2 timer FLAGS", 4, 76, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
61 {L
"CntReadBase Physical address", 8, 80, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
62 {L
"Platform Timer Count", 4, 88, L
"%d", NULL
,
63 (VOID
**)&GtdtPlatformTimerCount
, NULL
, NULL
},
64 {L
"Platform Timer Offset", 4, 92, L
"0x%x", NULL
,
65 (VOID
**)&GtdtPlatformTimerOffset
, NULL
, NULL
}
69 An ACPI_PARSER array describing the Platform timer header.
71 STATIC CONST ACPI_PARSER GtPlatformTimerHeaderParser
[] = {
72 {L
"Type", 1, 0, NULL
, NULL
, (VOID
**)&PlatformTimerType
, NULL
, NULL
},
73 {L
"Length", 2, 1, NULL
, NULL
, (VOID
**)&PlatformTimerLength
, NULL
, NULL
},
74 {L
"Reserved", 1, 3, NULL
, NULL
, NULL
, NULL
, NULL
}
78 An ACPI_PARSER array describing the Platform GT Block.
80 STATIC CONST ACPI_PARSER GtBlockParser
[] = {
81 {L
"Type", 1, 0, L
"%d", NULL
, NULL
, NULL
, NULL
},
82 {L
"Length", 2, 1, L
"%d", NULL
, (VOID
**)&GtBlockLength
, NULL
, NULL
},
83 {L
"Reserved", 1, 3, L
"%x", NULL
, NULL
, NULL
, NULL
},
84 {L
"Physical address (CntCtlBase)", 8, 4, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
85 {L
"Timer Count", 4, 12, L
"%d", NULL
, (VOID
**)&GtBlockTimerCount
,
86 ValidateGtBlockTimerCount
, NULL
},
87 {L
"Timer Offset", 4, 16, L
"%d", NULL
, (VOID
**)&GtBlockTimerOffset
, NULL
,
92 An ACPI_PARSER array describing the GT Block timer.
94 STATIC CONST ACPI_PARSER GtBlockTimerParser
[] = {
95 {L
"Frame Number", 1, 0, L
"%d", NULL
, NULL
, NULL
, NULL
},
96 {L
"Reserved", 3, 1, L
"%x %x %x", Dump3Chars
, NULL
, NULL
, NULL
},
97 {L
"Physical address (CntBaseX)", 8, 4, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
98 {L
"Physical address (CntEL0BaseX)", 8, 12, L
"0x%lx", NULL
, NULL
, NULL
,
100 {L
"Physical Timer GSIV", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
101 {L
"Physical Timer Flags", 4, 24, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
102 {L
"Virtual Timer GSIV", 4, 28, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
103 {L
"Virtual Timer Flags", 4, 32, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
104 {L
"Common Flags", 4, 36, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
108 An ACPI_PARSER array describing the Platform Watchdog.
110 STATIC CONST ACPI_PARSER SBSAGenericWatchdogParser
[] = {
111 {L
"Type", 1, 0, L
"%d", NULL
, NULL
, NULL
, NULL
},
112 {L
"Length", 2, 1, L
"%d", NULL
, NULL
, NULL
, NULL
},
113 {L
"Reserved", 1, 3, L
"%x", NULL
, NULL
, NULL
, NULL
},
114 {L
"RefreshFrame Physical address", 8, 4, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
115 {L
"ControlFrame Physical address", 8, 12, L
"0x%lx", NULL
, NULL
, NULL
, NULL
},
116 {L
"Watchdog Timer GSIV", 4, 20, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
117 {L
"Watchdog Timer Flags", 4, 24, L
"0x%x", NULL
, NULL
, NULL
, NULL
}
121 This function validates the GT Block timer count.
123 @param [in] Ptr Pointer to the start of the field data.
124 @param [in] Context Pointer to context specific information e.g. this
125 could be a pointer to the ACPI table header.
130 ValidateGtBlockTimerCount (
135 UINT32 BlockTimerCount
;
137 BlockTimerCount
= *(UINT32
*)Ptr
;
139 if (BlockTimerCount
> 8) {
140 IncrementErrorCount ();
142 L
"\nERROR: Timer Count = %d. Max Timer Count is 8.",
149 This function parses the Platform GT Block.
151 @param [in] Ptr Pointer to the start of the GT Block data.
152 @param [in] Length Length of the GT Block structure.
163 UINT32 GTBlockTimerLength
;
171 PARSER_PARAMS (GtBlockParser
)
173 GTBlockTimerLength
= (*GtBlockLength
- Offset
) / (*GtBlockTimerCount
);
176 if (*GtBlockTimerCount
!= 0) {
177 Ptr
+= (*GtBlockTimerOffset
);
179 while ((Index
< (*GtBlockTimerCount
)) && (Length
>= GTBlockTimerLength
)) {
186 PARSER_PARAMS (GtBlockTimerParser
)
188 // Increment by GT Block Timer structure size
195 IncrementErrorCount ();
197 L
"ERROR:GT Block Timer length mismatch. Unparsed %d bytes.\n",
205 This function parses the Platform Watchdog timer.
207 @param [in] Ptr Pointer to the start of the watchdog timer data.
208 @param [in] Length Length of the watchdog timer structure.
220 "SBSA Generic Watchdog",
223 PARSER_PARAMS (SBSAGenericWatchdogParser
)
228 This function parses the ACPI GTDT table.
229 When trace is enabled this function parses the GTDT table and
230 traces the ACPI table fields.
232 This function also parses the following platform timer structures:
236 This function also performs validation of the ACPI table fields.
238 @param [in] Trace If TRUE, trace the ACPI fields.
239 @param [in] Ptr Pointer to the start of the buffer.
240 @param [in] AcpiTableLength Length of the ACPI table.
241 @param [in] AcpiTableRevision Revision of the ACPI table.
248 IN UINT32 AcpiTableLength
,
249 IN UINT8 AcpiTableRevision
265 PARSER_PARAMS (GtdtParser
)
268 if (*GtdtPlatformTimerCount
!= 0) {
269 TimerPtr
= Ptr
+ (*GtdtPlatformTimerOffset
);
272 // Parse the Platform Timer Header
278 4, // GT Platform Timer structure header length.
279 PARSER_PARAMS (GtPlatformTimerHeaderParser
)
281 switch (*PlatformTimerType
) {
282 case EFI_ACPI_6_2_GTDT_GT_BLOCK
:
283 DumpGTBlock (TimerPtr
, *PlatformTimerLength
);
285 case EFI_ACPI_6_2_GTDT_SBSA_GENERIC_WATCHDOG
:
286 DumpWatchdogTimer (TimerPtr
, *PlatformTimerLength
);
289 IncrementErrorCount ();
291 L
"ERROR: INVALID Platform Timer Type = %d\n",
296 TimerPtr
+= (*PlatformTimerLength
);
298 } while (Index
< *GtdtPlatformTimerCount
);