TianoCore EDK2 master
Loading...
Searching...
No Matches
AcpiTableParser.c
Go to the documentation of this file.
1
14#include <Uefi.h>
16#include <Library/UefiLib.h>
17#include "AcpiParser.h"
18#include "AcpiTableParser.h"
19#include "AcpiView.h"
20#include "AcpiViewConfig.h"
21
22#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
23 #include "Arm/SbbrValidator.h"
24#endif
25
30
47EFIAPI
49 IN UINT32 Signature,
50 IN PARSE_ACPI_TABLE_PROC ParserProc
51 )
52{
53 UINT32 Index;
54
55 if ((ParserProc == NULL) || (Signature == ACPI_PARSER_SIGNATURE_NULL)) {
56 return EFI_INVALID_PARAMETER;
57 }
58
59 // Search if a parser is already installed
60 for (Index = 0;
61 Index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
62 Index++)
63 {
64 if (Signature == mTableParserList[Index].Signature) {
65 if (mTableParserList[Index].Parser != NULL) {
66 return EFI_ALREADY_STARTED;
67 }
68 }
69 }
70
71 // Find the first free slot and register the parser
72 for (Index = 0;
73 Index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
74 Index++)
75 {
76 if (mTableParserList[Index].Signature == ACPI_PARSER_SIGNATURE_NULL) {
77 mTableParserList[Index].Signature = Signature;
78 mTableParserList[Index].Parser = ParserProc;
79 return EFI_SUCCESS;
80 }
81 }
82
83 // No free slot found
84 return EFI_OUT_OF_RESOURCES;
85}
86
99EFIAPI
101 IN UINT32 Signature
102 )
103{
104 UINT32 Index;
105
106 if (Signature == ACPI_PARSER_SIGNATURE_NULL) {
107 return EFI_INVALID_PARAMETER;
108 }
109
110 for (Index = 0;
111 Index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
112 Index++)
113 {
114 if (Signature == mTableParserList[Index].Signature) {
117 return EFI_SUCCESS;
118 }
119 }
120
121 // No matching registered parser found.
122 return EFI_NOT_FOUND;
123}
124
139EFIAPI
141 IN UINT32 Signature,
142 OUT PARSE_ACPI_TABLE_PROC *ParserProc
143 )
144{
145 UINT32 Index;
146
147 if ((ParserProc == NULL) || (Signature == ACPI_PARSER_SIGNATURE_NULL)) {
148 return EFI_INVALID_PARAMETER;
149 }
150
151 for (Index = 0;
152 Index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
153 Index++)
154 {
155 if (Signature == mTableParserList[Index].Signature) {
156 *ParserProc = mTableParserList[Index].Parser;
157 return EFI_SUCCESS;
158 }
159 }
160
161 // No matching registered parser found.
162 return EFI_NOT_FOUND;
163}
164
179VOID
180EFIAPI
182 IN UINT8 *Ptr
183 )
184{
185 EFI_STATUS Status;
186 BOOLEAN Trace;
187 CONST UINT32 *AcpiTableSignature;
188 CONST UINT32 *AcpiTableLength;
189 CONST UINT8 *AcpiTableRevision;
190 CONST UINT8 *SignaturePtr;
191 PARSE_ACPI_TABLE_PROC ParserProc;
192
194 Ptr,
195 &AcpiTableSignature,
196 &AcpiTableLength,
197 &AcpiTableRevision
198 );
199
201 *AcpiTableSignature,
202 Ptr,
203 *AcpiTableLength
204 );
205
206 if (Trace) {
207 DumpRaw (Ptr, *AcpiTableLength);
208
209 // Do not process the ACPI table any further if the table length read
210 // is invalid. The ACPI table should at least contain the table header.
211 if (*AcpiTableLength < sizeof (EFI_ACPI_DESCRIPTION_HEADER)) {
212 SignaturePtr = (CONST UINT8 *)AcpiTableSignature;
214 Print (
215 L"ERROR: Invalid %c%c%c%c table length. Length = %d\n",
216 SignaturePtr[0],
217 SignaturePtr[1],
218 SignaturePtr[2],
219 SignaturePtr[3],
220 *AcpiTableLength
221 );
222 return;
223 }
224
225 if (GetConsistencyChecking ()) {
226 VerifyChecksum (TRUE, Ptr, *AcpiTableLength);
227 }
228 }
229
230 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
232 ArmSbbrIncrementTableCount (*AcpiTableSignature);
233 }
234
235 #endif
236
237 Status = GetParser (*AcpiTableSignature, &ParserProc);
238 if (EFI_ERROR (Status)) {
239 // No registered parser found, do default handling.
240 if (Trace) {
241 DumpAcpiHeader (Ptr);
242 }
243
244 return;
245 }
246
247 ParserProc (
248 Trace,
249 Ptr,
250 *AcpiTableLength,
251 *AcpiTableRevision
252 );
253}
UINT32 EFIAPI ParseAcpiHeader(IN UINT8 *Ptr, OUT CONST UINT32 **Signature, OUT CONST UINT32 **Length, OUT CONST UINT8 **Revision)
Definition: AcpiParser.c:914
BOOLEAN EFIAPI VerifyChecksum(IN BOOLEAN Log, IN UINT8 *Ptr, IN UINT32 Length)
Definition: AcpiParser.c:117
UINT32 EFIAPI DumpAcpiHeader(IN UINT8 *Ptr)
Definition: AcpiParser.c:885
VOID EFIAPI IncrementErrorCount(VOID)
Definition: AcpiParser.c:83
VOID EFIAPI DumpRaw(IN UINT8 *Ptr, IN UINT32 Length)
Definition: AcpiParser.c:184
EFI_STATUS EFIAPI GetParser(IN UINT32 Signature, OUT PARSE_ACPI_TABLE_PROC *ParserProc)
VOID EFIAPI ProcessAcpiTable(IN UINT8 *Ptr)
STATIC ACPI_TABLE_PARSER mTableParserList[MAX_ACPI_TABLE_PARSERS]
EFI_STATUS EFIAPI RegisterParser(IN UINT32 Signature, IN PARSE_ACPI_TABLE_PROC ParserProc)
EFI_STATUS EFIAPI DeregisterParser(IN UINT32 Signature)
VOID(EFIAPI * PARSE_ACPI_TABLE_PROC)(IN BOOLEAN Trace, IN UINT8 *Ptr, IN UINT32 AcpiTableLength, IN UINT8 AcpiTableRevision)
#define MAX_ACPI_TABLE_PARSERS
#define ACPI_PARSER_SIGNATURE_NULL
BOOLEAN ProcessTableReportOptions(IN CONST UINT32 Signature, IN CONST UINT8 *TablePtr, IN CONST UINT32 Length)
Definition: AcpiView.c:79
BOOLEAN EFIAPI GetConsistencyChecking(VOID)
BOOLEAN EFIAPI GetMandatoryTableValidate(VOID)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
BOOLEAN EFIAPI ArmSbbrIncrementTableCount(UINT32 Signature)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)
Definition: UefiLibPrint.c:113
UINT32 Signature
ACPI table signature.
PARSE_ACPI_TABLE_PROC Parser
The ACPI table parser function.