TianoCore EDK2 master
Loading...
Searching...
No Matches
GtdtParser.c
Go to the documentation of this file.
1
12#include <Library/UefiLib.h>
13#include "AcpiParser.h"
14#include "AcpiTableParser.h"
15#include "AcpiViewConfig.h"
16
17// "The number of GT Block Timers must be less than or equal to 8"
18#define GT_BLOCK_TIMER_COUNT_MAX 8
19
20// Local variables
21STATIC CONST UINT32 *GtdtPlatformTimerCount;
22STATIC CONST UINT32 *GtdtPlatformTimerOffset;
23STATIC CONST UINT8 *PlatformTimerType;
24STATIC CONST UINT16 *PlatformTimerLength;
25STATIC CONST UINT32 *GtBlockTimerCount;
26STATIC CONST UINT32 *GtBlockTimerOffset;
28
38VOID
39EFIAPI
41 IN UINT8 *Ptr,
42 IN UINT32 Length,
43 IN VOID *Context
44 )
45{
46 UINT32 BlockTimerCount;
47
48 BlockTimerCount = *(UINT32 *)Ptr;
49
50 if (BlockTimerCount > GT_BLOCK_TIMER_COUNT_MAX) {
52 Print (
53 L"\nERROR: Timer Count = %d. Max Timer Count is %d.",
54 BlockTimerCount,
55 GT_BLOCK_TIMER_COUNT_MAX
56 );
57 }
58}
59
69VOID
70EFIAPI
72 IN UINT8 *Ptr,
73 IN UINT32 Length,
74 IN VOID *Context
75 )
76{
77 UINT8 FrameNumber;
78
79 FrameNumber = *(UINT8 *)Ptr;
80
81 if (FrameNumber >= GT_BLOCK_TIMER_COUNT_MAX) {
83 Print (
84 L"\nERROR: GT Frame Number = %d. GT Frame Number must be in range 0-%d.",
85 FrameNumber,
86 GT_BLOCK_TIMER_COUNT_MAX - 1
87 );
88 }
89}
90
95 PARSE_ACPI_HEADER (&AcpiHdrInfo),
96 { L"CntControlBase Physical Address",8, 36, L"0x%lx", NULL, NULL,
97 NULL, NULL },
98 { L"Reserved", 4, 44, L"0x%x", NULL, NULL,NULL, NULL },
99 { L"Secure EL1 timer GSIV", 4, 48, L"0x%x", NULL, NULL,NULL, NULL },
100 { L"Secure EL1 timer FLAGS", 4, 52, L"0x%x", NULL, NULL,NULL, NULL },
101
102 { L"Non-Secure EL1 timer GSIV", 4, 56, L"0x%x", NULL, NULL,NULL, NULL },
103 { L"Non-Secure EL1 timer FLAGS", 4, 60, L"0x%x", NULL, NULL,NULL, NULL },
104
105 { L"Virtual timer GSIV", 4, 64, L"0x%x", NULL, NULL,NULL, NULL },
106 { L"Virtual timer FLAGS", 4, 68, L"0x%x", NULL, NULL,NULL, NULL },
107
108 { L"Non-Secure EL2 timer GSIV", 4, 72, L"0x%x", NULL, NULL,NULL, NULL },
109 { L"Non-Secure EL2 timer FLAGS", 4, 76, L"0x%x", NULL, NULL,NULL, NULL },
110
111 { L"CntReadBase Physical address", 8, 80, L"0x%lx", NULL, NULL,NULL, NULL },
112 { L"Platform Timer Count", 4, 88, L"%d", NULL,
113 (VOID **)&GtdtPlatformTimerCount, NULL, NULL },
114 { L"Platform Timer Offset", 4, 92, L"0x%x", NULL,
115 (VOID **)&GtdtPlatformTimerOffset,NULL, NULL },
116 { L"Virtual EL2 Timer GSIV", 4, 96, L"0x%x", NULL, NULL,NULL, NULL },
117 { L"Virtual EL2 Timer Flags", 4, 100, L"0x%x", NULL, NULL,NULL, NULL }
118};
119
124 { L"Type", 1, 0, NULL, NULL, (VOID **)&PlatformTimerType, NULL, NULL },
125 { L"Length", 2, 1, NULL, NULL, (VOID **)&PlatformTimerLength, NULL, NULL },
126 { L"Reserved", 1, 3, NULL, NULL, NULL, NULL, NULL }
127};
128
133 { L"Type", 1, 0, L"%d", NULL, NULL, NULL, NULL },
134 { L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL },
135 { L"Reserved", 1, 3, L"%x", NULL, NULL, NULL, NULL },
136 { L"Physical address (CntCtlBase)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL },
137 { L"Timer Count", 4, 12, L"%d", NULL, (VOID **)&GtBlockTimerCount,
139 { L"Timer Offset", 4, 16, L"%d", NULL, (VOID **)&GtBlockTimerOffset, NULL,
140 NULL }
141};
142
147 { L"Frame Number", 1, 0, L"%d", NULL, NULL, ValidateGtFrameNumber, NULL },
148 { L"Reserved", 3, 1, L"%x %x %x", Dump3Chars, NULL, NULL, NULL },
149 { L"Physical address (CntBaseX)", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL },
150 { L"Physical address (CntEL0BaseX)", 8, 12, L"0x%lx", NULL, NULL, NULL,
151 NULL },
152 { L"Physical Timer GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
153 { L"Physical Timer Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL },
154 { L"Virtual Timer GSIV", 4, 28, L"0x%x", NULL, NULL, NULL, NULL },
155 { L"Virtual Timer Flags", 4, 32, L"0x%x", NULL, NULL, NULL, NULL },
156 { L"Common Flags", 4, 36, L"0x%x", NULL, NULL, NULL, NULL }
157};
158
163 { L"Type", 1, 0, L"%d", NULL, NULL, NULL, NULL },
164 { L"Length", 2, 1, L"%d", NULL, NULL, NULL, NULL },
165 { L"Reserved", 1, 3, L"%x", NULL, NULL, NULL, NULL },
166 { L"RefreshFrame Physical address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL },
167 { L"ControlFrame Physical address", 8, 12, L"0x%lx", NULL, NULL, NULL, NULL },
168 { L"Watchdog Timer GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
169 { L"Watchdog Timer Flags", 4, 24, L"0x%x", NULL, NULL, NULL, NULL }
170};
171
178STATIC
179VOID
181 IN UINT8 *Ptr,
182 IN UINT16 Length
183 )
184{
185 UINT32 Index;
186 UINT32 Offset;
187
188 ParseAcpi (
189 TRUE,
190 2,
191 "GT Block",
192 Ptr,
193 Length,
195 );
196
197 // Check if the values used to control the parsing logic have been
198 // successfully read.
199 if ((GtBlockTimerCount == NULL) ||
200 (GtBlockTimerOffset == NULL))
201 {
203 Print (
204 L"ERROR: Insufficient GT Block Structure length. Length = %d.\n",
205 Length
206 );
207 return;
208 }
209
210 Offset = *GtBlockTimerOffset;
211 Index = 0;
212
213 // Parse the specified number of GT Block Timer Structures or the GT Block
214 // Structure buffer length. Whichever is minimum.
215 while ((Index++ < *GtBlockTimerCount) &&
216 (Offset < Length))
217 {
218 Offset += ParseAcpi (
219 TRUE,
220 2,
221 "GT Block Timer",
222 Ptr + Offset,
223 Length - Offset,
225 );
226 }
227}
228
235STATIC
236VOID
238 IN UINT8 *Ptr,
239 IN UINT16 Length
240 )
241{
242 ParseAcpi (
243 TRUE,
244 2,
245 "Arm Generic Watchdog",
246 Ptr,
247 Length,
249 );
250}
251
268VOID
269EFIAPI
271 IN BOOLEAN Trace,
272 IN UINT8 *Ptr,
273 IN UINT32 AcpiTableLength,
274 IN UINT8 AcpiTableRevision
275 )
276{
277 UINT32 Index;
278 UINT32 Offset;
279 UINT8 *TimerPtr;
280
281 if (!Trace) {
282 return;
283 }
284
285 ParseAcpi (
286 TRUE,
287 0,
288 "GTDT",
289 Ptr,
290 AcpiTableLength,
292 );
293
294 // Check if the values used to control the parsing logic have been
295 // successfully read.
296 if ((GtdtPlatformTimerCount == NULL) ||
297 (GtdtPlatformTimerOffset == NULL))
298 {
300 Print (
301 L"ERROR: Insufficient table length. AcpiTableLength = %d.\n",
302 AcpiTableLength
303 );
304 return;
305 }
306
307 TimerPtr = Ptr + *GtdtPlatformTimerOffset;
308 Offset = *GtdtPlatformTimerOffset;
309 Index = 0;
310
311 // Parse the specified number of Platform Timer Structures or the GTDT
312 // buffer length. Whichever is minimum.
313 while ((Index++ < *GtdtPlatformTimerCount) &&
314 (Offset < AcpiTableLength))
315 {
316 // Parse the Platform Timer Header to obtain Length and Type
317 ParseAcpi (
318 FALSE,
319 0,
320 NULL,
321 TimerPtr,
322 AcpiTableLength - Offset,
324 );
325
326 // Check if the values used to control the parsing logic have been
327 // successfully read.
328 if ((PlatformTimerType == NULL) ||
329 (PlatformTimerLength == NULL))
330 {
332 Print (
333 L"ERROR: Insufficient remaining table buffer length to read the " \
334 L"Platform Timer Structure header. Length = %d.\n",
335 AcpiTableLength - Offset
336 );
337 return;
338 }
339
340 // Validate Platform Timer Structure length
341 if ((*PlatformTimerLength == 0) ||
342 ((Offset + (*PlatformTimerLength)) > AcpiTableLength))
343 {
345 Print (
346 L"ERROR: Invalid Platform Timer Structure length. " \
347 L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
348 *PlatformTimerLength,
349 Offset,
350 AcpiTableLength
351 );
352 return;
353 }
354
355 switch (*PlatformTimerType) {
357 DumpGTBlock (TimerPtr, *PlatformTimerLength);
358 break;
359 case EFI_ACPI_6_4_GTDT_ARM_GENERIC_WATCHDOG:
360 DumpWatchdogTimer (TimerPtr, *PlatformTimerLength);
361 break;
362 default:
364 Print (
365 L"ERROR: Invalid Platform Timer Type = %d\n",
366 *PlatformTimerType
367 );
368 break;
369 } // switch
370
371 TimerPtr += *PlatformTimerLength;
372 Offset += *PlatformTimerLength;
373 } // while
374}
#define EFI_ACPI_6_4_GTDT_GT_BLOCK
Definition: Acpi64.h:1421
VOID EFIAPI Dump3Chars(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length)
Definition: AcpiParser.c:326
VOID EFIAPI IncrementErrorCount(VOID)
Definition: AcpiParser.c:83
UINT32 EFIAPI ParseAcpi(IN BOOLEAN Trace, IN UINT32 Indent, IN CONST CHAR8 *AsciiName OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length, IN CONST ACPI_PARSER *Parser, IN UINT32 ParserItems)
Definition: AcpiParser.c:683
#define PARSER_PARAMS(Parser)
Definition: AcpiParser.h:494
#define PARSE_ACPI_HEADER(Info)
Definition: AcpiParser.h:501
STATIC CONST ACPI_PARSER ArmGenericWatchdogParser[]
Definition: GtdtParser.c:162
STATIC CONST ACPI_PARSER GtPlatformTimerHeaderParser[]
Definition: GtdtParser.c:123
STATIC VOID DumpGTBlock(IN UINT8 *Ptr, IN UINT16 Length)
Definition: GtdtParser.c:180
STATIC CONST ACPI_PARSER GtdtParser[]
Definition: GtdtParser.c:94
STATIC CONST ACPI_PARSER GtBlockTimerParser[]
Definition: GtdtParser.c:146
STATIC CONST ACPI_PARSER GtBlockParser[]
Definition: GtdtParser.c:132
VOID EFIAPI ParseAcpiGtdt(IN BOOLEAN Trace, IN UINT8 *Ptr, IN UINT32 AcpiTableLength, IN UINT8 AcpiTableRevision)
Definition: GtdtParser.c:270
STATIC VOID DumpWatchdogTimer(IN UINT8 *Ptr, IN UINT16 Length)
Definition: GtdtParser.c:237
STATIC VOID EFIAPI ValidateGtBlockTimerCount(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: GtdtParser.c:40
STATIC VOID EFIAPI ValidateGtFrameNumber(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: GtdtParser.c:71
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)
Definition: UefiLibPrint.c:113