2 Header file for ACPI parser
4 Copyright (c) 2016 - 2020, 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
{
261 /// String describing the ACPI table field
262 /// (Field column from ACPI table spec)
263 CONST CHAR16
*NameStr
;
265 /// The length of the field.
266 /// (Byte Length column from ACPI table spec)
269 /// The offset of the field from the start of the table.
270 /// (Byte Offset column from ACPI table spec)
273 /// Optional Print() style format string for tracing the data. If not
274 /// used this must be set to NULL.
275 CONST CHAR16
*Format
;
277 /// Optional pointer to a print formatter function which
278 /// is typically used to trace complex field information.
279 /// If not used this must be set to NULL.
280 /// The Format string is passed to the PrintFormatter function
281 /// but may be ignored by the implementation code.
282 FNPTR_PRINT_FORMATTER PrintFormatter
;
284 /// Optional pointer which may be set to request the parser to update
285 /// a pointer to the field data. This value is set after the FieldValidator
286 /// has been called and therefore should not be used by the FieldValidator.
287 /// If unused this must be set to NULL.
290 /// Optional pointer to a field validator function.
291 /// The function should directly report any appropriate error or warning
292 /// and invoke the appropriate counter update function.
293 /// If not used this parameter must be set to NULL.
294 FNPTR_FIELD_VALIDATOR FieldValidator
;
296 /// Optional pointer to context specific information,
297 /// which the Field Validator function can use to determine
298 /// additional information about the ACPI table and make
299 /// decisions about the field being validated.
300 /// e.g. this could be a pointer to the ACPI table header
305 A structure used to store the pointers to the members of the
306 ACPI description header structure that was parsed.
308 typedef struct AcpiDescriptionHeaderInfo
{
309 /// ACPI table signature
311 /// Length of the ACPI table
317 /// OEM Id - length is 6 bytes
326 UINT32
*CreatorRevision
;
327 } ACPI_DESCRIPTION_HEADER_INFO
;
330 This function is used to parse an ACPI table buffer.
332 The ACPI table buffer is parsed using the ACPI table parser information
333 specified by a pointer to an array of ACPI_PARSER elements. This parser
334 function iterates through each item on the ACPI_PARSER array and logs the
337 This function can optionally be used to parse ACPI tables and fetch specific
338 field values. The ItemPtr member of the ACPI_PARSER structure (where used)
339 is updated by this parser function to point to the selected field data
340 (e.g. useful for variable length nested fields).
342 @param [in] Trace Trace the ACPI fields TRUE else only parse the
344 @param [in] Indent Number of spaces to indent the output.
345 @param [in] AsciiName Optional pointer to an ASCII string that describes
346 the table being parsed.
347 @param [in] Ptr Pointer to the start of the buffer.
348 @param [in] Length Length of the buffer pointed by Ptr.
349 @param [in] Parser Pointer to an array of ACPI_PARSER structure that
350 describes the table being parsed.
351 @param [in] ParserItems Number of items in the ACPI_PARSER array.
353 @retval Number of bytes parsed.
360 IN CONST CHAR8
*AsciiName OPTIONAL
,
363 IN CONST ACPI_PARSER
*Parser
,
364 IN UINT32 ParserItems
368 This is a helper macro to pass parameters to the Parser functions.
370 @param [in] Parser The name of the ACPI_PARSER array describing the
373 #define PARSER_PARAMS(Parser) Parser, sizeof (Parser) / sizeof (Parser[0])
376 This is a helper macro for describing the ACPI header fields.
378 @param [out] Info Pointer to retrieve the ACPI table header information.
380 #define PARSE_ACPI_HEADER(Info) \
381 { L"Signature", 4, 0, NULL, Dump4Chars, \
382 (VOID**)&(Info)->Signature , NULL, NULL }, \
383 { L"Length", 4, 4, L"%d", NULL, \
384 (VOID**)&(Info)->Length, NULL, NULL }, \
385 { L"Revision", 1, 8, L"%d", NULL, \
386 (VOID**)&(Info)->Revision, NULL, NULL }, \
387 { L"Checksum", 1, 9, L"0x%X", NULL, \
388 (VOID**)&(Info)->Checksum, NULL, NULL }, \
389 { L"Oem ID", 6, 10, NULL, Dump6Chars, \
390 (VOID**)&(Info)->OemId, NULL, NULL }, \
391 { L"Oem Table ID", 8, 16, NULL, Dump8Chars, \
392 (VOID**)&(Info)->OemTableId, NULL, NULL }, \
393 { L"Oem Revision", 4, 24, L"0x%X", NULL, \
394 (VOID**)&(Info)->OemRevision, NULL, NULL }, \
395 { L"Creator ID", 4, 28, NULL, Dump4Chars, \
396 (VOID**)&(Info)->CreatorId, NULL, NULL }, \
397 { L"Creator Revision", 4, 32, L"0x%X", NULL, \
398 (VOID**)&(Info)->CreatorRevision, NULL, NULL }
401 This function indents and traces the GAS structure as described by the GasParser.
403 @param [in] Ptr Pointer to the start of the buffer.
404 @param [in] Indent Number of spaces to indent the output.
405 @param [in] Length Length of the GAS structure buffer.
407 @retval Number of bytes parsed.
418 This function traces the GAS structure as described by the GasParser.
420 @param [in] Format Optional format string for tracing the data.
421 @param [in] Ptr Pointer to the start of the buffer.
426 IN CONST CHAR16
*Format OPTIONAL
,
431 This function traces the ACPI header as described by the AcpiHeaderParser.
433 @param [in] Ptr Pointer to the start of the buffer.
435 @retval Number of bytes parsed.
444 This function parses the ACPI header as described by the AcpiHeaderParser.
446 This function optionally returns the Signature, Length and revision of the
449 @param [in] Ptr Pointer to the start of the buffer.
450 @param [out] Signature Gets location of the ACPI table signature.
451 @param [out] Length Gets location of the length of the ACPI table.
452 @param [out] Revision Gets location of the revision of the ACPI table.
454 @retval Number of bytes parsed.
460 OUT CONST UINT32
**Signature
,
461 OUT CONST UINT32
**Length
,
462 OUT CONST UINT8
**Revision
466 This function parses the ACPI AEST table.
467 When trace is enabled this function parses the AEST table and
468 traces the ACPI table fields.
470 This function also performs validation of the ACPI table fields.
472 @param [in] Trace If TRUE, trace the ACPI fields.
473 @param [in] Ptr Pointer to the start of the buffer.
474 @param [in] AcpiTableLength Length of the ACPI table.
475 @param [in] AcpiTableRevision Revision of the ACPI table.
482 IN UINT32 AcpiTableLength
,
483 IN UINT8 AcpiTableRevision
487 This function parses the ACPI BGRT table.
488 When trace is enabled this function parses the BGRT table and
489 traces the ACPI table fields.
491 This function also performs validation of the ACPI table fields.
493 @param [in] Trace If TRUE, trace the ACPI fields.
494 @param [in] Ptr Pointer to the start of the buffer.
495 @param [in] AcpiTableLength Length of the ACPI table.
496 @param [in] AcpiTableRevision Revision of the ACPI table.
503 IN UINT32 AcpiTableLength
,
504 IN UINT8 AcpiTableRevision
508 This function parses the ACPI DBG2 table.
509 When trace is enabled this function parses the DBG2 table and
510 traces the ACPI table fields.
512 This function also performs validation of the ACPI table fields.
514 @param [in] Trace If TRUE, trace the ACPI fields.
515 @param [in] Ptr Pointer to the start of the buffer.
516 @param [in] AcpiTableLength Length of the ACPI table.
517 @param [in] AcpiTableRevision Revision of the ACPI table.
524 IN UINT32 AcpiTableLength
,
525 IN UINT8 AcpiTableRevision
529 This function parses the ACPI DSDT table.
530 When trace is enabled this function parses the DSDT table and
531 traces the ACPI table fields.
532 For the DSDT table only the ACPI header fields are parsed and
535 @param [in] Trace If TRUE, trace the ACPI fields.
536 @param [in] Ptr Pointer to the start of the buffer.
537 @param [in] AcpiTableLength Length of the ACPI table.
538 @param [in] AcpiTableRevision Revision of the ACPI table.
545 IN UINT32 AcpiTableLength
,
546 IN UINT8 AcpiTableRevision
550 This function parses the ACPI FACS table.
551 When trace is enabled this function parses the FACS table and
552 traces the ACPI table fields.
554 This function also performs validation of the ACPI table fields.
556 @param [in] Trace If TRUE, trace the ACPI fields.
557 @param [in] Ptr Pointer to the start of the buffer.
558 @param [in] AcpiTableLength Length of the ACPI table.
559 @param [in] AcpiTableRevision Revision of the ACPI table.
566 IN UINT32 AcpiTableLength
,
567 IN UINT8 AcpiTableRevision
571 This function parses the ACPI FADT table.
572 This function parses the FADT table and optionally traces the ACPI
575 This function also performs validation of the ACPI table fields.
577 @param [in] Trace If TRUE, trace the ACPI fields.
578 @param [in] Ptr Pointer to the start of the buffer.
579 @param [in] AcpiTableLength Length of the ACPI table.
580 @param [in] AcpiTableRevision Revision of the ACPI table.
587 IN UINT32 AcpiTableLength
,
588 IN UINT8 AcpiTableRevision
592 This function parses the ACPI GTDT table.
593 When trace is enabled this function parses the GTDT table and
594 traces the ACPI table fields.
596 This function also parses the following platform timer structures:
600 This function also performs validation of the ACPI table fields.
602 @param [in] Trace If TRUE, trace the ACPI fields.
603 @param [in] Ptr Pointer to the start of the buffer.
604 @param [in] AcpiTableLength Length of the ACPI table.
605 @param [in] AcpiTableRevision Revision of the ACPI table.
612 IN UINT32 AcpiTableLength
,
613 IN UINT8 AcpiTableRevision
617 This function parses the ACPI HMAT table.
618 When trace is enabled this function parses the HMAT table and
619 traces the ACPI table fields.
621 This function parses the following HMAT structures:
622 - Memory Proximity Domain Attributes Structure (Type 0)
623 - System Locality Latency and Bandwidth Info Structure (Type 1)
624 - Memory Side Cache Info structure (Type 2)
626 This function also performs validation of the ACPI table fields.
628 @param [in] Trace If TRUE, trace the ACPI fields.
629 @param [in] Ptr Pointer to the start of the buffer.
630 @param [in] AcpiTableLength Length of the ACPI table.
631 @param [in] AcpiTableRevision Revision of the ACPI table.
638 IN UINT32 AcpiTableLength
,
639 IN UINT8 AcpiTableRevision
643 This function parses the ACPI IORT table.
644 When trace is enabled this function parses the IORT table and
645 traces the ACPI fields.
647 This function also parses the following nodes:
655 This function also performs validation of the ACPI table fields.
657 @param [in] Trace If TRUE, trace the ACPI fields.
658 @param [in] Ptr Pointer to the start of the buffer.
659 @param [in] AcpiTableLength Length of the ACPI table.
660 @param [in] AcpiTableRevision Revision of the ACPI table.
667 IN UINT32 AcpiTableLength
,
668 IN UINT8 AcpiTableRevision
672 This function parses the ACPI MADT table.
673 When trace is enabled this function parses the MADT table and
674 traces the ACPI table fields.
676 This function currently parses the following Interrupt Controller
684 This function also performs validation of the ACPI table fields.
686 @param [in] Trace If TRUE, trace the ACPI fields.
687 @param [in] Ptr Pointer to the start of the buffer.
688 @param [in] AcpiTableLength Length of the ACPI table.
689 @param [in] AcpiTableRevision Revision of the ACPI table.
696 IN UINT32 AcpiTableLength
,
697 IN UINT8 AcpiTableRevision
701 This function parses the ACPI MCFG table.
702 When trace is enabled this function parses the MCFG table and
703 traces the ACPI table fields.
705 This function also performs validation of the ACPI table fields.
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 PCCT table including its sub-structures
724 When trace is enabled this function parses the PCCT table and
725 traces the ACPI table fields.
727 This function also performs validation of the ACPI table fields.
729 @param [in] Trace If TRUE, trace the ACPI fields.
730 @param [in] Ptr Pointer to the start of the buffer.
731 @param [in] AcpiTableLength Length of the ACPI table.
732 @param [in] AcpiTableRevision Revision of the ACPI table.
739 IN UINT32 AcpiTableLength
,
740 IN UINT8 AcpiTableRevision
744 This function parses the ACPI PPTT table.
745 When trace is enabled this function parses the PPTT table and
746 traces the ACPI table fields.
748 This function also performs validation of the ACPI table fields.
750 @param [in] Trace If TRUE, trace the ACPI fields.
751 @param [in] Ptr Pointer to the start of the buffer.
752 @param [in] AcpiTableLength Length of the ACPI table.
753 @param [in] AcpiTableRevision Revision of the ACPI table.
760 IN UINT32 AcpiTableLength
,
761 IN UINT8 AcpiTableRevision
765 This function parses the ACPI RSDP table.
767 This function invokes the parser for the XSDT table.
768 * Note - This function does not support parsing of RSDT table.
770 This function also performs a RAW dump of the ACPI table and
771 validates the checksum.
773 @param [in] Trace If TRUE, trace the ACPI fields.
774 @param [in] Ptr Pointer to the start of the buffer.
775 @param [in] AcpiTableLength Length of the ACPI table.
776 @param [in] AcpiTableRevision Revision of the ACPI table.
783 IN UINT32 AcpiTableLength
,
784 IN UINT8 AcpiTableRevision
788 This function parses the ACPI SLIT table.
789 When trace is enabled this function parses the SLIT table and
790 traces the ACPI table fields.
792 This function also validates System Localities for the following:
793 - Diagonal elements have a normalized value of 10
794 - Relative distance from System Locality at i*N+j is same as
797 @param [in] Trace If TRUE, trace the ACPI fields.
798 @param [in] Ptr Pointer to the start of the buffer.
799 @param [in] AcpiTableLength Length of the ACPI table.
800 @param [in] AcpiTableRevision Revision of the ACPI table.
807 IN UINT32 AcpiTableLength
,
808 IN UINT8 AcpiTableRevision
812 This function parses the ACPI SPCR table.
813 When trace is enabled this function parses the SPCR table and
814 traces the ACPI table fields.
816 This function also performs validations of the ACPI table fields.
818 @param [in] Trace If TRUE, trace the ACPI fields.
819 @param [in] Ptr Pointer to the start of the buffer.
820 @param [in] AcpiTableLength Length of the ACPI table.
821 @param [in] AcpiTableRevision Revision of the ACPI table.
828 IN UINT32 AcpiTableLength
,
829 IN UINT8 AcpiTableRevision
833 This function parses the ACPI SRAT table.
834 When trace is enabled this function parses the SRAT table and
835 traces the ACPI table fields.
837 This function parses the following Resource Allocation Structures:
838 - Processor Local APIC/SAPIC Affinity Structure
839 - Memory Affinity Structure
840 - Processor Local x2APIC Affinity Structure
841 - GICC Affinity Structure
843 This function also performs validation of the ACPI table fields.
845 @param [in] Trace If TRUE, trace the ACPI fields.
846 @param [in] Ptr Pointer to the start of the buffer.
847 @param [in] AcpiTableLength Length of the ACPI table.
848 @param [in] AcpiTableRevision Revision of the ACPI table.
855 IN UINT32 AcpiTableLength
,
856 IN UINT8 AcpiTableRevision
860 This function parses the ACPI SSDT table.
861 When trace is enabled this function parses the SSDT table and
862 traces the ACPI table fields.
863 For the SSDT table only the ACPI header fields are
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 XSDT table
882 and optionally traces the ACPI table fields.
884 This function also performs validation of the XSDT table.
886 @param [in] Trace If TRUE, trace the ACPI fields.
887 @param [in] Ptr Pointer to the start of the buffer.
888 @param [in] AcpiTableLength Length of the ACPI table.
889 @param [in] AcpiTableRevision Revision of the ACPI table.
896 IN UINT32 AcpiTableLength
,
897 IN UINT8 AcpiTableRevision
900 #endif // ACPIPARSER_H_