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 traces 12 characters which can be optionally
189 formated using the format string if specified.
191 If no format string is specified the Format must be NULL.
193 @param [in] Format Optional format string for tracing the data.
194 @param [in] Ptr Pointer to the start of the buffer.
199 IN CONST CHAR16
* Format OPTIONAL
,
204 This function indents and prints the ACPI table Field Name.
206 @param [in] Indent Number of spaces to add to the global table
207 indent. The global table indent is 0 by default;
208 however this value is updated on entry to the
209 ParseAcpi() by adding the indent value provided to
210 ParseAcpi() and restored back on exit. Therefore
211 the total indent in the output is dependent on from
212 where this function is called.
213 @param [in] FieldName Pointer to the Field Name.
219 IN CONST CHAR16
* FieldName
223 This function pointer is the template for customizing the trace output
225 @param [in] Format Format string for tracing the data as specified by
226 the 'Format' member of ACPI_PARSER.
227 @param [in] Ptr Pointer to the start of the buffer.
229 typedef VOID (EFIAPI
*FNPTR_PRINT_FORMATTER
)(CONST CHAR16
* Format
, UINT8
* Ptr
);
232 This function pointer is the template for validating an ACPI table field.
234 @param [in] Ptr Pointer to the start of the field data.
235 @param [in] Context Pointer to context specific information as specified by
236 the 'Context' member of the ACPI_PARSER.
237 e.g. this could be a pointer to the ACPI table header.
239 typedef VOID (EFIAPI
*FNPTR_FIELD_VALIDATOR
)(UINT8
* Ptr
, VOID
* Context
);
242 The ACPI_PARSER structure describes the fields of an ACPI table and
243 provides means for the parser to interpret and trace appropriately.
245 The first three members are populated based on information present in
246 in the ACPI table specifications. The remaining members describe how
247 the parser should report the field information, validate the field data
248 and/or update an external pointer to the field (ItemPtr).
250 ParseAcpi() uses the format string specified by 'Format' for tracing
251 the field data. If the field is more complex and requires additional
252 processing for formatting and representation a print formatter function
253 can be specified in 'PrintFormatter'.
254 The PrintFormatter function may choose to use the format string
255 specified by 'Format' or use its own internal format string.
257 The 'Format' and 'PrintFormatter' members allow flexibility for
258 representing the field data.
260 typedef struct AcpiParser
{
262 /// String describing the ACPI table field
263 /// (Field column from ACPI table spec)
264 CONST CHAR16
* NameStr
;
266 /// The length of the field.
267 /// (Byte Length column from ACPI table spec)
270 /// The offset of the field from the start of the table.
271 /// (Byte Offset column from ACPI table spec)
274 /// Optional Print() style format string for tracing the data. If not
275 /// used this must be set to NULL.
276 CONST CHAR16
* Format
;
278 /// Optional pointer to a print formatter function which
279 /// is typically used to trace complex field information.
280 /// If not used this must be set to NULL.
281 /// The Format string is passed to the PrintFormatter function
282 /// but may be ignored by the implementation code.
283 FNPTR_PRINT_FORMATTER PrintFormatter
;
285 /// Optional pointer which may be set to request the parser to update
286 /// a pointer to the field data. If unused this must be set to NULL.
289 /// Optional pointer to a field validator function.
290 /// The function should directly report any appropriate error or warning
291 /// and invoke the appropriate counter update function.
292 /// If not used this parameter must be set to NULL.
293 FNPTR_FIELD_VALIDATOR FieldValidator
;
295 /// Optional pointer to context specific information,
296 /// which the Field Validator function can use to determine
297 /// additional information about the ACPI table and make
298 /// decisions about the field being validated.
299 /// e.g. this could be a pointer to the ACPI table header
304 A structure used to store the pointers to the members of the
305 ACPI description header structure that was parsed.
307 typedef struct AcpiDescriptionHeaderInfo
{
308 /// ACPI table signature
310 /// Length of the ACPI table
316 /// OEM Id - length is 6 bytes
325 UINT32
* CreatorRevision
;
326 } ACPI_DESCRIPTION_HEADER_INFO
;
329 This function is used to parse an ACPI table buffer.
331 The ACPI table buffer is parsed using the ACPI table parser information
332 specified by a pointer to an array of ACPI_PARSER elements. This parser
333 function iterates through each item on the ACPI_PARSER array and logs the
336 This function can optionally be used to parse ACPI tables and fetch specific
337 field values. The ItemPtr member of the ACPI_PARSER structure (where used)
338 is updated by this parser function to point to the selected field data
339 (e.g. useful for variable length nested fields).
341 @param [in] Trace Trace the ACPI fields TRUE else only parse the
343 @param [in] Indent Number of spaces to indent the output.
344 @param [in] AsciiName Optional pointer to an ASCII string that describes
345 the table being parsed.
346 @param [in] Ptr Pointer to the start of the buffer.
347 @param [in] Length Length of the buffer pointed by Ptr.
348 @param [in] Parser Pointer to an array of ACPI_PARSER structure that
349 describes the table being parsed.
350 @param [in] ParserItems Number of items in the ACPI_PARSER array.
352 @retval Number of bytes parsed.
359 IN CONST CHAR8
* AsciiName OPTIONAL
,
362 IN CONST ACPI_PARSER
* Parser
,
363 IN UINT32 ParserItems
367 This is a helper macro to pass parameters to the Parser functions.
369 @param [in] Parser The name of the ACPI_PARSER array describing the
372 #define PARSER_PARAMS(Parser) Parser, sizeof (Parser) / sizeof (Parser[0])
375 This is a helper macro for describing the ACPI header fields.
377 @param [out] Info Pointer to retrieve the ACPI table header information.
379 #define PARSE_ACPI_HEADER(Info) \
380 { L"Signature", 4, 0, NULL, Dump4Chars, \
381 (VOID**)&(Info)->Signature , NULL, NULL }, \
382 { L"Length", 4, 4, L"%d", NULL, \
383 (VOID**)&(Info)->Length, NULL, NULL }, \
384 { L"Revision", 1, 8, L"%d", NULL, \
385 (VOID**)&(Info)->Revision, NULL, NULL }, \
386 { L"Checksum", 1, 9, L"0x%X", NULL, \
387 (VOID**)&(Info)->Checksum, NULL, NULL }, \
388 { L"Oem ID", 6, 10, NULL, Dump6Chars, \
389 (VOID**)&(Info)->OemId, NULL, NULL }, \
390 { L"Oem Table ID", 8, 16, NULL, Dump8Chars, \
391 (VOID**)&(Info)->OemTableId, NULL, NULL }, \
392 { L"Oem Revision", 4, 24, L"0x%X", NULL, \
393 (VOID**)&(Info)->OemRevision, NULL, NULL }, \
394 { L"Creator ID", 4, 28, NULL, Dump4Chars, \
395 (VOID**)&(Info)->CreatorId, NULL, NULL }, \
396 { L"Creator Revision", 4, 32, L"0x%X", NULL, \
397 (VOID**)&(Info)->CreatorRevision, NULL, NULL }
400 Length of the ACPI GAS structure.
402 NOTE: This might normally be defined as
403 sizeof (EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE).
404 However, we deliberately minimise any reference to the EDK2 ACPI
405 headers in an attempt to provide cross checking.
407 #define GAS_LENGTH 12
410 Length of the ACPI Header structure.
412 NOTE: This might normally be defined as
413 sizeof (EFI_ACPI_DESCRIPTION_HEADER).
414 However, we deliberately minimise any reference to the EDK2 ACPI
415 headers in an attempt to provide cross checking.
417 #define ACPI_DESCRIPTION_HEADER_LENGTH 36
420 This function indents and traces the GAS structure as described by the GasParser.
422 @param [in] Ptr Pointer to the start of the buffer.
423 @param [in] Indent Number of spaces to indent the output.
424 @param [in] Length Length of the GAS structure buffer.
426 @retval Number of bytes parsed.
437 This function traces the GAS structure as described by the GasParser.
439 @param [in] Format Optional format string for tracing the data.
440 @param [in] Ptr Pointer to the start of the buffer.
445 IN CONST CHAR16
* Format OPTIONAL
,
450 This function traces the ACPI header as described by the AcpiHeaderParser.
452 @param [in] Ptr Pointer to the start of the buffer.
454 @retval Number of bytes parsed.
463 This function parses the ACPI header as described by the AcpiHeaderParser.
465 This function optionally returns the Signature, Length and revision of the
468 @param [in] Ptr Pointer to the start of the buffer.
469 @param [out] Signature Gets location of the ACPI table signature.
470 @param [out] Length Gets location of the length of the ACPI table.
471 @param [out] Revision Gets location of the revision of the ACPI table.
473 @retval Number of bytes parsed.
479 OUT CONST UINT32
** Signature
,
480 OUT CONST UINT32
** Length
,
481 OUT CONST UINT8
** Revision
485 This function parses the ACPI BGRT table.
486 When trace is enabled this function parses the BGRT table and
487 traces the ACPI table fields.
489 This function also performs validation of the ACPI table fields.
491 @param [in] Trace If TRUE, trace the ACPI fields.
492 @param [in] Ptr Pointer to the start of the buffer.
493 @param [in] AcpiTableLength Length of the ACPI table.
494 @param [in] AcpiTableRevision Revision of the ACPI table.
501 IN UINT32 AcpiTableLength
,
502 IN UINT8 AcpiTableRevision
506 This function parses the ACPI DBG2 table.
507 When trace is enabled this function parses the DBG2 table and
508 traces the ACPI table fields.
510 This function also performs validation of the ACPI table fields.
512 @param [in] Trace If TRUE, trace the ACPI fields.
513 @param [in] Ptr Pointer to the start of the buffer.
514 @param [in] AcpiTableLength Length of the ACPI table.
515 @param [in] AcpiTableRevision Revision of the ACPI table.
522 IN UINT32 AcpiTableLength
,
523 IN UINT8 AcpiTableRevision
527 This function parses the ACPI DSDT table.
528 When trace is enabled this function parses the DSDT table and
529 traces the ACPI table fields.
530 For the DSDT table only the ACPI header fields are parsed and
533 @param [in] Trace If TRUE, trace the ACPI fields.
534 @param [in] Ptr Pointer to the start of the buffer.
535 @param [in] AcpiTableLength Length of the ACPI table.
536 @param [in] AcpiTableRevision Revision of the ACPI table.
543 IN UINT32 AcpiTableLength
,
544 IN UINT8 AcpiTableRevision
548 This function parses the ACPI FACS table.
549 When trace is enabled this function parses the FACS table and
550 traces the ACPI table fields.
552 This function also performs validation of the ACPI table fields.
554 @param [in] Trace If TRUE, trace the ACPI fields.
555 @param [in] Ptr Pointer to the start of the buffer.
556 @param [in] AcpiTableLength Length of the ACPI table.
557 @param [in] AcpiTableRevision Revision of the ACPI table.
564 IN UINT32 AcpiTableLength
,
565 IN UINT8 AcpiTableRevision
569 This function parses the ACPI FADT table.
570 This function parses the FADT table and optionally traces the ACPI
573 This function also performs validation of the ACPI table fields.
575 @param [in] Trace If TRUE, trace the ACPI fields.
576 @param [in] Ptr Pointer to the start of the buffer.
577 @param [in] AcpiTableLength Length of the ACPI table.
578 @param [in] AcpiTableRevision Revision of the ACPI table.
585 IN UINT32 AcpiTableLength
,
586 IN UINT8 AcpiTableRevision
590 This function parses the ACPI GTDT table.
591 When trace is enabled this function parses the GTDT table and
592 traces the ACPI table fields.
594 This function also parses the following platform timer structures:
598 This function also performs validation of the ACPI table fields.
600 @param [in] Trace If TRUE, trace the ACPI fields.
601 @param [in] Ptr Pointer to the start of the buffer.
602 @param [in] AcpiTableLength Length of the ACPI table.
603 @param [in] AcpiTableRevision Revision of the ACPI table.
610 IN UINT32 AcpiTableLength
,
611 IN UINT8 AcpiTableRevision
615 This function parses the ACPI IORT table.
616 When trace is enabled this function parses the IORT table and
617 traces the ACPI fields.
619 This function also parses the following nodes:
627 This function also performs validation of the ACPI table fields.
629 @param [in] Trace If TRUE, trace the ACPI fields.
630 @param [in] Ptr Pointer to the start of the buffer.
631 @param [in] AcpiTableLength Length of the ACPI table.
632 @param [in] AcpiTableRevision Revision of the ACPI table.
639 IN UINT32 AcpiTableLength
,
640 IN UINT8 AcpiTableRevision
644 This function parses the ACPI MADT table.
645 When trace is enabled this function parses the MADT table and
646 traces the ACPI table fields.
648 This function currently parses the following Interrupt Controller
656 This function also performs validation of the ACPI table fields.
658 @param [in] Trace If TRUE, trace the ACPI fields.
659 @param [in] Ptr Pointer to the start of the buffer.
660 @param [in] AcpiTableLength Length of the ACPI table.
661 @param [in] AcpiTableRevision Revision of the ACPI table.
668 IN UINT32 AcpiTableLength
,
669 IN UINT8 AcpiTableRevision
673 This function parses the ACPI MCFG table.
674 When trace is enabled this function parses the MCFG table and
675 traces the ACPI table fields.
677 This function also performs validation of the ACPI table fields.
679 @param [in] Trace If TRUE, trace the ACPI fields.
680 @param [in] Ptr Pointer to the start of the buffer.
681 @param [in] AcpiTableLength Length of the ACPI table.
682 @param [in] AcpiTableRevision Revision of the ACPI table.
689 IN UINT32 AcpiTableLength
,
690 IN UINT8 AcpiTableRevision
694 This function parses the ACPI PPTT table.
695 When trace is enabled this function parses the PPTT table and
696 traces the ACPI table fields.
698 This function also performs validation of the ACPI table fields.
700 @param [in] Trace If TRUE, trace the ACPI fields.
701 @param [in] Ptr Pointer to the start of the buffer.
702 @param [in] AcpiTableLength Length of the ACPI table.
703 @param [in] AcpiTableRevision Revision of the ACPI table.
710 IN UINT32 AcpiTableLength
,
711 IN UINT8 AcpiTableRevision
715 This function parses the ACPI RSDP table.
717 This function invokes the parser for the XSDT table.
718 * Note - This function does not support parsing of RSDT table.
720 This function also performs a RAW dump of the ACPI table and
721 validates the checksum.
723 @param [in] Trace If TRUE, trace the ACPI fields.
724 @param [in] Ptr Pointer to the start of the buffer.
725 @param [in] AcpiTableLength Length of the ACPI table.
726 @param [in] AcpiTableRevision Revision of the ACPI table.
733 IN UINT32 AcpiTableLength
,
734 IN UINT8 AcpiTableRevision
738 This function parses the ACPI SLIT table.
739 When trace is enabled this function parses the SLIT table and
740 traces the ACPI table fields.
742 This function also validates System Localities for the following:
743 - Diagonal elements have a normalized value of 10
744 - Relative distance from System Locality at i*N+j is same as
747 @param [in] Trace If TRUE, trace the ACPI fields.
748 @param [in] Ptr Pointer to the start of the buffer.
749 @param [in] AcpiTableLength Length of the ACPI table.
750 @param [in] AcpiTableRevision Revision of the ACPI table.
757 IN UINT32 AcpiTableLength
,
758 IN UINT8 AcpiTableRevision
762 This function parses the ACPI SPCR table.
763 When trace is enabled this function parses the SPCR table and
764 traces the ACPI table fields.
766 This function also performs validations of the ACPI table fields.
768 @param [in] Trace If TRUE, trace the ACPI fields.
769 @param [in] Ptr Pointer to the start of the buffer.
770 @param [in] AcpiTableLength Length of the ACPI table.
771 @param [in] AcpiTableRevision Revision of the ACPI table.
778 IN UINT32 AcpiTableLength
,
779 IN UINT8 AcpiTableRevision
783 This function parses the ACPI SRAT table.
784 When trace is enabled this function parses the SRAT table and
785 traces the ACPI table fields.
787 This function parses the following Resource Allocation Structures:
788 - Processor Local APIC/SAPIC Affinity Structure
789 - Memory Affinity Structure
790 - Processor Local x2APIC Affinity Structure
791 - GICC Affinity Structure
793 This function also performs validation of the ACPI table fields.
795 @param [in] Trace If TRUE, trace the ACPI fields.
796 @param [in] Ptr Pointer to the start of the buffer.
797 @param [in] AcpiTableLength Length of the ACPI table.
798 @param [in] AcpiTableRevision Revision of the ACPI table.
805 IN UINT32 AcpiTableLength
,
806 IN UINT8 AcpiTableRevision
810 This function parses the ACPI SSDT table.
811 When trace is enabled this function parses the SSDT table and
812 traces the ACPI table fields.
813 For the SSDT table only the ACPI header fields are
816 @param [in] Trace If TRUE, trace the ACPI fields.
817 @param [in] Ptr Pointer to the start of the buffer.
818 @param [in] AcpiTableLength Length of the ACPI table.
819 @param [in] AcpiTableRevision Revision of the ACPI table.
826 IN UINT32 AcpiTableLength
,
827 IN UINT8 AcpiTableRevision
831 This function parses the ACPI XSDT table
832 and optionally traces the ACPI table fields.
834 This function also performs validation of the XSDT table.
836 @param [in] Trace If TRUE, trace the ACPI fields.
837 @param [in] Ptr Pointer to the start of the buffer.
838 @param [in] AcpiTableLength Length of the ACPI table.
839 @param [in] AcpiTableRevision Revision of the ACPI table.
846 IN UINT32 AcpiTableLength
,
847 IN UINT8 AcpiTableRevision
850 #endif // ACPIPARSER_H_