TianoCore EDK2 master
Loading...
Searching...
No Matches
EinjParser.c
Go to the documentation of this file.
1
12#include <Library/UefiLib.h>
13
14#include "AcpiParser.h"
15#include "AcpiTableParser.h"
16#include "AcpiView.h"
17
19STATIC UINT32 *mEinjInjectionHdrSize;
20STATIC UINT32 *mEinjInjectionEntryCnt;
21
22STATIC CONST CHAR16 *InstNameTable[] = {
23 L"READ_REGISTER",
24 L"READ_REGISTER_VALUE",
25 L"WRITE_REGISTER",
26 L"WRITE_REGISTER_VALUE",
27 L"NOOP",
28};
29
39VOID
40EFIAPI
42 IN UINT8 *Ptr,
43 IN UINT32 Length,
44 IN VOID *Context
45 )
46{
47 UINT8 Flags;
48
49 Flags = *(UINT8 *)Ptr;
50
51 if (Flags != 0) {
53 Print (L"\nERROR: Injection Flags must be zero...");
54 }
55}
56
61 PARSE_ACPI_HEADER (&mAcpiHdrInfo),
62 { L"Injection Header Size", 4, 36, L"%d", NULL, (VOID **)&mEinjInjectionHdrSize,
63 NULL, NULL },
64 { L"Injection Flags", 1, 40, L"0x%x", NULL, NULL, ValidateInjectionFlags,NULL },
65 { L"Reserved", 3, 41, NULL, NULL, NULL, NULL, NULL },
66 { L"Injection Entry Count", 4, 44, L"%d", NULL, (VOID **)&mEinjInjectionEntryCnt,
67 NULL, NULL },
70};
71
82VOID
83EFIAPI
85 IN UINT8 *Ptr,
86 IN UINT32 Length,
87 IN VOID *Context
88 )
89{
90 UINT8 InjectionAction;
91 UINT8 MaxInjectionAction;
92
93 InjectionAction = *(UINT8 *)Ptr;
94
102 MaxInjectionAction = EFI_ACPI_6_5_EINJ_GET_EXECUTE_OPERATION_TIMINGS;
103 } else {
104 MaxInjectionAction = EFI_ACPI_6_5_EINJ_EINJV2_GET_ERROR_TYPE;
105 }
106
107 if ((InjectionAction < EFI_ACPI_6_5_EINJ_BEGIN_INJECTION_OPERATION) ||
108 (InjectionAction > MaxInjectionAction))
109 {
111 Print (L"\nERROR: Invalid Injection Action(0x%x)...", InjectionAction);
112 }
113}
114
124STATIC
125VOID
126EFIAPI
128 IN UINT8 *Ptr,
129 IN UINT32 Length,
130 IN VOID *Context
131 )
132{
133 UINT8 Inst;
134
135 Inst = *Ptr;
136
138 if (Inst > EFI_ACPI_6_5_EINJ_NOOP) {
140 Print (L"\nERROR: Invalid Instruction(0x%x)...", Inst);
141 }
142 }
143}
144
154STATIC
155VOID
156EFIAPI
158 IN UINT8 *Ptr,
159 IN UINT32 Length,
160 IN VOID *Context
161 )
162{
164
165 RegisterRegion = (EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE *)Ptr;
166
167 if ((RegisterRegion->AddressSpaceId != EFI_ACPI_6_5_SYSTEM_MEMORY) &&
168 (RegisterRegion->AddressSpaceId != EFI_ACPI_6_5_SYSTEM_IO))
169 {
171 Print (L"\nERROR: Register Region Must be SYSTEM_MEMORY or SYSTEM_IO...");
172 }
173}
174
182STATIC
183VOID
184EFIAPI
186 IN CONST CHAR16 *Format OPTIONAL,
187 IN UINT8 *Ptr,
188 IN UINT32 Length
189 )
190{
191 UINT8 InjectionAction;
192 CONST CHAR16 *ActionName;
193
194 InjectionAction = *Ptr;
195
196 switch (InjectionAction) {
198 ActionName = L"BEGIN_INJECTION_OPERATION";
199 break;
200 case EFI_ACPI_6_5_EINJ_GET_TRIGGER_ERROR_ACTION_TABLE:
201 ActionName = L"GET_TRIGGER_ERROR_ACTION_TABLE";
202 break;
203 case EFI_ACPI_6_5_EINJ_SET_ERROR_TYPE:
204 ActionName = L"SET_ERROR_TYPE";
205 break;
206 case EFI_ACPI_6_5_EINJ_GET_ERROR_TYPE:
207 ActionName = L"GET_ERROR_TYPE";
208 break;
209 case EFI_ACPI_6_5_EINJ_END_OPERATION:
210 ActionName = L"END_OPERATION";
211 break;
212 case EFI_ACPI_6_5_EINJ_EXECUTE_OPERATION:
213 ActionName = L"EXECUTE_OPERATION";
214 break;
215 case EFI_ACPI_6_5_EINJ_CHECK_BUSY_STATUS:
216 ActionName = L"CHECK_BUSY_STATUS";
217 break;
218 case EFI_ACPI_6_5_EINJ_GET_COMMAND_STATUS:
219 ActionName = L"GET_COMMAND_STATUS";
220 break;
221 case EFI_ACPI_6_5_EINJ_SET_ERROR_TYPE_WITH_ADDRESS:
222 ActionName = L"SET_ERROR_TYPE_WITH_ADDRESS";
223 break;
224 case EFI_ACPI_6_5_EINJ_GET_EXECUTE_OPERATION_TIMINGS:
225 ActionName = L"GET_EXECUTE_OPERATION_TIMINGS";
226 break;
227 case EFI_ACPI_6_5_EINJ_EINJV2_SET_ERROR_TYPE:
228 ActionName = L"EINJV2_SET_ERROR_TYPE";
229 break;
230 case EFI_ACPI_6_5_EINJ_EINJV2_GET_ERROR_TYPE:
231 ActionName = L"EINJV2_GET_ERROR_TYPE";
232 break;
233 case EFI_ACPI_6_5_EINJ_TRIGGER_ERROR:
234 ActionName = L"TRIGGER_ERROR";
235 break;
236 default:
238 ActionName = L"UNKNOWN";
239 }
240
241 Print (L"%s(0x%x)", ActionName, InjectionAction);
242}
243
251STATIC
252VOID
253EFIAPI
255 IN CONST CHAR16 *Format OPTIONAL,
256 IN UINT8 *Ptr,
257 IN UINT32 Length
258 )
259{
260 UINT8 Inst;
261 CONST CHAR16 *InstName;
262
263 Inst = *Ptr;
264
265 if (Inst < ARRAY_SIZE (InstNameTable)) {
266 InstName = InstNameTable[Inst];
267 } else {
269 InstName = L"UNKNOWN";
270 }
271
272 Print (L"%s(0x%x)", InstName, Inst);
273}
274
279 { L"Injection Action", 1, 0, NULL, DumpInjectionInstAction, NULL,
281 { L"Instruction", 1, 1, NULL, DumpInstruction, NULL,
283 { L"Flags", 1, 2, L"0x%x", NULL, NULL,NULL, NULL },
284 { L"Reserved", 1, 3, NULL, NULL, NULL,NULL, NULL },
285 { L"Register Region", 12, 4, NULL, DumpGas, NULL,
287 { L"Value", 8, 16, L"0x%x", NULL, NULL,NULL, NULL },
288 { L"Mask", 8, 24, L"0x%x", NULL, NULL,NULL, NULL },
289};
290
303VOID
304EFIAPI
306 IN BOOLEAN Trace,
307 IN UINT8 *Ptr,
308 IN UINT32 AcpiTableLength,
309 IN UINT8 AcpiTableRevision
310 )
311{
312 UINT32 Offset;
313 UINT8 *InjInstEntryPtr;
314 UINT32 InjInstEntrySize;
315
316 if (!Trace) {
317 return;
318 }
319
320 Offset = ParseAcpi (
321 TRUE,
322 0,
323 "EINJ",
324 Ptr,
325 AcpiTableLength,
327 );
328
329 // Validate Error Source Descriptors Count.
330 if ((mEinjInjectionHdrSize == NULL) || (*mEinjInjectionHdrSize != Offset)) {
332 Print (L"ERROR: Invalid Injection Header...\n");
333 return;
334 }
335
336 if ((mEinjInjectionEntryCnt == NULL) || (*mEinjInjectionEntryCnt == 0)) {
338 Print (L"ERROR: Injection Instruction Entry should be presented...\n");
339 return;
340 }
341
342 InjInstEntrySize = sizeof (EFI_ACPI_6_5_EINJ_INJECTION_INSTRUCTION_ENTRY);
343
344 if ((*mEinjInjectionEntryCnt * InjInstEntrySize) != (AcpiTableLength - Offset)) {
346 Print (
347 L"ERROR: Incorrect count for Injection Instruction Entry.\n" \
348 L" Injection Entry Count= %d.\n" \
349 L" Present Count= %d.\n",
350 *mEinjInjectionEntryCnt,
351 (AcpiTableLength - Offset) / InjInstEntrySize
352 );
353 }
354
355 while (Offset < AcpiTableLength) {
356 InjInstEntryPtr = Ptr + Offset;
357
358 // Get Injection Instruction Entry.
359 ParseAcpi (
360 TRUE,
361 2,
362 "Injection Instruction Entry",
363 InjInstEntryPtr,
364 AcpiTableLength - Offset,
366 );
367
368 Offset += InjInstEntrySize;
369 } // while
370}
#define EFI_ACPI_6_5_EINJ_BEGIN_INJECTION_OPERATION
Definition: Acpi65.h:2447
#define EFI_ACPI_6_5_ERROR_INJECTION_TABLE_REVISION
Definition: Acpi65.h:2442
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 ValidateInjectionAction(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: EinjParser.c:84
STATIC VOID EFIAPI DumpInjectionInstAction(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length)
Definition: EinjParser.c:185
VOID EFIAPI ParseAcpiEinj(IN BOOLEAN Trace, IN UINT8 *Ptr, IN UINT32 AcpiTableLength, IN UINT8 AcpiTableRevision)
Definition: EinjParser.c:305
STATIC CONST ACPI_PARSER EinjParser[]
Definition: EinjParser.c:60
STATIC VOID EFIAPI ValidateRegisterRegion(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: EinjParser.c:157
STATIC CONST ACPI_PARSER EinjInjectionInstEntryParser[]
Definition: EinjParser.c:278
STATIC VOID EFIAPI ValidateInstruction(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: EinjParser.c:127
STATIC VOID EFIAPI DumpInstruction(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length)
Definition: EinjParser.c:254
STATIC VOID EFIAPI ValidateInjectionFlags(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: EinjParser.c:41
#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 ARRAY_SIZE(Array)
Definition: Base.h:1393
#define IN
Definition: Base.h:279
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)
Definition: UefiLibPrint.c:113
UINT8 * Revision
Revision.
Definition: AcpiParser.h:396