154803Srwatson/******************************************************************************
2160146Srwatson *
354803Srwatson * Module Name: dscontrol - Support for execution control opcodes -
454803Srwatson *                          if/else/while/return
585845Srwatson *
685845Srwatson *****************************************************************************/
754803Srwatson
854803Srwatson/******************************************************************************
954803Srwatson *
1054803Srwatson * 1. Copyright Notice
1154803Srwatson *
1254803Srwatson * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
1354803Srwatson * All rights reserved.
1454803Srwatson *
1554803Srwatson * 2. License
1654803Srwatson *
1754803Srwatson * 2.1. This is your license from Intel Corp. under its intellectual property
1854803Srwatson * rights. You may have additional license terms from the party that provided
1954803Srwatson * you this software, covering your right to use that party's intellectual
2054803Srwatson * property rights.
2154803Srwatson *
2254803Srwatson * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2354803Srwatson * copy of the source code appearing in this file ("Covered Code") an
2454803Srwatson * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2554803Srwatson * base code distributed originally by Intel ("Original Intel Code") to copy,
2654803Srwatson * make derivatives, distribute, use and display any portion of the Covered
2754803Srwatson * Code in any form, with the right to sublicense such rights; and
2854803Srwatson *
2973890Srwatson * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30160146Srwatson * license (with the right to sublicense), under only those claims of Intel
31160146Srwatson * patents that are infringed by the Original Intel Code, to make, use, sell,
32160146Srwatson * offer to sell, and import the Covered Code and derivative works thereof
33160146Srwatson * solely to the minimum extent necessary to exercise the above copyright
3454803Srwatson * license, and in no event shall the patent license extend to any additions
3554803Srwatson * to or modifications of the Original Intel Code. No other license or right
36116182Sobrien * is granted directly or by implication, estoppel or otherwise;
37116182Sobrien *
38116182Sobrien * The above copyright and patent license is granted only if the following
3954803Srwatson * conditions are met:
4054803Srwatson *
41150262Scsjp * 3. Conditions
42164033Srwatson *
4354803Srwatson * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4454803Srwatson * Redistribution of source code of any substantial portion of the Covered
4554803Srwatson * Code or modification with rights to further distribute source must include
4654803Srwatson * the above Copyright Notice, the above License, this list of Conditions,
4754803Srwatson * and the following Disclaimer and Export Compliance provision. In addition,
4854803Srwatson * Licensee must cause all Covered Code to which Licensee contributes to
49160597Srwatson * contain a file documenting the changes Licensee made to create that Covered
50164033Srwatson * Code and the date of any change. Licensee must include in that file the
51164033Srwatson * documentation of any changes made by any predecessor Licensee. Licensee
52164033Srwatson * must include a prominent statement that the modification is derived,
5373890Srwatson * directly or indirectly, from Original Intel Code.
5473890Srwatson *
5575571Srwatson * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56184427Strasz * Redistribution of source code of any substantial portion of the Covered
5773890Srwatson * Code or modification without rights to further distribute source must
5873890Srwatson * include the following Disclaimer and Export Compliance provision in the
59184413Strasz * documentation and/or other materials provided with distribution. In
60184413Strasz * addition, Licensee may not authorize further sublicense of source of any
61184413Strasz * portion of the Covered Code, and must include terms to the effect that the
6273890Srwatson * license from Licensee to its licensee is limited to the intellectual
6373890Srwatson * property embodied in the software Licensee provides to its licensee, and
64197680Strasz * not to intellectual property embodied in modifications its licensee may
65197680Strasz * make.
66201019Strasz *
67201019Strasz * 3.3. Redistribution of Executable. Redistribution in executable form of any
68197680Strasz * substantial portion of the Covered Code or modification must reproduce the
6973890Srwatson * above Copyright Notice, and the following Disclaimer and Export Compliance
7073890Srwatson * provision in the documentation and/or other materials provided with the
71160597Srwatson * distribution.
72164033Srwatson *
73160597Srwatson * 3.4. Intel retains all right, title, and interest in and to the Original
74160597Srwatson * Intel Code.
7573890Srwatson *
7673890Srwatson * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7773890Srwatson * Intel shall be used in advertising or otherwise to promote the sale, use or
7873890Srwatson * other dealings in products derived from or relating to the Covered Code
7973890Srwatson * without prior written authorization from Intel.
80160597Srwatson *
81164033Srwatson * 4. Disclaimer and Export Compliance
82164033Srwatson *
83164033Srwatson * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84164033Srwatson * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8573890Srwatson * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86164033Srwatson * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
8773890Srwatson * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
8873890Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89184427Strasz * PARTICULAR PURPOSE.
90170587Srwatson *
91164033Srwatson * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9273890Srwatson * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93212002Sjh * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94212002Sjh * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95212002Sjh * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96212002Sjh * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97212002Sjh * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98212002Sjh * LIMITED REMEDY.
99212002Sjh *
100212002Sjh * 4.3. Licensee shall not export, either directly or indirectly, any of this
101164033Srwatson * software or system incorporating such software without first obtaining any
10273890Srwatson * required license or other approval from the U. S. Department of Commerce or
10373890Srwatson * any other agency or department of the United States Government. In the
104184427Strasz * event Licensee exports any such software from the United States or
105164033Srwatson * re-exports any such software from a foreign destination, Licensee shall
10673890Srwatson * ensure that the distribution and export/re-export of the software is in
107184427Strasz * compliance with all laws, regulations, orders, or other restrictions of the
108170587Srwatson * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109164033Srwatson * any of its subsidiaries will export/re-export any technical data, process,
11073890Srwatson * software, or service, directly or indirectly, to any country for which the
111184427Strasz * United States government or any agency thereof requires an export license,
112164033Srwatson * other governmental approval, or letter of assurance, without first obtaining
11373890Srwatson * such license, approval or letter.
11473890Srwatson *
11582255Srwatson *****************************************************************************
11682255Srwatson *
117160597Srwatson * Alternatively, you may choose to be licensed under the terms of the
118160597Srwatson * following license:
11973890Srwatson *
12073890Srwatson * Redistribution and use in source and binary forms, with or without
12173890Srwatson * modification, are permitted provided that the following conditions
12273890Srwatson * are met:
12373890Srwatson * 1. Redistributions of source code must retain the above copyright
12475571Srwatson *    notice, this list of conditions, and the following disclaimer,
12573890Srwatson *    without modification.
12673890Srwatson * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12773890Srwatson *    substantially similar to the "NO WARRANTY" disclaimer below
12875404Sjedgar *    ("Disclaimer") and any redistribution must be conditioned upon
12973890Srwatson *    including a substantially similar Disclaimer requirement for further
13075404Sjedgar *    binary redistribution.
13173890Srwatson * 3. Neither the names of the above-listed copyright holders nor the names
13275404Sjedgar *    of any contributors may be used to endorse or promote products derived
133100481Srwatson *    from this software without specific prior written permission.
134184427Strasz *
13573890Srwatson * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136164033Srwatson * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137164033Srwatson * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138164033Srwatson * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139164033Srwatson * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140184427Strasz * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141184427Strasz * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
14273890Srwatson * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
14373890Srwatson * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14473890Srwatson * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14573890Srwatson * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14673890Srwatson *
14773890Srwatson * Alternatively, you may choose to be licensed under the terms of the
14873890Srwatson * GNU General Public License ("GPL") version 2 as published by the Free
14973890Srwatson * Software Foundation.
15073890Srwatson *
15173890Srwatson *****************************************************************************/
15273890Srwatson
15373890Srwatson#include <contrib/dev/acpica/include/acpi.h>
15473890Srwatson#include <contrib/dev/acpica/include/accommon.h>
15573890Srwatson#include <contrib/dev/acpica/include/amlcode.h>
15673890Srwatson#include <contrib/dev/acpica/include/acdispat.h>
15792666Speter#include <contrib/dev/acpica/include/acinterp.h>
15873890Srwatson#include <contrib/dev/acpica/include/acdebug.h>
15973890Srwatson
16073890Srwatson#define _COMPONENT          ACPI_DISPATCHER
16173890Srwatson        ACPI_MODULE_NAME    ("dscontrol")
162160597Srwatson
163160597Srwatson
164160597Srwatson/*******************************************************************************
165160597Srwatson *
16673890Srwatson * FUNCTION:    AcpiDsExecBeginControlOp
16773890Srwatson *
16873890Srwatson * PARAMETERS:  WalkList        - The list that owns the walk stack
16982255Srwatson *              Op              - The control Op
17073890Srwatson *
17173890Srwatson * RETURN:      Status
17273890Srwatson *
17373890Srwatson * DESCRIPTION: Handles all control ops encountered during control method
17482255Srwatson *              execution.
17582255Srwatson *
176160597Srwatson ******************************************************************************/
177160597Srwatson
178160597SrwatsonACPI_STATUS
179160597SrwatsonAcpiDsExecBeginControlOp (
180160597Srwatson    ACPI_WALK_STATE         *WalkState,
18182255Srwatson    ACPI_PARSE_OBJECT       *Op)
18273890Srwatson{
18373890Srwatson    ACPI_STATUS             Status = AE_OK;
18475404Sjedgar    ACPI_GENERIC_STATE      *ControlState;
18573890Srwatson
18675404Sjedgar
18773890Srwatson    ACPI_FUNCTION_NAME (DsExecBeginControlOp);
18875404Sjedgar
189100481Srwatson
19073890Srwatson    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op=%p Opcode=%2.2X State=%p\n",
191100481Srwatson        Op, Op->Common.AmlOpcode, WalkState));
19273890Srwatson
19373890Srwatson    switch (Op->Common.AmlOpcode)
194164033Srwatson    {
195164033Srwatson    case AML_WHILE_OP:
196164033Srwatson        /*
19773890Srwatson         * If this is an additional iteration of a while loop, continue.
19873890Srwatson         * There is no need to allocate a new control state.
19973890Srwatson         */
20073890Srwatson        if (WalkState->ControlState)
20173890Srwatson        {
20273890Srwatson            if (WalkState->ControlState->Control.AmlPredicateStart ==
20373890Srwatson                (WalkState->ParserState.Aml - 1))
20475404Sjedgar            {
20573890Srwatson                /* Reset the state to start-of-loop */
20675404Sjedgar
20773890Srwatson                WalkState->ControlState->Common.State =
20875404Sjedgar                    ACPI_CONTROL_CONDITIONAL_EXECUTING;
209100481Srwatson                break;
21073890Srwatson            }
211184427Strasz        }
21273890Srwatson
213164033Srwatson        /*lint -fallthrough */
214164033Srwatson
215164033Srwatson    case AML_IF_OP:
216184427Strasz        /*
217184427Strasz         * IF/WHILE: Create a new control state to manage these
21875571Srwatson         * constructs. We need to manage these as a stack, in order
21975571Srwatson         * to handle nesting.
22075571Srwatson         */
22175571Srwatson        ControlState = AcpiUtCreateControlState ();
22275571Srwatson        if (!ControlState)
22373890Srwatson        {
22473890Srwatson            Status = AE_NO_MEMORY;
22573890Srwatson            break;
22673890Srwatson        }
227160597Srwatson        /*
228160597Srwatson         * Save a pointer to the predicate for multiple executions
229160597Srwatson         * of a loop
230160597Srwatson         */
231160597Srwatson        ControlState->Control.AmlPredicateStart =
23273890Srwatson            WalkState->ParserState.Aml - 1;
23373890Srwatson        ControlState->Control.PackageEnd =
23473890Srwatson            WalkState->ParserState.PkgEnd;
23573890Srwatson        ControlState->Control.Opcode =
23673890Srwatson            Op->Common.AmlOpcode;
23775888Stmm        ControlState->Control.LoopTimeout = AcpiOsGetTimer () +
23875571Srwatson           (UINT64) (AcpiGbl_MaxLoopIterations * ACPI_100NSEC_PER_SEC);
23975571Srwatson
24075571Srwatson        /* Push the control state on this walk's control stack */
24175571Srwatson
24275571Srwatson        AcpiUtPushGenericState (&WalkState->ControlState, ControlState);
24375571Srwatson        break;
24475571Srwatson
245100481Srwatson    case AML_ELSE_OP:
24675571Srwatson
24775571Srwatson        /* Predicate is in the state object */
248184427Strasz        /* If predicate is true, the IF was executed, ignore ELSE part */
24975571Srwatson
25075571Srwatson        if (WalkState->LastPredicate)
25175571Srwatson        {
25275571Srwatson            Status = AE_CTRL_TRUE;
25375571Srwatson        }
25473890Srwatson
25575571Srwatson        break;
25675571Srwatson
25775571Srwatson    case AML_RETURN_OP:
25875571Srwatson
25975571Srwatson        break;
26075571Srwatson
26175571Srwatson    default:
26275571Srwatson
263100481Srwatson        break;
26475571Srwatson    }
26573890Srwatson
266184427Strasz    return (Status);
26775571Srwatson}
26873890Srwatson
26975571Srwatson
27075571Srwatson/*******************************************************************************
27175571Srwatson *
27273890Srwatson * FUNCTION:    AcpiDsExecEndControlOp
27392666Speter *
27473890Srwatson * PARAMETERS:  WalkList        - The list that owns the walk stack
27573890Srwatson *              Op              - The control Op
27673890Srwatson *
27773890Srwatson * RETURN:      Status
27873890Srwatson *
279160597Srwatson * DESCRIPTION: Handles all control ops encountered during control method
280160597Srwatson *              execution.
28173890Srwatson *
28273890Srwatson ******************************************************************************/
28373890Srwatson
28473890SrwatsonACPI_STATUS
28576139SrwatsonAcpiDsExecEndControlOp (
28675571Srwatson    ACPI_WALK_STATE         *WalkState,
28775571Srwatson    ACPI_PARSE_OBJECT       *Op)
28875571Srwatson{
28975571Srwatson    ACPI_STATUS             Status = AE_OK;
29075571Srwatson    ACPI_GENERIC_STATE      *ControlState;
29175571Srwatson
29275571Srwatson
293100481Srwatson    ACPI_FUNCTION_NAME (DsExecEndControlOp);
29475571Srwatson
29575571Srwatson
296164033Srwatson    switch (Op->Common.AmlOpcode)
297164033Srwatson    {
298164033Srwatson    case AML_IF_OP:
299184427Strasz
300184427Strasz        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[IF_OP] Op=%p\n", Op));
30175571Srwatson
30275571Srwatson        /*
30375571Srwatson         * Save the result of the predicate in case there is an
30475571Srwatson         * ELSE to come
30575571Srwatson         */
30675571Srwatson        WalkState->LastPredicate =
30773890Srwatson            (BOOLEAN) WalkState->ControlState->Common.Value;
30875571Srwatson
30975571Srwatson        /*
31075571Srwatson         * Pop the control state that was created at the start
31175571Srwatson         * of the IF and free it
31275571Srwatson         */
31375571Srwatson        ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
31475571Srwatson        AcpiUtDeleteGenericState (ControlState);
31575571Srwatson        break;
31675571Srwatson
317100481Srwatson    case AML_ELSE_OP:
31875571Srwatson
31975571Srwatson        break;
320164033Srwatson
321164033Srwatson    case AML_WHILE_OP:
322164033Srwatson
323184427Strasz        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "[WHILE_OP] Op=%p\n", Op));
324184427Strasz
32575571Srwatson        ControlState = WalkState->ControlState;
32675571Srwatson        if (ControlState->Common.Value)
32775571Srwatson        {
32875571Srwatson            /* Predicate was true, the body of the loop was just executed */
32975571Srwatson
33075571Srwatson            /*
33173890Srwatson             * This infinite loop detection mechanism allows the interpreter
33292666Speter             * to escape possibly infinite loops. This can occur in poorly
33373890Srwatson             * written AML when the hardware does not respond within a while
33473890Srwatson             * loop and the loop does not implement a timeout.
33573890Srwatson             */
33673890Srwatson            if (ACPI_TIME_AFTER (AcpiOsGetTimer (),
33773890Srwatson                    ControlState->Control.LoopTimeout))
33873890Srwatson            {
33973890Srwatson                Status = AE_AML_LOOP_TIMEOUT;
34073890Srwatson                break;
34173890Srwatson            }
34273890Srwatson
34373890Srwatson            /*
34473890Srwatson             * Go back and evaluate the predicate and maybe execute the loop
34573890Srwatson             * another time
34675404Sjedgar             */
34773890Srwatson            Status = AE_CTRL_PENDING;
34875404Sjedgar            WalkState->AmlLastWhile =
34973890Srwatson                ControlState->Control.AmlPredicateStart;
35075404Sjedgar            break;
351100481Srwatson        }
35273890Srwatson
353184427Strasz        /* Predicate was false, terminate this while loop */
35473890Srwatson
355164033Srwatson        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
356164033Srwatson            "[WHILE_OP] termination! Op=%p\n",Op));
357164033Srwatson
358184427Strasz        /* Pop this control state and free it */
35973890Srwatson
36073890Srwatson        ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
36173890Srwatson        AcpiUtDeleteGenericState (ControlState);
36273890Srwatson        break;
36373890Srwatson
36473890Srwatson    case AML_RETURN_OP:
365184427Strasz
36673890Srwatson        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
36773890Srwatson            "[RETURN_OP] Op=%p Arg=%p\n",Op, Op->Common.Value.Arg));
36873890Srwatson
369160597Srwatson        /*
370160597Srwatson         * One optional operand -- the return value
371160597Srwatson         * It can be either an immediate operand or a result that
37273890Srwatson         * has been bubbled up the tree
37373890Srwatson         */
37473890Srwatson        if (Op->Common.Value.Arg)
37573890Srwatson        {
37673890Srwatson            /* Since we have a real Return(), delete any implicit return */
37773890Srwatson
37873890Srwatson            AcpiDsClearImplicitReturn (WalkState);
37973890Srwatson
38073890Srwatson            /* Return statement has an immediate operand */
38175404Sjedgar
38273890Srwatson            Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
38375404Sjedgar            if (ACPI_FAILURE (Status))
38473890Srwatson            {
38575404Sjedgar                return (Status);
38673890Srwatson            }
38773890Srwatson
38873890Srwatson            /*
38973890Srwatson             * If value being returned is a Reference (such as
39075404Sjedgar             * an arg or local), resolve it now because it may
39173890Srwatson             * cease to exist at the end of the method.
39275404Sjedgar             */
39373890Srwatson            Status = AcpiExResolveToValue (
39475404Sjedgar                &WalkState->Operands [0], WalkState);
39573890Srwatson            if (ACPI_FAILURE (Status))
39673890Srwatson            {
39773890Srwatson                return (Status);
39873890Srwatson            }
39975404Sjedgar
40073890Srwatson            /*
40175404Sjedgar             * Get the return value and save as the last result
40273890Srwatson             * value. This is the only place where WalkState->ReturnDesc
40375404Sjedgar             * is set to anything other than zero!
40473890Srwatson             */
40573890Srwatson            WalkState->ReturnDesc = WalkState->Operands[0];
40673890Srwatson        }
40773890Srwatson        else if (WalkState->ResultCount)
40873890Srwatson        {
40973890Srwatson            /* Since we have a real Return(), delete any implicit return */
41073890Srwatson
41173890Srwatson            AcpiDsClearImplicitReturn (WalkState);
41273890Srwatson
41373890Srwatson            /*
41473890Srwatson             * The return value has come from a previous calculation.
41573890Srwatson             *
41673890Srwatson             * If value being returned is a Reference (such as
41773890Srwatson             * an arg or local), resolve it now because it may
41873890Srwatson             * cease to exist at the end of the method.
41973890Srwatson             *
42073890Srwatson             * Allow references created by the Index operator to return
42173890Srwatson             * unchanged.
42273890Srwatson             */
423192586Strasz            if ((ACPI_GET_DESCRIPTOR_TYPE (WalkState->Results->Results.ObjDesc[0]) ==
424192586Strasz                    ACPI_DESC_TYPE_OPERAND) &&
42573890Srwatson                ((WalkState->Results->Results.ObjDesc [0])->Common.Type ==
42673890Srwatson                    ACPI_TYPE_LOCAL_REFERENCE) &&
42773890Srwatson                ((WalkState->Results->Results.ObjDesc [0])->Reference.Class !=
42873890Srwatson                    ACPI_REFCLASS_INDEX))
42973890Srwatson            {
43073890Srwatson                Status = AcpiExResolveToValue (
43173890Srwatson                    &WalkState->Results->Results.ObjDesc [0], WalkState);
43273890Srwatson                if (ACPI_FAILURE (Status))
43373890Srwatson                {
43473890Srwatson                    return (Status);
43582769Sjedgar                }
43673890Srwatson            }
43773890Srwatson
43873890Srwatson            WalkState->ReturnDesc = WalkState->Results->Results.ObjDesc [0];
43982769Sjedgar        }
44073890Srwatson        else
44173890Srwatson        {
44273890Srwatson            /* No return operand */
44373890Srwatson
44473890Srwatson            if (WalkState->NumOperands)
44573890Srwatson            {
44673890Srwatson                AcpiUtRemoveReference (WalkState->Operands [0]);
44773890Srwatson            }
44873890Srwatson
44973890Srwatson            WalkState->Operands[0] = NULL;
45073890Srwatson            WalkState->NumOperands = 0;
45173890Srwatson            WalkState->ReturnDesc = NULL;
45273890Srwatson        }
45373890Srwatson
45473890Srwatson
45573890Srwatson        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
45675404Sjedgar            "Completed RETURN_OP State=%p, RetVal=%p\n",
45773890Srwatson            WalkState, WalkState->ReturnDesc));
45875404Sjedgar
45973890Srwatson        /* End the control method execution right now */
46075404Sjedgar
46173890Srwatson        Status = AE_CTRL_TERMINATE;
46275404Sjedgar        break;
46373890Srwatson
46475404Sjedgar    case AML_NOOP_OP:
46573890Srwatson
46675404Sjedgar        /* Just do nothing! */
46773890Srwatson
46875404Sjedgar        break;
46973890Srwatson
47075404Sjedgar    case AML_BREAKPOINT_OP:
47173890Srwatson
47275404Sjedgar        AcpiDbSignalBreakPoint (WalkState);
47373890Srwatson
47473890Srwatson        /* Call to the OSL in case OS wants a piece of the action */
47573890Srwatson
47673890Srwatson        Status = AcpiOsSignal (ACPI_SIGNAL_BREAKPOINT,
47773890Srwatson            "Executed AML Breakpoint opcode");
47873890Srwatson        break;
479160597Srwatson
480160597Srwatson    case AML_BREAK_OP:
481160597Srwatson    case AML_CONTINUE_OP: /* ACPI 2.0 */
482118407Srwatson
483118407Srwatson        /* Pop and delete control states until we find a while */
484118407Srwatson
485118407Srwatson        while (WalkState->ControlState &&
486118407Srwatson                (WalkState->ControlState->Control.Opcode != AML_WHILE_OP))
487118407Srwatson        {
488118407Srwatson            ControlState = AcpiUtPopGenericState (&WalkState->ControlState);
489118407Srwatson            AcpiUtDeleteGenericState (ControlState);
490118407Srwatson        }
491118407Srwatson
492118407Srwatson        /* No while found? */
493118407Srwatson
494118407Srwatson        if (!WalkState->ControlState)
495118407Srwatson        {
496118407Srwatson            return (AE_AML_NO_WHILE);
497118407Srwatson        }
498118407Srwatson
499118407Srwatson        /* Was: WalkState->AmlLastWhile = WalkState->ControlState->Control.AmlPredicateStart; */
500118407Srwatson
501118407Srwatson        WalkState->AmlLastWhile =
502118407Srwatson            WalkState->ControlState->Control.PackageEnd;
503118407Srwatson
504118407Srwatson        /* Return status depending on opcode */
505118407Srwatson
506118407Srwatson        if (Op->Common.AmlOpcode == AML_BREAK_OP)
507118407Srwatson        {
508118407Srwatson            Status = AE_CTRL_BREAK;
509118407Srwatson        }
510118407Srwatson        else
511118407Srwatson        {
512118407Srwatson            Status = AE_CTRL_CONTINUE;
513118407Srwatson        }
514118407Srwatson        break;
515118407Srwatson
516118407Srwatson    default:
517118407Srwatson
518118407Srwatson        ACPI_ERROR ((AE_INFO, "Unknown control opcode=0x%X Op=%p",
519118407Srwatson            Op->Common.AmlOpcode, Op));
520118407Srwatson
521118407Srwatson        Status = AE_AML_BAD_OPCODE;
522118407Srwatson        break;
523118407Srwatson    }
524118407Srwatson
525118407Srwatson    return (Status);
526118407Srwatson}
527118407Srwatson