TianoCore EDK2 master
Loading...
Searching...
No Matches
ErstParser.c
Go to the documentation of this file.
1
13#include <Library/UefiLib.h>
14#include "AcpiParser.h"
15#include "AcpiTableParser.h"
16
17// Local variables
19STATIC UINT32 *InstructionEntryCount;
20
25 L"BEGIN_WRITE_OPERATION",
26 L"BEGIN_READ_OPERATION",
27 L"BEGIN_CLEAR_OPERATION",
28 L"END_OPERATION",
29 L"SET_RECORD_OFFSET",
30 L"EXECUTE_OPERATION",
31 L"CHECK_BUSY_STATUS",
32 L"GET_COMMAND_STATUS",
33 L"GET_RECORD_IDENTIFIER",
34 L"SET_RECORD_IDENTIFIER",
35 L"GET_RECORD_COUNT",
36 L"BEGIN_DUMMY_WRITE_OPERATION",
37 L"RESERVED",
38 L"GET_ERROR_LOG_ADDRESS_RANGE",
39 L"GET_ERROR_LOG_ADDRESS_RANGE_LENGTH",
40 L"GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES",
41 L"GET_EXECUTE_OPERATION_TIMINGS"
42};
43
48 L"READ_REGISTER",
49 L"READ_REGISTER_VALUE",
50 L"WRITE_REGISTER",
51 L"WRITE_REGISTER_VALUE",
52 L"NOOP",
53 L"LOAD_VAR1",
54 L"LOAD_VAR2",
55 L"STORE_VAR1",
56 L"ADD",
57 L"SUBTRACT",
58 L"ADD_VALUE",
59 L"SUBTRACT_VALUE",
60 L"STALL",
61 L"STALL_WHILE_TRUE",
62 L"SKIP_NEXT_INSTRUCTION_IF_TRUE",
63 L"GOTO",
64 L"SET_SRC_ADDRESS_BASE",
65 L"SET_DST_ADDRESS_BASE",
66 L"MOVE_DATA"
67};
68
78VOID
79EFIAPI
81 IN UINT8 *Ptr,
82 IN UINT32 Length,
83 IN VOID *Context
84 )
85{
86 if (*Ptr > EFI_ACPI_6_4_ERST_GET_EXECUTE_OPERATION_TIMINGS) {
88 Print (L"\nError: 0x%02x is not a valid action encoding", *Ptr);
89 }
90}
91
100STATIC
101VOID
102EFIAPI
104 IN UINT8 *Ptr,
105 IN UINT32 Length,
106 IN VOID *Context
107 )
108{
109 if (*Ptr > EFI_ACPI_6_4_ERST_MOVE_DATA) {
111 Print (L"\nError: 0x%02x is not a valid instruction encoding", *Ptr);
112 }
113}
114
123STATIC
124VOID
125EFIAPI
127 IN UINT8 *Ptr,
128 IN UINT32 Length,
129 IN VOID *Context
130 )
131{
132 if ((*Ptr & 0xfe) != 0) {
134 Print (L"\nError: Reserved Flag bits not set to 0");
135 }
136}
137
145STATIC
146VOID
147EFIAPI
149 IN CONST CHAR16 *Table[],
150 IN UINT8 Index,
151 IN UINT8 NumEntries
152 )
153{
154 CONST CHAR16 *String;
155
156 if (Index < NumEntries) {
157 String = Table[Index];
158 } else {
159 String = L"**INVALID**";
160 }
161
162 Print (
163 L"0x%02x (%s)",
164 Index,
165 String
166 );
167}
168
176STATIC
177VOID
178EFIAPI
180 IN CONST CHAR16 *Format OPTIONAL,
181 IN UINT8 *Ptr,
182 IN UINT32 Length
183 )
184{
186}
187
195STATIC
196VOID
197EFIAPI
199 IN CONST CHAR16 *Format OPTIONAL,
200 IN UINT8 *Ptr,
201 IN UINT32 Length
202 )
203{
205}
206
211 PARSE_ACPI_HEADER (&AcpiHdrInfo),
212 { L"Serialization Header Size", 4, 36, L"0x%x", NULL, NULL, NULL, NULL },
213 { L"Reserved", 4, 40, L"0x%x", NULL, NULL, NULL, NULL },
214 { L"Instruction Entry Count", 4, 44, L"0x%x", NULL, (VOID **)&InstructionEntryCount, NULL, NULL }
215};
216
221 { L"Serialization Action", 1, 0, L"0x%x", DumpErstAction, NULL, ValidateErstAction, NULL },
222 { L"Instruction", 1, 1, L"0x%x", DumpErstInstruction, NULL, ValidateErstInstruction, NULL },
223 { L"Flags", 1, 2, L"0x%x", NULL, NULL, ValidateErstFlags, NULL },
224 { L"Reserved", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
225 { L"Register Region", 12, 4, NULL, DumpGas, NULL, NULL, NULL },
226 { L"Value", 8, 16, L"0x%llx", NULL, NULL, NULL, NULL },
227 { L"Mask", 8, 24, L"0x%llx", NULL, NULL, NULL, NULL }
228};
229
242VOID
243EFIAPI
245 IN BOOLEAN Trace,
246 IN UINT8 *Ptr,
247 IN UINT32 AcpiTableLength,
248 IN UINT8 AcpiTableRevision
249 )
250{
251 UINT32 Offset;
252
253 if (!Trace) {
254 return;
255 }
256
257 Offset = ParseAcpi (
258 Trace,
259 0,
260 "ERST",
261 Ptr,
262 AcpiTableLength,
264 );
265
266 if (sizeof (EFI_ACPI_6_4_ERST_SERIALIZATION_INSTRUCTION_ENTRY)*(*InstructionEntryCount) != (AcpiTableLength - Offset)) {
268 Print (
269 L"ERROR: Invalid InstructionEntryCount. " \
270 L"Count = %d. Offset = %d. AcpiTableLength = %d.\n",
271 *InstructionEntryCount,
272 Offset,
273 AcpiTableLength
274 );
275 return;
276 }
277
278 while (Offset < AcpiTableLength) {
279 Offset += ParseAcpi (
280 Trace,
281 2,
282 "Serialization Action",
283 Ptr + Offset,
284 (AcpiTableLength - Offset),
286 );
287 }
288}
VOID EFIAPI DumpGas(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length)
Definition: AcpiParser.c:867
VOID EFIAPI IncrementErrorCount(VOID)
Definition: AcpiParser.c:83
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)
Definition: AcpiParser.c:683
#define PARSER_PARAMS(Parser)
Definition: AcpiParser.h:494
#define PARSE_ACPI_HEADER(Info)
Definition: AcpiParser.h:501
STATIC VOID EFIAPI FormatByte(IN CONST CHAR16 *Table[], IN UINT8 Index, IN UINT8 NumEntries)
Definition: ErstParser.c:148
STATIC VOID EFIAPI DumpErstInstruction(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length)
Definition: ErstParser.c:198
STATIC CONST CHAR16 * ErstActionTable[]
Definition: ErstParser.c:24
STATIC CONST CHAR16 * ErstInstructionTable[]
Definition: ErstParser.c:47
STATIC CONST ACPI_PARSER ErstParser[]
Definition: ErstParser.c:210
STATIC VOID EFIAPI ValidateErstFlags(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: ErstParser.c:126
STATIC CONST ACPI_PARSER SerializationInstructionEntryParser[]
Definition: ErstParser.c:220
STATIC VOID EFIAPI DumpErstAction(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length)
Definition: ErstParser.c:179
STATIC VOID EFIAPI ValidateErstAction(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: ErstParser.c:80
VOID EFIAPI ParseAcpiErst(IN BOOLEAN Trace, IN UINT8 *Ptr, IN UINT32 AcpiTableLength, IN UINT8 AcpiTableRevision)
Definition: ErstParser.c:244
STATIC VOID EFIAPI ValidateErstInstruction(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: ErstParser.c:103
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define ARRAY_SIZE(Array)
Definition: Base.h:1393
#define IN
Definition: Base.h:279
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)
Definition: UefiLibPrint.c:113