diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/edk2/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/edk2/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c')
-rw-r--r-- | roms/edk2/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/roms/edk2/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c b/roms/edk2/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c new file mode 100644 index 000000000..e39061f8e --- /dev/null +++ b/roms/edk2/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c @@ -0,0 +1,140 @@ +/** @file
+ XSDT table parser
+
+ Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+ @par Reference(s):
+ - ACPI 6.2 Specification - Errata A, September 2017
+**/
+
+#include <IndustryStandard/Acpi.h>
+#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
+#include "AcpiParser.h"
+#include "AcpiTableParser.h"
+
+// Local variables
+STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
+
+/** An ACPI_PARSER array describing the ACPI XSDT table.
+*/
+STATIC CONST ACPI_PARSER XsdtParser[] = {
+ PARSE_ACPI_HEADER (&AcpiHdrInfo)
+};
+
+/**
+ Get the ACPI XSDT header info.
+**/
+CONST ACPI_DESCRIPTION_HEADER_INFO *
+EFIAPI
+GetAcpiXsdtHeaderInfo (
+ VOID
+)
+{
+ return &AcpiHdrInfo;
+}
+
+/**
+ This function parses the ACPI XSDT table and optionally traces the ACPI table fields.
+
+ This function also performs validation of the XSDT table.
+
+ @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] Ptr Pointer to the start of the buffer.
+ @param [in] AcpiTableLength Length of the ACPI table.
+ @param [in] AcpiTableRevision Revision of the ACPI table.
+**/
+VOID
+EFIAPI
+ParseAcpiXsdt (
+ IN BOOLEAN Trace,
+ IN UINT8* Ptr,
+ IN UINT32 AcpiTableLength,
+ IN UINT8 AcpiTableRevision
+ )
+{
+ UINT32 Offset;
+ UINT32 TableOffset;
+ UINT64* TablePointer;
+ UINTN EntryIndex;
+ CHAR16 Buffer[32];
+
+ Offset = ParseAcpi (
+ Trace,
+ 0,
+ "XSDT",
+ Ptr,
+ AcpiTableLength,
+ PARSER_PARAMS (XsdtParser)
+ );
+
+ TableOffset = Offset;
+
+ if (Trace) {
+ EntryIndex = 0;
+ TablePointer = (UINT64*)(Ptr + TableOffset);
+ while (Offset < AcpiTableLength) {
+ CONST UINT32* Signature;
+ CONST UINT32* Length;
+ CONST UINT8* Revision;
+
+ if ((UINT64*)(UINTN)(*TablePointer) != NULL) {
+ UINT8* SignaturePtr;
+
+ ParseAcpiHeader (
+ (UINT8*)(UINTN)(*TablePointer),
+ &Signature,
+ &Length,
+ &Revision
+ );
+
+ SignaturePtr = (UINT8*)Signature;
+
+ UnicodeSPrint (
+ Buffer,
+ sizeof (Buffer),
+ L"Entry[%d] - %c%c%c%c",
+ EntryIndex++,
+ SignaturePtr[0],
+ SignaturePtr[1],
+ SignaturePtr[2],
+ SignaturePtr[3]
+ );
+ } else {
+ UnicodeSPrint (
+ Buffer,
+ sizeof (Buffer),
+ L"Entry[%d]",
+ EntryIndex++
+ );
+ }
+
+ PrintFieldName (2, Buffer);
+ Print (L"0x%lx\n", *TablePointer);
+
+ // Validate the table pointers are not NULL
+ if ((UINT64*)(UINTN)(*TablePointer) == NULL) {
+ IncrementErrorCount ();
+ Print (
+ L"ERROR: Invalid table entry at 0x%lx, table address is 0x%lx\n",
+ TablePointer,
+ *TablePointer
+ );
+ }
+ Offset += sizeof (UINT64);
+ TablePointer++;
+ } // while
+ }
+
+ // Process the tables
+ Offset = TableOffset;
+ TablePointer = (UINT64*)(Ptr + TableOffset);
+ while (Offset < AcpiTableLength) {
+ if ((UINT64*)(UINTN)(*TablePointer) != NULL) {
+ ProcessAcpiTable ((UINT8*)(UINTN)(*TablePointer));
+ }
+ Offset += sizeof (UINT64);
+ TablePointer++;
+ } // while
+}
|