2 ACPI Sdt Protocol Driver
4 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "AcpiTable.h"
18 Return the child objects buffer from AML Handle's buffer.
20 @param[in] AmlParentHandle Parent handle.
21 @param[in] CurrentBuffer The current child buffer.
22 @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
25 @retval EFI_SUCCESS Success
26 @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
29 AmlGetChildFromObjectBuffer (
30 IN EFI_AML_HANDLE
*AmlParentHandle
,
31 IN UINT8
*CurrentBuffer
,
35 AML_BYTE_ENCODING
*AmlByteEncoding
;
39 // Root is considered as SCOPE, which has TermList.
40 // We need return only Object in TermList.
42 while ((UINTN
)CurrentBuffer
< (UINTN
)(AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
)) {
43 AmlByteEncoding
= AmlSearchByOpByte (CurrentBuffer
);
44 if (AmlByteEncoding
== NULL
) {
45 return EFI_INVALID_PARAMETER
;
48 // NOTE: We need return everything, because user might need parse the returned object.
50 if ((AmlByteEncoding
->Attribute
& AML_IS_NAME_CHAR
) == 0) {
51 *Buffer
= CurrentBuffer
;
55 DataSize
= AmlGetObjectSize (
58 (UINTN
)AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
- (UINTN
)CurrentBuffer
61 return EFI_INVALID_PARAMETER
;
63 CurrentBuffer
+= DataSize
;
74 Return the child ACPI objects from Root Handle.
76 @param[in] AmlParentHandle Parent handle. It is Root Handle.
77 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
78 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
81 @retval EFI_SUCCESS Success
82 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
86 IN EFI_AML_HANDLE
*AmlParentHandle
,
87 IN EFI_AML_HANDLE
*AmlHandle
,
93 if (AmlHandle
== NULL
) {
97 CurrentBuffer
= (VOID
*)AmlParentHandle
->Buffer
;
99 CurrentBuffer
= (VOID
*)(AmlHandle
->Buffer
+ AmlHandle
->Size
);
102 return AmlGetChildFromObjectBuffer (AmlParentHandle
, CurrentBuffer
, Buffer
);
106 Return the child objects buffer from AML Handle's option list.
108 @param[in] AmlParentHandle Parent handle.
109 @param[in] AmlHandle The current child handle.
110 @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
113 @retval EFI_SUCCESS Success
114 @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
117 AmlGetChildFromOptionList (
118 IN EFI_AML_HANDLE
*AmlParentHandle
,
119 IN EFI_AML_HANDLE
*AmlHandle
,
123 EFI_ACPI_DATA_TYPE DataType
;
126 AML_OP_PARSE_INDEX Index
;
128 AML_OP_PARSE_INDEX MaxTerm
;
130 Index
= AML_OP_PARSE_INDEX_GET_TERM1
;
131 MaxTerm
= AmlParentHandle
->AmlByteEncoding
->MaxIndex
;
132 while (Index
<= MaxTerm
) {
133 Status
= AmlParseOptionHandleCommon (
135 (AML_OP_PARSE_INDEX
)Index
,
140 if (EFI_ERROR (Status
)) {
141 return EFI_INVALID_PARAMETER
;
143 if (DataType
== EFI_ACPI_DATA_TYPE_NONE
) {
151 // Find it, and Check Data
153 if ((DataType
== EFI_ACPI_DATA_TYPE_CHILD
) &&
154 ((UINTN
)AmlHandle
->Buffer
< (UINTN
)Data
)) {
156 // Buffer < Data means current node is next one
172 Return the child objects buffer from AML Handle's object child list.
174 @param[in] AmlParentHandle Parent handle.
175 @param[in] AmlHandle The current child handle.
176 @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
179 @retval EFI_SUCCESS Success
180 @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
183 AmlGetChildFromObjectChildList (
184 IN EFI_AML_HANDLE
*AmlParentHandle
,
185 IN EFI_AML_HANDLE
*AmlHandle
,
190 UINT8
*CurrentBuffer
;
192 CurrentBuffer
= NULL
;
194 if ((AmlParentHandle
->AmlByteEncoding
->Attribute
& AML_HAS_CHILD_OBJ
) == 0) {
203 // Do we need add node within METHOD?
204 // Yes, just add Object is OK. But we need filter NameString for METHOD invoke.
208 // Now, we get the last node.
210 Status
= AmlGetOffsetAfterLastOption (AmlParentHandle
, &CurrentBuffer
);
211 if (EFI_ERROR (Status
)) {
212 return EFI_INVALID_PARAMETER
;
216 // Go through all the reset buffer.
218 if ((UINTN
)AmlHandle
->Buffer
< (UINTN
)CurrentBuffer
) {
220 // Buffer < Data means next node is first object
222 } else if ((UINTN
)AmlHandle
->Buffer
+ AmlHandle
->Size
< (UINTN
)AmlParentHandle
->Buffer
+ AmlParentHandle
->Size
) {
224 // There is still more node
226 CurrentBuffer
= AmlHandle
->Buffer
+ AmlHandle
->Size
;
235 return AmlGetChildFromObjectBuffer (AmlParentHandle
, CurrentBuffer
, Buffer
);
239 Return the child ACPI objects from Non-Root Handle.
241 @param[in] AmlParentHandle Parent handle. It is Non-Root Handle.
242 @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
243 @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
246 @retval EFI_SUCCESS Success
247 @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
250 AmlGetChildFromNonRoot (
251 IN EFI_AML_HANDLE
*AmlParentHandle
,
252 IN EFI_AML_HANDLE
*AmlHandle
,
258 if (AmlHandle
== NULL
) {
260 // NULL means first one
262 AmlHandle
= AmlParentHandle
;
268 Status
= AmlGetChildFromOptionList (AmlParentHandle
, AmlHandle
, Buffer
);
269 if (EFI_ERROR (Status
)) {
270 return EFI_INVALID_PARAMETER
;
272 if (*Buffer
!= NULL
) {
277 // 2. search ObjectList
279 return AmlGetChildFromObjectChildList (AmlParentHandle
, AmlHandle
, Buffer
);