1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
}
|