dsutils.c revision 1.1.1.2.4.2 1 1.1.1.2.4.2 rmind /*******************************************************************************
2 1.1.1.2.4.2 rmind *
3 1.1.1.2.4.2 rmind * Module Name: dsutils - Dispatcher utilities
4 1.1.1.2.4.2 rmind *
5 1.1.1.2.4.2 rmind ******************************************************************************/
6 1.1.1.2.4.2 rmind
7 1.1.1.2.4.2 rmind /*
8 1.1.1.2.4.2 rmind * Copyright (C) 2000 - 2011, Intel Corp.
9 1.1.1.2.4.2 rmind * All rights reserved.
10 1.1.1.2.4.2 rmind *
11 1.1.1.2.4.2 rmind * Redistribution and use in source and binary forms, with or without
12 1.1.1.2.4.2 rmind * modification, are permitted provided that the following conditions
13 1.1.1.2.4.2 rmind * are met:
14 1.1.1.2.4.2 rmind * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2.4.2 rmind * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2.4.2 rmind * without modification.
17 1.1.1.2.4.2 rmind * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2.4.2 rmind * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2.4.2 rmind * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2.4.2 rmind * including a substantially similar Disclaimer requirement for further
21 1.1.1.2.4.2 rmind * binary redistribution.
22 1.1.1.2.4.2 rmind * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2.4.2 rmind * of any contributors may be used to endorse or promote products derived
24 1.1.1.2.4.2 rmind * from this software without specific prior written permission.
25 1.1.1.2.4.2 rmind *
26 1.1.1.2.4.2 rmind * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2.4.2 rmind * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2.4.2 rmind * Software Foundation.
29 1.1.1.2.4.2 rmind *
30 1.1.1.2.4.2 rmind * NO WARRANTY
31 1.1.1.2.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2.4.2 rmind * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2.4.2 rmind * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2.4.2 rmind * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2.4.2 rmind * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2.4.2 rmind * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2.4.2 rmind */
43 1.1.1.2.4.2 rmind
44 1.1.1.2.4.2 rmind #define __DSUTILS_C__
45 1.1.1.2.4.2 rmind
46 1.1.1.2.4.2 rmind #include "acpi.h"
47 1.1.1.2.4.2 rmind #include "accommon.h"
48 1.1.1.2.4.2 rmind #include "acparser.h"
49 1.1.1.2.4.2 rmind #include "amlcode.h"
50 1.1.1.2.4.2 rmind #include "acdispat.h"
51 1.1.1.2.4.2 rmind #include "acinterp.h"
52 1.1.1.2.4.2 rmind #include "acnamesp.h"
53 1.1.1.2.4.2 rmind #include "acdebug.h"
54 1.1.1.2.4.2 rmind
55 1.1.1.2.4.2 rmind #define _COMPONENT ACPI_DISPATCHER
56 1.1.1.2.4.2 rmind ACPI_MODULE_NAME ("dsutils")
57 1.1.1.2.4.2 rmind
58 1.1.1.2.4.2 rmind
59 1.1.1.2.4.2 rmind /*******************************************************************************
60 1.1.1.2.4.2 rmind *
61 1.1.1.2.4.2 rmind * FUNCTION: AcpiDsClearImplicitReturn
62 1.1.1.2.4.2 rmind *
63 1.1.1.2.4.2 rmind * PARAMETERS: WalkState - Current State
64 1.1.1.2.4.2 rmind *
65 1.1.1.2.4.2 rmind * RETURN: None.
66 1.1.1.2.4.2 rmind *
67 1.1.1.2.4.2 rmind * DESCRIPTION: Clear and remove a reference on an implicit return value. Used
68 1.1.1.2.4.2 rmind * to delete "stale" return values (if enabled, the return value
69 1.1.1.2.4.2 rmind * from every operator is saved at least momentarily, in case the
70 1.1.1.2.4.2 rmind * parent method exits.)
71 1.1.1.2.4.2 rmind *
72 1.1.1.2.4.2 rmind ******************************************************************************/
73 1.1.1.2.4.2 rmind
74 1.1.1.2.4.2 rmind void
75 1.1.1.2.4.2 rmind AcpiDsClearImplicitReturn (
76 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState)
77 1.1.1.2.4.2 rmind {
78 1.1.1.2.4.2 rmind ACPI_FUNCTION_NAME (DsClearImplicitReturn);
79 1.1.1.2.4.2 rmind
80 1.1.1.2.4.2 rmind
81 1.1.1.2.4.2 rmind /*
82 1.1.1.2.4.2 rmind * Slack must be enabled for this feature
83 1.1.1.2.4.2 rmind */
84 1.1.1.2.4.2 rmind if (!AcpiGbl_EnableInterpreterSlack)
85 1.1.1.2.4.2 rmind {
86 1.1.1.2.4.2 rmind return;
87 1.1.1.2.4.2 rmind }
88 1.1.1.2.4.2 rmind
89 1.1.1.2.4.2 rmind if (WalkState->ImplicitReturnObj)
90 1.1.1.2.4.2 rmind {
91 1.1.1.2.4.2 rmind /*
92 1.1.1.2.4.2 rmind * Delete any "stale" implicit return. However, in
93 1.1.1.2.4.2 rmind * complex statements, the implicit return value can be
94 1.1.1.2.4.2 rmind * bubbled up several levels.
95 1.1.1.2.4.2 rmind */
96 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
97 1.1.1.2.4.2 rmind "Removing reference on stale implicit return obj %p\n",
98 1.1.1.2.4.2 rmind WalkState->ImplicitReturnObj));
99 1.1.1.2.4.2 rmind
100 1.1.1.2.4.2 rmind AcpiUtRemoveReference (WalkState->ImplicitReturnObj);
101 1.1.1.2.4.2 rmind WalkState->ImplicitReturnObj = NULL;
102 1.1.1.2.4.2 rmind }
103 1.1.1.2.4.2 rmind }
104 1.1.1.2.4.2 rmind
105 1.1.1.2.4.2 rmind
106 1.1.1.2.4.2 rmind #ifndef ACPI_NO_METHOD_EXECUTION
107 1.1.1.2.4.2 rmind /*******************************************************************************
108 1.1.1.2.4.2 rmind *
109 1.1.1.2.4.2 rmind * FUNCTION: AcpiDsDoImplicitReturn
110 1.1.1.2.4.2 rmind *
111 1.1.1.2.4.2 rmind * PARAMETERS: ReturnDesc - The return value
112 1.1.1.2.4.2 rmind * WalkState - Current State
113 1.1.1.2.4.2 rmind * AddReference - True if a reference should be added to the
114 1.1.1.2.4.2 rmind * return object
115 1.1.1.2.4.2 rmind *
116 1.1.1.2.4.2 rmind * RETURN: TRUE if implicit return enabled, FALSE otherwise
117 1.1.1.2.4.2 rmind *
118 1.1.1.2.4.2 rmind * DESCRIPTION: Implements the optional "implicit return". We save the result
119 1.1.1.2.4.2 rmind * of every ASL operator and control method invocation in case the
120 1.1.1.2.4.2 rmind * parent method exit. Before storing a new return value, we
121 1.1.1.2.4.2 rmind * delete the previous return value.
122 1.1.1.2.4.2 rmind *
123 1.1.1.2.4.2 rmind ******************************************************************************/
124 1.1.1.2.4.2 rmind
125 1.1.1.2.4.2 rmind BOOLEAN
126 1.1.1.2.4.2 rmind AcpiDsDoImplicitReturn (
127 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *ReturnDesc,
128 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState,
129 1.1.1.2.4.2 rmind BOOLEAN AddReference)
130 1.1.1.2.4.2 rmind {
131 1.1.1.2.4.2 rmind ACPI_FUNCTION_NAME (DsDoImplicitReturn);
132 1.1.1.2.4.2 rmind
133 1.1.1.2.4.2 rmind
134 1.1.1.2.4.2 rmind /*
135 1.1.1.2.4.2 rmind * Slack must be enabled for this feature, and we must
136 1.1.1.2.4.2 rmind * have a valid return object
137 1.1.1.2.4.2 rmind */
138 1.1.1.2.4.2 rmind if ((!AcpiGbl_EnableInterpreterSlack) ||
139 1.1.1.2.4.2 rmind (!ReturnDesc))
140 1.1.1.2.4.2 rmind {
141 1.1.1.2.4.2 rmind return (FALSE);
142 1.1.1.2.4.2 rmind }
143 1.1.1.2.4.2 rmind
144 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
145 1.1.1.2.4.2 rmind "Result %p will be implicitly returned; Prev=%p\n",
146 1.1.1.2.4.2 rmind ReturnDesc,
147 1.1.1.2.4.2 rmind WalkState->ImplicitReturnObj));
148 1.1.1.2.4.2 rmind
149 1.1.1.2.4.2 rmind /*
150 1.1.1.2.4.2 rmind * Delete any "stale" implicit return value first. However, in
151 1.1.1.2.4.2 rmind * complex statements, the implicit return value can be
152 1.1.1.2.4.2 rmind * bubbled up several levels, so we don't clear the value if it
153 1.1.1.2.4.2 rmind * is the same as the ReturnDesc.
154 1.1.1.2.4.2 rmind */
155 1.1.1.2.4.2 rmind if (WalkState->ImplicitReturnObj)
156 1.1.1.2.4.2 rmind {
157 1.1.1.2.4.2 rmind if (WalkState->ImplicitReturnObj == ReturnDesc)
158 1.1.1.2.4.2 rmind {
159 1.1.1.2.4.2 rmind return (TRUE);
160 1.1.1.2.4.2 rmind }
161 1.1.1.2.4.2 rmind AcpiDsClearImplicitReturn (WalkState);
162 1.1.1.2.4.2 rmind }
163 1.1.1.2.4.2 rmind
164 1.1.1.2.4.2 rmind /* Save the implicit return value, add a reference if requested */
165 1.1.1.2.4.2 rmind
166 1.1.1.2.4.2 rmind WalkState->ImplicitReturnObj = ReturnDesc;
167 1.1.1.2.4.2 rmind if (AddReference)
168 1.1.1.2.4.2 rmind {
169 1.1.1.2.4.2 rmind AcpiUtAddReference (ReturnDesc);
170 1.1.1.2.4.2 rmind }
171 1.1.1.2.4.2 rmind
172 1.1.1.2.4.2 rmind return (TRUE);
173 1.1.1.2.4.2 rmind }
174 1.1.1.2.4.2 rmind
175 1.1.1.2.4.2 rmind
176 1.1.1.2.4.2 rmind /*******************************************************************************
177 1.1.1.2.4.2 rmind *
178 1.1.1.2.4.2 rmind * FUNCTION: AcpiDsIsResultUsed
179 1.1.1.2.4.2 rmind *
180 1.1.1.2.4.2 rmind * PARAMETERS: Op - Current Op
181 1.1.1.2.4.2 rmind * WalkState - Current State
182 1.1.1.2.4.2 rmind *
183 1.1.1.2.4.2 rmind * RETURN: TRUE if result is used, FALSE otherwise
184 1.1.1.2.4.2 rmind *
185 1.1.1.2.4.2 rmind * DESCRIPTION: Check if a result object will be used by the parent
186 1.1.1.2.4.2 rmind *
187 1.1.1.2.4.2 rmind ******************************************************************************/
188 1.1.1.2.4.2 rmind
189 1.1.1.2.4.2 rmind BOOLEAN
190 1.1.1.2.4.2 rmind AcpiDsIsResultUsed (
191 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
192 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState)
193 1.1.1.2.4.2 rmind {
194 1.1.1.2.4.2 rmind const ACPI_OPCODE_INFO *ParentInfo;
195 1.1.1.2.4.2 rmind
196 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE_PTR (DsIsResultUsed, Op);
197 1.1.1.2.4.2 rmind
198 1.1.1.2.4.2 rmind
199 1.1.1.2.4.2 rmind /* Must have both an Op and a Result Object */
200 1.1.1.2.4.2 rmind
201 1.1.1.2.4.2 rmind if (!Op)
202 1.1.1.2.4.2 rmind {
203 1.1.1.2.4.2 rmind ACPI_ERROR ((AE_INFO, "Null Op"));
204 1.1.1.2.4.2 rmind return_UINT8 (TRUE);
205 1.1.1.2.4.2 rmind }
206 1.1.1.2.4.2 rmind
207 1.1.1.2.4.2 rmind /*
208 1.1.1.2.4.2 rmind * We know that this operator is not a
209 1.1.1.2.4.2 rmind * Return() operator (would not come here.) The following code is the
210 1.1.1.2.4.2 rmind * optional support for a so-called "implicit return". Some AML code
211 1.1.1.2.4.2 rmind * assumes that the last value of the method is "implicitly" returned
212 1.1.1.2.4.2 rmind * to the caller. Just save the last result as the return value.
213 1.1.1.2.4.2 rmind * NOTE: this is optional because the ASL language does not actually
214 1.1.1.2.4.2 rmind * support this behavior.
215 1.1.1.2.4.2 rmind */
216 1.1.1.2.4.2 rmind (void) AcpiDsDoImplicitReturn (WalkState->ResultObj, WalkState, TRUE);
217 1.1.1.2.4.2 rmind
218 1.1.1.2.4.2 rmind /*
219 1.1.1.2.4.2 rmind * Now determine if the parent will use the result
220 1.1.1.2.4.2 rmind *
221 1.1.1.2.4.2 rmind * If there is no parent, or the parent is a ScopeOp, we are executing
222 1.1.1.2.4.2 rmind * at the method level. An executing method typically has no parent,
223 1.1.1.2.4.2 rmind * since each method is parsed separately. A method invoked externally
224 1.1.1.2.4.2 rmind * via ExecuteControlMethod has a ScopeOp as the parent.
225 1.1.1.2.4.2 rmind */
226 1.1.1.2.4.2 rmind if ((!Op->Common.Parent) ||
227 1.1.1.2.4.2 rmind (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP))
228 1.1.1.2.4.2 rmind {
229 1.1.1.2.4.2 rmind /* No parent, the return value cannot possibly be used */
230 1.1.1.2.4.2 rmind
231 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
232 1.1.1.2.4.2 rmind "At Method level, result of [%s] not used\n",
233 1.1.1.2.4.2 rmind AcpiPsGetOpcodeName (Op->Common.AmlOpcode)));
234 1.1.1.2.4.2 rmind return_UINT8 (FALSE);
235 1.1.1.2.4.2 rmind }
236 1.1.1.2.4.2 rmind
237 1.1.1.2.4.2 rmind /* Get info on the parent. The RootOp is AML_SCOPE */
238 1.1.1.2.4.2 rmind
239 1.1.1.2.4.2 rmind ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
240 1.1.1.2.4.2 rmind if (ParentInfo->Class == AML_CLASS_UNKNOWN)
241 1.1.1.2.4.2 rmind {
242 1.1.1.2.4.2 rmind ACPI_ERROR ((AE_INFO,
243 1.1.1.2.4.2 rmind "Unknown parent opcode Op=%p", Op));
244 1.1.1.2.4.2 rmind return_UINT8 (FALSE);
245 1.1.1.2.4.2 rmind }
246 1.1.1.2.4.2 rmind
247 1.1.1.2.4.2 rmind /*
248 1.1.1.2.4.2 rmind * Decide what to do with the result based on the parent. If
249 1.1.1.2.4.2 rmind * the parent opcode will not use the result, delete the object.
250 1.1.1.2.4.2 rmind * Otherwise leave it as is, it will be deleted when it is used
251 1.1.1.2.4.2 rmind * as an operand later.
252 1.1.1.2.4.2 rmind */
253 1.1.1.2.4.2 rmind switch (ParentInfo->Class)
254 1.1.1.2.4.2 rmind {
255 1.1.1.2.4.2 rmind case AML_CLASS_CONTROL:
256 1.1.1.2.4.2 rmind
257 1.1.1.2.4.2 rmind switch (Op->Common.Parent->Common.AmlOpcode)
258 1.1.1.2.4.2 rmind {
259 1.1.1.2.4.2 rmind case AML_RETURN_OP:
260 1.1.1.2.4.2 rmind
261 1.1.1.2.4.2 rmind /* Never delete the return value associated with a return opcode */
262 1.1.1.2.4.2 rmind
263 1.1.1.2.4.2 rmind goto ResultUsed;
264 1.1.1.2.4.2 rmind
265 1.1.1.2.4.2 rmind case AML_IF_OP:
266 1.1.1.2.4.2 rmind case AML_WHILE_OP:
267 1.1.1.2.4.2 rmind
268 1.1.1.2.4.2 rmind /*
269 1.1.1.2.4.2 rmind * If we are executing the predicate AND this is the predicate op,
270 1.1.1.2.4.2 rmind * we will use the return value
271 1.1.1.2.4.2 rmind */
272 1.1.1.2.4.2 rmind if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) &&
273 1.1.1.2.4.2 rmind (WalkState->ControlState->Control.PredicateOp == Op))
274 1.1.1.2.4.2 rmind {
275 1.1.1.2.4.2 rmind goto ResultUsed;
276 1.1.1.2.4.2 rmind }
277 1.1.1.2.4.2 rmind break;
278 1.1.1.2.4.2 rmind
279 1.1.1.2.4.2 rmind default:
280 1.1.1.2.4.2 rmind /* Ignore other control opcodes */
281 1.1.1.2.4.2 rmind break;
282 1.1.1.2.4.2 rmind }
283 1.1.1.2.4.2 rmind
284 1.1.1.2.4.2 rmind /* The general control opcode returns no result */
285 1.1.1.2.4.2 rmind
286 1.1.1.2.4.2 rmind goto ResultNotUsed;
287 1.1.1.2.4.2 rmind
288 1.1.1.2.4.2 rmind
289 1.1.1.2.4.2 rmind case AML_CLASS_CREATE:
290 1.1.1.2.4.2 rmind
291 1.1.1.2.4.2 rmind /*
292 1.1.1.2.4.2 rmind * These opcodes allow TermArg(s) as operands and therefore
293 1.1.1.2.4.2 rmind * the operands can be method calls. The result is used.
294 1.1.1.2.4.2 rmind */
295 1.1.1.2.4.2 rmind goto ResultUsed;
296 1.1.1.2.4.2 rmind
297 1.1.1.2.4.2 rmind
298 1.1.1.2.4.2 rmind case AML_CLASS_NAMED_OBJECT:
299 1.1.1.2.4.2 rmind
300 1.1.1.2.4.2 rmind if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP) ||
301 1.1.1.2.4.2 rmind (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP) ||
302 1.1.1.2.4.2 rmind (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
303 1.1.1.2.4.2 rmind (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) ||
304 1.1.1.2.4.2 rmind (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP) ||
305 1.1.1.2.4.2 rmind (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP) ||
306 1.1.1.2.4.2 rmind (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP))
307 1.1.1.2.4.2 rmind {
308 1.1.1.2.4.2 rmind /*
309 1.1.1.2.4.2 rmind * These opcodes allow TermArg(s) as operands and therefore
310 1.1.1.2.4.2 rmind * the operands can be method calls. The result is used.
311 1.1.1.2.4.2 rmind */
312 1.1.1.2.4.2 rmind goto ResultUsed;
313 1.1.1.2.4.2 rmind }
314 1.1.1.2.4.2 rmind
315 1.1.1.2.4.2 rmind goto ResultNotUsed;
316 1.1.1.2.4.2 rmind
317 1.1.1.2.4.2 rmind
318 1.1.1.2.4.2 rmind default:
319 1.1.1.2.4.2 rmind
320 1.1.1.2.4.2 rmind /*
321 1.1.1.2.4.2 rmind * In all other cases. the parent will actually use the return
322 1.1.1.2.4.2 rmind * object, so keep it.
323 1.1.1.2.4.2 rmind */
324 1.1.1.2.4.2 rmind goto ResultUsed;
325 1.1.1.2.4.2 rmind }
326 1.1.1.2.4.2 rmind
327 1.1.1.2.4.2 rmind
328 1.1.1.2.4.2 rmind ResultUsed:
329 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
330 1.1.1.2.4.2 rmind "Result of [%s] used by Parent [%s] Op=%p\n",
331 1.1.1.2.4.2 rmind AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
332 1.1.1.2.4.2 rmind AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
333 1.1.1.2.4.2 rmind
334 1.1.1.2.4.2 rmind return_UINT8 (TRUE);
335 1.1.1.2.4.2 rmind
336 1.1.1.2.4.2 rmind
337 1.1.1.2.4.2 rmind ResultNotUsed:
338 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
339 1.1.1.2.4.2 rmind "Result of [%s] not used by Parent [%s] Op=%p\n",
340 1.1.1.2.4.2 rmind AcpiPsGetOpcodeName (Op->Common.AmlOpcode),
341 1.1.1.2.4.2 rmind AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode), Op));
342 1.1.1.2.4.2 rmind
343 1.1.1.2.4.2 rmind return_UINT8 (FALSE);
344 1.1.1.2.4.2 rmind }
345 1.1.1.2.4.2 rmind
346 1.1.1.2.4.2 rmind
347 1.1.1.2.4.2 rmind /*******************************************************************************
348 1.1.1.2.4.2 rmind *
349 1.1.1.2.4.2 rmind * FUNCTION: AcpiDsDeleteResultIfNotUsed
350 1.1.1.2.4.2 rmind *
351 1.1.1.2.4.2 rmind * PARAMETERS: Op - Current parse Op
352 1.1.1.2.4.2 rmind * ResultObj - Result of the operation
353 1.1.1.2.4.2 rmind * WalkState - Current state
354 1.1.1.2.4.2 rmind *
355 1.1.1.2.4.2 rmind * RETURN: Status
356 1.1.1.2.4.2 rmind *
357 1.1.1.2.4.2 rmind * DESCRIPTION: Used after interpretation of an opcode. If there is an internal
358 1.1.1.2.4.2 rmind * result descriptor, check if the parent opcode will actually use
359 1.1.1.2.4.2 rmind * this result. If not, delete the result now so that it will
360 1.1.1.2.4.2 rmind * not become orphaned.
361 1.1.1.2.4.2 rmind *
362 1.1.1.2.4.2 rmind ******************************************************************************/
363 1.1.1.2.4.2 rmind
364 1.1.1.2.4.2 rmind void
365 1.1.1.2.4.2 rmind AcpiDsDeleteResultIfNotUsed (
366 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op,
367 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *ResultObj,
368 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState)
369 1.1.1.2.4.2 rmind {
370 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *ObjDesc;
371 1.1.1.2.4.2 rmind ACPI_STATUS Status;
372 1.1.1.2.4.2 rmind
373 1.1.1.2.4.2 rmind
374 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE_PTR (DsDeleteResultIfNotUsed, ResultObj);
375 1.1.1.2.4.2 rmind
376 1.1.1.2.4.2 rmind
377 1.1.1.2.4.2 rmind if (!Op)
378 1.1.1.2.4.2 rmind {
379 1.1.1.2.4.2 rmind ACPI_ERROR ((AE_INFO, "Null Op"));
380 1.1.1.2.4.2 rmind return_VOID;
381 1.1.1.2.4.2 rmind }
382 1.1.1.2.4.2 rmind
383 1.1.1.2.4.2 rmind if (!ResultObj)
384 1.1.1.2.4.2 rmind {
385 1.1.1.2.4.2 rmind return_VOID;
386 1.1.1.2.4.2 rmind }
387 1.1.1.2.4.2 rmind
388 1.1.1.2.4.2 rmind if (!AcpiDsIsResultUsed (Op, WalkState))
389 1.1.1.2.4.2 rmind {
390 1.1.1.2.4.2 rmind /* Must pop the result stack (ObjDesc should be equal to ResultObj) */
391 1.1.1.2.4.2 rmind
392 1.1.1.2.4.2 rmind Status = AcpiDsResultPop (&ObjDesc, WalkState);
393 1.1.1.2.4.2 rmind if (ACPI_SUCCESS (Status))
394 1.1.1.2.4.2 rmind {
395 1.1.1.2.4.2 rmind AcpiUtRemoveReference (ResultObj);
396 1.1.1.2.4.2 rmind }
397 1.1.1.2.4.2 rmind }
398 1.1.1.2.4.2 rmind
399 1.1.1.2.4.2 rmind return_VOID;
400 1.1.1.2.4.2 rmind }
401 1.1.1.2.4.2 rmind
402 1.1.1.2.4.2 rmind
403 1.1.1.2.4.2 rmind /*******************************************************************************
404 1.1.1.2.4.2 rmind *
405 1.1.1.2.4.2 rmind * FUNCTION: AcpiDsResolveOperands
406 1.1.1.2.4.2 rmind *
407 1.1.1.2.4.2 rmind * PARAMETERS: WalkState - Current walk state with operands on stack
408 1.1.1.2.4.2 rmind *
409 1.1.1.2.4.2 rmind * RETURN: Status
410 1.1.1.2.4.2 rmind *
411 1.1.1.2.4.2 rmind * DESCRIPTION: Resolve all operands to their values. Used to prepare
412 1.1.1.2.4.2 rmind * arguments to a control method invocation (a call from one
413 1.1.1.2.4.2 rmind * method to another.)
414 1.1.1.2.4.2 rmind *
415 1.1.1.2.4.2 rmind ******************************************************************************/
416 1.1.1.2.4.2 rmind
417 1.1.1.2.4.2 rmind ACPI_STATUS
418 1.1.1.2.4.2 rmind AcpiDsResolveOperands (
419 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState)
420 1.1.1.2.4.2 rmind {
421 1.1.1.2.4.2 rmind UINT32 i;
422 1.1.1.2.4.2 rmind ACPI_STATUS Status = AE_OK;
423 1.1.1.2.4.2 rmind
424 1.1.1.2.4.2 rmind
425 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE_PTR (DsResolveOperands, WalkState);
426 1.1.1.2.4.2 rmind
427 1.1.1.2.4.2 rmind
428 1.1.1.2.4.2 rmind /*
429 1.1.1.2.4.2 rmind * Attempt to resolve each of the valid operands
430 1.1.1.2.4.2 rmind * Method arguments are passed by reference, not by value. This means
431 1.1.1.2.4.2 rmind * that the actual objects are passed, not copies of the objects.
432 1.1.1.2.4.2 rmind */
433 1.1.1.2.4.2 rmind for (i = 0; i < WalkState->NumOperands; i++)
434 1.1.1.2.4.2 rmind {
435 1.1.1.2.4.2 rmind Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState);
436 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
437 1.1.1.2.4.2 rmind {
438 1.1.1.2.4.2 rmind break;
439 1.1.1.2.4.2 rmind }
440 1.1.1.2.4.2 rmind }
441 1.1.1.2.4.2 rmind
442 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
443 1.1.1.2.4.2 rmind }
444 1.1.1.2.4.2 rmind
445 1.1.1.2.4.2 rmind
446 1.1.1.2.4.2 rmind /*******************************************************************************
447 1.1.1.2.4.2 rmind *
448 1.1.1.2.4.2 rmind * FUNCTION: AcpiDsClearOperands
449 1.1.1.2.4.2 rmind *
450 1.1.1.2.4.2 rmind * PARAMETERS: WalkState - Current walk state with operands on stack
451 1.1.1.2.4.2 rmind *
452 1.1.1.2.4.2 rmind * RETURN: None
453 1.1.1.2.4.2 rmind *
454 1.1.1.2.4.2 rmind * DESCRIPTION: Clear all operands on the current walk state operand stack.
455 1.1.1.2.4.2 rmind *
456 1.1.1.2.4.2 rmind ******************************************************************************/
457 1.1.1.2.4.2 rmind
458 1.1.1.2.4.2 rmind void
459 1.1.1.2.4.2 rmind AcpiDsClearOperands (
460 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState)
461 1.1.1.2.4.2 rmind {
462 1.1.1.2.4.2 rmind UINT32 i;
463 1.1.1.2.4.2 rmind
464 1.1.1.2.4.2 rmind
465 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE_PTR (DsClearOperands, WalkState);
466 1.1.1.2.4.2 rmind
467 1.1.1.2.4.2 rmind
468 1.1.1.2.4.2 rmind /* Remove a reference on each operand on the stack */
469 1.1.1.2.4.2 rmind
470 1.1.1.2.4.2 rmind for (i = 0; i < WalkState->NumOperands; i++)
471 1.1.1.2.4.2 rmind {
472 1.1.1.2.4.2 rmind /*
473 1.1.1.2.4.2 rmind * Remove a reference to all operands, including both
474 1.1.1.2.4.2 rmind * "Arguments" and "Targets".
475 1.1.1.2.4.2 rmind */
476 1.1.1.2.4.2 rmind AcpiUtRemoveReference (WalkState->Operands[i]);
477 1.1.1.2.4.2 rmind WalkState->Operands[i] = NULL;
478 1.1.1.2.4.2 rmind }
479 1.1.1.2.4.2 rmind
480 1.1.1.2.4.2 rmind WalkState->NumOperands = 0;
481 1.1.1.2.4.2 rmind return_VOID;
482 1.1.1.2.4.2 rmind }
483 1.1.1.2.4.2 rmind #endif
484 1.1.1.2.4.2 rmind
485 1.1.1.2.4.2 rmind
486 1.1.1.2.4.2 rmind /*******************************************************************************
487 1.1.1.2.4.2 rmind *
488 1.1.1.2.4.2 rmind * FUNCTION: AcpiDsCreateOperand
489 1.1.1.2.4.2 rmind *
490 1.1.1.2.4.2 rmind * PARAMETERS: WalkState - Current walk state
491 1.1.1.2.4.2 rmind * Arg - Parse object for the argument
492 1.1.1.2.4.2 rmind * ArgIndex - Which argument (zero based)
493 1.1.1.2.4.2 rmind *
494 1.1.1.2.4.2 rmind * RETURN: Status
495 1.1.1.2.4.2 rmind *
496 1.1.1.2.4.2 rmind * DESCRIPTION: Translate a parse tree object that is an argument to an AML
497 1.1.1.2.4.2 rmind * opcode to the equivalent interpreter object. This may include
498 1.1.1.2.4.2 rmind * looking up a name or entering a new name into the internal
499 1.1.1.2.4.2 rmind * namespace.
500 1.1.1.2.4.2 rmind *
501 1.1.1.2.4.2 rmind ******************************************************************************/
502 1.1.1.2.4.2 rmind
503 1.1.1.2.4.2 rmind ACPI_STATUS
504 1.1.1.2.4.2 rmind AcpiDsCreateOperand (
505 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState,
506 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Arg,
507 1.1.1.2.4.2 rmind UINT32 ArgIndex)
508 1.1.1.2.4.2 rmind {
509 1.1.1.2.4.2 rmind ACPI_STATUS Status = AE_OK;
510 1.1.1.2.4.2 rmind char *NameString;
511 1.1.1.2.4.2 rmind UINT32 NameLength;
512 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *ObjDesc;
513 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *ParentOp;
514 1.1.1.2.4.2 rmind UINT16 Opcode;
515 1.1.1.2.4.2 rmind ACPI_INTERPRETER_MODE InterpreterMode;
516 1.1.1.2.4.2 rmind const ACPI_OPCODE_INFO *OpInfo;
517 1.1.1.2.4.2 rmind
518 1.1.1.2.4.2 rmind
519 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE_PTR (DsCreateOperand, Arg);
520 1.1.1.2.4.2 rmind
521 1.1.1.2.4.2 rmind
522 1.1.1.2.4.2 rmind /* A valid name must be looked up in the namespace */
523 1.1.1.2.4.2 rmind
524 1.1.1.2.4.2 rmind if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
525 1.1.1.2.4.2 rmind (Arg->Common.Value.String) &&
526 1.1.1.2.4.2 rmind !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK))
527 1.1.1.2.4.2 rmind {
528 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", Arg));
529 1.1.1.2.4.2 rmind
530 1.1.1.2.4.2 rmind /* Get the entire name string from the AML stream */
531 1.1.1.2.4.2 rmind
532 1.1.1.2.4.2 rmind Status = AcpiExGetNameString (ACPI_TYPE_ANY, Arg->Common.Value.Buffer,
533 1.1.1.2.4.2 rmind &NameString, &NameLength);
534 1.1.1.2.4.2 rmind
535 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
536 1.1.1.2.4.2 rmind {
537 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
538 1.1.1.2.4.2 rmind }
539 1.1.1.2.4.2 rmind
540 1.1.1.2.4.2 rmind /* All prefixes have been handled, and the name is in NameString */
541 1.1.1.2.4.2 rmind
542 1.1.1.2.4.2 rmind /*
543 1.1.1.2.4.2 rmind * Special handling for BufferField declarations. This is a deferred
544 1.1.1.2.4.2 rmind * opcode that unfortunately defines the field name as the last
545 1.1.1.2.4.2 rmind * parameter instead of the first. We get here when we are performing
546 1.1.1.2.4.2 rmind * the deferred execution, so the actual name of the field is already
547 1.1.1.2.4.2 rmind * in the namespace. We don't want to attempt to look it up again
548 1.1.1.2.4.2 rmind * because we may be executing in a different scope than where the
549 1.1.1.2.4.2 rmind * actual opcode exists.
550 1.1.1.2.4.2 rmind */
551 1.1.1.2.4.2 rmind if ((WalkState->DeferredNode) &&
552 1.1.1.2.4.2 rmind (WalkState->DeferredNode->Type == ACPI_TYPE_BUFFER_FIELD) &&
553 1.1.1.2.4.2 rmind (ArgIndex == (UINT32) ((WalkState->Opcode == AML_CREATE_FIELD_OP) ? 3 : 2)))
554 1.1.1.2.4.2 rmind {
555 1.1.1.2.4.2 rmind ObjDesc = ACPI_CAST_PTR (
556 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT, WalkState->DeferredNode);
557 1.1.1.2.4.2 rmind Status = AE_OK;
558 1.1.1.2.4.2 rmind }
559 1.1.1.2.4.2 rmind else /* All other opcodes */
560 1.1.1.2.4.2 rmind {
561 1.1.1.2.4.2 rmind /*
562 1.1.1.2.4.2 rmind * Differentiate between a namespace "create" operation
563 1.1.1.2.4.2 rmind * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
564 1.1.1.2.4.2 rmind * IMODE_EXECUTE) in order to support the creation of
565 1.1.1.2.4.2 rmind * namespace objects during the execution of control methods.
566 1.1.1.2.4.2 rmind */
567 1.1.1.2.4.2 rmind ParentOp = Arg->Common.Parent;
568 1.1.1.2.4.2 rmind OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode);
569 1.1.1.2.4.2 rmind if ((OpInfo->Flags & AML_NSNODE) &&
570 1.1.1.2.4.2 rmind (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) &&
571 1.1.1.2.4.2 rmind (ParentOp->Common.AmlOpcode != AML_REGION_OP) &&
572 1.1.1.2.4.2 rmind (ParentOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP))
573 1.1.1.2.4.2 rmind {
574 1.1.1.2.4.2 rmind /* Enter name into namespace if not found */
575 1.1.1.2.4.2 rmind
576 1.1.1.2.4.2 rmind InterpreterMode = ACPI_IMODE_LOAD_PASS2;
577 1.1.1.2.4.2 rmind }
578 1.1.1.2.4.2 rmind else
579 1.1.1.2.4.2 rmind {
580 1.1.1.2.4.2 rmind /* Return a failure if name not found */
581 1.1.1.2.4.2 rmind
582 1.1.1.2.4.2 rmind InterpreterMode = ACPI_IMODE_EXECUTE;
583 1.1.1.2.4.2 rmind }
584 1.1.1.2.4.2 rmind
585 1.1.1.2.4.2 rmind Status = AcpiNsLookup (WalkState->ScopeInfo, NameString,
586 1.1.1.2.4.2 rmind ACPI_TYPE_ANY, InterpreterMode,
587 1.1.1.2.4.2 rmind ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
588 1.1.1.2.4.2 rmind WalkState,
589 1.1.1.2.4.2 rmind ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc));
590 1.1.1.2.4.2 rmind /*
591 1.1.1.2.4.2 rmind * The only case where we pass through (ignore) a NOT_FOUND
592 1.1.1.2.4.2 rmind * error is for the CondRefOf opcode.
593 1.1.1.2.4.2 rmind */
594 1.1.1.2.4.2 rmind if (Status == AE_NOT_FOUND)
595 1.1.1.2.4.2 rmind {
596 1.1.1.2.4.2 rmind if (ParentOp->Common.AmlOpcode == AML_COND_REF_OF_OP)
597 1.1.1.2.4.2 rmind {
598 1.1.1.2.4.2 rmind /*
599 1.1.1.2.4.2 rmind * For the Conditional Reference op, it's OK if
600 1.1.1.2.4.2 rmind * the name is not found; We just need a way to
601 1.1.1.2.4.2 rmind * indicate this to the interpreter, set the
602 1.1.1.2.4.2 rmind * object to the root
603 1.1.1.2.4.2 rmind */
604 1.1.1.2.4.2 rmind ObjDesc = ACPI_CAST_PTR (
605 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT, AcpiGbl_RootNode);
606 1.1.1.2.4.2 rmind Status = AE_OK;
607 1.1.1.2.4.2 rmind }
608 1.1.1.2.4.2 rmind else
609 1.1.1.2.4.2 rmind {
610 1.1.1.2.4.2 rmind /*
611 1.1.1.2.4.2 rmind * We just plain didn't find it -- which is a
612 1.1.1.2.4.2 rmind * very serious error at this point
613 1.1.1.2.4.2 rmind */
614 1.1.1.2.4.2 rmind Status = AE_AML_NAME_NOT_FOUND;
615 1.1.1.2.4.2 rmind }
616 1.1.1.2.4.2 rmind }
617 1.1.1.2.4.2 rmind
618 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
619 1.1.1.2.4.2 rmind {
620 1.1.1.2.4.2 rmind ACPI_ERROR_NAMESPACE (NameString, Status);
621 1.1.1.2.4.2 rmind }
622 1.1.1.2.4.2 rmind }
623 1.1.1.2.4.2 rmind
624 1.1.1.2.4.2 rmind /* Free the namestring created above */
625 1.1.1.2.4.2 rmind
626 1.1.1.2.4.2 rmind ACPI_FREE (NameString);
627 1.1.1.2.4.2 rmind
628 1.1.1.2.4.2 rmind /* Check status from the lookup */
629 1.1.1.2.4.2 rmind
630 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
631 1.1.1.2.4.2 rmind {
632 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
633 1.1.1.2.4.2 rmind }
634 1.1.1.2.4.2 rmind
635 1.1.1.2.4.2 rmind /* Put the resulting object onto the current object stack */
636 1.1.1.2.4.2 rmind
637 1.1.1.2.4.2 rmind Status = AcpiDsObjStackPush (ObjDesc, WalkState);
638 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
639 1.1.1.2.4.2 rmind {
640 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
641 1.1.1.2.4.2 rmind }
642 1.1.1.2.4.2 rmind ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
643 1.1.1.2.4.2 rmind }
644 1.1.1.2.4.2 rmind else
645 1.1.1.2.4.2 rmind {
646 1.1.1.2.4.2 rmind /* Check for null name case */
647 1.1.1.2.4.2 rmind
648 1.1.1.2.4.2 rmind if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
649 1.1.1.2.4.2 rmind !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK))
650 1.1.1.2.4.2 rmind {
651 1.1.1.2.4.2 rmind /*
652 1.1.1.2.4.2 rmind * If the name is null, this means that this is an
653 1.1.1.2.4.2 rmind * optional result parameter that was not specified
654 1.1.1.2.4.2 rmind * in the original ASL. Create a Zero Constant for a
655 1.1.1.2.4.2 rmind * placeholder. (Store to a constant is a Noop.)
656 1.1.1.2.4.2 rmind */
657 1.1.1.2.4.2 rmind Opcode = AML_ZERO_OP; /* Has no arguments! */
658 1.1.1.2.4.2 rmind
659 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
660 1.1.1.2.4.2 rmind "Null namepath: Arg=%p\n", Arg));
661 1.1.1.2.4.2 rmind }
662 1.1.1.2.4.2 rmind else
663 1.1.1.2.4.2 rmind {
664 1.1.1.2.4.2 rmind Opcode = Arg->Common.AmlOpcode;
665 1.1.1.2.4.2 rmind }
666 1.1.1.2.4.2 rmind
667 1.1.1.2.4.2 rmind /* Get the object type of the argument */
668 1.1.1.2.4.2 rmind
669 1.1.1.2.4.2 rmind OpInfo = AcpiPsGetOpcodeInfo (Opcode);
670 1.1.1.2.4.2 rmind if (OpInfo->ObjectType == ACPI_TYPE_INVALID)
671 1.1.1.2.4.2 rmind {
672 1.1.1.2.4.2 rmind return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
673 1.1.1.2.4.2 rmind }
674 1.1.1.2.4.2 rmind
675 1.1.1.2.4.2 rmind if ((OpInfo->Flags & AML_HAS_RETVAL) || (Arg->Common.Flags & ACPI_PARSEOP_IN_STACK))
676 1.1.1.2.4.2 rmind {
677 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
678 1.1.1.2.4.2 rmind "Argument previously created, already stacked\n"));
679 1.1.1.2.4.2 rmind
680 1.1.1.2.4.2 rmind ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (
681 1.1.1.2.4.2 rmind WalkState->Operands [WalkState->NumOperands - 1], WalkState));
682 1.1.1.2.4.2 rmind
683 1.1.1.2.4.2 rmind /*
684 1.1.1.2.4.2 rmind * Use value that was already previously returned
685 1.1.1.2.4.2 rmind * by the evaluation of this argument
686 1.1.1.2.4.2 rmind */
687 1.1.1.2.4.2 rmind Status = AcpiDsResultPop (&ObjDesc, WalkState);
688 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
689 1.1.1.2.4.2 rmind {
690 1.1.1.2.4.2 rmind /*
691 1.1.1.2.4.2 rmind * Only error is underflow, and this indicates
692 1.1.1.2.4.2 rmind * a missing or null operand!
693 1.1.1.2.4.2 rmind */
694 1.1.1.2.4.2 rmind ACPI_EXCEPTION ((AE_INFO, Status,
695 1.1.1.2.4.2 rmind "Missing or null operand"));
696 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
697 1.1.1.2.4.2 rmind }
698 1.1.1.2.4.2 rmind }
699 1.1.1.2.4.2 rmind else
700 1.1.1.2.4.2 rmind {
701 1.1.1.2.4.2 rmind /* Create an ACPI_INTERNAL_OBJECT for the argument */
702 1.1.1.2.4.2 rmind
703 1.1.1.2.4.2 rmind ObjDesc = AcpiUtCreateInternalObject (OpInfo->ObjectType);
704 1.1.1.2.4.2 rmind if (!ObjDesc)
705 1.1.1.2.4.2 rmind {
706 1.1.1.2.4.2 rmind return_ACPI_STATUS (AE_NO_MEMORY);
707 1.1.1.2.4.2 rmind }
708 1.1.1.2.4.2 rmind
709 1.1.1.2.4.2 rmind /* Initialize the new object */
710 1.1.1.2.4.2 rmind
711 1.1.1.2.4.2 rmind Status = AcpiDsInitObjectFromOp (
712 1.1.1.2.4.2 rmind WalkState, Arg, Opcode, &ObjDesc);
713 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
714 1.1.1.2.4.2 rmind {
715 1.1.1.2.4.2 rmind AcpiUtDeleteObjectDesc (ObjDesc);
716 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
717 1.1.1.2.4.2 rmind }
718 1.1.1.2.4.2 rmind }
719 1.1.1.2.4.2 rmind
720 1.1.1.2.4.2 rmind /* Put the operand object on the object stack */
721 1.1.1.2.4.2 rmind
722 1.1.1.2.4.2 rmind Status = AcpiDsObjStackPush (ObjDesc, WalkState);
723 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
724 1.1.1.2.4.2 rmind {
725 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
726 1.1.1.2.4.2 rmind }
727 1.1.1.2.4.2 rmind
728 1.1.1.2.4.2 rmind ACPI_DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState));
729 1.1.1.2.4.2 rmind }
730 1.1.1.2.4.2 rmind
731 1.1.1.2.4.2 rmind return_ACPI_STATUS (AE_OK);
732 1.1.1.2.4.2 rmind }
733 1.1.1.2.4.2 rmind
734 1.1.1.2.4.2 rmind
735 1.1.1.2.4.2 rmind /*******************************************************************************
736 1.1.1.2.4.2 rmind *
737 1.1.1.2.4.2 rmind * FUNCTION: AcpiDsCreateOperands
738 1.1.1.2.4.2 rmind *
739 1.1.1.2.4.2 rmind * PARAMETERS: WalkState - Current state
740 1.1.1.2.4.2 rmind * FirstArg - First argument of a parser argument tree
741 1.1.1.2.4.2 rmind *
742 1.1.1.2.4.2 rmind * RETURN: Status
743 1.1.1.2.4.2 rmind *
744 1.1.1.2.4.2 rmind * DESCRIPTION: Convert an operator's arguments from a parse tree format to
745 1.1.1.2.4.2 rmind * namespace objects and place those argument object on the object
746 1.1.1.2.4.2 rmind * stack in preparation for evaluation by the interpreter.
747 1.1.1.2.4.2 rmind *
748 1.1.1.2.4.2 rmind ******************************************************************************/
749 1.1.1.2.4.2 rmind
750 1.1.1.2.4.2 rmind ACPI_STATUS
751 1.1.1.2.4.2 rmind AcpiDsCreateOperands (
752 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState,
753 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *FirstArg)
754 1.1.1.2.4.2 rmind {
755 1.1.1.2.4.2 rmind ACPI_STATUS Status = AE_OK;
756 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Arg;
757 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Arguments[ACPI_OBJ_NUM_OPERANDS];
758 1.1.1.2.4.2 rmind UINT32 ArgCount = 0;
759 1.1.1.2.4.2 rmind UINT32 Index = WalkState->NumOperands;
760 1.1.1.2.4.2 rmind UINT32 i;
761 1.1.1.2.4.2 rmind
762 1.1.1.2.4.2 rmind
763 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE_PTR (DsCreateOperands, FirstArg);
764 1.1.1.2.4.2 rmind
765 1.1.1.2.4.2 rmind
766 1.1.1.2.4.2 rmind /* Get all arguments in the list */
767 1.1.1.2.4.2 rmind
768 1.1.1.2.4.2 rmind Arg = FirstArg;
769 1.1.1.2.4.2 rmind while (Arg)
770 1.1.1.2.4.2 rmind {
771 1.1.1.2.4.2 rmind if (Index >= ACPI_OBJ_NUM_OPERANDS)
772 1.1.1.2.4.2 rmind {
773 1.1.1.2.4.2 rmind return_ACPI_STATUS (AE_BAD_DATA);
774 1.1.1.2.4.2 rmind }
775 1.1.1.2.4.2 rmind
776 1.1.1.2.4.2 rmind Arguments[Index] = Arg;
777 1.1.1.2.4.2 rmind WalkState->Operands [Index] = NULL;
778 1.1.1.2.4.2 rmind
779 1.1.1.2.4.2 rmind /* Move on to next argument, if any */
780 1.1.1.2.4.2 rmind
781 1.1.1.2.4.2 rmind Arg = Arg->Common.Next;
782 1.1.1.2.4.2 rmind ArgCount++;
783 1.1.1.2.4.2 rmind Index++;
784 1.1.1.2.4.2 rmind }
785 1.1.1.2.4.2 rmind
786 1.1.1.2.4.2 rmind Index--;
787 1.1.1.2.4.2 rmind
788 1.1.1.2.4.2 rmind /* It is the appropriate order to get objects from the Result stack */
789 1.1.1.2.4.2 rmind
790 1.1.1.2.4.2 rmind for (i = 0; i < ArgCount; i++)
791 1.1.1.2.4.2 rmind {
792 1.1.1.2.4.2 rmind Arg = Arguments[Index];
793 1.1.1.2.4.2 rmind
794 1.1.1.2.4.2 rmind /* Force the filling of the operand stack in inverse order */
795 1.1.1.2.4.2 rmind
796 1.1.1.2.4.2 rmind WalkState->OperandIndex = (UINT8) Index;
797 1.1.1.2.4.2 rmind
798 1.1.1.2.4.2 rmind Status = AcpiDsCreateOperand (WalkState, Arg, Index);
799 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
800 1.1.1.2.4.2 rmind {
801 1.1.1.2.4.2 rmind goto Cleanup;
802 1.1.1.2.4.2 rmind }
803 1.1.1.2.4.2 rmind
804 1.1.1.2.4.2 rmind Index--;
805 1.1.1.2.4.2 rmind
806 1.1.1.2.4.2 rmind ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%u (%p) done, Arg1=%p\n",
807 1.1.1.2.4.2 rmind Index, Arg, FirstArg));
808 1.1.1.2.4.2 rmind }
809 1.1.1.2.4.2 rmind
810 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
811 1.1.1.2.4.2 rmind
812 1.1.1.2.4.2 rmind
813 1.1.1.2.4.2 rmind Cleanup:
814 1.1.1.2.4.2 rmind /*
815 1.1.1.2.4.2 rmind * We must undo everything done above; meaning that we must
816 1.1.1.2.4.2 rmind * pop everything off of the operand stack and delete those
817 1.1.1.2.4.2 rmind * objects
818 1.1.1.2.4.2 rmind */
819 1.1.1.2.4.2 rmind AcpiDsObjStackPopAndDelete (ArgCount, WalkState);
820 1.1.1.2.4.2 rmind
821 1.1.1.2.4.2 rmind ACPI_EXCEPTION ((AE_INFO, Status, "While creating Arg %u", Index));
822 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
823 1.1.1.2.4.2 rmind }
824 1.1.1.2.4.2 rmind
825 1.1.1.2.4.2 rmind
826 1.1.1.2.4.2 rmind /*****************************************************************************
827 1.1.1.2.4.2 rmind *
828 1.1.1.2.4.2 rmind * FUNCTION: AcpiDsEvaluateNamePath
829 1.1.1.2.4.2 rmind *
830 1.1.1.2.4.2 rmind * PARAMETERS: WalkState - Current state of the parse tree walk,
831 1.1.1.2.4.2 rmind * the opcode of current operation should be
832 1.1.1.2.4.2 rmind * AML_INT_NAMEPATH_OP
833 1.1.1.2.4.2 rmind *
834 1.1.1.2.4.2 rmind * RETURN: Status
835 1.1.1.2.4.2 rmind *
836 1.1.1.2.4.2 rmind * DESCRIPTION: Translate the -NamePath- parse tree object to the equivalent
837 1.1.1.2.4.2 rmind * interpreter object, convert it to value, if needed, duplicate
838 1.1.1.2.4.2 rmind * it, if needed, and push it onto the current result stack.
839 1.1.1.2.4.2 rmind *
840 1.1.1.2.4.2 rmind ****************************************************************************/
841 1.1.1.2.4.2 rmind
842 1.1.1.2.4.2 rmind ACPI_STATUS
843 1.1.1.2.4.2 rmind AcpiDsEvaluateNamePath (
844 1.1.1.2.4.2 rmind ACPI_WALK_STATE *WalkState)
845 1.1.1.2.4.2 rmind {
846 1.1.1.2.4.2 rmind ACPI_STATUS Status = AE_OK;
847 1.1.1.2.4.2 rmind ACPI_PARSE_OBJECT *Op = WalkState->Op;
848 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
849 1.1.1.2.4.2 rmind ACPI_OPERAND_OBJECT *NewObjDesc;
850 1.1.1.2.4.2 rmind UINT8 Type;
851 1.1.1.2.4.2 rmind
852 1.1.1.2.4.2 rmind
853 1.1.1.2.4.2 rmind ACPI_FUNCTION_TRACE_PTR (DsEvaluateNamePath, WalkState);
854 1.1.1.2.4.2 rmind
855 1.1.1.2.4.2 rmind
856 1.1.1.2.4.2 rmind if (!Op->Common.Parent)
857 1.1.1.2.4.2 rmind {
858 1.1.1.2.4.2 rmind /* This happens after certain exception processing */
859 1.1.1.2.4.2 rmind
860 1.1.1.2.4.2 rmind goto Exit;
861 1.1.1.2.4.2 rmind }
862 1.1.1.2.4.2 rmind
863 1.1.1.2.4.2 rmind if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
864 1.1.1.2.4.2 rmind (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) ||
865 1.1.1.2.4.2 rmind (Op->Common.Parent->Common.AmlOpcode == AML_REF_OF_OP))
866 1.1.1.2.4.2 rmind {
867 1.1.1.2.4.2 rmind /* TBD: Should we specify this feature as a bit of OpInfo->Flags of these opcodes? */
868 1.1.1.2.4.2 rmind
869 1.1.1.2.4.2 rmind goto Exit;
870 1.1.1.2.4.2 rmind }
871 1.1.1.2.4.2 rmind
872 1.1.1.2.4.2 rmind Status = AcpiDsCreateOperand (WalkState, Op, 0);
873 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
874 1.1.1.2.4.2 rmind {
875 1.1.1.2.4.2 rmind goto Exit;
876 1.1.1.2.4.2 rmind }
877 1.1.1.2.4.2 rmind
878 1.1.1.2.4.2 rmind if (Op->Common.Flags & ACPI_PARSEOP_TARGET)
879 1.1.1.2.4.2 rmind {
880 1.1.1.2.4.2 rmind NewObjDesc = *Operand;
881 1.1.1.2.4.2 rmind goto PushResult;
882 1.1.1.2.4.2 rmind }
883 1.1.1.2.4.2 rmind
884 1.1.1.2.4.2 rmind Type = (*Operand)->Common.Type;
885 1.1.1.2.4.2 rmind
886 1.1.1.2.4.2 rmind Status = AcpiExResolveToValue (Operand, WalkState);
887 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
888 1.1.1.2.4.2 rmind {
889 1.1.1.2.4.2 rmind goto Exit;
890 1.1.1.2.4.2 rmind }
891 1.1.1.2.4.2 rmind
892 1.1.1.2.4.2 rmind if (Type == ACPI_TYPE_INTEGER)
893 1.1.1.2.4.2 rmind {
894 1.1.1.2.4.2 rmind /* It was incremented by AcpiExResolveToValue */
895 1.1.1.2.4.2 rmind
896 1.1.1.2.4.2 rmind AcpiUtRemoveReference (*Operand);
897 1.1.1.2.4.2 rmind
898 1.1.1.2.4.2 rmind Status = AcpiUtCopyIobjectToIobject (*Operand, &NewObjDesc, WalkState);
899 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
900 1.1.1.2.4.2 rmind {
901 1.1.1.2.4.2 rmind goto Exit;
902 1.1.1.2.4.2 rmind }
903 1.1.1.2.4.2 rmind }
904 1.1.1.2.4.2 rmind else
905 1.1.1.2.4.2 rmind {
906 1.1.1.2.4.2 rmind /*
907 1.1.1.2.4.2 rmind * The object either was anew created or is
908 1.1.1.2.4.2 rmind * a Namespace node - don't decrement it.
909 1.1.1.2.4.2 rmind */
910 1.1.1.2.4.2 rmind NewObjDesc = *Operand;
911 1.1.1.2.4.2 rmind }
912 1.1.1.2.4.2 rmind
913 1.1.1.2.4.2 rmind /* Cleanup for name-path operand */
914 1.1.1.2.4.2 rmind
915 1.1.1.2.4.2 rmind Status = AcpiDsObjStackPop (1, WalkState);
916 1.1.1.2.4.2 rmind if (ACPI_FAILURE (Status))
917 1.1.1.2.4.2 rmind {
918 1.1.1.2.4.2 rmind WalkState->ResultObj = NewObjDesc;
919 1.1.1.2.4.2 rmind goto Exit;
920 1.1.1.2.4.2 rmind }
921 1.1.1.2.4.2 rmind
922 1.1.1.2.4.2 rmind PushResult:
923 1.1.1.2.4.2 rmind
924 1.1.1.2.4.2 rmind WalkState->ResultObj = NewObjDesc;
925 1.1.1.2.4.2 rmind
926 1.1.1.2.4.2 rmind Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
927 1.1.1.2.4.2 rmind if (ACPI_SUCCESS (Status))
928 1.1.1.2.4.2 rmind {
929 1.1.1.2.4.2 rmind /* Force to take it from stack */
930 1.1.1.2.4.2 rmind
931 1.1.1.2.4.2 rmind Op->Common.Flags |= ACPI_PARSEOP_IN_STACK;
932 1.1.1.2.4.2 rmind }
933 1.1.1.2.4.2 rmind
934 1.1.1.2.4.2 rmind Exit:
935 1.1.1.2.4.2 rmind
936 1.1.1.2.4.2 rmind return_ACPI_STATUS (Status);
937 1.1.1.2.4.2 rmind }
938