OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
AcpiParser.h
Go to the documentation of this file.
1
6#ifndef ACPI_PARSER_H
7#define ACPI_PARSER_H
8
9typedef struct {
17 UINT8 *TableStart;
21 UINT8 *TableEnd;
26 UINT32 *PathStart;
36 UINT32 *PathEnd;
40 UINT32 Nesting;
50
51#define IDENT_LEN 4
52#define OPCODE_LEN 8
53#define MAX_NESTING 1024
54
58#define CONTEXT_ENTER(Context, Name) \
59 DEBUG (( \
60 DEBUG_VERBOSE, \
61 "%a 0x%x (looking for %c%c%c%c)\n", \
62 (Name), \
63 (UINT32) ((Context)->CurrentOpcode - (Context)->TableStart), \
64 ((CHAR8 *) (Context)->CurrentIdentifier)[3], \
65 ((CHAR8 *) (Context)->CurrentIdentifier)[2], \
66 ((CHAR8 *) (Context)->CurrentIdentifier)[1], \
67 ((CHAR8 *) (Context)->CurrentIdentifier)[0] \
68 ));
69
70#define PRINT_ACPI_NAME(Str, Name, Length) \
71 DEBUG (( \
72 DEBUG_VERBOSE, \
73 "%a %u (%c%c%c%c)\n", \
74 (Str), \
75 (Length), \
76 (Length) > 0 ? (Name)[((Length) - 1) * 4 + 0] : 'Z', \
77 (Length) > 0 ? (Name)[((Length) - 1) * 4 + 1] : 'Z', \
78 (Length) > 0 ? (Name)[((Length) - 1) * 4 + 2] : 'Z', \
79 (Length) > 0 ? (Name)[((Length) - 1) * 4 + 3] : 'Z' \
80 ));
81
85#define CONTEXT_HAS_WORK(Context) do {\
86 ASSERT ((Context) != NULL); \
87 ASSERT ((Context)->CurrentOpcode != NULL); \
88 ASSERT ((Context)->TableEnd != NULL); \
89 ASSERT ((Context)->CurrentOpcode < (Context)->TableEnd); /* Must always have work to do. */ \
90 ASSERT ((Context)->PathStart != NULL); \
91 ASSERT ((Context)->PathEnd != NULL); \
92 ASSERT ((Context)->CurrentIdentifier != NULL); \
93 ASSERT ((Context)->CurrentIdentifier < (Context)->PathEnd); /* Must always have IDs to parse. */ \
94 ASSERT ((Context)->RequiredEntry > 0); \
95 ASSERT ((Context)->EntriesFound < (Context)->RequiredEntry); /* Must have entries to find. */ \
96 } while (0)
97
101#define CONTEXT_INCREASE_NESTING(Context) do {\
102 ++(Context)->Nesting; \
103 if ((Context)->Nesting > MAX_NESTING) { \
104 return EFI_OUT_OF_RESOURCES; \
105 } \
106 } while (0)
107
112#define CONTEXT_DECREASE_NESTING(Context) do {\
113 ASSERT ((Context)->Nesting > 0); \
114 --(Context)->Nesting; \
115 } while (0)
116
120#define CONTEXT_PEEK_BYTES(Context, Bytes) do {\
121 if ((UINT32) ((Context)->TableEnd - (Context)->CurrentOpcode) < (UINT32) (Bytes)) { \
122 return EFI_DEVICE_ERROR; \
123 } \
124 } while (0)
125
129#define CONTEXT_CONSUME_BYTES(Context, Bytes) do {\
130 if ((UINT32) ((Context)->TableEnd - (Context)->CurrentOpcode) < (UINT32) (Bytes)) { \
131 return EFI_DEVICE_ERROR; \
132 } \
133 (Context)->CurrentOpcode += (Bytes); \
134 } while (0)
135
141#define CONTEXT_ADVANCE_OPCODE(Context) do {\
142 if ((UINT32) ((Context)->TableEnd - (Context)->CurrentOpcode) <= 1U) { \
143 return EFI_DEVICE_ERROR; \
144 } \
145 ++(Context)->CurrentOpcode; \
146 } while (0)
147
160EFI_STATUS
162 IN OUT ACPI_PARSER_CONTEXT *Context,
163 OUT UINT8 **Result
164 );
165
166#endif // ACPI_PARSER_H
EFI_STATUS InternalAcpiParseTerm(IN OUT ACPI_PARSER_CONTEXT *Context, OUT UINT8 **Result)
UINT32 * CurrentIdentifier
Definition AcpiParser.h:32