]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
CryptoPkg: Fix coding style
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / AcpiParser.c
CommitLineData
a6eaba4d 1/** @file\r
ee4dc24f
RN
2 ACPI parser\r
3\r
5a119220 4 Copyright (c) 2016 - 2019, 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
ee4dc24f 297 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
a6eaba4d
DB
408/**\r
409 This function indents and prints the ACPI table Field Name.\r
ee4dc24f
RN
410\r
411 @param [in] Indent Number of spaces to add to the global table indent.\r
412 The global table indent is 0 by default; however\r
413 this value is updated on entry to the ParseAcpi()\r
414 by adding the indent value provided to ParseAcpi()\r
415 and restored back on exit.\r
416 Therefore the total indent in the output is\r
417 dependent on from where this function is called.\r
418 @param [in] FieldName Pointer to the Field Name.\r
a6eaba4d 419**/\r
ee4dc24f
RN
420VOID\r
421EFIAPI\r
422PrintFieldName (\r
423 IN UINT32 Indent,\r
424 IN CONST CHAR16* FieldName\r
425)\r
426{\r
427 Print (\r
428 L"%*a%-*s : ",\r
429 gIndent + Indent,\r
430 "",\r
431 (OUTPUT_FIELD_COLUMN_WIDTH - gIndent - Indent),\r
432 FieldName\r
433 );\r
434}\r
435\r
a6eaba4d
DB
436/**\r
437 This function is used to parse an ACPI table buffer.\r
ee4dc24f
RN
438\r
439 The ACPI table buffer is parsed using the ACPI table parser information\r
440 specified by a pointer to an array of ACPI_PARSER elements. This parser\r
441 function iterates through each item on the ACPI_PARSER array and logs the\r
442 ACPI table fields.\r
443\r
444 This function can optionally be used to parse ACPI tables and fetch specific\r
445 field values. The ItemPtr member of the ACPI_PARSER structure (where used)\r
446 is updated by this parser function to point to the selected field data\r
447 (e.g. useful for variable length nested fields).\r
448\r
449 @param [in] Trace Trace the ACPI fields TRUE else only parse the\r
450 table.\r
451 @param [in] Indent Number of spaces to indent the output.\r
452 @param [in] AsciiName Optional pointer to an ASCII string that describes\r
453 the table being parsed.\r
454 @param [in] Ptr Pointer to the start of the buffer.\r
455 @param [in] Length Length of the buffer pointed by Ptr.\r
456 @param [in] Parser Pointer to an array of ACPI_PARSER structure that\r
457 describes the table being parsed.\r
458 @param [in] ParserItems Number of items in the ACPI_PARSER array.\r
459\r
460 @retval Number of bytes parsed.\r
a6eaba4d 461**/\r
ee4dc24f
RN
462UINT32\r
463EFIAPI\r
464ParseAcpi (\r
465 IN BOOLEAN Trace,\r
466 IN UINT32 Indent,\r
467 IN CONST CHAR8* AsciiName OPTIONAL,\r
468 IN UINT8* Ptr,\r
469 IN UINT32 Length,\r
470 IN CONST ACPI_PARSER* Parser,\r
471 IN UINT32 ParserItems\r
472)\r
473{\r
474 UINT32 Index;\r
f75c7478
DB
475 UINT32 Offset;\r
476 BOOLEAN HighLight;\r
ed874680 477 UINTN OriginalAttribute;\r
f75c7478 478\r
0154e02d
SZ
479 //\r
480 // set local variables to suppress incorrect compiler/analyzer warnings\r
481 //\r
482 OriginalAttribute = 0;\r
f75c7478 483 Offset = 0;\r
ee4dc24f
RN
484\r
485 // Increment the Indent\r
486 gIndent += Indent;\r
487\r
488 if (Trace && (AsciiName != NULL)){\r
f75c7478 489 HighLight = GetColourHighlighting ();\r
ee4dc24f
RN
490\r
491 if (HighLight) {\r
492 OriginalAttribute = gST->ConOut->Mode->Attribute;\r
493 gST->ConOut->SetAttribute (\r
494 gST->ConOut,\r
495 EFI_TEXT_ATTR(EFI_YELLOW,\r
496 ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4))\r
497 );\r
498 }\r
499 Print (\r
500 L"%*a%-*a :\n",\r
501 gIndent,\r
502 "",\r
503 (OUTPUT_FIELD_COLUMN_WIDTH - gIndent),\r
504 AsciiName\r
505 );\r
506 if (HighLight) {\r
507 gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);\r
508 }\r
509 }\r
510\r
511 for (Index = 0; Index < ParserItems; Index++) {\r
512 if ((Offset + Parser[Index].Length) > Length) {\r
513 // We don't parse past the end of the max length specified\r
514 break;\r
515 }\r
516\r
f73843d5
KK
517 if (GetConsistencyChecking () &&\r
518 (Offset != Parser[Index].Offset)) {\r
ee4dc24f
RN
519 IncrementErrorCount ();\r
520 Print (\r
521 L"\nERROR: %a: Offset Mismatch for %s\n"\r
e6f958d1 522 L"CurrentOffset = %d FieldOffset = %d\n",\r
ee4dc24f
RN
523 AsciiName,\r
524 Parser[Index].NameStr,\r
525 Offset,\r
526 Parser[Index].Offset\r
527 );\r
528 }\r
529\r
530 if (Trace) {\r
531 // if there is a Formatter function let the function handle\r
532 // the printing else if a Format is specified in the table use\r
533 // the Format for printing\r
534 PrintFieldName (2, Parser[Index].NameStr);\r
535 if (Parser[Index].PrintFormatter != NULL) {\r
536 Parser[Index].PrintFormatter (Parser[Index].Format, Ptr);\r
537 } else if (Parser[Index].Format != NULL) {\r
538 switch (Parser[Index].Length) {\r
539 case 1:\r
540 DumpUint8 (Parser[Index].Format, Ptr);\r
541 break;\r
542 case 2:\r
543 DumpUint16 (Parser[Index].Format, Ptr);\r
544 break;\r
545 case 4:\r
546 DumpUint32 (Parser[Index].Format, Ptr);\r
547 break;\r
548 case 8:\r
549 DumpUint64 (Parser[Index].Format, Ptr);\r
550 break;\r
551 default:\r
552 Print (\r
553 L"\nERROR: %a: CANNOT PARSE THIS FIELD, Field Length = %d\n",\r
554 AsciiName,\r
555 Parser[Index].Length\r
556 );\r
557 } // switch\r
558\r
559 // Validating only makes sense if we are tracing\r
560 // the parsed table entries, to report by table name.\r
f73843d5
KK
561 if (GetConsistencyChecking () &&\r
562 (Parser[Index].FieldValidator != NULL)) {\r
ee4dc24f
RN
563 Parser[Index].FieldValidator (Ptr, Parser[Index].Context);\r
564 }\r
565 }\r
566 Print (L"\n");\r
567 } // if (Trace)\r
568\r
569 if (Parser[Index].ItemPtr != NULL) {\r
570 *Parser[Index].ItemPtr = (VOID*)Ptr;\r
571 }\r
572\r
573 Ptr += Parser[Index].Length;\r
574 Offset += Parser[Index].Length;\r
575 } // for\r
576\r
577 // Decrement the Indent\r
578 gIndent -= Indent;\r
579 return Offset;\r
580}\r
581\r
a6eaba4d
DB
582/**\r
583 An array describing the ACPI Generic Address Structure.\r
ee4dc24f
RN
584 The GasParser array is used by the ParseAcpi function to parse and/or trace\r
585 the GAS structure.\r
a6eaba4d 586**/\r
ee4dc24f
RN
587STATIC CONST ACPI_PARSER GasParser[] = {\r
588 {L"Address Space ID", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},\r
589 {L"Register Bit Width", 1, 1, L"0x%x", NULL, NULL, NULL, NULL},\r
590 {L"Register Bit Offset", 1, 2, L"0x%x", NULL, NULL, NULL, NULL},\r
591 {L"Address Size", 1, 3, L"0x%x", NULL, NULL, NULL, NULL},\r
592 {L"Address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL}\r
593};\r
594\r
a6eaba4d
DB
595/**\r
596 This function indents and traces the GAS structure as described by the GasParser.\r
ee4dc24f
RN
597\r
598 @param [in] Ptr Pointer to the start of the buffer.\r
599 @param [in] Indent Number of spaces to indent the output.\r
58cc0ffe
KK
600 @param [in] Length Length of the GAS structure buffer.\r
601\r
602 @retval Number of bytes parsed.\r
a6eaba4d 603**/\r
58cc0ffe 604UINT32\r
ee4dc24f
RN
605EFIAPI\r
606DumpGasStruct (\r
607 IN UINT8* Ptr,\r
58cc0ffe
KK
608 IN UINT32 Indent,\r
609 IN UINT32 Length\r
ee4dc24f
RN
610 )\r
611{\r
612 Print (L"\n");\r
58cc0ffe
KK
613 return ParseAcpi (\r
614 TRUE,\r
615 Indent,\r
616 NULL,\r
617 Ptr,\r
618 Length,\r
619 PARSER_PARAMS (GasParser)\r
620 );\r
ee4dc24f
RN
621}\r
622\r
a6eaba4d
DB
623/**\r
624 This function traces the GAS structure as described by the GasParser.\r
ee4dc24f
RN
625\r
626 @param [in] Format Optional format string for tracing the data.\r
627 @param [in] Ptr Pointer to the start of the buffer.\r
a6eaba4d 628**/\r
ee4dc24f
RN
629VOID\r
630EFIAPI\r
631DumpGas (\r
632 IN CONST CHAR16* Format OPTIONAL,\r
633 IN UINT8* Ptr\r
634 )\r
635{\r
58cc0ffe 636 DumpGasStruct (Ptr, 2, GAS_LENGTH);\r
ee4dc24f
RN
637}\r
638\r
a6eaba4d
DB
639/**\r
640 This function traces the ACPI header as described by the AcpiHeaderParser.\r
ee4dc24f
RN
641\r
642 @param [in] Ptr Pointer to the start of the buffer.\r
643\r
644 @retval Number of bytes parsed.\r
a6eaba4d 645**/\r
ee4dc24f
RN
646UINT32\r
647EFIAPI\r
648DumpAcpiHeader (\r
649 IN UINT8* Ptr\r
650 )\r
651{\r
ee4dc24f
RN
652 return ParseAcpi (\r
653 TRUE,\r
654 0,\r
655 "ACPI Table Header",\r
656 Ptr,\r
657 ACPI_DESCRIPTION_HEADER_LENGTH,\r
658 PARSER_PARAMS (AcpiHeaderParser)\r
659 );\r
660}\r
661\r
a6eaba4d
DB
662/**\r
663 This function parses the ACPI header as described by the AcpiHeaderParser.\r
ee4dc24f
RN
664\r
665 This function optionally returns the signature, length and revision of the\r
666 ACPI table.\r
667\r
668 @param [in] Ptr Pointer to the start of the buffer.\r
669 @param [out] Signature Gets location of the ACPI table signature.\r
670 @param [out] Length Gets location of the length of the ACPI table.\r
671 @param [out] Revision Gets location of the revision of the ACPI table.\r
672\r
673 @retval Number of bytes parsed.\r
a6eaba4d 674**/\r
ee4dc24f
RN
675UINT32\r
676EFIAPI\r
677ParseAcpiHeader (\r
678 IN UINT8* Ptr,\r
679 OUT CONST UINT32** Signature,\r
680 OUT CONST UINT32** Length,\r
681 OUT CONST UINT8** Revision\r
682 )\r
683{\r
684 UINT32 BytesParsed;\r
ee4dc24f
RN
685\r
686 BytesParsed = ParseAcpi (\r
687 FALSE,\r
688 0,\r
689 NULL,\r
690 Ptr,\r
691 ACPI_DESCRIPTION_HEADER_LENGTH,\r
692 PARSER_PARAMS (AcpiHeaderParser)\r
693 );\r
694\r
695 *Signature = AcpiHdrInfo.Signature;\r
696 *Length = AcpiHdrInfo.Length;\r
697 *Revision = AcpiHdrInfo.Revision;\r
698\r
699 return BytesParsed;\r
700}\r