dscontrol.c revision 1.18 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: dscontrol - Support for execution control opcodes -
4 1.1 jruoho * if/else/while/return
5 1.1 jruoho *
6 1.1 jruoho *****************************************************************************/
7 1.1 jruoho
8 1.17 christos /******************************************************************************
9 1.17 christos *
10 1.17 christos * 1. Copyright Notice
11 1.17 christos *
12 1.18 christos * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
13 1.1 jruoho * All rights reserved.
14 1.1 jruoho *
15 1.17 christos * 2. License
16 1.17 christos *
17 1.17 christos * 2.1. This is your license from Intel Corp. under its intellectual property
18 1.17 christos * rights. You may have additional license terms from the party that provided
19 1.17 christos * you this software, covering your right to use that party's intellectual
20 1.17 christos * property rights.
21 1.17 christos *
22 1.17 christos * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 1.17 christos * copy of the source code appearing in this file ("Covered Code") an
24 1.17 christos * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 1.17 christos * base code distributed originally by Intel ("Original Intel Code") to copy,
26 1.17 christos * make derivatives, distribute, use and display any portion of the Covered
27 1.17 christos * Code in any form, with the right to sublicense such rights; and
28 1.17 christos *
29 1.17 christos * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 1.17 christos * license (with the right to sublicense), under only those claims of Intel
31 1.17 christos * patents that are infringed by the Original Intel Code, to make, use, sell,
32 1.17 christos * offer to sell, and import the Covered Code and derivative works thereof
33 1.17 christos * solely to the minimum extent necessary to exercise the above copyright
34 1.17 christos * license, and in no event shall the patent license extend to any additions
35 1.17 christos * to or modifications of the Original Intel Code. No other license or right
36 1.17 christos * is granted directly or by implication, estoppel or otherwise;
37 1.17 christos *
38 1.17 christos * The above copyright and patent license is granted only if the following
39 1.17 christos * conditions are met:
40 1.17 christos *
41 1.17 christos * 3. Conditions
42 1.17 christos *
43 1.17 christos * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 1.17 christos * Redistribution of source code of any substantial portion of the Covered
45 1.17 christos * Code or modification with rights to further distribute source must include
46 1.17 christos * the above Copyright Notice, the above License, this list of Conditions,
47 1.17 christos * and the following Disclaimer and Export Compliance provision. In addition,
48 1.17 christos * Licensee must cause all Covered Code to which Licensee contributes to
49 1.17 christos * contain a file documenting the changes Licensee made to create that Covered
50 1.17 christos * Code and the date of any change. Licensee must include in that file the
51 1.17 christos * documentation of any changes made by any predecessor Licensee. Licensee
52 1.17 christos * must include a prominent statement that the modification is derived,
53 1.17 christos * directly or indirectly, from Original Intel Code.
54 1.17 christos *
55 1.17 christos * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 1.17 christos * Redistribution of source code of any substantial portion of the Covered
57 1.17 christos * Code or modification without rights to further distribute source must
58 1.17 christos * include the following Disclaimer and Export Compliance provision in the
59 1.17 christos * documentation and/or other materials provided with distribution. In
60 1.17 christos * addition, Licensee may not authorize further sublicense of source of any
61 1.17 christos * portion of the Covered Code, and must include terms to the effect that the
62 1.17 christos * license from Licensee to its licensee is limited to the intellectual
63 1.17 christos * property embodied in the software Licensee provides to its licensee, and
64 1.17 christos * not to intellectual property embodied in modifications its licensee may
65 1.17 christos * make.
66 1.17 christos *
67 1.17 christos * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 1.17 christos * substantial portion of the Covered Code or modification must reproduce the
69 1.17 christos * above Copyright Notice, and the following Disclaimer and Export Compliance
70 1.17 christos * provision in the documentation and/or other materials provided with the
71 1.17 christos * distribution.
72 1.17 christos *
73 1.17 christos * 3.4. Intel retains all right, title, and interest in and to the Original
74 1.17 christos * Intel Code.
75 1.17 christos *
76 1.17 christos * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 1.17 christos * Intel shall be used in advertising or otherwise to promote the sale, use or
78 1.17 christos * other dealings in products derived from or relating to the Covered Code
79 1.17 christos * without prior written authorization from Intel.
80 1.17 christos *
81 1.17 christos * 4. Disclaimer and Export Compliance
82 1.17 christos *
83 1.17 christos * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 1.17 christos * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 1.17 christos * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 1.17 christos * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 1.17 christos * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 1.17 christos * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 1.17 christos * PARTICULAR PURPOSE.
90 1.17 christos *
91 1.17 christos * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 1.17 christos * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 1.17 christos * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 1.17 christos * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 1.17 christos * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 1.17 christos * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 1.17 christos * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 1.17 christos * LIMITED REMEDY.
99 1.17 christos *
100 1.17 christos * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 1.17 christos * software or system incorporating such software without first obtaining any
102 1.17 christos * required license or other approval from the U. S. Department of Commerce or
103 1.17 christos * any other agency or department of the United States Government. In the
104 1.17 christos * event Licensee exports any such software from the United States or
105 1.17 christos * re-exports any such software from a foreign destination, Licensee shall
106 1.17 christos * ensure that the distribution and export/re-export of the software is in
107 1.17 christos * compliance with all laws, regulations, orders, or other restrictions of the
108 1.17 christos * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 1.17 christos * any of its subsidiaries will export/re-export any technical data, process,
110 1.17 christos * software, or service, directly or indirectly, to any country for which the
111 1.17 christos * United States government or any agency thereof requires an export license,
112 1.17 christos * other governmental approval, or letter of assurance, without first obtaining
113 1.17 christos * such license, approval or letter.
114 1.17 christos *
115 1.17 christos *****************************************************************************
116 1.17 christos *
117 1.17 christos * Alternatively, you may choose to be licensed under the terms of the
118 1.17 christos * following license:
119 1.17 christos *
120 1.1 jruoho * Redistribution and use in source and binary forms, with or without
121 1.1 jruoho * modification, are permitted provided that the following conditions
122 1.1 jruoho * are met:
123 1.1 jruoho * 1. Redistributions of source code must retain the above copyright
124 1.1 jruoho * notice, this list of conditions, and the following disclaimer,
125 1.1 jruoho * without modification.
126 1.1 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
127 1.1 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
128 1.1 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
129 1.1 jruoho * including a substantially similar Disclaimer requirement for further
130 1.1 jruoho * binary redistribution.
131 1.1 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
132 1.1 jruoho * of any contributors may be used to endorse or promote products derived
133 1.1 jruoho * from this software without specific prior written permission.
134 1.1 jruoho *
135 1.1 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136 1.1 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137 1.14 christos * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138 1.1 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139 1.17 christos * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140 1.17 christos * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141 1.17 christos * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142 1.17 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143 1.17 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144 1.17 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145 1.17 christos * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 1.17 christos *
147 1.17 christos * Alternatively, you may choose to be licensed under the terms of the
148 1.17 christos * GNU General Public License ("GPL") version 2 as published by the Free
149 1.17 christos * Software Foundation.
150 1.17 christos *
151 1.17 christos *****************************************************************************/
152 1.1 jruoho
153 1.1 jruoho #include "acpi.h"
154 1.1 jruoho #include "accommon.h"
155 1.1 jruoho #include "amlcode.h"
156 1.1 jruoho #include "acdispat.h"
157 1.1 jruoho #include "acinterp.h"
158 1.6 christos #include "acdebug.h"
159 1.1 jruoho
160 1.1 jruoho #define _COMPONENT ACPI_DISPATCHER
161 1.1 jruoho ACPI_MODULE_NAME ("dscontrol")
162 1.1 jruoho
163 1.1 jruoho
164 1.1 jruoho /*******************************************************************************
165 1.1 jruoho *
166 1.1 jruoho * FUNCTION: AcpiDsExecBeginControlOp
167 1.1 jruoho *
168 1.1 jruoho * PARAMETERS: WalkList - The list that owns the walk stack
169 1.1 jruoho * Op - The control Op
170 1.1 jruoho *
171 1.1 jruoho * RETURN: Status
172 1.1 jruoho *
173 1.1 jruoho * DESCRIPTION: Handles all control ops encountered during control method
174 1.1 jruoho * execution.
175 1.1 jruoho *
176 1.1 jruoho ******************************************************************************/
177 1.1 jruoho
178 1.1 jruoho ACPI_STATUS
179 1.1 jruoho AcpiDsExecBeginControlOp (
180 1.1 jruoho ACPI_WALK_STATE *WalkState,
181 1.1 jruoho ACPI_PARSE_OBJECT *Op)
182 1.1 jruoho {
183 1.1 jruoho ACPI_STATUS Status = AE_OK;
184 1.1 jruoho ACPI_GENERIC_STATE *ControlState;
185 1.1 jruoho
186 1.1 jruoho
187 1.1 jruoho ACPI_FUNCTION_NAME (DsExecBeginControlOp);
188 1.1 jruoho
189 1.1 jruoho
190 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n",
191 1.1 jruoho Op, Op->Common.AmlOpcode, WalkState));
192 1.1 jruoho
193 1.1 jruoho switch (Op->Common.AmlOpcode)
194 1.1 jruoho {
195 1.1 jruoho case AML_WHILE_OP:
196 1.1 jruoho /*
197 1.1 jruoho * If this is an additional iteration of a while loop, continue.
198 1.1 jruoho * There is no need to allocate a new control state.
199 1.1 jruoho */
200 1.1 jruoho if (WalkState->ControlState)
201 1.1 jruoho {
202 1.1 jruoho if (WalkState->ControlState->Control.AmlPredicateStart ==
203 1.1 jruoho (WalkState->ParserState.Aml - 1))
204 1.1 jruoho {
205 1.1 jruoho /* Reset the state to start-of-loop */
206 1.1 jruoho
207 1.1 jruoho WalkState->ControlState->Common.State =
208 1.1 jruoho ACPI_CONTROL_CONDITIONAL_EXECUTING;
209 1.1 jruoho break;
210 1.1 jruoho }
211 1.1 jruoho }
212 1.1 jruoho
213 1.14 christos ACPI_FALLTHROUGH;
214 1.1 jruoho
215 1.1 jruoho case AML_IF_OP:
216 1.1 jruoho /*
217 1.1 jruoho * IF/WHILE: Create a new control state to manage these
218 1.1 jruoho * constructs. We need to manage these as a stack, in order
219 1.1 jruoho * to handle nesting.
220 1.1 jruoho */
221 1.1 jruoho ControlState = AcpiUtCreateControlState ();
222 1.1 jruoho if (!ControlState)
223 1.1 jruoho {
224 1.1 jruoho Status = AE_NO_MEMORY;
225 1.1 jruoho break;
226 1.1 jruoho }
227 1.1 jruoho /*
228 1.1 jruoho * Save a pointer to the predicate for multiple executions
229 1.1 jruoho * of a loop
230 1.1 jruoho */
231 1.6 christos ControlState->Control.AmlPredicateStart =
232 1.6 christos WalkState->ParserState.Aml - 1;
233 1.6 christos ControlState->Control.PackageEnd =
234 1.6 christos WalkState->ParserState.PkgEnd;
235 1.6 christos ControlState->Control.Opcode =
236 1.6 christos Op->Common.AmlOpcode;
237 1.9 christos ControlState->Control.LoopTimeout = AcpiOsGetTimer () +
238 1.12 christos ((UINT64) AcpiGbl_MaxLoopIterations * ACPI_100NSEC_PER_SEC);
239 1.1 jruoho
240 1.1 jruoho /* Push the control state on this walk's control stack */
241 1.1 jruoho
242 1.1 jruoho AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
243 1.1 jruoho break;
244 1.1 jruoho
245 1.1 jruoho case AML_ELSE_OP:
246 1.1 jruoho
247 1.1 jruoho /* Predicate is in the state object */
248 1.1 jruoho /* If predicate is true, the IF was executed, ignore ELSE part */
249 1.1 jruoho
250 1.1 jruoho if (WalkState->LastPredicate)
251 1.1 jruoho {
252 1.1 jruoho Status = AE_CTRL_TRUE;
253 1.1 jruoho }
254 1.1 jruoho
255 1.1 jruoho break;
256 1.1 jruoho
257 1.1 jruoho case AML_RETURN_OP:
258 1.1 jruoho
259 1.1 jruoho break;
260 1.1 jruoho
261 1.1 jruoho default:
262 1.3 christos
263 1.1 jruoho break;
264 1.1 jruoho }
265 1.1 jruoho
266 1.1 jruoho return (Status);
267 1.1 jruoho }
268 1.1 jruoho
269 1.1 jruoho
270 1.1 jruoho /*******************************************************************************
271 1.1 jruoho *
272 1.1 jruoho * FUNCTION: AcpiDsExecEndControlOp
273 1.1 jruoho *
274 1.1 jruoho * PARAMETERS: WalkList - The list that owns the walk stack
275 1.1 jruoho * Op - The control Op
276 1.1 jruoho *
277 1.1 jruoho * RETURN: Status
278 1.1 jruoho *
279 1.1 jruoho * DESCRIPTION: Handles all control ops encountered during control method
280 1.1 jruoho * execution.
281 1.1 jruoho *
282 1.1 jruoho ******************************************************************************/
283 1.1 jruoho
284 1.1 jruoho ACPI_STATUS
285 1.1 jruoho AcpiDsExecEndControlOp (
286 1.1 jruoho ACPI_WALK_STATE *WalkState,
287 1.1 jruoho ACPI_PARSE_OBJECT *Op)
288 1.1 jruoho {
289 1.1 jruoho ACPI_STATUS Status = AE_OK;
290 1.1 jruoho ACPI_GENERIC_STATE *ControlState;
291 1.1 jruoho
292 1.1 jruoho
293 1.1 jruoho ACPI_FUNCTION_NAME (DsExecEndControlOp);
294 1.1 jruoho
295 1.1 jruoho
296 1.1 jruoho switch (Op->Common.AmlOpcode)
297 1.1 jruoho {
298 1.1 jruoho case AML_IF_OP:
299 1.1 jruoho
300 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
301 1.1 jruoho
302 1.1 jruoho /*
303 1.1 jruoho * Save the result of the predicate in case there is an
304 1.1 jruoho * ELSE to come
305 1.1 jruoho */
306 1.1 jruoho WalkState->LastPredicate =
307 1.1 jruoho (BOOLEAN) WalkState->ControlState->Common.Value;
308 1.1 jruoho
309 1.1 jruoho /*
310 1.1 jruoho * Pop the control state that was created at the start
311 1.1 jruoho * of the IF and free it
312 1.1 jruoho */
313 1.1 jruoho ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
314 1.1 jruoho AcpiUtDeleteGenericState (ControlState);
315 1.1 jruoho break;
316 1.1 jruoho
317 1.1 jruoho case AML_ELSE_OP:
318 1.1 jruoho
319 1.1 jruoho break;
320 1.1 jruoho
321 1.1 jruoho case AML_WHILE_OP:
322 1.1 jruoho
323 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op));
324 1.1 jruoho
325 1.1 jruoho ControlState = WalkState->ControlState;
326 1.1 jruoho if (ControlState->Common.Value)
327 1.1 jruoho {
328 1.1 jruoho /* Predicate was true, the body of the loop was just executed */
329 1.1 jruoho
330 1.1 jruoho /*
331 1.9 christos * This infinite loop detection mechanism allows the interpreter
332 1.9 christos * to escape possibly infinite loops. This can occur in poorly
333 1.9 christos * written AML when the hardware does not respond within a while
334 1.9 christos * loop and the loop does not implement a timeout.
335 1.1 jruoho */
336 1.9 christos if (ACPI_TIME_AFTER (AcpiOsGetTimer (),
337 1.9 christos ControlState->Control.LoopTimeout))
338 1.1 jruoho {
339 1.9 christos Status = AE_AML_LOOP_TIMEOUT;
340 1.1 jruoho break;
341 1.1 jruoho }
342 1.1 jruoho
343 1.1 jruoho /*
344 1.1 jruoho * Go back and evaluate the predicate and maybe execute the loop
345 1.1 jruoho * another time
346 1.1 jruoho */
347 1.1 jruoho Status = AE_CTRL_PENDING;
348 1.6 christos WalkState->AmlLastWhile =
349 1.6 christos ControlState->Control.AmlPredicateStart;
350 1.1 jruoho break;
351 1.1 jruoho }
352 1.1 jruoho
353 1.1 jruoho /* Predicate was false, terminate this while loop */
354 1.1 jruoho
355 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
356 1.1 jruoho "[WHILE_OP] termination! Op=%p\n",Op));
357 1.1 jruoho
358 1.1 jruoho /* Pop this control state and free it */
359 1.1 jruoho
360 1.1 jruoho ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
361 1.1 jruoho AcpiUtDeleteGenericState (ControlState);
362 1.1 jruoho break;
363 1.1 jruoho
364 1.1 jruoho case AML_RETURN_OP:
365 1.1 jruoho
366 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
367 1.1 jruoho "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg));
368 1.1 jruoho
369 1.1 jruoho /*
370 1.1 jruoho * One optional operand -- the return value
371 1.1 jruoho * It can be either an immediate operand or a result that
372 1.1 jruoho * has been bubbled up the tree
373 1.1 jruoho */
374 1.1 jruoho if (Op->Common.Value.Arg)
375 1.1 jruoho {
376 1.1 jruoho /* Since we have a real Return(), delete any implicit return */
377 1.1 jruoho
378 1.1 jruoho AcpiDsClearImplicitReturn (WalkState);
379 1.1 jruoho
380 1.1 jruoho /* Return statement has an immediate operand */
381 1.1 jruoho
382 1.1 jruoho Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
383 1.1 jruoho if (ACPI_FAILURE (Status))
384 1.1 jruoho {
385 1.1 jruoho return (Status);
386 1.1 jruoho }
387 1.1 jruoho
388 1.1 jruoho /*
389 1.1 jruoho * If value being returned is a Reference (such as
390 1.1 jruoho * an arg or local), resolve it now because it may
391 1.1 jruoho * cease to exist at the end of the method.
392 1.1 jruoho */
393 1.6 christos Status = AcpiExResolveToValue (
394 1.6 christos &WalkState->Operands [0], WalkState);
395 1.1 jruoho if (ACPI_FAILURE (Status))
396 1.1 jruoho {
397 1.1 jruoho return (Status);
398 1.1 jruoho }
399 1.1 jruoho
400 1.1 jruoho /*
401 1.1 jruoho * Get the return value and save as the last result
402 1.3 christos * value. This is the only place where WalkState->ReturnDesc
403 1.1 jruoho * is set to anything other than zero!
404 1.1 jruoho */
405 1.1 jruoho WalkState->ReturnDesc = WalkState->Operands[0];
406 1.1 jruoho }
407 1.1 jruoho else if (WalkState->ResultCount)
408 1.1 jruoho {
409 1.1 jruoho /* Since we have a real Return(), delete any implicit return */
410 1.1 jruoho
411 1.1 jruoho AcpiDsClearImplicitReturn (WalkState);
412 1.1 jruoho
413 1.1 jruoho /*
414 1.1 jruoho * The return value has come from a previous calculation.
415 1.1 jruoho *
416 1.1 jruoho * If value being returned is a Reference (such as
417 1.1 jruoho * an arg or local), resolve it now because it may
418 1.1 jruoho * cease to exist at the end of the method.
419 1.1 jruoho *
420 1.1 jruoho * Allow references created by the Index operator to return
421 1.1 jruoho * unchanged.
422 1.1 jruoho */
423 1.6 christos if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) ==
424 1.6 christos ACPI_DESC_TYPE_OPERAND) &&
425 1.6 christos ((WalkState->Results->Results.ObjDesc [0])->Common.Type ==
426 1.6 christos ACPI_TYPE_LOCAL_REFERENCE) &&
427 1.6 christos ((WalkState->Results->Results.ObjDesc [0])->Reference.Class !=
428 1.6 christos ACPI_REFCLASS_INDEX))
429 1.1 jruoho {
430 1.6 christos Status = AcpiExResolveToValue (
431 1.6 christos &WalkState->Results->Results.ObjDesc [0], WalkState);
432 1.1 jruoho if (ACPI_FAILURE (Status))
433 1.1 jruoho {
434 1.1 jruoho return (Status);
435 1.1 jruoho }
436 1.1 jruoho }
437 1.1 jruoho
438 1.1 jruoho WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0];
439 1.1 jruoho }
440 1.1 jruoho else
441 1.1 jruoho {
442 1.1 jruoho /* No return operand */
443 1.1 jruoho
444 1.1 jruoho if (WalkState->NumOperands)
445 1.1 jruoho {
446 1.1 jruoho AcpiUtRemoveReference (WalkState->Operands [0]);
447 1.1 jruoho }
448 1.1 jruoho
449 1.6 christos WalkState->Operands[0] = NULL;
450 1.6 christos WalkState->NumOperands = 0;
451 1.6 christos WalkState->ReturnDesc = NULL;
452 1.1 jruoho }
453 1.1 jruoho
454 1.1 jruoho
455 1.1 jruoho ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
456 1.1 jruoho "Completed RETURN_OP State=%p, RetVal=%p\n",
457 1.1 jruoho WalkState, WalkState->ReturnDesc));
458 1.1 jruoho
459 1.1 jruoho /* End the control method execution right now */
460 1.1 jruoho
461 1.1 jruoho Status = AE_CTRL_TERMINATE;
462 1.1 jruoho break;
463 1.1 jruoho
464 1.1 jruoho case AML_NOOP_OP:
465 1.1 jruoho
466 1.1 jruoho /* Just do nothing! */
467 1.3 christos
468 1.1 jruoho break;
469 1.1 jruoho
470 1.8 christos case AML_BREAKPOINT_OP:
471 1.1 jruoho
472 1.6 christos AcpiDbSignalBreakPoint (WalkState);
473 1.1 jruoho
474 1.1 jruoho /* Call to the OSL in case OS wants a piece of the action */
475 1.1 jruoho
476 1.1 jruoho Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT,
477 1.6 christos __UNCONST("Executed AML Breakpoint opcode"));
478 1.1 jruoho break;
479 1.1 jruoho
480 1.1 jruoho case AML_BREAK_OP:
481 1.1 jruoho case AML_CONTINUE_OP: /* ACPI 2.0 */
482 1.1 jruoho
483 1.1 jruoho /* Pop and delete control states until we find a while */
484 1.1 jruoho
485 1.1 jruoho while (WalkState->ControlState &&
486 1.1 jruoho (WalkState->ControlState->Control.Opcode != AML_WHILE_OP))
487 1.1 jruoho {
488 1.1 jruoho ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
489 1.1 jruoho AcpiUtDeleteGenericState (ControlState);
490 1.1 jruoho }
491 1.1 jruoho
492 1.1 jruoho /* No while found? */
493 1.1 jruoho
494 1.1 jruoho if (!WalkState->ControlState)
495 1.1 jruoho {
496 1.1 jruoho return (AE_AML_NO_WHILE);
497 1.1 jruoho }
498 1.1 jruoho
499 1.1 jruoho /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
500 1.1 jruoho
501 1.6 christos WalkState->AmlLastWhile =
502 1.6 christos WalkState->ControlState->Control.PackageEnd;
503 1.1 jruoho
504 1.1 jruoho /* Return status depending on opcode */
505 1.1 jruoho
506 1.1 jruoho if (Op->Common.AmlOpcode == AML_BREAK_OP)
507 1.1 jruoho {
508 1.1 jruoho Status = AE_CTRL_BREAK;
509 1.1 jruoho }
510 1.1 jruoho else
511 1.1 jruoho {
512 1.1 jruoho Status = AE_CTRL_CONTINUE;
513 1.1 jruoho }
514 1.1 jruoho break;
515 1.1 jruoho
516 1.1 jruoho default:
517 1.1 jruoho
518 1.1 jruoho ACPI_ERROR ((AE_INFO, "Unknown control opcode=0x%X Op=%p",
519 1.1 jruoho Op->Common.AmlOpcode, Op));
520 1.1 jruoho
521 1.1 jruoho Status = AE_AML_BAD_OPCODE;
522 1.1 jruoho break;
523 1.1 jruoho }
524 1.1 jruoho
525 1.1 jruoho return (Status);
526 1.1 jruoho }
527