2 Header file for ACPI parser
4 Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
5 Copyright (c) 2022, AMD Incorporated. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #define OUTPUT_FIELD_COLUMN_WIDTH 36
14 /// The RSDP table signature is "RSD PTR " (8 bytes)
15 /// However The signature for ACPI tables is 4 bytes.
16 /// To work around this oddity define a signature type
17 /// that allows us to process the log options.
18 #define RSDP_TABLE_INFO SIGNATURE_32('R', 'S', 'D', 'P')
21 This function increments the ACPI table error counter.
30 This function increments the ACPI table warning counter.
34 IncrementWarningCount (
39 This function verifies the ACPI table checksum.
41 This function verifies the checksum for the ACPI table and optionally
44 @param [in] Log If TRUE log the status of the checksum.
45 @param [in] Ptr Pointer to the start of the table buffer.
46 @param [in] Length The length of the buffer.
48 @retval TRUE The checksum is OK.
49 @retval FALSE The checksum failed.
60 This function performs a raw data dump of the ACPI table.
62 @param [in] Ptr Pointer to the start of the table buffer.
63 @param [in] Length The length of the buffer.
73 This function traces 1 byte of datum as specified in the format string.
75 @param [in] Format The format string for tracing the data.
76 @param [in] Ptr Pointer to the start of the buffer.
81 IN CONST CHAR16
*Format
,
86 This function traces 2 bytes of data as specified in the format string.
88 @param [in] Format The format string for tracing the data.
89 @param [in] Ptr Pointer to the start of the buffer.
94 IN CONST CHAR16
*Format
,
99 This function traces 4 bytes of data as specified in the format string.
101 @param [in] Format The format string for tracing the data.
102 @param [in] Ptr Pointer to the start of the buffer.
107 IN CONST CHAR16
*Format
,
112 This function traces 8 bytes of data as specified by the format string.
114 @param [in] Format The format string for tracing the data.
115 @param [in] Ptr Pointer to the start of the buffer.
120 IN CONST CHAR16
*Format
,
125 This function traces 3 characters which can be optionally
126 formated using the format string if specified.
128 If no format string is specified the Format must be NULL.
130 @param [in] Format Optional format string for tracing the data.
131 @param [in] Ptr Pointer to the start of the buffer.
136 IN CONST CHAR16
*Format OPTIONAL
,
141 This function traces 4 characters which can be optionally
142 formated using the format string if specified.
144 If no format string is specified the Format must be NULL.
146 @param [in] Format Optional format string for tracing the data.
147 @param [in] Ptr Pointer to the start of the buffer.
152 IN CONST CHAR16
*Format OPTIONAL
,
157 This function traces 6 characters which can be optionally
158 formated using the format string if specified.
160 If no format string is specified the Format must be NULL.
162 @param [in] Format Optional format string for tracing the data.
163 @param [in] Ptr Pointer to the start of the buffer.
168 IN CONST CHAR16
*Format OPTIONAL
,
173 This function traces 8 characters which can be optionally
174 formated using the format string if specified.
176 If no format string is specified the Format must be NULL.
178 @param [in] Format Optional format string for tracing the data.
179 @param [in] Ptr Pointer to the start of the buffer.
184 IN CONST CHAR16
*Format OPTIONAL
,
189 This function traces 12 characters which can be optionally
190 formated using the format string if specified.
192 If no format string is specified the Format must be NULL.
194 @param [in] Format Optional format string for tracing the data.
195 @param [in] Ptr Pointer to the start of the buffer.
200 IN CONST CHAR16
*Format OPTIONAL
,
205 This function indents and prints the ACPI table Field Name.
207 @param [in] Indent Number of spaces to add to the global table
208 indent. The global table indent is 0 by default;
209 however this value is updated on entry to the
210 ParseAcpi() by adding the indent value provided to
211 ParseAcpi() and restored back on exit. Therefore
212 the total indent in the output is dependent on from
213 where this function is called.
214 @param [in] FieldName Pointer to the Field Name.
220 IN CONST CHAR16
*FieldName
224 This function pointer is the template for customizing the trace output
226 @param [in] Format Format string for tracing the data as specified by
227 the 'Format' member of ACPI_PARSER.
228 @param [in] Ptr Pointer to the start of the buffer.
230 typedef VOID (EFIAPI
*FNPTR_PRINT_FORMATTER
)(CONST CHAR16
*Format
, UINT8
*Ptr
);
233 This function pointer is the template for validating an ACPI table field.
235 @param [in] Ptr Pointer to the start of the field data.
236 @param [in] Context Pointer to context specific information as specified by
237 the 'Context' member of the ACPI_PARSER.
238 e.g. this could be a pointer to the ACPI table header.
240 typedef VOID (EFIAPI
*FNPTR_FIELD_VALIDATOR
)(UINT8
*Ptr
, VOID
*Context
);
243 The ACPI_PARSER structure describes the fields of an ACPI table and
244 provides means for the parser to interpret and trace appropriately.
246 The first three members are populated based on information present in
247 in the ACPI table specifications. The remaining members describe how
248 the parser should report the field information, validate the field data
249 and/or update an external pointer to the field (ItemPtr).
251 ParseAcpi() uses the format string specified by 'Format' for tracing
252 the field data. If the field is more complex and requires additional
253 processing for formatting and representation a print formatter function
254 can be specified in 'PrintFormatter'.
256 ParseAcpiBitFields() uses AcpiParser structure to parse the bit fields.
257 It considers Length as a number of bits that need to be parsed.
258 Also, the Offset field will be considered as starting offset of the bitfield.
260 The PrintFormatter function may choose to use the format string
261 specified by 'Format' or use its own internal format string.
263 The 'Format' and 'PrintFormatter' members allow flexibility for
264 representing the field data.
266 typedef struct AcpiParser
{
267 /// String describing the ACPI table field
268 /// (Field column from ACPI table spec)
269 CONST CHAR16
*NameStr
;
271 /// The length of the field.
272 /// (Byte Length column from ACPI table spec)
273 /// Length(in bits) of the bitfield if used with ParseAcpiBitFields().
276 /// The offset of the field from the start of the table.
277 /// (Byte Offset column from ACPI table spec)
278 /// The Bit offset of the field if used with ParseAcpiBitFields().
281 /// Optional Print() style format string for tracing the data. If not
282 /// used this must be set to NULL.
283 CONST CHAR16
*Format
;
285 /// Optional pointer to a print formatter function which
286 /// is typically used to trace complex field information.
287 /// If not used this must be set to NULL.
288 /// The Format string is passed to the PrintFormatter function
289 /// but may be ignored by the implementation code.
290 FNPTR_PRINT_FORMATTER PrintFormatter
;
292 /// Optional pointer which may be set to request the parser to update
293 /// a pointer to the field data. This value is set after the FieldValidator
294 /// has been called and therefore should not be used by the FieldValidator.
295 /// If unused this must be set to NULL.
296 /// ItemPtr is not supported with ParseAcpiBitFields().
299 /// Optional pointer to a field validator function.
300 /// The function should directly report any appropriate error or warning
301 /// and invoke the appropriate counter update function.
302 /// If not used this parameter must be set to NULL.
303 FNPTR_FIELD_VALIDATOR FieldValidator
;
305 /// Optional pointer to context specific information,
306 /// which the Field Validator function can use to determine
307 /// additional information about the ACPI table and make
308 /// decisions about the field being validated.
309 /// e.g. this could be a pointer to the ACPI table header
314 A structure used to store the pointers to the members of the
315 ACPI description header structure that was parsed.
317 typedef struct AcpiDescriptionHeaderInfo
{
318 /// ACPI table signature
320 /// Length of the ACPI table
326 /// OEM Id - length is 6 bytes
335 UINT32
*CreatorRevision
;
336 } ACPI_DESCRIPTION_HEADER_INFO
;
339 This function is used to parse an ACPI table buffer.
341 The ACPI table buffer is parsed using the ACPI table parser information
342 specified by a pointer to an array of ACPI_PARSER elements. This parser
343 function iterates through each item on the ACPI_PARSER array and logs the
346 This function can optionally be used to parse ACPI tables and fetch specific
347 field values. The ItemPtr member of the ACPI_PARSER structure (where used)
348 is updated by this parser function to point to the selected field data
349 (e.g. useful for variable length nested fields).
351 @param [in] Trace Trace the ACPI fields TRUE else only parse the
353 @param [in] Indent Number of spaces to indent the output.
354 @param [in] AsciiName Optional pointer to an ASCII string that describes
355 the table being parsed.
356 @param [in] Ptr Pointer to the start of the buffer.
357 @param [in] Length Length of the buffer pointed by Ptr.
358 @param [in] Parser Pointer to an array of ACPI_PARSER structure that
359 describes the table being parsed.
360 @param [in] ParserItems Number of items in the ACPI_PARSER array.
362 @retval Number of bytes parsed.
369 IN CONST CHAR8
*AsciiName OPTIONAL
,
372 IN CONST ACPI_PARSER
*Parser
,
373 IN UINT32 ParserItems
377 This function is used to parse an ACPI table bitfield buffer.
379 The ACPI table buffer is parsed using the ACPI table parser information
380 specified by a pointer to an array of ACPI_PARSER elements. This parser
381 function iterates through each item on the ACPI_PARSER array and logs the ACPI table bitfields.
383 This function can optionally be used to parse ACPI tables and fetch specific
384 field values. The ItemPtr member of the ACPI_PARSER structure (where used)
385 is updated by this parser function to point to the selected field data
386 (e.g. useful for variable length nested fields).
388 ItemPtr member of ACPI_PARSER is not supported with this function.
390 @param [in] Trace Trace the ACPI fields TRUE else only parse the
392 @param [in] Indent Number of spaces to indent the output.
393 @param [in] AsciiName Optional pointer to an ASCII string that describes
394 the table being parsed.
395 @param [in] Ptr Pointer to the start of the buffer.
396 @param [in] Length Length of the buffer pointed by Ptr.
397 @param [in] Parser Pointer to an array of ACPI_PARSER structure that
398 describes the table being parsed.
399 @param [in] ParserItems Number of items in the ACPI_PARSER array.
401 @retval Number of bits parsed.
408 IN CONST CHAR8
*AsciiName OPTIONAL
,
411 IN CONST ACPI_PARSER
*Parser
,
412 IN UINT32 ParserItems
416 This is a helper macro to pass parameters to the Parser functions.
418 @param [in] Parser The name of the ACPI_PARSER array describing the
421 #define PARSER_PARAMS(Parser) Parser, sizeof (Parser) / sizeof (Parser[0])
424 This is a helper macro for describing the ACPI header fields.
426 @param [out] Info Pointer to retrieve the ACPI table header information.
428 #define PARSE_ACPI_HEADER(Info) \
429 { L"Signature", 4, 0, NULL, Dump4Chars, \
430 (VOID**)&(Info)->Signature , NULL, NULL }, \
431 { L"Length", 4, 4, L"%d", NULL, \
432 (VOID**)&(Info)->Length, NULL, NULL }, \
433 { L"Revision", 1, 8, L"%d", NULL, \
434 (VOID**)&(Info)->Revision, NULL, NULL }, \
435 { L"Checksum", 1, 9, L"0x%X", NULL, \
436 (VOID**)&(Info)->Checksum, NULL, NULL }, \
437 { L"Oem ID", 6, 10, NULL, Dump6Chars, \
438 (VOID**)&(Info)->OemId, NULL, NULL }, \
439 { L"Oem Table ID", 8, 16, NULL, Dump8Chars, \
440 (VOID**)&(Info)->OemTableId, NULL, NULL }, \
441 { L"Oem Revision", 4, 24, L"0x%X", NULL, \
442 (VOID**)&(Info)->OemRevision, NULL, NULL }, \
443 { L"Creator ID", 4, 28, NULL, Dump4Chars, \
444 (VOID**)&(Info)->CreatorId, NULL, NULL }, \
445 { L"Creator Revision", 4, 32, L"0x%X", NULL, \
446 (VOID**)&(Info)->CreatorRevision, NULL, NULL }
449 This function indents and traces the GAS structure as described by the GasParser.
451 @param [in] Ptr Pointer to the start of the buffer.
452 @param [in] Indent Number of spaces to indent the output.
453 @param [in] Length Length of the GAS structure buffer.
455 @retval Number of bytes parsed.
466 This function traces the GAS structure as described by the GasParser.
468 @param [in] Format Optional format string for tracing the data.
469 @param [in] Ptr Pointer to the start of the buffer.
474 IN CONST CHAR16
*Format OPTIONAL
,
479 This function traces the ACPI header as described by the AcpiHeaderParser.
481 @param [in] Ptr Pointer to the start of the buffer.
483 @retval Number of bytes parsed.
492 This function parses the ACPI header as described by the AcpiHeaderParser.
494 This function optionally returns the Signature, Length and revision of the
497 @param [in] Ptr Pointer to the start of the buffer.
498 @param [out] Signature Gets location of the ACPI table signature.
499 @param [out] Length Gets location of the length of the ACPI table.
500 @param [out] Revision Gets location of the revision of the ACPI table.
502 @retval Number of bytes parsed.
508 OUT CONST UINT32
**Signature
,
509 OUT CONST UINT32
**Length
,
510 OUT CONST UINT8
**Revision
514 This function parses the ACPI AEST table.
515 When trace is enabled this function parses the AEST table and
516 traces the ACPI table fields.
518 This function also performs validation of the ACPI table fields.
520 @param [in] Trace If TRUE, trace the ACPI fields.
521 @param [in] Ptr Pointer to the start of the buffer.
522 @param [in] AcpiTableLength Length of the ACPI table.
523 @param [in] AcpiTableRevision Revision of the ACPI table.
530 IN UINT32 AcpiTableLength
,
531 IN UINT8 AcpiTableRevision
535 This function parses the ACPI APMT table.
536 When trace is enabled this function parses the APMT table and
537 traces the ACPI table fields.
539 This function also performs validation of the ACPI table fields.
541 @param [in] Trace If TRUE, trace the ACPI fields.
542 @param [in] Ptr Pointer to the start of the buffer.
543 @param [in] AcpiTableLength Length of the ACPI table.
544 @param [in] AcpiTableRevision Revision of the ACPI table.
551 IN UINT32 AcpiTableLength
,
552 IN UINT8 AcpiTableRevision
556 This function parses the ACPI BGRT table.
557 When trace is enabled this function parses the BGRT table and
558 traces the ACPI table fields.
560 This function also performs validation of the ACPI table fields.
562 @param [in] Trace If TRUE, trace the ACPI fields.
563 @param [in] Ptr Pointer to the start of the buffer.
564 @param [in] AcpiTableLength Length of the ACPI table.
565 @param [in] AcpiTableRevision Revision of the ACPI table.
572 IN UINT32 AcpiTableLength
,
573 IN UINT8 AcpiTableRevision
577 This function parses the ACPI DBG2 table.
578 When trace is enabled this function parses the DBG2 table and
579 traces the ACPI table fields.
581 This function also performs validation of the ACPI table fields.
583 @param [in] Trace If TRUE, trace the ACPI fields.
584 @param [in] Ptr Pointer to the start of the buffer.
585 @param [in] AcpiTableLength Length of the ACPI table.
586 @param [in] AcpiTableRevision Revision of the ACPI table.
593 IN UINT32 AcpiTableLength
,
594 IN UINT8 AcpiTableRevision
598 This function parses the ACPI DSDT table.
599 When trace is enabled this function parses the DSDT table and
600 traces the ACPI table fields.
601 For the DSDT table only the ACPI header fields are parsed and
604 @param [in] Trace If TRUE, trace the ACPI fields.
605 @param [in] Ptr Pointer to the start of the buffer.
606 @param [in] AcpiTableLength Length of the ACPI table.
607 @param [in] AcpiTableRevision Revision of the ACPI table.
614 IN UINT32 AcpiTableLength
,
615 IN UINT8 AcpiTableRevision
619 This function parses the ACPI FACS table.
620 When trace is enabled this function parses the FACS table and
621 traces the ACPI table fields.
623 This function also performs validation of the ACPI table fields.
625 @param [in] Trace If TRUE, trace the ACPI fields.
626 @param [in] Ptr Pointer to the start of the buffer.
627 @param [in] AcpiTableLength Length of the ACPI table.
628 @param [in] AcpiTableRevision Revision of the ACPI table.
635 IN UINT32 AcpiTableLength
,
636 IN UINT8 AcpiTableRevision
640 This function parses the ACPI FADT table.
641 This function parses the FADT table and optionally traces the ACPI
644 This function also performs validation of the ACPI table fields.
646 @param [in] Trace If TRUE, trace the ACPI fields.
647 @param [in] Ptr Pointer to the start of the buffer.
648 @param [in] AcpiTableLength Length of the ACPI table.
649 @param [in] AcpiTableRevision Revision of the ACPI table.
656 IN UINT32 AcpiTableLength
,
657 IN UINT8 AcpiTableRevision
661 This function parses the ACPI GTDT table.
662 When trace is enabled this function parses the GTDT table and
663 traces the ACPI table fields.
665 This function also parses the following platform timer structures:
669 This function also performs validation of the ACPI table fields.
671 @param [in] Trace If TRUE, trace the ACPI fields.
672 @param [in] Ptr Pointer to the start of the buffer.
673 @param [in] AcpiTableLength Length of the ACPI table.
674 @param [in] AcpiTableRevision Revision of the ACPI table.
681 IN UINT32 AcpiTableLength
,
682 IN UINT8 AcpiTableRevision
686 This function parses the ACPI HMAT table.
687 When trace is enabled this function parses the HMAT table and
688 traces the ACPI table fields.
690 This function parses the following HMAT structures:
691 - Memory Proximity Domain Attributes Structure (Type 0)
692 - System Locality Latency and Bandwidth Info Structure (Type 1)
693 - Memory Side Cache Info structure (Type 2)
695 This function also performs validation of the ACPI table fields.
697 @param [in] Trace If TRUE, trace the ACPI fields.
698 @param [in] Ptr Pointer to the start of the buffer.
699 @param [in] AcpiTableLength Length of the ACPI table.
700 @param [in] AcpiTableRevision Revision of the ACPI table.
707 IN UINT32 AcpiTableLength
,
708 IN UINT8 AcpiTableRevision
712 This function parses the ACPI IORT table.
713 When trace is enabled this function parses the IORT table and
714 traces the ACPI fields.
716 This function also parses the following nodes:
724 This function also performs validation of the ACPI table fields.
726 @param [in] Trace If TRUE, trace the ACPI fields.
727 @param [in] Ptr Pointer to the start of the buffer.
728 @param [in] AcpiTableLength Length of the ACPI table.
729 @param [in] AcpiTableRevision Revision of the ACPI table.
736 IN UINT32 AcpiTableLength
,
737 IN UINT8 AcpiTableRevision
741 This function parses the ACPI MADT table.
742 When trace is enabled this function parses the MADT table and
743 traces the ACPI table fields.
745 This function currently parses the following Interrupt Controller
753 This function also performs validation of the ACPI table fields.
755 @param [in] Trace If TRUE, trace the ACPI fields.
756 @param [in] Ptr Pointer to the start of the buffer.
757 @param [in] AcpiTableLength Length of the ACPI table.
758 @param [in] AcpiTableRevision Revision of the ACPI table.
765 IN UINT32 AcpiTableLength
,
766 IN UINT8 AcpiTableRevision
770 This function parses the ACPI MCFG table.
771 When trace is enabled this function parses the MCFG table and
772 traces the ACPI table fields.
774 This function also performs validation of the ACPI table fields.
776 @param [in] Trace If TRUE, trace the ACPI fields.
777 @param [in] Ptr Pointer to the start of the buffer.
778 @param [in] AcpiTableLength Length of the ACPI table.
779 @param [in] AcpiTableRevision Revision of the ACPI table.
786 IN UINT32 AcpiTableLength
,
787 IN UINT8 AcpiTableRevision
791 This function parses the ACPI PCCT table including its sub-structures
793 When trace is enabled this function parses the PCCT table and
794 traces the ACPI table fields.
796 This function also performs validation of the ACPI table fields.
798 @param [in] Trace If TRUE, trace the ACPI fields.
799 @param [in] Ptr Pointer to the start of the buffer.
800 @param [in] AcpiTableLength Length of the ACPI table.
801 @param [in] AcpiTableRevision Revision of the ACPI table.
808 IN UINT32 AcpiTableLength
,
809 IN UINT8 AcpiTableRevision
813 This function parses the ACPI PPTT table.
814 When trace is enabled this function parses the PPTT table and
815 traces the ACPI table fields.
817 This function also performs validation of the ACPI table fields.
819 @param [in] Trace If TRUE, trace the ACPI fields.
820 @param [in] Ptr Pointer to the start of the buffer.
821 @param [in] AcpiTableLength Length of the ACPI table.
822 @param [in] AcpiTableRevision Revision of the ACPI table.
829 IN UINT32 AcpiTableLength
,
830 IN UINT8 AcpiTableRevision
834 This function parses the ACPI RSDP table.
836 This function invokes the parser for the XSDT table.
837 * Note - This function does not support parsing of RSDT table.
839 This function also performs a RAW dump of the ACPI table and
840 validates the checksum.
842 @param [in] Trace If TRUE, trace the ACPI fields.
843 @param [in] Ptr Pointer to the start of the buffer.
844 @param [in] AcpiTableLength Length of the ACPI table.
845 @param [in] AcpiTableRevision Revision of the ACPI table.
852 IN UINT32 AcpiTableLength
,
853 IN UINT8 AcpiTableRevision
857 This function parses the ACPI SLIT table.
858 When trace is enabled this function parses the SLIT table and
859 traces the ACPI table fields.
861 This function also validates System Localities for the following:
862 - Diagonal elements have a normalized value of 10
863 - Relative distance from System Locality at i*N+j is same as
866 @param [in] Trace If TRUE, trace the ACPI fields.
867 @param [in] Ptr Pointer to the start of the buffer.
868 @param [in] AcpiTableLength Length of the ACPI table.
869 @param [in] AcpiTableRevision Revision of the ACPI table.
876 IN UINT32 AcpiTableLength
,
877 IN UINT8 AcpiTableRevision
881 This function parses the ACPI SPCR table.
882 When trace is enabled this function parses the SPCR table and
883 traces the ACPI table fields.
885 This function also performs validations of the ACPI table fields.
887 @param [in] Trace If TRUE, trace the ACPI fields.
888 @param [in] Ptr Pointer to the start of the buffer.
889 @param [in] AcpiTableLength Length of the ACPI table.
890 @param [in] AcpiTableRevision Revision of the ACPI table.
897 IN UINT32 AcpiTableLength
,
898 IN UINT8 AcpiTableRevision
902 This function parses the ACPI SRAT table.
903 When trace is enabled this function parses the SRAT table and
904 traces the ACPI table fields.
906 This function parses the following Resource Allocation Structures:
907 - Processor Local APIC/SAPIC Affinity Structure
908 - Memory Affinity Structure
909 - Processor Local x2APIC Affinity Structure
910 - GICC Affinity Structure
912 This function also performs validation of the ACPI table fields.
914 @param [in] Trace If TRUE, trace the ACPI fields.
915 @param [in] Ptr Pointer to the start of the buffer.
916 @param [in] AcpiTableLength Length of the ACPI table.
917 @param [in] AcpiTableRevision Revision of the ACPI table.
924 IN UINT32 AcpiTableLength
,
925 IN UINT8 AcpiTableRevision
929 This function parses the ACPI SSDT table.
930 When trace is enabled this function parses the SSDT table and
931 traces the ACPI table fields.
932 For the SSDT table only the ACPI header fields are
935 @param [in] Trace If TRUE, trace the ACPI fields.
936 @param [in] Ptr Pointer to the start of the buffer.
937 @param [in] AcpiTableLength Length of the ACPI table.
938 @param [in] AcpiTableRevision Revision of the ACPI table.
945 IN UINT32 AcpiTableLength
,
946 IN UINT8 AcpiTableRevision
950 This function parses the ACPI XSDT table
951 and optionally traces the ACPI table fields.
953 This function also performs validation of the XSDT table.
955 @param [in] Trace If TRUE, trace the ACPI fields.
956 @param [in] Ptr Pointer to the start of the buffer.
957 @param [in] AcpiTableLength Length of the ACPI table.
958 @param [in] AcpiTableRevision Revision of the ACPI table.
965 IN UINT32 AcpiTableLength
,
966 IN UINT8 AcpiTableRevision
969 #endif // ACPIPARSER_H_