]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
ShellPkg: acpiview: Remove duplicate ACPI structure size definitions
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / AcpiParser.c
CommitLineData
a6eaba4d 1/** @file\r
ee4dc24f
RN
2 ACPI parser\r
3\r
0b9026a8 4 Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.\r
56ba3746 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
ee4dc24f
RN
6**/\r
7\r
8#include <Uefi.h>\r
9#include <Library/UefiLib.h>\r
10#include <Library/UefiBootServicesTableLib.h>\r
11#include "AcpiParser.h"\r
12#include "AcpiView.h"\r
13\r
14STATIC UINT32 gIndent;\r
15STATIC UINT32 mTableErrorCount;\r
16STATIC UINT32 mTableWarningCount;\r
17\r
f75c7478
DB
18STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;\r
19\r
20/**\r
21 An ACPI_PARSER array describing the ACPI header.\r
22**/\r
23STATIC CONST ACPI_PARSER AcpiHeaderParser[] = {\r
24 PARSE_ACPI_HEADER (&AcpiHdrInfo)\r
25};\r
26\r
a6eaba4d
DB
27/**\r
28 This function resets the ACPI table error counter to Zero.\r
29**/\r
ee4dc24f
RN
30VOID\r
31ResetErrorCount (\r
32 VOID\r
33 )\r
34{\r
35 mTableErrorCount = 0;\r
36}\r
37\r
a6eaba4d
DB
38/**\r
39 This function returns the ACPI table error count.\r
ee4dc24f
RN
40\r
41 @retval Returns the count of errors detected in the ACPI tables.\r
a6eaba4d 42**/\r
ee4dc24f
RN
43UINT32\r
44GetErrorCount (\r
45 VOID\r
46 )\r
47{\r
48 return mTableErrorCount;\r
49}\r
50\r
a6eaba4d
DB
51/**\r
52 This function resets the ACPI table warning counter to Zero.\r
53**/\r
ee4dc24f
RN
54VOID\r
55ResetWarningCount (\r
56 VOID\r
57 )\r
58{\r
59 mTableWarningCount = 0;\r
60}\r
61\r
a6eaba4d
DB
62/**\r
63 This function returns the ACPI table warning count.\r
ee4dc24f
RN
64\r
65 @retval Returns the count of warning detected in the ACPI tables.\r
a6eaba4d 66**/\r
ee4dc24f
RN
67UINT32\r
68GetWarningCount (\r
69 VOID\r
70 )\r
71{\r
72 return mTableWarningCount;\r
73}\r
74\r
a6eaba4d
DB
75/**\r
76 This function increments the ACPI table error counter.\r
77**/\r
ee4dc24f
RN
78VOID\r
79EFIAPI\r
80IncrementErrorCount (\r
81 VOID\r
82 )\r
83{\r
84 mTableErrorCount++;\r
85}\r
86\r
a6eaba4d
DB
87/**\r
88 This function increments the ACPI table warning counter.\r
89**/\r
ee4dc24f
RN
90VOID\r
91EFIAPI\r
92IncrementWarningCount (\r
93 VOID\r
94 )\r
95{\r
96 mTableWarningCount++;\r
97}\r
98\r
a6eaba4d
DB
99/**\r
100 This function verifies the ACPI table checksum.\r
ee4dc24f
RN
101\r
102 This function verifies the checksum for the ACPI table and optionally\r
103 prints the status.\r
104\r
105 @param [in] Log If TRUE log the status of the checksum.\r
106 @param [in] Ptr Pointer to the start of the table buffer.\r
107 @param [in] Length The length of the buffer.\r
108\r
109 @retval TRUE The checksum is OK.\r
110 @retval FALSE The checksum failed.\r
a6eaba4d 111**/\r
ee4dc24f
RN
112BOOLEAN\r
113EFIAPI\r
114VerifyChecksum (\r
115 IN BOOLEAN Log,\r
116 IN UINT8* Ptr,\r
117 IN UINT32 Length\r
118 )\r
119{\r
f75c7478
DB
120 UINTN ByteCount;\r
121 UINT8 Checksum;\r
ee4dc24f
RN
122 UINTN OriginalAttribute;\r
123\r
0154e02d
SZ
124 //\r
125 // set local variables to suppress incorrect compiler/analyzer warnings\r
126 //\r
127 OriginalAttribute = 0;\r
f75c7478
DB
128 ByteCount = 0;\r
129 Checksum = 0;\r
130\r
ee4dc24f
RN
131 while (ByteCount < Length) {\r
132 Checksum += *(Ptr++);\r
133 ByteCount++;\r
134 }\r
135\r
136 if (Log) {\r
137 OriginalAttribute = gST->ConOut->Mode->Attribute;\r
138 if (Checksum == 0) {\r
139 if (GetColourHighlighting ()) {\r
140 gST->ConOut->SetAttribute (\r
141 gST->ConOut,\r
142 EFI_TEXT_ATTR (EFI_GREEN,\r
143 ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))\r
144 );\r
145 }\r
5a119220 146 Print (L"Table Checksum : OK\n\n");\r
ee4dc24f
RN
147 } else {\r
148 IncrementErrorCount ();\r
149 if (GetColourHighlighting ()) {\r
150 gST->ConOut->SetAttribute (\r
151 gST->ConOut,\r
152 EFI_TEXT_ATTR (EFI_RED,\r
153 ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))\r
154 );\r
155 }\r
5a119220 156 Print (L"Table Checksum : FAILED (0x%X)\n\n", Checksum);\r
ee4dc24f
RN
157 }\r
158 if (GetColourHighlighting ()) {\r
159 gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);\r
160 }\r
161 }\r
162\r
163 return (Checksum == 0);\r
164}\r
165\r
a6eaba4d
DB
166/**\r
167 This function performs a raw data dump of the ACPI table.\r
ee4dc24f
RN
168\r
169 @param [in] Ptr Pointer to the start of the table buffer.\r
170 @param [in] Length The length of the buffer.\r
a6eaba4d 171**/\r
ee4dc24f
RN
172VOID\r
173EFIAPI\r
174DumpRaw (\r
175 IN UINT8* Ptr,\r
176 IN UINT32 Length\r
177 )\r
178{\r
f75c7478 179 UINTN ByteCount;\r
ee4dc24f 180 UINTN PartLineChars;\r
f75c7478 181 UINTN AsciiBufferIndex;\r
ee4dc24f
RN
182 CHAR8 AsciiBuffer[17];\r
183\r
f75c7478
DB
184 ByteCount = 0;\r
185 AsciiBufferIndex = 0;\r
186\r
ee4dc24f
RN
187 Print (L"Address : 0x%p\n", Ptr);\r
188 Print (L"Length : %d\n", Length);\r
189\r
190 while (ByteCount < Length) {\r
191 if ((ByteCount & 0x0F) == 0) {\r
192 AsciiBuffer[AsciiBufferIndex] = '\0';\r
193 Print (L" %a\n%08X : ", AsciiBuffer, ByteCount);\r
194 AsciiBufferIndex = 0;\r
195 } else if ((ByteCount & 0x07) == 0) {\r
196 Print (L"- ");\r
197 }\r
198\r
199 if ((*Ptr >= ' ') && (*Ptr < 0x7F)) {\r
200 AsciiBuffer[AsciiBufferIndex++] = *Ptr;\r
201 } else {\r
202 AsciiBuffer[AsciiBufferIndex++] = '.';\r
203 }\r
204\r
205 Print (L"%02X ", *Ptr++);\r
206\r
207 ByteCount++;\r
208 }\r
209\r
210 // Justify the final line using spaces before printing\r
211 // the ASCII data.\r
212 PartLineChars = (Length & 0x0F);\r
213 if (PartLineChars != 0) {\r
214 PartLineChars = 48 - (PartLineChars * 3);\r
215 if ((Length & 0x0F) <= 8) {\r
216 PartLineChars += 2;\r
217 }\r
218 while (PartLineChars > 0) {\r
219 Print (L" ");\r
220 PartLineChars--;\r
221 }\r
222 }\r
223\r
224 // Print ASCII data for the final line.\r
225 AsciiBuffer[AsciiBufferIndex] = '\0';\r
5a119220 226 Print (L" %a\n\n", AsciiBuffer);\r
ee4dc24f
RN
227}\r
228\r
a6eaba4d
DB
229/**\r
230 This function traces 1 byte of data as specified in the format string.\r
ee4dc24f
RN
231\r
232 @param [in] Format The format string for tracing the data.\r
233 @param [in] Ptr Pointer to the start of the buffer.\r
a6eaba4d 234**/\r
ee4dc24f
RN
235VOID\r
236EFIAPI\r
237DumpUint8 (\r
238 IN CONST CHAR16* Format,\r
239 IN UINT8* Ptr\r
240 )\r
241{\r
242 Print (Format, *Ptr);\r
243}\r
244\r
a6eaba4d
DB
245/**\r
246 This function traces 2 bytes of data as specified in the format string.\r
ee4dc24f
RN
247\r
248 @param [in] Format The format string for tracing the data.\r
249 @param [in] Ptr Pointer to the start of the buffer.\r
a6eaba4d 250**/\r
ee4dc24f
RN
251VOID\r
252EFIAPI\r
253DumpUint16 (\r
254 IN CONST CHAR16* Format,\r
255 IN UINT8* Ptr\r
256 )\r
257{\r
258 Print (Format, *(UINT16*)Ptr);\r
259}\r
260\r
a6eaba4d
DB
261/**\r
262 This function traces 4 bytes of data as specified in the format string.\r
ee4dc24f
RN
263\r
264 @param [in] Format The format string for tracing the data.\r
265 @param [in] Ptr Pointer to the start of the buffer.\r
a6eaba4d 266**/\r
ee4dc24f
RN
267VOID\r
268EFIAPI\r
269DumpUint32 (\r
270 IN CONST CHAR16* Format,\r
271 IN UINT8* Ptr\r
272 )\r
273{\r
274 Print (Format, *(UINT32*)Ptr);\r
275}\r
276\r
a6eaba4d
DB
277/**\r
278 This function traces 8 bytes of data as specified by the format string.\r
ee4dc24f
RN
279\r
280 @param [in] Format The format string for tracing the data.\r
281 @param [in] Ptr Pointer to the start of the buffer.\r
a6eaba4d 282**/\r
ee4dc24f
RN
283VOID\r
284EFIAPI\r
285DumpUint64 (\r
286 IN CONST CHAR16* Format,\r
287 IN UINT8* Ptr\r
288 )\r
289{\r
290 // Some fields are not aligned and this causes alignment faults\r
291 // on ARM platforms if the compiler generates LDRD instructions.\r
292 // Perform word access so that LDRD instructions are not generated.\r
f75c7478
DB
293 UINT64 Val;\r
294\r
295 Val = *(UINT32*)(Ptr + sizeof (UINT32));\r
296\r
5726bdd9 297 Val = LShiftU64(Val,32);\r
81038d50 298 Val |= (UINT64)*(UINT32*)Ptr;\r
ee4dc24f
RN
299\r
300 Print (Format, Val);\r
301}\r
302\r
a6eaba4d
DB
303/**\r
304 This function traces 3 characters which can be optionally\r
305 formated using the format string if specified.\r
ee4dc24f
RN
306\r
307 If no format string is specified the Format must be NULL.\r
308\r
309 @param [in] Format Optional format string for tracing the data.\r
310 @param [in] Ptr Pointer to the start of the buffer.\r
a6eaba4d 311**/\r
ee4dc24f
RN
312VOID\r
313EFIAPI\r
314Dump3Chars (\r
315 IN CONST CHAR16* Format OPTIONAL,\r
316 IN UINT8* Ptr\r
317 )\r
318{\r
319 Print (\r
320 (Format != NULL) ? Format : L"%c%c%c",\r
321 Ptr[0],\r
322 Ptr[1],\r
323 Ptr[2]\r
324 );\r
325}\r
326\r
a6eaba4d
DB
327/**\r
328 This function traces 4 characters which can be optionally\r
329 formated using the format string if specified.\r
ee4dc24f
RN
330\r
331 If no format string is specified the Format must be NULL.\r
332\r
333 @param [in] Format Optional format string for tracing the data.\r
334 @param [in] Ptr Pointer to the start of the buffer.\r
a6eaba4d 335**/\r
ee4dc24f
RN
336VOID\r
337EFIAPI\r
338Dump4Chars (\r
339 IN CONST CHAR16* Format OPTIONAL,\r
340 IN UINT8* Ptr\r
341 )\r
342{\r
343 Print (\r
344 (Format != NULL) ? Format : L"%c%c%c%c",\r
345 Ptr[0],\r
346 Ptr[1],\r
347 Ptr[2],\r
348 Ptr[3]\r
349 );\r
350}\r
351\r
a6eaba4d
DB
352/**\r
353 This function traces 6 characters which can be optionally\r
354 formated using the format string if specified.\r
ee4dc24f
RN
355\r
356 If no format string is specified the Format must be NULL.\r
357\r
358 @param [in] Format Optional format string for tracing the data.\r
359 @param [in] Ptr Pointer to the start of the buffer.\r
a6eaba4d 360**/\r
ee4dc24f
RN
361VOID\r
362EFIAPI\r
363Dump6Chars (\r
364 IN CONST CHAR16* Format OPTIONAL,\r
365 IN UINT8* Ptr\r
366 )\r
367{\r
368 Print (\r
369 (Format != NULL) ? Format : L"%c%c%c%c%c%c",\r
370 Ptr[0],\r
371 Ptr[1],\r
372 Ptr[2],\r
373 Ptr[3],\r
374 Ptr[4],\r
375 Ptr[5]\r
376 );\r
377}\r
378\r
a6eaba4d
DB
379/**\r
380 This function traces 8 characters which can be optionally\r
381 formated using the format string if specified.\r
ee4dc24f
RN
382\r
383 If no format string is specified the Format must be NULL.\r
384\r
385 @param [in] Format Optional format string for tracing the data.\r
386 @param [in] Ptr Pointer to the start of the buffer.\r
a6eaba4d 387**/\r
ee4dc24f
RN
388VOID\r
389EFIAPI\r
390Dump8Chars (\r
391 IN CONST CHAR16* Format OPTIONAL,\r
392 IN UINT8* Ptr\r
393 )\r
394{\r
395 Print (\r
396 (Format != NULL) ? Format : L"%c%c%c%c%c%c%c%c",\r
397 Ptr[0],\r
398 Ptr[1],\r
399 Ptr[2],\r
400 Ptr[3],\r
401 Ptr[4],\r
402 Ptr[5],\r
403 Ptr[6],\r
404 Ptr[7]\r
405 );\r
406}\r
407\r
710ff749
KK
408/**\r
409 This function traces 12 characters which can be optionally\r
410 formated using the format string if specified.\r
411\r
412 If no format string is specified the Format must be NULL.\r
413\r
414 @param [in] Format Optional format string for tracing the data.\r
415 @param [in] Ptr Pointer to the start of the buffer.\r
416**/\r
417VOID\r
418EFIAPI\r
419Dump12Chars (\r
420 IN CONST CHAR16* Format OPTIONAL,\r
421 IN UINT8* Ptr\r
422 )\r
423{\r
424 Print (\r
425 (Format != NULL) ? Format : L"%c%c%c%c%c%c%c%c%c%c%c%c",\r
426 Ptr[0],\r
427 Ptr[1],\r
428 Ptr[2],\r
429 Ptr[3],\r
430 Ptr[4],\r
431 Ptr[5],\r
432 Ptr[6],\r
433 Ptr[7],\r
434 Ptr[8],\r
435 Ptr[9],\r
436 Ptr[10],\r
437 Ptr[11]\r
438 );\r
439}\r
440\r
a6eaba4d
DB
441/**\r
442 This function indents and prints the ACPI table Field Name.\r
ee4dc24f
RN
443\r
444 @param [in] Indent Number of spaces to add to the global table indent.\r
445 The global table indent is 0 by default; however\r
446 this value is updated on entry to the ParseAcpi()\r
447 by adding the indent value provided to ParseAcpi()\r
448 and restored back on exit.\r
449 Therefore the total indent in the output is\r
450 dependent on from where this function is called.\r
451 @param [in] FieldName Pointer to the Field Name.\r
a6eaba4d 452**/\r
ee4dc24f
RN
453VOID\r
454EFIAPI\r
455PrintFieldName (\r
456 IN UINT32 Indent,\r
457 IN CONST CHAR16* FieldName\r
458)\r
459{\r
460 Print (\r
461 L"%*a%-*s : ",\r
462 gIndent + Indent,\r
463 "",\r
464 (OUTPUT_FIELD_COLUMN_WIDTH - gIndent - Indent),\r
465 FieldName\r
466 );\r
467}\r
468\r
a6eaba4d
DB
469/**\r
470 This function is used to parse an ACPI table buffer.\r
ee4dc24f
RN
471\r
472 The ACPI table buffer is parsed using the ACPI table parser information\r
473 specified by a pointer to an array of ACPI_PARSER elements. This parser\r
474 function iterates through each item on the ACPI_PARSER array and logs the\r
475 ACPI table fields.\r
476\r
477 This function can optionally be used to parse ACPI tables and fetch specific\r
478 field values. The ItemPtr member of the ACPI_PARSER structure (where used)\r
479 is updated by this parser function to point to the selected field data\r
480 (e.g. useful for variable length nested fields).\r
481\r
482 @param [in] Trace Trace the ACPI fields TRUE else only parse the\r
483 table.\r
484 @param [in] Indent Number of spaces to indent the output.\r
485 @param [in] AsciiName Optional pointer to an ASCII string that describes\r
486 the table being parsed.\r
487 @param [in] Ptr Pointer to the start of the buffer.\r
488 @param [in] Length Length of the buffer pointed by Ptr.\r
489 @param [in] Parser Pointer to an array of ACPI_PARSER structure that\r
490 describes the table being parsed.\r
491 @param [in] ParserItems Number of items in the ACPI_PARSER array.\r
492\r
493 @retval Number of bytes parsed.\r
a6eaba4d 494**/\r
ee4dc24f
RN
495UINT32\r
496EFIAPI\r
497ParseAcpi (\r
498 IN BOOLEAN Trace,\r
499 IN UINT32 Indent,\r
500 IN CONST CHAR8* AsciiName OPTIONAL,\r
501 IN UINT8* Ptr,\r
502 IN UINT32 Length,\r
503 IN CONST ACPI_PARSER* Parser,\r
504 IN UINT32 ParserItems\r
505)\r
506{\r
507 UINT32 Index;\r
f75c7478
DB
508 UINT32 Offset;\r
509 BOOLEAN HighLight;\r
ed874680 510 UINTN OriginalAttribute;\r
f75c7478 511\r
0154e02d
SZ
512 //\r
513 // set local variables to suppress incorrect compiler/analyzer warnings\r
514 //\r
515 OriginalAttribute = 0;\r
f75c7478 516 Offset = 0;\r
ee4dc24f
RN
517\r
518 // Increment the Indent\r
519 gIndent += Indent;\r
520\r
521 if (Trace && (AsciiName != NULL)){\r
f75c7478 522 HighLight = GetColourHighlighting ();\r
ee4dc24f
RN
523\r
524 if (HighLight) {\r
525 OriginalAttribute = gST->ConOut->Mode->Attribute;\r
526 gST->ConOut->SetAttribute (\r
527 gST->ConOut,\r
528 EFI_TEXT_ATTR(EFI_YELLOW,\r
529 ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))\r
530 );\r
531 }\r
532 Print (\r
533 L"%*a%-*a :\n",\r
534 gIndent,\r
535 "",\r
536 (OUTPUT_FIELD_COLUMN_WIDTH - gIndent),\r
537 AsciiName\r
538 );\r
539 if (HighLight) {\r
540 gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);\r
541 }\r
542 }\r
543\r
544 for (Index = 0; Index < ParserItems; Index++) {\r
545 if ((Offset + Parser[Index].Length) > Length) {\r
5bd326c5
KK
546\r
547 // For fields outside the buffer length provided, reset any pointers\r
548 // which were supposed to be updated by this function call\r
549 if (Parser[Index].ItemPtr != NULL) {\r
550 *Parser[Index].ItemPtr = NULL;\r
551 }\r
552\r
ee4dc24f 553 // We don't parse past the end of the max length specified\r
5bd326c5 554 continue;\r
ee4dc24f
RN
555 }\r
556\r
f73843d5
KK
557 if (GetConsistencyChecking () &&\r
558 (Offset != Parser[Index].Offset)) {\r
ee4dc24f
RN
559 IncrementErrorCount ();\r
560 Print (\r
561 L"\nERROR: %a: Offset Mismatch for %s\n"\r
e6f958d1 562 L"CurrentOffset = %d FieldOffset = %d\n",\r
ee4dc24f
RN
563 AsciiName,\r
564 Parser[Index].NameStr,\r
565 Offset,\r
566 Parser[Index].Offset\r
567 );\r
568 }\r
569\r
570 if (Trace) {\r
571 // if there is a Formatter function let the function handle\r
572 // the printing else if a Format is specified in the table use\r
573 // the Format for printing\r
574 PrintFieldName (2, Parser[Index].NameStr);\r
575 if (Parser[Index].PrintFormatter != NULL) {\r
576 Parser[Index].PrintFormatter (Parser[Index].Format, Ptr);\r
577 } else if (Parser[Index].Format != NULL) {\r
578 switch (Parser[Index].Length) {\r
579 case 1:\r
580 DumpUint8 (Parser[Index].Format, Ptr);\r
581 break;\r
582 case 2:\r
583 DumpUint16 (Parser[Index].Format, Ptr);\r
584 break;\r
585 case 4:\r
586 DumpUint32 (Parser[Index].Format, Ptr);\r
587 break;\r
588 case 8:\r
589 DumpUint64 (Parser[Index].Format, Ptr);\r
590 break;\r
591 default:\r
592 Print (\r
593 L"\nERROR: %a: CANNOT PARSE THIS FIELD, Field Length = %d\n",\r
594 AsciiName,\r
595 Parser[Index].Length\r
596 );\r
597 } // switch\r
598\r
599 // Validating only makes sense if we are tracing\r
600 // the parsed table entries, to report by table name.\r
f73843d5
KK
601 if (GetConsistencyChecking () &&\r
602 (Parser[Index].FieldValidator != NULL)) {\r
ee4dc24f
RN
603 Parser[Index].FieldValidator (Ptr, Parser[Index].Context);\r
604 }\r
605 }\r
606 Print (L"\n");\r
607 } // if (Trace)\r
608\r
609 if (Parser[Index].ItemPtr != NULL) {\r
610 *Parser[Index].ItemPtr = (VOID*)Ptr;\r
611 }\r
612\r
613 Ptr += Parser[Index].Length;\r
614 Offset += Parser[Index].Length;\r
615 } // for\r
616\r
617 // Decrement the Indent\r
618 gIndent -= Indent;\r
619 return Offset;\r
620}\r
621\r
a6eaba4d
DB
622/**\r
623 An array describing the ACPI Generic Address Structure.\r
ee4dc24f
RN
624 The GasParser array is used by the ParseAcpi function to parse and/or trace\r
625 the GAS structure.\r
a6eaba4d 626**/\r
ee4dc24f
RN
627STATIC CONST ACPI_PARSER GasParser[] = {\r
628 {L"Address Space ID", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},\r
629 {L"Register Bit Width", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},\r
630 {L"Register Bit Offset", 1, 2, L"0x%x", NULL, NULL, NULL, NULL},\r
631 {L"Address Size", 1, 3, L"0x%x", NULL, NULL, NULL, NULL},\r
632 {L"Address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL}\r
633};\r
634\r
a6eaba4d
DB
635/**\r
636 This function indents and traces the GAS structure as described by the GasParser.\r
ee4dc24f
RN
637\r
638 @param [in] Ptr Pointer to the start of the buffer.\r
639 @param [in] Indent Number of spaces to indent the output.\r
58cc0ffe
KK
640 @param [in] Length Length of the GAS structure buffer.\r
641\r
642 @retval Number of bytes parsed.\r
a6eaba4d 643**/\r
58cc0ffe 644UINT32\r
ee4dc24f
RN
645EFIAPI\r
646DumpGasStruct (\r
647 IN UINT8* Ptr,\r
58cc0ffe
KK
648 IN UINT32 Indent,\r
649 IN UINT32 Length\r
ee4dc24f
RN
650 )\r
651{\r
652 Print (L"\n");\r
58cc0ffe
KK
653 return ParseAcpi (\r
654 TRUE,\r
655 Indent,\r
656 NULL,\r
657 Ptr,\r
658 Length,\r
659 PARSER_PARAMS (GasParser)\r
660 );\r
ee4dc24f
RN
661}\r
662\r
a6eaba4d
DB
663/**\r
664 This function traces the GAS structure as described by the GasParser.\r
ee4dc24f
RN
665\r
666 @param [in] Format Optional format string for tracing the data.\r
667 @param [in] Ptr Pointer to the start of the buffer.\r
a6eaba4d 668**/\r
ee4dc24f
RN
669VOID\r
670EFIAPI\r
671DumpGas (\r
672 IN CONST CHAR16* Format OPTIONAL,\r
673 IN UINT8* Ptr\r
674 )\r
675{\r
0b9026a8 676 DumpGasStruct (Ptr, 2, sizeof (EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE));\r
ee4dc24f
RN
677}\r
678\r
a6eaba4d
DB
679/**\r
680 This function traces the ACPI header as described by the AcpiHeaderParser.\r
ee4dc24f
RN
681\r
682 @param [in] Ptr Pointer to the start of the buffer.\r
683\r
684 @retval Number of bytes parsed.\r
a6eaba4d 685**/\r
ee4dc24f
RN
686UINT32\r
687EFIAPI\r
688DumpAcpiHeader (\r
689 IN UINT8* Ptr\r
690 )\r
691{\r
ee4dc24f
RN
692 return ParseAcpi (\r
693 TRUE,\r
694 0,\r
695 "ACPI Table Header",\r
696 Ptr,\r
0b9026a8 697 sizeof (EFI_ACPI_DESCRIPTION_HEADER),\r
ee4dc24f
RN
698 PARSER_PARAMS (AcpiHeaderParser)\r
699 );\r
700}\r
701\r
a6eaba4d
DB
702/**\r
703 This function parses the ACPI header as described by the AcpiHeaderParser.\r
ee4dc24f
RN
704\r
705 This function optionally returns the signature, length and revision of the\r
706 ACPI table.\r
707\r
708 @param [in] Ptr Pointer to the start of the buffer.\r
709 @param [out] Signature Gets location of the ACPI table signature.\r
710 @param [out] Length Gets location of the length of the ACPI table.\r
711 @param [out] Revision Gets location of the revision of the ACPI table.\r
712\r
713 @retval Number of bytes parsed.\r
a6eaba4d 714**/\r
ee4dc24f
RN
715UINT32\r
716EFIAPI\r
717ParseAcpiHeader (\r
718 IN UINT8* Ptr,\r
719 OUT CONST UINT32** Signature,\r
720 OUT CONST UINT32** Length,\r
721 OUT CONST UINT8** Revision\r
722 )\r
723{\r
724 UINT32 BytesParsed;\r
ee4dc24f
RN
725\r
726 BytesParsed = ParseAcpi (\r
727 FALSE,\r
728 0,\r
729 NULL,\r
730 Ptr,\r
0b9026a8 731 sizeof (EFI_ACPI_DESCRIPTION_HEADER),\r
ee4dc24f
RN
732 PARSER_PARAMS (AcpiHeaderParser)\r
733 );\r
734\r
735 *Signature = AcpiHdrInfo.Signature;\r
736 *Length = AcpiHdrInfo.Length;\r
737 *Revision = AcpiHdrInfo.Revision;\r
738\r
739 return BytesParsed;\r
740}\r