2 ACPI Sdt Protocol Driver
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 Return the child objects buffer from AML Handle's buffer.
14 @param[in] AmlParentHandle Parent handle.
15 @param[in] CurrentBuffer The current child buffer.
16 @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
19 @retval EFI_SUCCESS Success
20 @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
23 AmlGetChildFromObjectBuffer (
24 IN EFI_AML_HANDLE
*AmlParentHandle
,
25 IN UINT8
*CurrentBuffer
,
29 AML_BYTE_ENCODING
*AmlByteEncoding
;
33 // Root is considered as SCOPE, which has TermList.
34 // We need return only Object in TermList.
36 while ((UINTN
)CurrentBuffer
< (UINTN
)(AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
)) {
37 AmlByteEncoding
= AmlSearchByOpByte (CurrentBuffer
);
38 if (AmlByteEncoding
== NULL
) {
39 return EFI_INVALID_PARAMETER
;
42 // NOTE: We need return everything, because user might need parse the returned object.
44 if ((AmlByteEncoding
->Attribute
& AML_IS_NAME_CHAR
) == 0) {
45 *Buffer
= CurrentBuffer
;
49 DataSize
= AmlGetObjectSize (
52 (UINTN
)AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
- (UINTN
)CurrentBuffer
55 return EFI_INVALID_PARAMETER
;
57 CurrentBuffer
+= DataSize
;
68 Return the child ACPI objects from Root Handle.
70 @param[in] AmlParentHandle Parent handle. It is Root Handle.
71 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
72 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
75 @retval EFI_SUCCESS Success
76 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
80 IN EFI_AML_HANDLE
*AmlParentHandle
,
81 IN EFI_AML_HANDLE
*AmlHandle
,
87 if (AmlHandle
== NULL
) {
91 CurrentBuffer
= (VOID
*)AmlParentHandle
->Buffer
;
93 CurrentBuffer
= (VOID
*)(AmlHandle
->Buffer
+ AmlHandle
->Size
);
96 return AmlGetChildFromObjectBuffer (AmlParentHandle
, CurrentBuffer
, Buffer
);
100 Return the child objects buffer from AML Handle's option list.
102 @param[in] AmlParentHandle Parent handle.
103 @param[in] AmlHandle The current child handle.
104 @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
107 @retval EFI_SUCCESS Success
108 @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
111 AmlGetChildFromOptionList (
112 IN EFI_AML_HANDLE
*AmlParentHandle
,
113 IN EFI_AML_HANDLE
*AmlHandle
,
117 EFI_ACPI_DATA_TYPE DataType
;
120 AML_OP_PARSE_INDEX Index
;
122 AML_OP_PARSE_INDEX MaxTerm
;
124 Index
= AML_OP_PARSE_INDEX_GET_TERM1
;
125 MaxTerm
= AmlParentHandle
->AmlByteEncoding
->MaxIndex
;
126 while (Index
<= MaxTerm
) {
127 Status
= AmlParseOptionHandleCommon (
129 (AML_OP_PARSE_INDEX
)Index
,
134 if (EFI_ERROR (Status
)) {
135 return EFI_INVALID_PARAMETER
;
137 if (DataType
== EFI_ACPI_DATA_TYPE_NONE
) {
145 // Find it, and Check Data
147 if ((DataType
== EFI_ACPI_DATA_TYPE_CHILD
) &&
148 ((UINTN
)AmlHandle
->Buffer
< (UINTN
)Data
)) {
150 // Buffer < Data means current node is next one
166 Return the child objects buffer from AML Handle's object child list.
168 @param[in] AmlParentHandle Parent handle.
169 @param[in] AmlHandle The current child handle.
170 @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
173 @retval EFI_SUCCESS Success
174 @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
177 AmlGetChildFromObjectChildList (
178 IN EFI_AML_HANDLE
*AmlParentHandle
,
179 IN EFI_AML_HANDLE
*AmlHandle
,
184 UINT8
*CurrentBuffer
;
186 CurrentBuffer
= NULL
;
188 if ((AmlParentHandle
->AmlByteEncoding
->Attribute
& AML_HAS_CHILD_OBJ
) == 0) {
197 // Do we need add node within METHOD?
198 // Yes, just add Object is OK. But we need filter NameString for METHOD invoke.
202 // Now, we get the last node.
204 Status
= AmlGetOffsetAfterLastOption (AmlParentHandle
, &CurrentBuffer
);
205 if (EFI_ERROR (Status
)) {
206 return EFI_INVALID_PARAMETER
;
210 // Go through all the reset buffer.
212 if ((UINTN
)AmlHandle
->Buffer
< (UINTN
)CurrentBuffer
) {
214 // Buffer < Data means next node is first object
216 } else if ((UINTN
)AmlHandle
->Buffer
+ AmlHandle
->Size
< (UINTN
)AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
) {
218 // There is still more node
220 CurrentBuffer
= AmlHandle
->Buffer
+ AmlHandle
->Size
;
229 return AmlGetChildFromObjectBuffer (AmlParentHandle
, CurrentBuffer
, Buffer
);
233 Return the child ACPI objects from Non-Root Handle.
235 @param[in] AmlParentHandle Parent handle. It is Non-Root Handle.
236 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
237 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
240 @retval EFI_SUCCESS Success
241 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
244 AmlGetChildFromNonRoot (
245 IN EFI_AML_HANDLE
*AmlParentHandle
,
246 IN EFI_AML_HANDLE
*AmlHandle
,
252 if (AmlHandle
== NULL
) {
254 // NULL means first one
256 AmlHandle
= AmlParentHandle
;
262 Status
= AmlGetChildFromOptionList (AmlParentHandle
, AmlHandle
, Buffer
);
263 if (EFI_ERROR (Status
)) {
264 return EFI_INVALID_PARAMETER
;
266 if (*Buffer
!= NULL
) {
271 // 2. search ObjectList
273 return AmlGetChildFromObjectChildList (AmlParentHandle
, AmlHandle
, Buffer
);