2 Header file for ACPI parser
4 Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #define OUTPUT_FIELD_COLUMN_WIDTH 36
13 /// The RSDP table signature is "RSD PTR " (8 bytes)
14 /// However The signature for ACPI tables is 4 bytes.
15 /// To work around this oddity define a signature type
16 /// that allows us to process the log options.
17 #define RSDP_TABLE_INFO SIGNATURE_32('R', 'S', 'D', 'P')
20 This function increments the ACPI table error counter.
29 This function increments the ACPI table warning counter.
33 IncrementWarningCount (
38 This function verifies the ACPI table checksum.
40 This function verifies the checksum for the ACPI table and optionally
43 @param [in] Log If TRUE log the status of the checksum.
44 @param [in] Ptr Pointer to the start of the table buffer.
45 @param [in] Length The length of the buffer.
47 @retval TRUE The checksum is OK.
48 @retval FALSE The checksum failed.
59 This function performs a raw data dump of the ACPI table.
61 @param [in] Ptr Pointer to the start of the table buffer.
62 @param [in] Length The length of the buffer.
72 This function traces 1 byte of datum as specified in the format string.
74 @param [in] Format The format string for tracing the data.
75 @param [in] Ptr Pointer to the start of the buffer.
80 IN CONST CHAR16
* Format
,
85 This function traces 2 bytes of data as specified in the format string.
87 @param [in] Format The format string for tracing the data.
88 @param [in] Ptr Pointer to the start of the buffer.
93 IN CONST CHAR16
* Format
,
98 This function traces 4 bytes of data as specified in the format string.
100 @param [in] Format The format string for tracing the data.
101 @param [in] Ptr Pointer to the start of the buffer.
106 IN CONST CHAR16
* Format
,
111 This function traces 8 bytes of data as specified by the format string.
113 @param [in] Format The format string for tracing the data.
114 @param [in] Ptr Pointer to the start of the buffer.
119 IN CONST CHAR16
* Format
,
124 This function traces 3 characters which can be optionally
125 formated using the format string if specified.
127 If no format string is specified the Format must be NULL.
129 @param [in] Format Optional format string for tracing the data.
130 @param [in] Ptr Pointer to the start of the buffer.
135 IN CONST CHAR16
* Format OPTIONAL
,
140 This function traces 4 characters which can be optionally
141 formated using the format string if specified.
143 If no format string is specified the Format must be NULL.
145 @param [in] Format Optional format string for tracing the data.
146 @param [in] Ptr Pointer to the start of the buffer.
151 IN CONST CHAR16
* Format OPTIONAL
,
156 This function traces 6 characters which can be optionally
157 formated using the format string if specified.
159 If no format string is specified the Format must be NULL.
161 @param [in] Format Optional format string for tracing the data.
162 @param [in] Ptr Pointer to the start of the buffer.
167 IN CONST CHAR16
* Format OPTIONAL
,
172 This function traces 8 characters which can be optionally
173 formated using the format string if specified.
175 If no format string is specified the Format must be NULL.
177 @param [in] Format Optional format string for tracing the data.
178 @param [in] Ptr Pointer to the start of the buffer.
183 IN CONST CHAR16
* Format OPTIONAL
,
188 This function indents and prints the ACPI table Field Name.
190 @param [in] Indent Number of spaces to add to the global table
191 indent. The global table indent is 0 by default;
192 however this value is updated on entry to the
193 ParseAcpi() by adding the indent value provided to
194 ParseAcpi() and restored back on exit. Therefore
195 the total indent in the output is dependent on from
196 where this function is called.
197 @param [in] FieldName Pointer to the Field Name.
203 IN CONST CHAR16
* FieldName
207 This function pointer is the template for customizing the trace output
209 @param [in] Format Format string for tracing the data as specified by
210 the 'Format' member of ACPI_PARSER.
211 @param [in] Ptr Pointer to the start of the buffer.
213 typedef VOID (EFIAPI
*FNPTR_PRINT_FORMATTER
)(CONST CHAR16
* Format
, UINT8
* Ptr
);
216 This function pointer is the template for validating an ACPI table field.
218 @param [in] Ptr Pointer to the start of the field data.
219 @param [in] Context Pointer to context specific information as specified by
220 the 'Context' member of the ACPI_PARSER.
221 e.g. this could be a pointer to the ACPI table header.
223 typedef VOID (EFIAPI
*FNPTR_FIELD_VALIDATOR
)(UINT8
* Ptr
, VOID
* Context
);
226 The ACPI_PARSER structure describes the fields of an ACPI table and
227 provides means for the parser to interpret and trace appropriately.
229 The first three members are populated based on information present in
230 in the ACPI table specifications. The remaining members describe how
231 the parser should report the field information, validate the field data
232 and/or update an external pointer to the field (ItemPtr).
234 ParseAcpi() uses the format string specified by 'Format' for tracing
235 the field data. If the field is more complex and requires additional
236 processing for formatting and representation a print formatter function
237 can be specified in 'PrintFormatter'.
238 The PrintFormatter function may choose to use the format string
239 specified by 'Format' or use its own internal format string.
241 The 'Format' and 'PrintFormatter' members allow flexibility for
242 representing the field data.
244 typedef struct AcpiParser
{
246 /// String describing the ACPI table field
247 /// (Field column from ACPI table spec)
248 CONST CHAR16
* NameStr
;
250 /// The length of the field.
251 /// (Byte Length column from ACPI table spec)
254 /// The offset of the field from the start of the table.
255 /// (Byte Offset column from ACPI table spec)
258 /// Optional Print() style format string for tracing the data. If not
259 /// used this must be set to NULL.
260 CONST CHAR16
* Format
;
262 /// Optional pointer to a print formatter function which
263 /// is typically used to trace complex field information.
264 /// If not used this must be set to NULL.
265 /// The Format string is passed to the PrintFormatter function
266 /// but may be ignored by the implementation code.
267 FNPTR_PRINT_FORMATTER PrintFormatter
;
269 /// Optional pointer which may be set to request the parser to update
270 /// a pointer to the field data. If unused this must be set to NULL.
273 /// Optional pointer to a field validator function.
274 /// The function should directly report any appropriate error or warning
275 /// and invoke the appropriate counter update function.
276 /// If not used this parameter must be set to NULL.
277 FNPTR_FIELD_VALIDATOR FieldValidator
;
279 /// Optional pointer to context specific information,
280 /// which the Field Validator function can use to determine
281 /// additional information about the ACPI table and make
282 /// decisions about the field being validated.
283 /// e.g. this could be a pointer to the ACPI table header
288 A structure used to store the pointers to the members of the
289 ACPI description header structure that was parsed.
291 typedef struct AcpiDescriptionHeaderInfo
{
292 /// ACPI table signature
294 /// Length of the ACPI table
300 /// OEM Id - length is 6 bytes
309 UINT32
* CreatorRevision
;
310 } ACPI_DESCRIPTION_HEADER_INFO
;
313 This function is used to parse an ACPI table buffer.
315 The ACPI table buffer is parsed using the ACPI table parser information
316 specified by a pointer to an array of ACPI_PARSER elements. This parser
317 function iterates through each item on the ACPI_PARSER array and logs the
320 This function can optionally be used to parse ACPI tables and fetch specific
321 field values. The ItemPtr member of the ACPI_PARSER structure (where used)
322 is updated by this parser function to point to the selected field data
323 (e.g. useful for variable length nested fields).
325 @param [in] Trace Trace the ACPI fields TRUE else only parse the
327 @param [in] Indent Number of spaces to indent the output.
328 @param [in] AsciiName Optional pointer to an ASCII string that describes
329 the table being parsed.
330 @param [in] Ptr Pointer to the start of the buffer.
331 @param [in] Length Length of the buffer pointed by Ptr.
332 @param [in] Parser Pointer to an array of ACPI_PARSER structure that
333 describes the table being parsed.
334 @param [in] ParserItems Number of items in the ACPI_PARSER array.
336 @retval Number of bytes parsed.
343 IN CONST CHAR8
* AsciiName OPTIONAL
,
346 IN CONST ACPI_PARSER
* Parser
,
347 IN UINT32 ParserItems
351 This is a helper macro to pass parameters to the Parser functions.
353 @param [in] Parser The name of the ACPI_PARSER array describing the
356 #define PARSER_PARAMS(Parser) Parser, sizeof (Parser) / sizeof (Parser[0])
359 This is a helper macro for describing the ACPI header fields.
361 @param [out] Info Pointer to retrieve the ACPI table header information.
363 #define PARSE_ACPI_HEADER(Info) \
364 { L"Signature", 4, 0, NULL, Dump4Chars, \
365 (VOID**)&(Info)->Signature , NULL, NULL }, \
366 { L"Length", 4, 4, L"%d", NULL, \
367 (VOID**)&(Info)->Length, NULL, NULL }, \
368 { L"Revision", 1, 8, L"%d", NULL, \
369 (VOID**)&(Info)->Revision, NULL, NULL }, \
370 { L"Checksum", 1, 9, L"0x%X", NULL, \
371 (VOID**)&(Info)->Checksum, NULL, NULL }, \
372 { L"Oem ID", 6, 10, NULL, Dump6Chars, \
373 (VOID**)&(Info)->OemId, NULL, NULL }, \
374 { L"Oem Table ID", 8, 16, NULL, Dump8Chars, \
375 (VOID**)&(Info)->OemTableId, NULL, NULL }, \
376 { L"Oem Revision", 4, 24, L"0x%X", NULL, \
377 (VOID**)&(Info)->OemRevision, NULL, NULL }, \
378 { L"Creator ID", 4, 28, NULL, Dump4Chars, \
379 (VOID**)&(Info)->CreatorId, NULL, NULL }, \
380 { L"Creator Revision", 4, 32, L"0x%X", NULL, \
381 (VOID**)&(Info)->CreatorRevision, NULL, NULL }
384 Length of the ACPI GAS structure.
386 NOTE: This might normally be defined as
387 sizeof (EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE).
388 However, we deliberately minimise any reference to the EDK2 ACPI
389 headers in an attempt to provide cross checking.
391 #define GAS_LENGTH 12
394 Length of the ACPI Header structure.
396 NOTE: This might normally be defined as
397 sizeof (EFI_ACPI_DESCRIPTION_HEADER).
398 However, we deliberately minimise any reference to the EDK2 ACPI
399 headers in an attempt to provide cross checking.
401 #define ACPI_DESCRIPTION_HEADER_LENGTH 36
404 This function indents and traces the GAS structure as described by the GasParser.
406 @param [in] Ptr Pointer to the start of the buffer.
407 @param [in] Indent Number of spaces to indent the output.
408 @param [in] Length Length of the GAS structure buffer.
410 @retval Number of bytes parsed.
421 This function traces the GAS structure as described by the GasParser.
423 @param [in] Format Optional format string for tracing the data.
424 @param [in] Ptr Pointer to the start of the buffer.
429 IN CONST CHAR16
* Format OPTIONAL
,
434 This function traces the ACPI header as described by the AcpiHeaderParser.
436 @param [in] Ptr Pointer to the start of the buffer.
438 @retval Number of bytes parsed.
447 This function parses the ACPI header as described by the AcpiHeaderParser.
449 This function optionally returns the Signature, Length and revision of the
452 @param [in] Ptr Pointer to the start of the buffer.
453 @param [out] Signature Gets location of the ACPI table signature.
454 @param [out] Length Gets location of the length of the ACPI table.
455 @param [out] Revision Gets location of the revision of the ACPI table.
457 @retval Number of bytes parsed.
463 OUT CONST UINT32
** Signature
,
464 OUT CONST UINT32
** Length
,
465 OUT CONST UINT8
** Revision
469 This function parses the ACPI BGRT table.
470 When trace is enabled this function parses the BGRT table and
471 traces the ACPI table fields.
473 This function also performs validation of the ACPI table fields.
475 @param [in] Trace If TRUE, trace the ACPI fields.
476 @param [in] Ptr Pointer to the start of the buffer.
477 @param [in] AcpiTableLength Length of the ACPI table.
478 @param [in] AcpiTableRevision Revision of the ACPI table.
485 IN UINT32 AcpiTableLength
,
486 IN UINT8 AcpiTableRevision
490 This function parses the ACPI DBG2 table.
491 When trace is enabled this function parses the DBG2 table and
492 traces the ACPI table fields.
494 This function also performs validation of the ACPI table fields.
496 @param [in] Trace If TRUE, trace the ACPI fields.
497 @param [in] Ptr Pointer to the start of the buffer.
498 @param [in] AcpiTableLength Length of the ACPI table.
499 @param [in] AcpiTableRevision Revision of the ACPI table.
506 IN UINT32 AcpiTableLength
,
507 IN UINT8 AcpiTableRevision
511 This function parses the ACPI DSDT table.
512 When trace is enabled this function parses the DSDT table and
513 traces the ACPI table fields.
514 For the DSDT table only the ACPI header fields are parsed and
517 @param [in] Trace If TRUE, trace the ACPI fields.
518 @param [in] Ptr Pointer to the start of the buffer.
519 @param [in] AcpiTableLength Length of the ACPI table.
520 @param [in] AcpiTableRevision Revision of the ACPI table.
527 IN UINT32 AcpiTableLength
,
528 IN UINT8 AcpiTableRevision
532 This function parses the ACPI FACS table.
533 When trace is enabled this function parses the FACS table and
534 traces the ACPI table fields.
536 This function also performs validation of the ACPI table fields.
538 @param [in] Trace If TRUE, trace the ACPI fields.
539 @param [in] Ptr Pointer to the start of the buffer.
540 @param [in] AcpiTableLength Length of the ACPI table.
541 @param [in] AcpiTableRevision Revision of the ACPI table.
548 IN UINT32 AcpiTableLength
,
549 IN UINT8 AcpiTableRevision
553 This function parses the ACPI FADT table.
554 This function parses the FADT table and optionally traces the ACPI
557 This function also performs validation of the ACPI table fields.
559 @param [in] Trace If TRUE, trace the ACPI fields.
560 @param [in] Ptr Pointer to the start of the buffer.
561 @param [in] AcpiTableLength Length of the ACPI table.
562 @param [in] AcpiTableRevision Revision of the ACPI table.
569 IN UINT32 AcpiTableLength
,
570 IN UINT8 AcpiTableRevision
574 This function parses the ACPI GTDT table.
575 When trace is enabled this function parses the GTDT table and
576 traces the ACPI table fields.
578 This function also parses the following platform timer structures:
582 This function also performs validation of the ACPI table fields.
584 @param [in] Trace If TRUE, trace the ACPI fields.
585 @param [in] Ptr Pointer to the start of the buffer.
586 @param [in] AcpiTableLength Length of the ACPI table.
587 @param [in] AcpiTableRevision Revision of the ACPI table.
594 IN UINT32 AcpiTableLength
,
595 IN UINT8 AcpiTableRevision
599 This function parses the ACPI IORT table.
600 When trace is enabled this function parses the IORT table and
601 traces the ACPI fields.
603 This function also parses the following nodes:
611 This function also performs validation of the ACPI table fields.
613 @param [in] Trace If TRUE, trace the ACPI fields.
614 @param [in] Ptr Pointer to the start of the buffer.
615 @param [in] AcpiTableLength Length of the ACPI table.
616 @param [in] AcpiTableRevision Revision of the ACPI table.
623 IN UINT32 AcpiTableLength
,
624 IN UINT8 AcpiTableRevision
628 This function parses the ACPI MADT table.
629 When trace is enabled this function parses the MADT table and
630 traces the ACPI table fields.
632 This function currently parses the following Interrupt Controller
640 This function also performs validation of the ACPI table fields.
642 @param [in] Trace If TRUE, trace the ACPI fields.
643 @param [in] Ptr Pointer to the start of the buffer.
644 @param [in] AcpiTableLength Length of the ACPI table.
645 @param [in] AcpiTableRevision Revision of the ACPI table.
652 IN UINT32 AcpiTableLength
,
653 IN UINT8 AcpiTableRevision
657 This function parses the ACPI MCFG table.
658 When trace is enabled this function parses the MCFG table and
659 traces the ACPI table fields.
661 This function also performs validation of the ACPI table fields.
663 @param [in] Trace If TRUE, trace the ACPI fields.
664 @param [in] Ptr Pointer to the start of the buffer.
665 @param [in] AcpiTableLength Length of the ACPI table.
666 @param [in] AcpiTableRevision Revision of the ACPI table.
673 IN UINT32 AcpiTableLength
,
674 IN UINT8 AcpiTableRevision
678 This function parses the ACPI PPTT table.
679 When trace is enabled this function parses the PPTT table and
680 traces the ACPI table fields.
682 This function also performs validation of the ACPI table fields.
684 @param [in] Trace If TRUE, trace the ACPI fields.
685 @param [in] Ptr Pointer to the start of the buffer.
686 @param [in] AcpiTableLength Length of the ACPI table.
687 @param [in] AcpiTableRevision Revision of the ACPI table.
694 IN UINT32 AcpiTableLength
,
695 IN UINT8 AcpiTableRevision
699 This function parses the ACPI RSDP table.
701 This function invokes the parser for the XSDT table.
702 * Note - This function does not support parsing of RSDT table.
704 This function also performs a RAW dump of the ACPI table and
705 validates the checksum.
707 @param [in] Trace If TRUE, trace the ACPI fields.
708 @param [in] Ptr Pointer to the start of the buffer.
709 @param [in] AcpiTableLength Length of the ACPI table.
710 @param [in] AcpiTableRevision Revision of the ACPI table.
717 IN UINT32 AcpiTableLength
,
718 IN UINT8 AcpiTableRevision
722 This function parses the ACPI SLIT table.
723 When trace is enabled this function parses the SLIT table and
724 traces the ACPI table fields.
726 This function also validates System Localities for the following:
727 - Diagonal elements have a normalized value of 10
728 - Relative distance from System Locality at i*N+j is same as
731 @param [in] Trace If TRUE, trace the ACPI fields.
732 @param [in] Ptr Pointer to the start of the buffer.
733 @param [in] AcpiTableLength Length of the ACPI table.
734 @param [in] AcpiTableRevision Revision of the ACPI table.
741 IN UINT32 AcpiTableLength
,
742 IN UINT8 AcpiTableRevision
746 This function parses the ACPI SPCR table.
747 When trace is enabled this function parses the SPCR table and
748 traces the ACPI table fields.
750 This function also performs validations of the ACPI table fields.
752 @param [in] Trace If TRUE, trace the ACPI fields.
753 @param [in] Ptr Pointer to the start of the buffer.
754 @param [in] AcpiTableLength Length of the ACPI table.
755 @param [in] AcpiTableRevision Revision of the ACPI table.
762 IN UINT32 AcpiTableLength
,
763 IN UINT8 AcpiTableRevision
767 This function parses the ACPI SRAT table.
768 When trace is enabled this function parses the SRAT table and
769 traces the ACPI table fields.
771 This function parses the following Resource Allocation Structures:
772 - Processor Local APIC/SAPIC Affinity Structure
773 - Memory Affinity Structure
774 - Processor Local x2APIC Affinity Structure
775 - GICC Affinity Structure
777 This function also performs validation of the ACPI table fields.
779 @param [in] Trace If TRUE, trace the ACPI fields.
780 @param [in] Ptr Pointer to the start of the buffer.
781 @param [in] AcpiTableLength Length of the ACPI table.
782 @param [in] AcpiTableRevision Revision of the ACPI table.
789 IN UINT32 AcpiTableLength
,
790 IN UINT8 AcpiTableRevision
794 This function parses the ACPI SSDT table.
795 When trace is enabled this function parses the SSDT table and
796 traces the ACPI table fields.
797 For the SSDT table only the ACPI header fields are
800 @param [in] Trace If TRUE, trace the ACPI fields.
801 @param [in] Ptr Pointer to the start of the buffer.
802 @param [in] AcpiTableLength Length of the ACPI table.
803 @param [in] AcpiTableRevision Revision of the ACPI table.
810 IN UINT32 AcpiTableLength
,
811 IN UINT8 AcpiTableRevision
815 This function parses the ACPI XSDT table
816 and optionally traces the ACPI table fields.
818 This function also performs validation of the XSDT table.
820 @param [in] Trace If TRUE, trace the ACPI fields.
821 @param [in] Ptr Pointer to the start of the buffer.
822 @param [in] AcpiTableLength Length of the ACPI table.
823 @param [in] AcpiTableRevision Revision of the ACPI table.
830 IN UINT32 AcpiTableLength
,
831 IN UINT8 AcpiTableRevision
834 #endif // ACPIPARSER_H_