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
;
43 // NOTE: We need return everything, because user might need parse the returned object.
45 if ((AmlByteEncoding
->Attribute
& AML_IS_NAME_CHAR
) == 0) {
46 *Buffer
= CurrentBuffer
;
50 DataSize
= AmlGetObjectSize (
53 (UINTN
)AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
- (UINTN
)CurrentBuffer
56 return EFI_INVALID_PARAMETER
;
59 CurrentBuffer
+= DataSize
;
70 Return the child ACPI objects from Root Handle.
72 @param[in] AmlParentHandle Parent handle. It is Root Handle.
73 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
74 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
77 @retval EFI_SUCCESS Success
78 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
82 IN EFI_AML_HANDLE
*AmlParentHandle
,
83 IN EFI_AML_HANDLE
*AmlHandle
,
89 if (AmlHandle
== NULL
) {
93 CurrentBuffer
= (VOID
*)AmlParentHandle
->Buffer
;
95 CurrentBuffer
= (VOID
*)(AmlHandle
->Buffer
+ AmlHandle
->Size
);
98 return AmlGetChildFromObjectBuffer (AmlParentHandle
, CurrentBuffer
, Buffer
);
102 Return the child objects buffer from AML Handle's option list.
104 @param[in] AmlParentHandle Parent handle.
105 @param[in] AmlHandle The current child handle.
106 @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
109 @retval EFI_SUCCESS Success
110 @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
113 AmlGetChildFromOptionList (
114 IN EFI_AML_HANDLE
*AmlParentHandle
,
115 IN EFI_AML_HANDLE
*AmlHandle
,
119 EFI_ACPI_DATA_TYPE DataType
;
122 AML_OP_PARSE_INDEX Index
;
124 AML_OP_PARSE_INDEX MaxTerm
;
126 Index
= AML_OP_PARSE_INDEX_GET_TERM1
;
127 MaxTerm
= AmlParentHandle
->AmlByteEncoding
->MaxIndex
;
128 while (Index
<= MaxTerm
) {
129 Status
= AmlParseOptionHandleCommon (
131 (AML_OP_PARSE_INDEX
)Index
,
136 if (EFI_ERROR (Status
)) {
137 return EFI_INVALID_PARAMETER
;
140 if (DataType
== EFI_ACPI_DATA_TYPE_NONE
) {
148 // Find it, and Check Data
150 if ((DataType
== EFI_ACPI_DATA_TYPE_CHILD
) &&
151 ((UINTN
)AmlHandle
->Buffer
< (UINTN
)Data
))
154 // Buffer < Data means current node is next one
171 Return the child objects buffer from AML Handle's object child list.
173 @param[in] AmlParentHandle Parent handle.
174 @param[in] AmlHandle The current child handle.
175 @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
178 @retval EFI_SUCCESS Success
179 @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
182 AmlGetChildFromObjectChildList (
183 IN EFI_AML_HANDLE
*AmlParentHandle
,
184 IN EFI_AML_HANDLE
*AmlHandle
,
189 UINT8
*CurrentBuffer
;
191 CurrentBuffer
= NULL
;
193 if ((AmlParentHandle
->AmlByteEncoding
->Attribute
& AML_HAS_CHILD_OBJ
) == 0) {
202 // Do we need add node within METHOD?
203 // Yes, just add Object is OK. But we need filter NameString for METHOD invoke.
207 // Now, we get the last node.
209 Status
= AmlGetOffsetAfterLastOption (AmlParentHandle
, &CurrentBuffer
);
210 if (EFI_ERROR (Status
)) {
211 return EFI_INVALID_PARAMETER
;
215 // Go through all the reset buffer.
217 if ((UINTN
)AmlHandle
->Buffer
< (UINTN
)CurrentBuffer
) {
219 // Buffer < Data means next node is first object
221 } else if ((UINTN
)AmlHandle
->Buffer
+ AmlHandle
->Size
< (UINTN
)AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
) {
223 // There is still more node
225 CurrentBuffer
= AmlHandle
->Buffer
+ AmlHandle
->Size
;
234 return AmlGetChildFromObjectBuffer (AmlParentHandle
, CurrentBuffer
, Buffer
);
238 Return the child ACPI objects from Non-Root Handle.
240 @param[in] AmlParentHandle Parent handle. It is Non-Root Handle.
241 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
242 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
245 @retval EFI_SUCCESS Success
246 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
249 AmlGetChildFromNonRoot (
250 IN EFI_AML_HANDLE
*AmlParentHandle
,
251 IN EFI_AML_HANDLE
*AmlHandle
,
257 if (AmlHandle
== NULL
) {
259 // NULL means first one
261 AmlHandle
= AmlParentHandle
;
267 Status
= AmlGetChildFromOptionList (AmlParentHandle
, AmlHandle
, Buffer
);
268 if (EFI_ERROR (Status
)) {
269 return EFI_INVALID_PARAMETER
;
272 if (*Buffer
!= NULL
) {
277 // 2. search ObjectList
279 return AmlGetChildFromObjectChildList (AmlParentHandle
, AmlHandle
, Buffer
);