TianoCore EDK2 master
AcpiParser.c File Reference
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include "AcpiParser.h"
#include "AcpiView.h"
#include "AcpiViewConfig.h"

Go to the source code of this file.

Functions

VOID ResetErrorCount (VOID)
 
UINT32 GetErrorCount (VOID)
 
VOID ResetWarningCount (VOID)
 
UINT32 GetWarningCount (VOID)
 
VOID EFIAPI IncrementErrorCount (VOID)
 
VOID EFIAPI IncrementWarningCount (VOID)
 
BOOLEAN EFIAPI VerifyChecksum (IN BOOLEAN Log, IN UINT8 *Ptr, IN UINT32 Length)
 
VOID EFIAPI DumpRaw (IN UINT8 *Ptr, IN UINT32 Length)
 
VOID EFIAPI DumpUint8 (IN CONST CHAR16 *Format, IN UINT8 *Ptr)
 
VOID EFIAPI DumpUint16 (IN CONST CHAR16 *Format, IN UINT8 *Ptr)
 
VOID EFIAPI DumpUint32 (IN CONST CHAR16 *Format, IN UINT8 *Ptr)
 
VOID EFIAPI DumpUint64 (IN CONST CHAR16 *Format, IN UINT8 *Ptr)
 
VOID EFIAPI Dump3Chars (IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
 
VOID EFIAPI Dump4Chars (IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
 
VOID EFIAPI Dump6Chars (IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
 
VOID EFIAPI Dump8Chars (IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
 
VOID EFIAPI Dump12Chars (IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
 
VOID EFIAPI PrintFieldName (IN UINT32 Indent, IN CONST CHAR16 *FieldName)
 
UINT32 EFIAPI ParseAcpi (IN BOOLEAN Trace, IN UINT32 Indent, IN CONST CHAR8 *AsciiName OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length, IN CONST ACPI_PARSER *Parser, IN UINT32 ParserItems)
 
UINT32 EFIAPI DumpGasStruct (IN UINT8 *Ptr, IN UINT32 Indent, IN UINT32 Length)
 
VOID EFIAPI DumpGas (IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr)
 
UINT32 EFIAPI DumpAcpiHeader (IN UINT8 *Ptr)
 
UINT32 EFIAPI ParseAcpiHeader (IN UINT8 *Ptr, OUT CONST UINT32 **Signature, OUT CONST UINT32 **Length, OUT CONST UINT8 **Revision)
 
UINT32 EFIAPI ParseAcpiBitFields (IN BOOLEAN Trace, IN UINT32 Indent, IN CONST CHAR8 *AsciiName OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length, IN CONST ACPI_PARSER *Parser, IN UINT32 ParserItems)
 

Variables

STATIC UINT32 gIndent
 
STATIC UINT32 mTableErrorCount
 
STATIC UINT32 mTableWarningCount
 
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
 
STATIC CONST ACPI_PARSER AcpiHeaderParser []
 
STATIC CONST ACPI_PARSER GasParser []
 

Detailed Description

ACPI parser

Copyright (c) 2016 - 2021, Arm Limited. All rights reserved. Copyright (c) 2022, AMD Incorporated. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file AcpiParser.c.

Function Documentation

◆ Dump12Chars()

VOID EFIAPI Dump12Chars ( IN CONST CHAR16 *Format  OPTIONAL,
IN UINT8 Ptr 
)

This function traces 12 characters which can be optionally formated using the format string if specified.

If no format string is specified the Format must be NULL.

Parameters
[in]FormatOptional format string for tracing the data.
[in]PtrPointer to the start of the buffer.

Definition at line 430 of file AcpiParser.c.

◆ Dump3Chars()

VOID EFIAPI Dump3Chars ( IN CONST CHAR16 *Format  OPTIONAL,
IN UINT8 Ptr 
)

This function traces 3 characters which can be optionally formated using the format string if specified.

If no format string is specified the Format must be NULL.

Parameters
[in]FormatOptional format string for tracing the data.
[in]PtrPointer to the start of the buffer.

Definition at line 325 of file AcpiParser.c.

◆ Dump4Chars()

VOID EFIAPI Dump4Chars ( IN CONST CHAR16 *Format  OPTIONAL,
IN UINT8 Ptr 
)

This function traces 4 characters which can be optionally formated using the format string if specified.

If no format string is specified the Format must be NULL.

Parameters
[in]FormatOptional format string for tracing the data.
[in]PtrPointer to the start of the buffer.

Definition at line 349 of file AcpiParser.c.

◆ Dump6Chars()

VOID EFIAPI Dump6Chars ( IN CONST CHAR16 *Format  OPTIONAL,
IN UINT8 Ptr 
)

This function traces 6 characters which can be optionally formated using the format string if specified.

If no format string is specified the Format must be NULL.

Parameters
[in]FormatOptional format string for tracing the data.
[in]PtrPointer to the start of the buffer.

Definition at line 374 of file AcpiParser.c.

◆ Dump8Chars()

VOID EFIAPI Dump8Chars ( IN CONST CHAR16 *Format  OPTIONAL,
IN UINT8 Ptr 
)

This function traces 8 characters which can be optionally formated using the format string if specified.

If no format string is specified the Format must be NULL.

Parameters
[in]FormatOptional format string for tracing the data.
[in]PtrPointer to the start of the buffer.

Definition at line 401 of file AcpiParser.c.

◆ DumpAcpiHeader()

UINT32 EFIAPI DumpAcpiHeader ( IN UINT8 Ptr)

This function traces the ACPI header as described by the AcpiHeaderParser.

Parameters
[in]PtrPointer to the start of the buffer.
Return values
Numberof bytes parsed.

Definition at line 704 of file AcpiParser.c.

◆ DumpGas()

VOID EFIAPI DumpGas ( IN CONST CHAR16 *Format  OPTIONAL,
IN UINT8 Ptr 
)

This function traces the GAS structure as described by the GasParser.

Parameters
[in]FormatOptional format string for tracing the data.
[in]PtrPointer to the start of the buffer.

Definition at line 687 of file AcpiParser.c.

◆ DumpGasStruct()

UINT32 EFIAPI DumpGasStruct ( IN UINT8 Ptr,
IN UINT32  Indent,
IN UINT32  Length 
)

This function indents and traces the GAS structure as described by the GasParser.

Parameters
[in]PtrPointer to the start of the buffer.
[in]IndentNumber of spaces to indent the output.
[in]LengthLength of the GAS structure buffer.
Return values
Numberof bytes parsed.

Definition at line 662 of file AcpiParser.c.

◆ DumpRaw()

VOID EFIAPI DumpRaw ( IN UINT8 Ptr,
IN UINT32  Length 
)

This function performs a raw data dump of the ACPI table.

Parameters
[in]PtrPointer to the start of the table buffer.
[in]LengthThe length of the buffer.

Definition at line 184 of file AcpiParser.c.

◆ DumpUint16()

VOID EFIAPI DumpUint16 ( IN CONST CHAR16 Format,
IN UINT8 Ptr 
)

This function traces 2 bytes of data as specified in the format string.

Parameters
[in]FormatThe format string for tracing the data.
[in]PtrPointer to the start of the buffer.

Definition at line 264 of file AcpiParser.c.

◆ DumpUint32()

VOID EFIAPI DumpUint32 ( IN CONST CHAR16 Format,
IN UINT8 Ptr 
)

This function traces 4 bytes of data as specified in the format string.

Parameters
[in]FormatThe format string for tracing the data.
[in]PtrPointer to the start of the buffer.

Definition at line 280 of file AcpiParser.c.

◆ DumpUint64()

VOID EFIAPI DumpUint64 ( IN CONST CHAR16 Format,
IN UINT8 Ptr 
)

This function traces 8 bytes of data as specified by the format string.

Parameters
[in]FormatThe format string for tracing the data.
[in]PtrPointer to the start of the buffer.

Definition at line 296 of file AcpiParser.c.

◆ DumpUint8()

VOID EFIAPI DumpUint8 ( IN CONST CHAR16 Format,
IN UINT8 Ptr 
)

This function traces 1 byte of data as specified in the format string.

Parameters
[in]FormatThe format string for tracing the data.
[in]PtrPointer to the start of the buffer.

Definition at line 248 of file AcpiParser.c.

◆ GetErrorCount()

UINT32 GetErrorCount ( VOID  )

This function returns the ACPI table error count.

Return values
Returnsthe count of errors detected in the ACPI tables.

Definition at line 47 of file AcpiParser.c.

◆ GetWarningCount()

UINT32 GetWarningCount ( VOID  )

This function returns the ACPI table warning count.

Return values
Returnsthe count of warning detected in the ACPI tables.

Definition at line 71 of file AcpiParser.c.

◆ IncrementErrorCount()

VOID EFIAPI IncrementErrorCount ( VOID  )

This function increments the ACPI table error counter.

Definition at line 83 of file AcpiParser.c.

◆ IncrementWarningCount()

VOID EFIAPI IncrementWarningCount ( VOID  )

This function increments the ACPI table warning counter.

Definition at line 95 of file AcpiParser.c.

◆ ParseAcpi()

UINT32 EFIAPI ParseAcpi ( IN BOOLEAN  Trace,
IN UINT32  Indent,
IN CONST CHAR8 *AsciiName  OPTIONAL,
IN UINT8 Ptr,
IN UINT32  Length,
IN CONST ACPI_PARSER Parser,
IN UINT32  ParserItems 
)

This function is used to parse an ACPI table buffer.

The ACPI table buffer is parsed using the ACPI table parser information specified by a pointer to an array of ACPI_PARSER elements. This parser function iterates through each item on the ACPI_PARSER array and logs the ACPI table fields.

This function can optionally be used to parse ACPI tables and fetch specific field values. The ItemPtr member of the ACPI_PARSER structure (where used) is updated by this parser function to point to the selected field data (e.g. useful for variable length nested fields).

Parameters
[in]TraceTrace the ACPI fields TRUE else only parse the table.
[in]IndentNumber of spaces to indent the output.
[in]AsciiNameOptional pointer to an ASCII string that describes the table being parsed.
[in]PtrPointer to the start of the buffer.
[in]LengthLength of the buffer pointed by Ptr.
[in]ParserPointer to an array of ACPI_PARSER structure that describes the table being parsed.
[in]ParserItemsNumber of items in the ACPI_PARSER array.
Return values
Numberof bytes parsed.

Definition at line 508 of file AcpiParser.c.

◆ ParseAcpiBitFields()

UINT32 EFIAPI ParseAcpiBitFields ( IN BOOLEAN  Trace,
IN UINT32  Indent,
IN CONST CHAR8 *AsciiName  OPTIONAL,
IN UINT8 Ptr,
IN UINT32  Length,
IN CONST ACPI_PARSER Parser,
IN UINT32  ParserItems 
)

This function is used to parse an ACPI table bitfield buffer.

The ACPI table buffer is parsed using the ACPI table parser information specified by a pointer to an array of ACPI_PARSER elements. This parser function iterates through each item on the ACPI_PARSER array and logs the ACPI table bitfields.

This function can optionally be used to parse ACPI tables and fetch specific field values. The ItemPtr member of the ACPI_PARSER structure (where used) is updated by this parser function to point to the selected field data (e.g. useful for variable length nested fields).

ItemPtr member of ACPI_PARSER is not supported with this function.

Parameters
[in]TraceTrace the ACPI fields TRUE else only parse the table.
[in]IndentNumber of spaces to indent the output.
[in]AsciiNameOptional pointer to an ASCII string that describes the table being parsed.
[in]PtrPointer to the start of the buffer.
[in]LengthLength in bytes of the buffer pointed by Ptr.
[in]ParserPointer to an array of ACPI_PARSER structure that describes the table being parsed.
[in]ParserItemsNumber of items in the ACPI_PARSER array.
Return values
Numberof bits parsed.

Definition at line 787 of file AcpiParser.c.

◆ ParseAcpiHeader()

UINT32 EFIAPI ParseAcpiHeader ( IN UINT8 Ptr,
OUT CONST UINT32 **  Signature,
OUT CONST UINT32 **  Length,
OUT CONST UINT8 **  Revision 
)

This function parses the ACPI header as described by the AcpiHeaderParser.

This function optionally returns the signature, length and revision of the ACPI table.

Parameters
[in]PtrPointer to the start of the buffer.
[out]SignatureGets location of the ACPI table signature.
[out]LengthGets location of the length of the ACPI table.
[out]RevisionGets location of the revision of the ACPI table.
Return values
Numberof bytes parsed.

Definition at line 733 of file AcpiParser.c.

◆ PrintFieldName()

VOID EFIAPI PrintFieldName ( IN UINT32  Indent,
IN CONST CHAR16 FieldName 
)

This function indents and prints the ACPI table Field Name.

Parameters
[in]IndentNumber of spaces to add to the global table indent. The global table indent is 0 by default; however this value is updated on entry to the ParseAcpi() by adding the indent value provided to ParseAcpi() and restored back on exit. Therefore the total indent in the output is dependent on from where this function is called.
[in]FieldNamePointer to the Field Name.

Definition at line 466 of file AcpiParser.c.

◆ ResetErrorCount()

VOID ResetErrorCount ( VOID  )

This function resets the ACPI table error counter to Zero.

Definition at line 34 of file AcpiParser.c.

◆ ResetWarningCount()

VOID ResetWarningCount ( VOID  )

This function resets the ACPI table warning counter to Zero.

Definition at line 58 of file AcpiParser.c.

◆ VerifyChecksum()

BOOLEAN EFIAPI VerifyChecksum ( IN BOOLEAN  Log,
IN UINT8 Ptr,
IN UINT32  Length 
)

This function verifies the ACPI table checksum.

This function verifies the checksum for the ACPI table and optionally prints the status.

Parameters
[in]LogIf TRUE log the status of the checksum.
[in]PtrPointer to the start of the table buffer.
[in]LengthThe length of the buffer.
Return values
TRUEThe checksum is OK.
FALSEThe checksum failed.

Definition at line 117 of file AcpiParser.c.

Variable Documentation

◆ AcpiHdrInfo

Definition at line 21 of file AcpiParser.c.

◆ AcpiHeaderParser

STATIC CONST ACPI_PARSER AcpiHeaderParser[]
Initial value:
= {
}

An ACPI_PARSER array describing the ACPI header.

Definition at line 26 of file AcpiParser.c.

◆ GasParser

STATIC CONST ACPI_PARSER GasParser[]
Initial value:
= {
{ L"Address Space ID", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Register Bit Width", 1, 1, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Register Bit Offset", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Access Size", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Address", 8, 4, L"0x%lx", NULL, NULL, NULL, NULL }
}
#define NULL
Definition: Base.h:312

An array describing the ACPI Generic Address Structure. The GasParser array is used by the ParseAcpi function to parse and/or trace the GAS structure.

Definition at line 643 of file AcpiParser.c.

◆ gIndent

STATIC UINT32 gIndent

Definition at line 17 of file AcpiParser.c.

◆ mTableErrorCount

STATIC UINT32 mTableErrorCount

Definition at line 18 of file AcpiParser.c.

◆ mTableWarningCount

STATIC UINT32 mTableWarningCount

Definition at line 19 of file AcpiParser.c.