TianoCore EDK2 master
Loading...
Searching...
No Matches
AmlChild.c
Go to the documentation of this file.
1
9#include "AcpiTable.h"
10
24 IN EFI_AML_HANDLE *AmlParentHandle,
25 IN UINT8 *CurrentBuffer,
26 OUT VOID **Buffer
27 )
28{
29 AML_BYTE_ENCODING *AmlByteEncoding;
30 UINTN DataSize;
31
32 //
33 // Root is considered as SCOPE, which has TermList.
34 // We need return only Object in TermList.
35 //
36 while ((UINTN)CurrentBuffer < (UINTN)(AmlParentHandle->Buffer + AmlParentHandle->Size)) {
37 AmlByteEncoding = AmlSearchByOpByte (CurrentBuffer);
38 if (AmlByteEncoding == NULL) {
39 return EFI_INVALID_PARAMETER;
40 }
41
42 //
43 // NOTE: We need return everything, because user might need parse the returned object.
44 //
45 if ((AmlByteEncoding->Attribute & AML_IS_NAME_CHAR) == 0) {
46 *Buffer = CurrentBuffer;
47 return EFI_SUCCESS;
48 }
49
50 DataSize = AmlGetObjectSize (
51 AmlByteEncoding,
52 CurrentBuffer,
53 (UINTN)AmlParentHandle->Buffer + AmlParentHandle->Size - (UINTN)CurrentBuffer
54 );
55 if (DataSize == 0) {
56 return EFI_INVALID_PARAMETER;
57 }
58
59 CurrentBuffer += DataSize;
60 }
61
62 //
63 // No more
64 //
65 *Buffer = NULL;
66 return EFI_SUCCESS;
67}
68
82 IN EFI_AML_HANDLE *AmlParentHandle,
83 IN EFI_AML_HANDLE *AmlHandle,
84 OUT VOID **Buffer
85 )
86{
87 UINT8 *CurrentBuffer;
88
89 if (AmlHandle == NULL) {
90 //
91 // First One
92 //
93 CurrentBuffer = (VOID *)AmlParentHandle->Buffer;
94 } else {
95 CurrentBuffer = (VOID *)(AmlHandle->Buffer + AmlHandle->Size);
96 }
97
98 return AmlGetChildFromObjectBuffer (AmlParentHandle, CurrentBuffer, Buffer);
99}
100
114 IN EFI_AML_HANDLE *AmlParentHandle,
115 IN EFI_AML_HANDLE *AmlHandle,
116 OUT VOID **Buffer
117 )
118{
119 EFI_ACPI_DATA_TYPE DataType;
120 VOID *Data;
121 UINTN DataSize;
122 AML_OP_PARSE_INDEX Index;
123 EFI_STATUS Status;
124 AML_OP_PARSE_INDEX MaxTerm;
125
126 Index = AML_OP_PARSE_INDEX_GET_TERM1;
127 MaxTerm = AmlParentHandle->AmlByteEncoding->MaxIndex;
128 while (Index <= MaxTerm) {
130 AmlParentHandle,
131 (AML_OP_PARSE_INDEX)Index,
132 &DataType,
133 (VOID **)&Data,
134 &DataSize
135 );
136 if (EFI_ERROR (Status)) {
137 return EFI_INVALID_PARAMETER;
138 }
139
140 if (DataType == EFI_ACPI_DATA_TYPE_NONE) {
141 //
142 // Not found
143 //
144 break;
145 }
146
147 //
148 // Find it, and Check Data
149 //
150 if ((DataType == EFI_ACPI_DATA_TYPE_CHILD) &&
151 ((UINTN)AmlHandle->Buffer < (UINTN)Data))
152 {
153 //
154 // Buffer < Data means current node is next one
155 //
156 *Buffer = Data;
157 return EFI_SUCCESS;
158 }
159
160 //
161 // Not Child
162 //
163 Index++;
164 }
165
166 *Buffer = NULL;
167 return EFI_SUCCESS;
168}
169
183 IN EFI_AML_HANDLE *AmlParentHandle,
184 IN EFI_AML_HANDLE *AmlHandle,
185 OUT VOID **Buffer
186 )
187{
188 EFI_STATUS Status;
189 UINT8 *CurrentBuffer;
190
191 CurrentBuffer = NULL;
192
193 if ((AmlParentHandle->AmlByteEncoding->Attribute & AML_HAS_CHILD_OBJ) == 0) {
194 //
195 // No ObjectList
196 //
197 *Buffer = NULL;
198 return EFI_SUCCESS;
199 }
200
201 //
202 // Do we need add node within METHOD?
203 // Yes, just add Object is OK. But we need filter NameString for METHOD invoke.
204 //
205
206 //
207 // Now, we get the last node.
208 //
209 Status = AmlGetOffsetAfterLastOption (AmlParentHandle, &CurrentBuffer);
210 if (EFI_ERROR (Status)) {
211 return EFI_INVALID_PARAMETER;
212 }
213
214 //
215 // Go through all the reset buffer.
216 //
217 if ((UINTN)AmlHandle->Buffer < (UINTN)CurrentBuffer) {
218 //
219 // Buffer < Data means next node is first object
220 //
221 } else if ((UINTN)AmlHandle->Buffer + AmlHandle->Size < (UINTN)AmlParentHandle->Buffer + AmlParentHandle->Size) {
222 //
223 // There is still more node
224 //
225 CurrentBuffer = AmlHandle->Buffer + AmlHandle->Size;
226 } else {
227 //
228 // No more data
229 //
230 *Buffer = NULL;
231 return EFI_SUCCESS;
232 }
233
234 return AmlGetChildFromObjectBuffer (AmlParentHandle, CurrentBuffer, Buffer);
235}
236
250 IN EFI_AML_HANDLE *AmlParentHandle,
251 IN EFI_AML_HANDLE *AmlHandle,
252 OUT VOID **Buffer
253 )
254{
255 EFI_STATUS Status;
256
257 if (AmlHandle == NULL) {
258 //
259 // NULL means first one
260 //
261 AmlHandle = AmlParentHandle;
262 }
263
264 //
265 // 1. Get Option
266 //
267 Status = AmlGetChildFromOptionList (AmlParentHandle, AmlHandle, Buffer);
268 if (EFI_ERROR (Status)) {
269 return EFI_INVALID_PARAMETER;
270 }
271
272 if (*Buffer != NULL) {
273 return EFI_SUCCESS;
274 }
275
276 //
277 // 2. search ObjectList
278 //
279 return AmlGetChildFromObjectChildList (AmlParentHandle, AmlHandle, Buffer);
280}
UINT64 UINTN
UINTN AmlGetObjectSize(IN AML_BYTE_ENCODING *AmlByteEncoding, IN UINT8 *Buffer, IN UINTN MaxBufferSize)
Definition: AmlOption.c:308
EFI_STATUS AmlParseOptionHandleCommon(IN EFI_AML_HANDLE *AmlHandle, IN AML_OP_PARSE_INDEX Index, OUT EFI_ACPI_DATA_TYPE *DataType, OUT VOID **Data, OUT UINTN *DataSize)
Definition: AmlOption.c:449
AML_BYTE_ENCODING * AmlSearchByOpByte(IN UINT8 *OpByteBuffer)
Definition: Aml.c:180
EFI_STATUS AmlGetOffsetAfterLastOption(IN EFI_AML_HANDLE *AmlHandle, OUT UINT8 **Buffer)
Definition: AmlOption.c:398
#define AML_IS_NAME_CHAR
Definition: Aml.h:70
#define AML_HAS_CHILD_OBJ
Definition: Aml.h:75
EFI_STATUS AmlGetChildFromObjectChildList(IN EFI_AML_HANDLE *AmlParentHandle, IN EFI_AML_HANDLE *AmlHandle, OUT VOID **Buffer)
Definition: AmlChild.c:182
EFI_STATUS AmlGetChildFromRoot(IN EFI_AML_HANDLE *AmlParentHandle, IN EFI_AML_HANDLE *AmlHandle, OUT VOID **Buffer)
Definition: AmlChild.c:81
EFI_STATUS AmlGetChildFromOptionList(IN EFI_AML_HANDLE *AmlParentHandle, IN EFI_AML_HANDLE *AmlHandle, OUT VOID **Buffer)
Definition: AmlChild.c:113
EFI_STATUS AmlGetChildFromObjectBuffer(IN EFI_AML_HANDLE *AmlParentHandle, IN UINT8 *CurrentBuffer, OUT VOID **Buffer)
Definition: AmlChild.c:23
EFI_STATUS AmlGetChildFromNonRoot(IN EFI_AML_HANDLE *AmlParentHandle, IN EFI_AML_HANDLE *AmlHandle, OUT VOID **Buffer)
Definition: AmlChild.c:249
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
AML_OP_ATTRIBUTE Attribute
Additional information on the AML object.
Definition: Aml.h:145