xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/components/dispatcher/dswexec.c (revision 6dde014f768e0ee49bae871ed857cf433837b9ff)
10174267aSFredrik Holmqvist /******************************************************************************
20174267aSFredrik Holmqvist  *
30174267aSFredrik Holmqvist  * Module Name: dswexec - Dispatcher method execution callbacks;
40174267aSFredrik Holmqvist  *                        dispatch to interpreter.
50174267aSFredrik Holmqvist  *
60174267aSFredrik Holmqvist  *****************************************************************************/
70174267aSFredrik Holmqvist 
80174267aSFredrik Holmqvist /******************************************************************************
90174267aSFredrik Holmqvist  *
100174267aSFredrik Holmqvist  * 1. Copyright Notice
110174267aSFredrik Holmqvist  *
12*6dde014fSPulkoMandy  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
130174267aSFredrik Holmqvist  * All rights reserved.
140174267aSFredrik Holmqvist  *
150174267aSFredrik Holmqvist  * 2. License
160174267aSFredrik Holmqvist  *
170174267aSFredrik Holmqvist  * 2.1. This is your license from Intel Corp. under its intellectual property
180174267aSFredrik Holmqvist  * rights. You may have additional license terms from the party that provided
190174267aSFredrik Holmqvist  * you this software, covering your right to use that party's intellectual
200174267aSFredrik Holmqvist  * property rights.
210174267aSFredrik Holmqvist  *
220174267aSFredrik Holmqvist  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
230174267aSFredrik Holmqvist  * copy of the source code appearing in this file ("Covered Code") an
240174267aSFredrik Holmqvist  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
250174267aSFredrik Holmqvist  * base code distributed originally by Intel ("Original Intel Code") to copy,
260174267aSFredrik Holmqvist  * make derivatives, distribute, use and display any portion of the Covered
270174267aSFredrik Holmqvist  * Code in any form, with the right to sublicense such rights; and
280174267aSFredrik Holmqvist  *
290174267aSFredrik Holmqvist  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
300174267aSFredrik Holmqvist  * license (with the right to sublicense), under only those claims of Intel
310174267aSFredrik Holmqvist  * patents that are infringed by the Original Intel Code, to make, use, sell,
320174267aSFredrik Holmqvist  * offer to sell, and import the Covered Code and derivative works thereof
330174267aSFredrik Holmqvist  * solely to the minimum extent necessary to exercise the above copyright
340174267aSFredrik Holmqvist  * license, and in no event shall the patent license extend to any additions
350174267aSFredrik Holmqvist  * to or modifications of the Original Intel Code. No other license or right
360174267aSFredrik Holmqvist  * is granted directly or by implication, estoppel or otherwise;
370174267aSFredrik Holmqvist  *
380174267aSFredrik Holmqvist  * The above copyright and patent license is granted only if the following
390174267aSFredrik Holmqvist  * conditions are met:
400174267aSFredrik Holmqvist  *
410174267aSFredrik Holmqvist  * 3. Conditions
420174267aSFredrik Holmqvist  *
430174267aSFredrik Holmqvist  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
440174267aSFredrik Holmqvist  * Redistribution of source code of any substantial portion of the Covered
450174267aSFredrik Holmqvist  * Code or modification with rights to further distribute source must include
460174267aSFredrik Holmqvist  * the above Copyright Notice, the above License, this list of Conditions,
470174267aSFredrik Holmqvist  * and the following Disclaimer and Export Compliance provision. In addition,
480174267aSFredrik Holmqvist  * Licensee must cause all Covered Code to which Licensee contributes to
490174267aSFredrik Holmqvist  * contain a file documenting the changes Licensee made to create that Covered
500174267aSFredrik Holmqvist  * Code and the date of any change. Licensee must include in that file the
510174267aSFredrik Holmqvist  * documentation of any changes made by any predecessor Licensee. Licensee
520174267aSFredrik Holmqvist  * must include a prominent statement that the modification is derived,
530174267aSFredrik Holmqvist  * directly or indirectly, from Original Intel Code.
540174267aSFredrik Holmqvist  *
550174267aSFredrik Holmqvist  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
560174267aSFredrik Holmqvist  * Redistribution of source code of any substantial portion of the Covered
570174267aSFredrik Holmqvist  * Code or modification without rights to further distribute source must
580174267aSFredrik Holmqvist  * include the following Disclaimer and Export Compliance provision in the
590174267aSFredrik Holmqvist  * documentation and/or other materials provided with distribution. In
600174267aSFredrik Holmqvist  * addition, Licensee may not authorize further sublicense of source of any
610174267aSFredrik Holmqvist  * portion of the Covered Code, and must include terms to the effect that the
620174267aSFredrik Holmqvist  * license from Licensee to its licensee is limited to the intellectual
630174267aSFredrik Holmqvist  * property embodied in the software Licensee provides to its licensee, and
640174267aSFredrik Holmqvist  * not to intellectual property embodied in modifications its licensee may
650174267aSFredrik Holmqvist  * make.
660174267aSFredrik Holmqvist  *
670174267aSFredrik Holmqvist  * 3.3. Redistribution of Executable. Redistribution in executable form of any
680174267aSFredrik Holmqvist  * substantial portion of the Covered Code or modification must reproduce the
690174267aSFredrik Holmqvist  * above Copyright Notice, and the following Disclaimer and Export Compliance
700174267aSFredrik Holmqvist  * provision in the documentation and/or other materials provided with the
710174267aSFredrik Holmqvist  * distribution.
720174267aSFredrik Holmqvist  *
730174267aSFredrik Holmqvist  * 3.4. Intel retains all right, title, and interest in and to the Original
740174267aSFredrik Holmqvist  * Intel Code.
750174267aSFredrik Holmqvist  *
760174267aSFredrik Holmqvist  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
770174267aSFredrik Holmqvist  * Intel shall be used in advertising or otherwise to promote the sale, use or
780174267aSFredrik Holmqvist  * other dealings in products derived from or relating to the Covered Code
790174267aSFredrik Holmqvist  * without prior written authorization from Intel.
800174267aSFredrik Holmqvist  *
810174267aSFredrik Holmqvist  * 4. Disclaimer and Export Compliance
820174267aSFredrik Holmqvist  *
830174267aSFredrik Holmqvist  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
840174267aSFredrik Holmqvist  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
850174267aSFredrik Holmqvist  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
860174267aSFredrik Holmqvist  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
870174267aSFredrik Holmqvist  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
880174267aSFredrik Holmqvist  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
890174267aSFredrik Holmqvist  * PARTICULAR PURPOSE.
900174267aSFredrik Holmqvist  *
910174267aSFredrik Holmqvist  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
920174267aSFredrik Holmqvist  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
930174267aSFredrik Holmqvist  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
940174267aSFredrik Holmqvist  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
950174267aSFredrik Holmqvist  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
960174267aSFredrik Holmqvist  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
970174267aSFredrik Holmqvist  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
980174267aSFredrik Holmqvist  * LIMITED REMEDY.
990174267aSFredrik Holmqvist  *
1000174267aSFredrik Holmqvist  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1010174267aSFredrik Holmqvist  * software or system incorporating such software without first obtaining any
1020174267aSFredrik Holmqvist  * required license or other approval from the U. S. Department of Commerce or
1030174267aSFredrik Holmqvist  * any other agency or department of the United States Government. In the
1040174267aSFredrik Holmqvist  * event Licensee exports any such software from the United States or
1050174267aSFredrik Holmqvist  * re-exports any such software from a foreign destination, Licensee shall
1060174267aSFredrik Holmqvist  * ensure that the distribution and export/re-export of the software is in
1070174267aSFredrik Holmqvist  * compliance with all laws, regulations, orders, or other restrictions of the
1080174267aSFredrik Holmqvist  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1090174267aSFredrik Holmqvist  * any of its subsidiaries will export/re-export any technical data, process,
1100174267aSFredrik Holmqvist  * software, or service, directly or indirectly, to any country for which the
1110174267aSFredrik Holmqvist  * United States government or any agency thereof requires an export license,
1120174267aSFredrik Holmqvist  * other governmental approval, or letter of assurance, without first obtaining
1130174267aSFredrik Holmqvist  * such license, approval or letter.
1140174267aSFredrik Holmqvist  *
115ff2e2f81SFredrik Holmqvist  *****************************************************************************
116ff2e2f81SFredrik Holmqvist  *
117ff2e2f81SFredrik Holmqvist  * Alternatively, you may choose to be licensed under the terms of the
118ff2e2f81SFredrik Holmqvist  * following license:
119ff2e2f81SFredrik Holmqvist  *
120ff2e2f81SFredrik Holmqvist  * Redistribution and use in source and binary forms, with or without
121ff2e2f81SFredrik Holmqvist  * modification, are permitted provided that the following conditions
122ff2e2f81SFredrik Holmqvist  * are met:
123ff2e2f81SFredrik Holmqvist  * 1. Redistributions of source code must retain the above copyright
124ff2e2f81SFredrik Holmqvist  *    notice, this list of conditions, and the following disclaimer,
125ff2e2f81SFredrik Holmqvist  *    without modification.
126ff2e2f81SFredrik Holmqvist  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
127ff2e2f81SFredrik Holmqvist  *    substantially similar to the "NO WARRANTY" disclaimer below
128ff2e2f81SFredrik Holmqvist  *    ("Disclaimer") and any redistribution must be conditioned upon
129ff2e2f81SFredrik Holmqvist  *    including a substantially similar Disclaimer requirement for further
130ff2e2f81SFredrik Holmqvist  *    binary redistribution.
131ff2e2f81SFredrik Holmqvist  * 3. Neither the names of the above-listed copyright holders nor the names
132ff2e2f81SFredrik Holmqvist  *    of any contributors may be used to endorse or promote products derived
133ff2e2f81SFredrik Holmqvist  *    from this software without specific prior written permission.
134ff2e2f81SFredrik Holmqvist  *
135ff2e2f81SFredrik Holmqvist  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
136ff2e2f81SFredrik Holmqvist  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
137ff2e2f81SFredrik Holmqvist  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
138ff2e2f81SFredrik Holmqvist  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
139ff2e2f81SFredrik Holmqvist  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
140ff2e2f81SFredrik Holmqvist  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
141ff2e2f81SFredrik Holmqvist  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
142ff2e2f81SFredrik Holmqvist  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
143ff2e2f81SFredrik Holmqvist  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
144ff2e2f81SFredrik Holmqvist  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
145ff2e2f81SFredrik Holmqvist  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146ff2e2f81SFredrik Holmqvist  *
147ff2e2f81SFredrik Holmqvist  * Alternatively, you may choose to be licensed under the terms of the
148ff2e2f81SFredrik Holmqvist  * GNU General Public License ("GPL") version 2 as published by the Free
149ff2e2f81SFredrik Holmqvist  * Software Foundation.
150ff2e2f81SFredrik Holmqvist  *
1510174267aSFredrik Holmqvist  *****************************************************************************/
1520174267aSFredrik Holmqvist 
1530174267aSFredrik Holmqvist #include "acpi.h"
1540174267aSFredrik Holmqvist #include "accommon.h"
1550174267aSFredrik Holmqvist #include "acparser.h"
1560174267aSFredrik Holmqvist #include "amlcode.h"
1570174267aSFredrik Holmqvist #include "acdispat.h"
1580174267aSFredrik Holmqvist #include "acinterp.h"
1590174267aSFredrik Holmqvist #include "acnamesp.h"
1600174267aSFredrik Holmqvist #include "acdebug.h"
1610ffed378SFredrik Holmqvist #ifdef ACPI_EXEC_APP
1620ffed378SFredrik Holmqvist #include "aecommon.h"
1630ffed378SFredrik Holmqvist #endif
1640174267aSFredrik Holmqvist 
1650174267aSFredrik Holmqvist #define _COMPONENT          ACPI_DISPATCHER
1660174267aSFredrik Holmqvist         ACPI_MODULE_NAME    ("dswexec")
1670174267aSFredrik Holmqvist 
1680174267aSFredrik Holmqvist /*
1690174267aSFredrik Holmqvist  * Dispatch table for opcode classes
1700174267aSFredrik Holmqvist  */
1710174267aSFredrik Holmqvist static ACPI_EXECUTE_OP      AcpiGbl_OpTypeDispatch [] =
1720174267aSFredrik Holmqvist {
1730174267aSFredrik Holmqvist     AcpiExOpcode_0A_0T_1R,
1740174267aSFredrik Holmqvist     AcpiExOpcode_1A_0T_0R,
1750174267aSFredrik Holmqvist     AcpiExOpcode_1A_0T_1R,
17615338de9SPulkoMandy     NULL,   /* Was: AcpiExOpcode_1A_0T_0R (Was for Load operator) */
1770174267aSFredrik Holmqvist     AcpiExOpcode_1A_1T_1R,
1780174267aSFredrik Holmqvist     AcpiExOpcode_2A_0T_0R,
1790174267aSFredrik Holmqvist     AcpiExOpcode_2A_0T_1R,
1800174267aSFredrik Holmqvist     AcpiExOpcode_2A_1T_1R,
1810174267aSFredrik Holmqvist     AcpiExOpcode_2A_2T_1R,
1820174267aSFredrik Holmqvist     AcpiExOpcode_3A_0T_0R,
1830174267aSFredrik Holmqvist     AcpiExOpcode_3A_1T_1R,
1840174267aSFredrik Holmqvist     AcpiExOpcode_6A_0T_1R
1850174267aSFredrik Holmqvist };
1860174267aSFredrik Holmqvist 
1870174267aSFredrik Holmqvist 
1880174267aSFredrik Holmqvist /*****************************************************************************
1890174267aSFredrik Holmqvist  *
1900174267aSFredrik Holmqvist  * FUNCTION:    AcpiDsGetPredicateValue
1910174267aSFredrik Holmqvist  *
1920174267aSFredrik Holmqvist  * PARAMETERS:  WalkState       - Current state of the parse tree walk
1930174267aSFredrik Holmqvist  *              ResultObj       - if non-zero, pop result from result stack
1940174267aSFredrik Holmqvist  *
1950174267aSFredrik Holmqvist  * RETURN:      Status
1960174267aSFredrik Holmqvist  *
1970174267aSFredrik Holmqvist  * DESCRIPTION: Get the result of a predicate evaluation
1980174267aSFredrik Holmqvist  *
1990174267aSFredrik Holmqvist  ****************************************************************************/
2000174267aSFredrik Holmqvist 
2010174267aSFredrik Holmqvist ACPI_STATUS
AcpiDsGetPredicateValue(ACPI_WALK_STATE * WalkState,ACPI_OPERAND_OBJECT * ResultObj)2020174267aSFredrik Holmqvist AcpiDsGetPredicateValue (
2030174267aSFredrik Holmqvist     ACPI_WALK_STATE         *WalkState,
2040174267aSFredrik Holmqvist     ACPI_OPERAND_OBJECT     *ResultObj)
2050174267aSFredrik Holmqvist {
2060174267aSFredrik Holmqvist     ACPI_STATUS             Status = AE_OK;
2070174267aSFredrik Holmqvist     ACPI_OPERAND_OBJECT     *ObjDesc;
2080174267aSFredrik Holmqvist     ACPI_OPERAND_OBJECT     *LocalObjDesc = NULL;
2090174267aSFredrik Holmqvist 
2100174267aSFredrik Holmqvist 
2110174267aSFredrik Holmqvist     ACPI_FUNCTION_TRACE_PTR (DsGetPredicateValue, WalkState);
2120174267aSFredrik Holmqvist 
2130174267aSFredrik Holmqvist 
2140174267aSFredrik Holmqvist     WalkState->ControlState->Common.State = 0;
2150174267aSFredrik Holmqvist 
2160174267aSFredrik Holmqvist     if (ResultObj)
2170174267aSFredrik Holmqvist     {
2180174267aSFredrik Holmqvist         Status = AcpiDsResultPop (&ObjDesc, WalkState);
2190174267aSFredrik Holmqvist         if (ACPI_FAILURE (Status))
2200174267aSFredrik Holmqvist         {
2210174267aSFredrik Holmqvist             ACPI_EXCEPTION ((AE_INFO, Status,
2220174267aSFredrik Holmqvist                 "Could not get result from predicate evaluation"));
2230174267aSFredrik Holmqvist 
2240174267aSFredrik Holmqvist             return_ACPI_STATUS (Status);
2250174267aSFredrik Holmqvist         }
2260174267aSFredrik Holmqvist     }
2270174267aSFredrik Holmqvist     else
2280174267aSFredrik Holmqvist     {
2290174267aSFredrik Holmqvist         Status = AcpiDsCreateOperand (WalkState, WalkState->Op, 0);
2300174267aSFredrik Holmqvist         if (ACPI_FAILURE (Status))
2310174267aSFredrik Holmqvist         {
2320174267aSFredrik Holmqvist             return_ACPI_STATUS (Status);
2330174267aSFredrik Holmqvist         }
2340174267aSFredrik Holmqvist 
2350174267aSFredrik Holmqvist         Status = AcpiExResolveToValue (&WalkState->Operands [0], WalkState);
2360174267aSFredrik Holmqvist         if (ACPI_FAILURE (Status))
2370174267aSFredrik Holmqvist         {
2380174267aSFredrik Holmqvist             return_ACPI_STATUS (Status);
2390174267aSFredrik Holmqvist         }
2400174267aSFredrik Holmqvist 
2410174267aSFredrik Holmqvist         ObjDesc = WalkState->Operands [0];
2420174267aSFredrik Holmqvist     }
2430174267aSFredrik Holmqvist 
2440174267aSFredrik Holmqvist     if (!ObjDesc)
2450174267aSFredrik Holmqvist     {
2460174267aSFredrik Holmqvist         ACPI_ERROR ((AE_INFO,
2470174267aSFredrik Holmqvist             "No predicate ObjDesc=%p State=%p",
2480174267aSFredrik Holmqvist             ObjDesc, WalkState));
2490174267aSFredrik Holmqvist 
2500174267aSFredrik Holmqvist         return_ACPI_STATUS (AE_AML_NO_OPERAND);
2510174267aSFredrik Holmqvist     }
2520174267aSFredrik Holmqvist 
2530174267aSFredrik Holmqvist     /*
2540174267aSFredrik Holmqvist      * Result of predicate evaluation must be an Integer
2550174267aSFredrik Holmqvist      * object. Implicitly convert the argument if necessary.
2560174267aSFredrik Holmqvist      */
257ff2e2f81SFredrik Holmqvist     Status = AcpiExConvertToInteger (ObjDesc, &LocalObjDesc,
258ff2e2f81SFredrik Holmqvist         ACPI_IMPLICIT_CONVERSION);
2590174267aSFredrik Holmqvist     if (ACPI_FAILURE (Status))
2600174267aSFredrik Holmqvist     {
2610174267aSFredrik Holmqvist         goto Cleanup;
2620174267aSFredrik Holmqvist     }
2630174267aSFredrik Holmqvist 
2640174267aSFredrik Holmqvist     if (LocalObjDesc->Common.Type != ACPI_TYPE_INTEGER)
2650174267aSFredrik Holmqvist     {
2660174267aSFredrik Holmqvist         ACPI_ERROR ((AE_INFO,
2670174267aSFredrik Holmqvist             "Bad predicate (not an integer) ObjDesc=%p State=%p Type=0x%X",
2680174267aSFredrik Holmqvist             ObjDesc, WalkState, ObjDesc->Common.Type));
2690174267aSFredrik Holmqvist 
2700174267aSFredrik Holmqvist         Status = AE_AML_OPERAND_TYPE;
2710174267aSFredrik Holmqvist         goto Cleanup;
2720174267aSFredrik Holmqvist     }
2730174267aSFredrik Holmqvist 
2740174267aSFredrik Holmqvist     /* Truncate the predicate to 32-bits if necessary */
2750174267aSFredrik Holmqvist 
276c70258b7SJérôme Duval     (void) AcpiExTruncateFor32bitTable (LocalObjDesc);
2770174267aSFredrik Holmqvist 
2780174267aSFredrik Holmqvist     /*
2790174267aSFredrik Holmqvist      * Save the result of the predicate evaluation on
2800174267aSFredrik Holmqvist      * the control stack
2810174267aSFredrik Holmqvist      */
2820174267aSFredrik Holmqvist     if (LocalObjDesc->Integer.Value)
2830174267aSFredrik Holmqvist     {
2840174267aSFredrik Holmqvist         WalkState->ControlState->Common.Value = TRUE;
2850174267aSFredrik Holmqvist     }
2860174267aSFredrik Holmqvist     else
2870174267aSFredrik Holmqvist     {
2880174267aSFredrik Holmqvist         /*
2890174267aSFredrik Holmqvist          * Predicate is FALSE, we will just toss the
2900174267aSFredrik Holmqvist          * rest of the package
2910174267aSFredrik Holmqvist          */
2920174267aSFredrik Holmqvist         WalkState->ControlState->Common.Value = FALSE;
2930174267aSFredrik Holmqvist         Status = AE_CTRL_FALSE;
2940174267aSFredrik Holmqvist     }
2950174267aSFredrik Holmqvist 
2960174267aSFredrik Holmqvist     /* Predicate can be used for an implicit return value */
2970174267aSFredrik Holmqvist 
2980174267aSFredrik Holmqvist     (void) AcpiDsDoImplicitReturn (LocalObjDesc, WalkState, TRUE);
2990174267aSFredrik Holmqvist 
3000174267aSFredrik Holmqvist 
3010174267aSFredrik Holmqvist Cleanup:
3020174267aSFredrik Holmqvist 
303b64e8511SFredrik Holmqvist     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
304b64e8511SFredrik Holmqvist         "Completed a predicate eval=%X Op=%p\n",
3050174267aSFredrik Holmqvist         WalkState->ControlState->Common.Value, WalkState->Op));
3060174267aSFredrik Holmqvist 
3070174267aSFredrik Holmqvist     /* Break to debugger to display result */
3080174267aSFredrik Holmqvist 
309b64e8511SFredrik Holmqvist     AcpiDbDisplayResultObject (LocalObjDesc, WalkState);
3100174267aSFredrik Holmqvist 
3110174267aSFredrik Holmqvist     /*
3120174267aSFredrik Holmqvist      * Delete the predicate result object (we know that
3130174267aSFredrik Holmqvist      * we don't need it anymore)
3140174267aSFredrik Holmqvist      */
3150174267aSFredrik Holmqvist     if (LocalObjDesc != ObjDesc)
3160174267aSFredrik Holmqvist     {
3170174267aSFredrik Holmqvist         AcpiUtRemoveReference (LocalObjDesc);
3180174267aSFredrik Holmqvist     }
3190174267aSFredrik Holmqvist     AcpiUtRemoveReference (ObjDesc);
3200174267aSFredrik Holmqvist 
3210174267aSFredrik Holmqvist     WalkState->ControlState->Common.State = ACPI_CONTROL_NORMAL;
3220174267aSFredrik Holmqvist     return_ACPI_STATUS (Status);
3230174267aSFredrik Holmqvist }
3240174267aSFredrik Holmqvist 
3250174267aSFredrik Holmqvist 
3260174267aSFredrik Holmqvist /*****************************************************************************
3270174267aSFredrik Holmqvist  *
3280174267aSFredrik Holmqvist  * FUNCTION:    AcpiDsExecBeginOp
3290174267aSFredrik Holmqvist  *
3300174267aSFredrik Holmqvist  * PARAMETERS:  WalkState       - Current state of the parse tree walk
3310174267aSFredrik Holmqvist  *              OutOp           - Where to return op if a new one is created
3320174267aSFredrik Holmqvist  *
3330174267aSFredrik Holmqvist  * RETURN:      Status
3340174267aSFredrik Holmqvist  *
3350174267aSFredrik Holmqvist  * DESCRIPTION: Descending callback used during the execution of control
3360174267aSFredrik Holmqvist  *              methods. This is where most operators and operands are
3370174267aSFredrik Holmqvist  *              dispatched to the interpreter.
3380174267aSFredrik Holmqvist  *
3390174267aSFredrik Holmqvist  ****************************************************************************/
3400174267aSFredrik Holmqvist 
3410174267aSFredrik Holmqvist ACPI_STATUS
AcpiDsExecBeginOp(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT ** OutOp)3420174267aSFredrik Holmqvist AcpiDsExecBeginOp (
3430174267aSFredrik Holmqvist     ACPI_WALK_STATE         *WalkState,
3440174267aSFredrik Holmqvist     ACPI_PARSE_OBJECT       **OutOp)
3450174267aSFredrik Holmqvist {
3460174267aSFredrik Holmqvist     ACPI_PARSE_OBJECT       *Op;
3470174267aSFredrik Holmqvist     ACPI_STATUS             Status = AE_OK;
3480174267aSFredrik Holmqvist     UINT32                  OpcodeClass;
3490174267aSFredrik Holmqvist 
3500174267aSFredrik Holmqvist 
3510174267aSFredrik Holmqvist     ACPI_FUNCTION_TRACE_PTR (DsExecBeginOp, WalkState);
3520174267aSFredrik Holmqvist 
3530174267aSFredrik Holmqvist 
3540174267aSFredrik Holmqvist     Op = WalkState->Op;
3550174267aSFredrik Holmqvist     if (!Op)
3560174267aSFredrik Holmqvist     {
3570174267aSFredrik Holmqvist         Status = AcpiDsLoad2BeginOp (WalkState, OutOp);
3580174267aSFredrik Holmqvist         if (ACPI_FAILURE (Status))
3590174267aSFredrik Holmqvist         {
3600174267aSFredrik Holmqvist             goto ErrorExit;
3610174267aSFredrik Holmqvist         }
3620174267aSFredrik Holmqvist 
3630174267aSFredrik Holmqvist         Op = *OutOp;
3640174267aSFredrik Holmqvist         WalkState->Op = Op;
3650174267aSFredrik Holmqvist         WalkState->Opcode = Op->Common.AmlOpcode;
3660174267aSFredrik Holmqvist         WalkState->OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
3670174267aSFredrik Holmqvist 
3680174267aSFredrik Holmqvist         if (AcpiNsOpensScope (WalkState->OpInfo->ObjectType))
3690174267aSFredrik Holmqvist         {
3700174267aSFredrik Holmqvist             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
3710174267aSFredrik Holmqvist                 "(%s) Popping scope for Op %p\n",
3720174267aSFredrik Holmqvist                 AcpiUtGetTypeName (WalkState->OpInfo->ObjectType), Op));
3730174267aSFredrik Holmqvist 
3740174267aSFredrik Holmqvist             Status = AcpiDsScopeStackPop (WalkState);
3750174267aSFredrik Holmqvist             if (ACPI_FAILURE (Status))
3760174267aSFredrik Holmqvist             {
3770174267aSFredrik Holmqvist                 goto ErrorExit;
3780174267aSFredrik Holmqvist             }
3790174267aSFredrik Holmqvist         }
3800174267aSFredrik Holmqvist     }
3810174267aSFredrik Holmqvist 
3820174267aSFredrik Holmqvist     if (Op == WalkState->Origin)
3830174267aSFredrik Holmqvist     {
3840174267aSFredrik Holmqvist         if (OutOp)
3850174267aSFredrik Holmqvist         {
3860174267aSFredrik Holmqvist             *OutOp = Op;
3870174267aSFredrik Holmqvist         }
3880174267aSFredrik Holmqvist 
3890174267aSFredrik Holmqvist         return_ACPI_STATUS (AE_OK);
3900174267aSFredrik Holmqvist     }
3910174267aSFredrik Holmqvist 
3920174267aSFredrik Holmqvist     /*
3930174267aSFredrik Holmqvist      * If the previous opcode was a conditional, this opcode
3940174267aSFredrik Holmqvist      * must be the beginning of the associated predicate.
3950174267aSFredrik Holmqvist      * Save this knowledge in the current scope descriptor
3960174267aSFredrik Holmqvist      */
3970174267aSFredrik Holmqvist     if ((WalkState->ControlState) &&
3980174267aSFredrik Holmqvist         (WalkState->ControlState->Common.State ==
3990174267aSFredrik Holmqvist             ACPI_CONTROL_CONDITIONAL_EXECUTING))
4000174267aSFredrik Holmqvist     {
401b64e8511SFredrik Holmqvist         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
402b64e8511SFredrik Holmqvist             "Exec predicate Op=%p State=%p\n",
4030174267aSFredrik Holmqvist             Op, WalkState));
4040174267aSFredrik Holmqvist 
405b64e8511SFredrik Holmqvist         WalkState->ControlState->Common.State =
406b64e8511SFredrik Holmqvist             ACPI_CONTROL_PREDICATE_EXECUTING;
4070174267aSFredrik Holmqvist 
4080174267aSFredrik Holmqvist         /* Save start of predicate */
4090174267aSFredrik Holmqvist 
4100174267aSFredrik Holmqvist         WalkState->ControlState->Control.PredicateOp = Op;
4110174267aSFredrik Holmqvist     }
4120174267aSFredrik Holmqvist 
4130174267aSFredrik Holmqvist 
4140174267aSFredrik Holmqvist     OpcodeClass = WalkState->OpInfo->Class;
4150174267aSFredrik Holmqvist 
4160174267aSFredrik Holmqvist     /* We want to send namepaths to the load code */
4170174267aSFredrik Holmqvist 
4180174267aSFredrik Holmqvist     if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
4190174267aSFredrik Holmqvist     {
4200174267aSFredrik Holmqvist         OpcodeClass = AML_CLASS_NAMED_OBJECT;
4210174267aSFredrik Holmqvist     }
4220174267aSFredrik Holmqvist 
4230174267aSFredrik Holmqvist     /*
4240174267aSFredrik Holmqvist      * Handle the opcode based upon the opcode type
4250174267aSFredrik Holmqvist      */
4260174267aSFredrik Holmqvist     switch (OpcodeClass)
4270174267aSFredrik Holmqvist     {
4280174267aSFredrik Holmqvist     case AML_CLASS_CONTROL:
4290174267aSFredrik Holmqvist 
4300174267aSFredrik Holmqvist         Status = AcpiDsExecBeginControlOp (WalkState, Op);
4310174267aSFredrik Holmqvist         break;
4320174267aSFredrik Holmqvist 
4330174267aSFredrik Holmqvist     case AML_CLASS_NAMED_OBJECT:
4340174267aSFredrik Holmqvist 
4350174267aSFredrik Holmqvist         if (WalkState->WalkType & ACPI_WALK_METHOD)
4360174267aSFredrik Holmqvist         {
4370174267aSFredrik Holmqvist             /*
4380174267aSFredrik Holmqvist              * Found a named object declaration during method execution;
4390174267aSFredrik Holmqvist              * we must enter this object into the namespace. The created
4400174267aSFredrik Holmqvist              * object is temporary and will be deleted upon completion of
4410174267aSFredrik Holmqvist              * the execution of this method.
4420174267aSFredrik Holmqvist              *
4430174267aSFredrik Holmqvist              * Note 10/2010: Except for the Scope() op. This opcode does
4440174267aSFredrik Holmqvist              * not actually create a new object, it refers to an existing
4450174267aSFredrik Holmqvist              * object. However, for Scope(), we want to indeed open a
4460174267aSFredrik Holmqvist              * new scope.
4470174267aSFredrik Holmqvist              */
4480174267aSFredrik Holmqvist             if (Op->Common.AmlOpcode != AML_SCOPE_OP)
4490174267aSFredrik Holmqvist             {
4500174267aSFredrik Holmqvist                 Status = AcpiDsLoad2BeginOp (WalkState, NULL);
4510174267aSFredrik Holmqvist             }
4520174267aSFredrik Holmqvist             else
4530174267aSFredrik Holmqvist             {
454b64e8511SFredrik Holmqvist                 Status = AcpiDsScopeStackPush (
455b64e8511SFredrik Holmqvist                     Op->Named.Node, Op->Named.Node->Type, WalkState);
4560174267aSFredrik Holmqvist                 if (ACPI_FAILURE (Status))
4570174267aSFredrik Holmqvist                 {
4580174267aSFredrik Holmqvist                     return_ACPI_STATUS (Status);
4590174267aSFredrik Holmqvist                 }
4600174267aSFredrik Holmqvist             }
4610174267aSFredrik Holmqvist         }
4620174267aSFredrik Holmqvist         break;
4630174267aSFredrik Holmqvist 
4640174267aSFredrik Holmqvist     case AML_CLASS_EXECUTE:
4650174267aSFredrik Holmqvist     case AML_CLASS_CREATE:
4660174267aSFredrik Holmqvist 
4670174267aSFredrik Holmqvist         break;
4680174267aSFredrik Holmqvist 
4690174267aSFredrik Holmqvist     default:
470c70258b7SJérôme Duval 
4710174267aSFredrik Holmqvist         break;
4720174267aSFredrik Holmqvist     }
4730174267aSFredrik Holmqvist 
4740174267aSFredrik Holmqvist     /* Nothing to do here during method execution */
4750174267aSFredrik Holmqvist 
4760174267aSFredrik Holmqvist     return_ACPI_STATUS (Status);
4770174267aSFredrik Holmqvist 
4780174267aSFredrik Holmqvist 
4790174267aSFredrik Holmqvist ErrorExit:
4800174267aSFredrik Holmqvist     Status = AcpiDsMethodError (Status, WalkState);
4810174267aSFredrik Holmqvist     return_ACPI_STATUS (Status);
4820174267aSFredrik Holmqvist }
4830174267aSFredrik Holmqvist 
4840174267aSFredrik Holmqvist 
4850174267aSFredrik Holmqvist /*****************************************************************************
4860174267aSFredrik Holmqvist  *
4870174267aSFredrik Holmqvist  * FUNCTION:    AcpiDsExecEndOp
4880174267aSFredrik Holmqvist  *
4890174267aSFredrik Holmqvist  * PARAMETERS:  WalkState       - Current state of the parse tree walk
4900174267aSFredrik Holmqvist  *
4910174267aSFredrik Holmqvist  * RETURN:      Status
4920174267aSFredrik Holmqvist  *
4930174267aSFredrik Holmqvist  * DESCRIPTION: Ascending callback used during the execution of control
4940174267aSFredrik Holmqvist  *              methods. The only thing we really need to do here is to
4950174267aSFredrik Holmqvist  *              notice the beginning of IF, ELSE, and WHILE blocks.
4960174267aSFredrik Holmqvist  *
4970174267aSFredrik Holmqvist  ****************************************************************************/
4980174267aSFredrik Holmqvist 
4990174267aSFredrik Holmqvist ACPI_STATUS
AcpiDsExecEndOp(ACPI_WALK_STATE * WalkState)5000174267aSFredrik Holmqvist AcpiDsExecEndOp (
5010174267aSFredrik Holmqvist     ACPI_WALK_STATE         *WalkState)
5020174267aSFredrik Holmqvist {
5030174267aSFredrik Holmqvist     ACPI_PARSE_OBJECT       *Op;
5040174267aSFredrik Holmqvist     ACPI_STATUS             Status = AE_OK;
5050174267aSFredrik Holmqvist     UINT32                  OpType;
5060174267aSFredrik Holmqvist     UINT32                  OpClass;
5070174267aSFredrik Holmqvist     ACPI_PARSE_OBJECT       *NextOp;
5080174267aSFredrik Holmqvist     ACPI_PARSE_OBJECT       *FirstArg;
5090ffed378SFredrik Holmqvist #ifdef ACPI_EXEC_APP
5100ffed378SFredrik Holmqvist     char                    *Namepath;
5110ffed378SFredrik Holmqvist     ACPI_OPERAND_OBJECT     *ObjDesc;
5120ffed378SFredrik Holmqvist #endif
5130174267aSFredrik Holmqvist 
5140174267aSFredrik Holmqvist     ACPI_FUNCTION_TRACE_PTR (DsExecEndOp, WalkState);
5150174267aSFredrik Holmqvist 
5160174267aSFredrik Holmqvist 
5170174267aSFredrik Holmqvist     Op = WalkState->Op;
5180174267aSFredrik Holmqvist     OpType = WalkState->OpInfo->Type;
5190174267aSFredrik Holmqvist     OpClass = WalkState->OpInfo->Class;
5200174267aSFredrik Holmqvist 
5210174267aSFredrik Holmqvist     if (OpClass == AML_CLASS_UNKNOWN)
5220174267aSFredrik Holmqvist     {
5230174267aSFredrik Holmqvist         ACPI_ERROR ((AE_INFO, "Unknown opcode 0x%X", Op->Common.AmlOpcode));
5240174267aSFredrik Holmqvist         return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
5250174267aSFredrik Holmqvist     }
5260174267aSFredrik Holmqvist 
5270174267aSFredrik Holmqvist     FirstArg = Op->Common.Value.Arg;
5280174267aSFredrik Holmqvist 
5290174267aSFredrik Holmqvist     /* Init the walk state */
5300174267aSFredrik Holmqvist 
5310174267aSFredrik Holmqvist     WalkState->NumOperands = 0;
5320174267aSFredrik Holmqvist     WalkState->OperandIndex = 0;
5330174267aSFredrik Holmqvist     WalkState->ReturnDesc = NULL;
5340174267aSFredrik Holmqvist     WalkState->ResultObj = NULL;
5350174267aSFredrik Holmqvist 
5360174267aSFredrik Holmqvist     /* Call debugger for single step support (DEBUG build only) */
5370174267aSFredrik Holmqvist 
538b64e8511SFredrik Holmqvist     Status = AcpiDbSingleStep (WalkState, Op, OpClass);
539b64e8511SFredrik Holmqvist     if (ACPI_FAILURE (Status))
540b64e8511SFredrik Holmqvist     {
541b64e8511SFredrik Holmqvist         return_ACPI_STATUS (Status);
542b64e8511SFredrik Holmqvist     }
5430174267aSFredrik Holmqvist 
5440174267aSFredrik Holmqvist     /* Decode the Opcode Class */
5450174267aSFredrik Holmqvist 
5460174267aSFredrik Holmqvist     switch (OpClass)
5470174267aSFredrik Holmqvist     {
5480174267aSFredrik Holmqvist     case AML_CLASS_ARGUMENT:    /* Constants, literals, etc. */
5490174267aSFredrik Holmqvist 
5500174267aSFredrik Holmqvist         if (WalkState->Opcode == AML_INT_NAMEPATH_OP)
5510174267aSFredrik Holmqvist         {
5520174267aSFredrik Holmqvist             Status = AcpiDsEvaluateNamePath (WalkState);
5530174267aSFredrik Holmqvist             if (ACPI_FAILURE (Status))
5540174267aSFredrik Holmqvist             {
5550174267aSFredrik Holmqvist                 goto Cleanup;
5560174267aSFredrik Holmqvist             }
5570174267aSFredrik Holmqvist         }
5580174267aSFredrik Holmqvist         break;
5590174267aSFredrik Holmqvist 
5600174267aSFredrik Holmqvist     case AML_CLASS_EXECUTE:     /* Most operators with arguments */
5610174267aSFredrik Holmqvist 
5620174267aSFredrik Holmqvist         /* Build resolved operand stack */
5630174267aSFredrik Holmqvist 
5640174267aSFredrik Holmqvist         Status = AcpiDsCreateOperands (WalkState, FirstArg);
5650174267aSFredrik Holmqvist         if (ACPI_FAILURE (Status))
5660174267aSFredrik Holmqvist         {
5670174267aSFredrik Holmqvist             goto Cleanup;
5680174267aSFredrik Holmqvist         }
5690174267aSFredrik Holmqvist 
5700174267aSFredrik Holmqvist         /*
5710174267aSFredrik Holmqvist          * All opcodes require operand resolution, with the only exceptions
57215338de9SPulkoMandy          * being the ObjectType and SizeOf operators as well as opcodes that
57315338de9SPulkoMandy          * take no arguments.
5740174267aSFredrik Holmqvist          */
57515338de9SPulkoMandy         if (!(WalkState->OpInfo->Flags & AML_NO_OPERAND_RESOLVE) &&
57615338de9SPulkoMandy             (WalkState->OpInfo->Flags & AML_HAS_ARGS))
5770174267aSFredrik Holmqvist         {
5780174267aSFredrik Holmqvist             /* Resolve all operands */
5790174267aSFredrik Holmqvist 
5800174267aSFredrik Holmqvist             Status = AcpiExResolveOperands (WalkState->Opcode,
5810174267aSFredrik Holmqvist                 &(WalkState->Operands [WalkState->NumOperands -1]),
5820174267aSFredrik Holmqvist                 WalkState);
5830174267aSFredrik Holmqvist         }
5840174267aSFredrik Holmqvist 
5850174267aSFredrik Holmqvist         if (ACPI_SUCCESS (Status))
5860174267aSFredrik Holmqvist         {
5870174267aSFredrik Holmqvist             /*
5880174267aSFredrik Holmqvist              * Dispatch the request to the appropriate interpreter handler
5890174267aSFredrik Holmqvist              * routine. There is one routine per opcode "type" based upon the
5900174267aSFredrik Holmqvist              * number of opcode arguments and return type.
5910174267aSFredrik Holmqvist              */
5920174267aSFredrik Holmqvist             Status = AcpiGbl_OpTypeDispatch[OpType] (WalkState);
5930174267aSFredrik Holmqvist         }
5940174267aSFredrik Holmqvist         else
5950174267aSFredrik Holmqvist         {
5960174267aSFredrik Holmqvist             /*
5970174267aSFredrik Holmqvist              * Treat constructs of the form "Store(LocalX,LocalX)" as noops when the
5980174267aSFredrik Holmqvist              * Local is uninitialized.
5990174267aSFredrik Holmqvist              */
6000174267aSFredrik Holmqvist             if  ((Status == AE_AML_UNINITIALIZED_LOCAL) &&
6010174267aSFredrik Holmqvist                 (WalkState->Opcode == AML_STORE_OP) &&
6020174267aSFredrik Holmqvist                 (WalkState->Operands[0]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
6030174267aSFredrik Holmqvist                 (WalkState->Operands[1]->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
6040174267aSFredrik Holmqvist                 (WalkState->Operands[0]->Reference.Class ==
6050174267aSFredrik Holmqvist                  WalkState->Operands[1]->Reference.Class) &&
6060174267aSFredrik Holmqvist                 (WalkState->Operands[0]->Reference.Value ==
6070174267aSFredrik Holmqvist                  WalkState->Operands[1]->Reference.Value))
6080174267aSFredrik Holmqvist             {
6090174267aSFredrik Holmqvist                 Status = AE_OK;
6100174267aSFredrik Holmqvist             }
6110174267aSFredrik Holmqvist             else
6120174267aSFredrik Holmqvist             {
6130174267aSFredrik Holmqvist                 ACPI_EXCEPTION ((AE_INFO, Status,
6140174267aSFredrik Holmqvist                     "While resolving operands for [%s]",
6150174267aSFredrik Holmqvist                     AcpiPsGetOpcodeName (WalkState->Opcode)));
6160174267aSFredrik Holmqvist             }
6170174267aSFredrik Holmqvist         }
6180174267aSFredrik Holmqvist 
6190174267aSFredrik Holmqvist         /* Always delete the argument objects and clear the operand stack */
6200174267aSFredrik Holmqvist 
6210174267aSFredrik Holmqvist         AcpiDsClearOperands (WalkState);
6220174267aSFredrik Holmqvist 
6230174267aSFredrik Holmqvist         /*
6240174267aSFredrik Holmqvist          * If a result object was returned from above, push it on the
6250174267aSFredrik Holmqvist          * current result stack
6260174267aSFredrik Holmqvist          */
6270174267aSFredrik Holmqvist         if (ACPI_SUCCESS (Status) &&
6280174267aSFredrik Holmqvist             WalkState->ResultObj)
6290174267aSFredrik Holmqvist         {
6300174267aSFredrik Holmqvist             Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
6310174267aSFredrik Holmqvist         }
6320174267aSFredrik Holmqvist         break;
6330174267aSFredrik Holmqvist 
6340174267aSFredrik Holmqvist     default:
6350174267aSFredrik Holmqvist 
6360174267aSFredrik Holmqvist         switch (OpType)
6370174267aSFredrik Holmqvist         {
6380174267aSFredrik Holmqvist         case AML_TYPE_CONTROL:    /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
6390174267aSFredrik Holmqvist 
6400174267aSFredrik Holmqvist             /* 1 Operand, 0 ExternalResult, 0 InternalResult */
6410174267aSFredrik Holmqvist 
6420174267aSFredrik Holmqvist             Status = AcpiDsExecEndControlOp (WalkState, Op);
6430174267aSFredrik Holmqvist 
6440174267aSFredrik Holmqvist             break;
6450174267aSFredrik Holmqvist 
6460174267aSFredrik Holmqvist         case AML_TYPE_METHOD_CALL:
6470174267aSFredrik Holmqvist             /*
6480174267aSFredrik Holmqvist              * If the method is referenced from within a package
6490174267aSFredrik Holmqvist              * declaration, it is not a invocation of the method, just
6500174267aSFredrik Holmqvist              * a reference to it.
6510174267aSFredrik Holmqvist              */
6520174267aSFredrik Holmqvist             if ((Op->Asl.Parent) &&
6530174267aSFredrik Holmqvist                ((Op->Asl.Parent->Asl.AmlOpcode == AML_PACKAGE_OP) ||
654ff2e2f81SFredrik Holmqvist                 (Op->Asl.Parent->Asl.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
6550174267aSFredrik Holmqvist             {
6560174267aSFredrik Holmqvist                 ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
6570174267aSFredrik Holmqvist                     "Method Reference in a Package, Op=%p\n", Op));
6580174267aSFredrik Holmqvist 
659b64e8511SFredrik Holmqvist                 Op->Common.Node = (ACPI_NAMESPACE_NODE *)
660b64e8511SFredrik Holmqvist                     Op->Asl.Value.Arg->Asl.Node;
6610174267aSFredrik Holmqvist                 AcpiUtAddReference (Op->Asl.Value.Arg->Asl.Node->Object);
6620174267aSFredrik Holmqvist                 return_ACPI_STATUS (AE_OK);
6630174267aSFredrik Holmqvist             }
6640174267aSFredrik Holmqvist 
665ad5bbfb8SFredrik Holmqvist             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
666ad5bbfb8SFredrik Holmqvist                 "Method invocation, Op=%p\n", Op));
6670174267aSFredrik Holmqvist 
6680174267aSFredrik Holmqvist             /*
6690174267aSFredrik Holmqvist              * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains
6700174267aSFredrik Holmqvist              * the method Node pointer
6710174267aSFredrik Holmqvist              */
6720174267aSFredrik Holmqvist             /* NextOp points to the op that holds the method name */
6730174267aSFredrik Holmqvist 
6740174267aSFredrik Holmqvist             NextOp = FirstArg;
6750174267aSFredrik Holmqvist 
6760174267aSFredrik Holmqvist             /* NextOp points to first argument op */
6770174267aSFredrik Holmqvist 
6780174267aSFredrik Holmqvist             NextOp = NextOp->Common.Next;
6790174267aSFredrik Holmqvist 
6800174267aSFredrik Holmqvist             /*
6810174267aSFredrik Holmqvist              * Get the method's arguments and put them on the operand stack
6820174267aSFredrik Holmqvist              */
6830174267aSFredrik Holmqvist             Status = AcpiDsCreateOperands (WalkState, NextOp);
6840174267aSFredrik Holmqvist             if (ACPI_FAILURE (Status))
6850174267aSFredrik Holmqvist             {
6860174267aSFredrik Holmqvist                 break;
6870174267aSFredrik Holmqvist             }
6880174267aSFredrik Holmqvist 
6890174267aSFredrik Holmqvist             /*
6900174267aSFredrik Holmqvist              * Since the operands will be passed to another control method,
6910174267aSFredrik Holmqvist              * we must resolve all local references here (Local variables,
6920174267aSFredrik Holmqvist              * arguments to *this* method, etc.)
6930174267aSFredrik Holmqvist              */
6940174267aSFredrik Holmqvist             Status = AcpiDsResolveOperands (WalkState);
6950174267aSFredrik Holmqvist             if (ACPI_FAILURE (Status))
6960174267aSFredrik Holmqvist             {
6970174267aSFredrik Holmqvist                 /* On error, clear all resolved operands */
6980174267aSFredrik Holmqvist 
6990174267aSFredrik Holmqvist                 AcpiDsClearOperands (WalkState);
7000174267aSFredrik Holmqvist                 break;
7010174267aSFredrik Holmqvist             }
7020174267aSFredrik Holmqvist 
7030174267aSFredrik Holmqvist             /*
7040174267aSFredrik Holmqvist              * Tell the walk loop to preempt this running method and
7050174267aSFredrik Holmqvist              * execute the new method
7060174267aSFredrik Holmqvist              */
7070174267aSFredrik Holmqvist             Status = AE_CTRL_TRANSFER;
7080174267aSFredrik Holmqvist 
7090174267aSFredrik Holmqvist             /*
7100174267aSFredrik Holmqvist              * Return now; we don't want to disturb anything,
7110174267aSFredrik Holmqvist              * especially the operand count!
7120174267aSFredrik Holmqvist              */
7130174267aSFredrik Holmqvist             return_ACPI_STATUS (Status);
7140174267aSFredrik Holmqvist 
7150174267aSFredrik Holmqvist         case AML_TYPE_CREATE_FIELD:
7160174267aSFredrik Holmqvist 
7170174267aSFredrik Holmqvist             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
7180174267aSFredrik Holmqvist                 "Executing CreateField Buffer/Index Op=%p\n", Op));
7190174267aSFredrik Holmqvist 
7200174267aSFredrik Holmqvist             Status = AcpiDsLoad2EndOp (WalkState);
7210174267aSFredrik Holmqvist             if (ACPI_FAILURE (Status))
7220174267aSFredrik Holmqvist             {
7230174267aSFredrik Holmqvist                 break;
7240174267aSFredrik Holmqvist             }
7250174267aSFredrik Holmqvist 
7260174267aSFredrik Holmqvist             Status = AcpiDsEvalBufferFieldOperands (WalkState, Op);
7270ffed378SFredrik Holmqvist             if (ACPI_FAILURE (Status))
7280ffed378SFredrik Holmqvist             {
7290ffed378SFredrik Holmqvist                 break;
7300ffed378SFredrik Holmqvist             }
7310ffed378SFredrik Holmqvist 
7320ffed378SFredrik Holmqvist #ifdef ACPI_EXEC_APP
7330ffed378SFredrik Holmqvist             /*
7340ffed378SFredrik Holmqvist              * AcpiExec support for namespace initialization file (initialize
7350ffed378SFredrik Holmqvist              * BufferFields in this code.)
7360ffed378SFredrik Holmqvist              */
7370ffed378SFredrik Holmqvist             Namepath = AcpiNsGetExternalPathname (Op->Common.Node);
7380ffed378SFredrik Holmqvist             Status = AeLookupInitFileEntry (Namepath, &ObjDesc);
7390ffed378SFredrik Holmqvist             if (ACPI_SUCCESS (Status))
7400ffed378SFredrik Holmqvist             {
7410ffed378SFredrik Holmqvist                 Status = AcpiExWriteDataToField (ObjDesc, Op->Common.Node->Object, NULL);
74215338de9SPulkoMandy                 if (ACPI_FAILURE (Status))
7430ffed378SFredrik Holmqvist                 {
7440ffed378SFredrik Holmqvist                     ACPI_EXCEPTION ((AE_INFO, Status, "While writing to buffer field"));
7450ffed378SFredrik Holmqvist                 }
7460ffed378SFredrik Holmqvist             }
7470ffed378SFredrik Holmqvist             ACPI_FREE (Namepath);
7480ffed378SFredrik Holmqvist             Status = AE_OK;
7490ffed378SFredrik Holmqvist #endif
7500174267aSFredrik Holmqvist             break;
7510174267aSFredrik Holmqvist 
7520174267aSFredrik Holmqvist 
7530174267aSFredrik Holmqvist         case AML_TYPE_CREATE_OBJECT:
7540174267aSFredrik Holmqvist 
7550174267aSFredrik Holmqvist             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
75608c9948cSFredrik Holmqvist                 "Executing CreateObject (Buffer/Package) Op=%p Child=%p ParentOpcode=%4.4X\n",
75708c9948cSFredrik Holmqvist                 Op, Op->Named.Value.Arg, Op->Common.Parent->Common.AmlOpcode));
7580174267aSFredrik Holmqvist 
7590174267aSFredrik Holmqvist             switch (Op->Common.Parent->Common.AmlOpcode)
7600174267aSFredrik Holmqvist             {
7610174267aSFredrik Holmqvist             case AML_NAME_OP:
7620174267aSFredrik Holmqvist                 /*
7630174267aSFredrik Holmqvist                  * Put the Node on the object stack (Contains the ACPI Name
7640174267aSFredrik Holmqvist                  * of this object)
7650174267aSFredrik Holmqvist                  */
766b64e8511SFredrik Holmqvist                 WalkState->Operands[0] = (void *)
767b64e8511SFredrik Holmqvist                     Op->Common.Parent->Common.Node;
7680174267aSFredrik Holmqvist                 WalkState->NumOperands = 1;
7690174267aSFredrik Holmqvist 
7700174267aSFredrik Holmqvist                 Status = AcpiDsCreateNode (WalkState,
771b64e8511SFredrik Holmqvist                     Op->Common.Parent->Common.Node, Op->Common.Parent);
7720174267aSFredrik Holmqvist                 if (ACPI_FAILURE (Status))
7730174267aSFredrik Holmqvist                 {
7740174267aSFredrik Holmqvist                     break;
7750174267aSFredrik Holmqvist                 }
7760174267aSFredrik Holmqvist 
7770ffed378SFredrik Holmqvist                 ACPI_FALLTHROUGH;
7780174267aSFredrik Holmqvist 
7790174267aSFredrik Holmqvist             case AML_INT_EVAL_SUBTREE_OP:
7800174267aSFredrik Holmqvist 
7810174267aSFredrik Holmqvist                 Status = AcpiDsEvalDataObjectOperands (WalkState, Op,
7820174267aSFredrik Holmqvist                     AcpiNsGetAttachedObject (Op->Common.Parent->Common.Node));
7830174267aSFredrik Holmqvist                 break;
7840174267aSFredrik Holmqvist 
7850174267aSFredrik Holmqvist             default:
7860174267aSFredrik Holmqvist 
7870174267aSFredrik Holmqvist                 Status = AcpiDsEvalDataObjectOperands (WalkState, Op, NULL);
7880174267aSFredrik Holmqvist                 break;
7890174267aSFredrik Holmqvist             }
7900174267aSFredrik Holmqvist 
7910174267aSFredrik Holmqvist             /*
7920174267aSFredrik Holmqvist              * If a result object was returned from above, push it on the
7930174267aSFredrik Holmqvist              * current result stack
7940174267aSFredrik Holmqvist              */
7950174267aSFredrik Holmqvist             if (WalkState->ResultObj)
7960174267aSFredrik Holmqvist             {
7970174267aSFredrik Holmqvist                 Status = AcpiDsResultPush (WalkState->ResultObj, WalkState);
7980174267aSFredrik Holmqvist             }
7990174267aSFredrik Holmqvist             break;
8000174267aSFredrik Holmqvist 
8010174267aSFredrik Holmqvist         case AML_TYPE_NAMED_FIELD:
8020174267aSFredrik Holmqvist         case AML_TYPE_NAMED_COMPLEX:
8030174267aSFredrik Holmqvist         case AML_TYPE_NAMED_SIMPLE:
8040174267aSFredrik Holmqvist         case AML_TYPE_NAMED_NO_OBJ:
8050174267aSFredrik Holmqvist 
8060174267aSFredrik Holmqvist             Status = AcpiDsLoad2EndOp (WalkState);
8070174267aSFredrik Holmqvist             if (ACPI_FAILURE (Status))
8080174267aSFredrik Holmqvist             {
8090174267aSFredrik Holmqvist                 break;
8100174267aSFredrik Holmqvist             }
8110174267aSFredrik Holmqvist 
8120174267aSFredrik Holmqvist             if (Op->Common.AmlOpcode == AML_REGION_OP)
8130174267aSFredrik Holmqvist             {
8140174267aSFredrik Holmqvist                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
8150174267aSFredrik Holmqvist                     "Executing OpRegion Address/Length Op=%p\n", Op));
8160174267aSFredrik Holmqvist 
8170174267aSFredrik Holmqvist                 Status = AcpiDsEvalRegionOperands (WalkState, Op);
8180174267aSFredrik Holmqvist                 if (ACPI_FAILURE (Status))
8190174267aSFredrik Holmqvist                 {
8200174267aSFredrik Holmqvist                     break;
8210174267aSFredrik Holmqvist                 }
8220174267aSFredrik Holmqvist             }
8230174267aSFredrik Holmqvist             else if (Op->Common.AmlOpcode == AML_DATA_REGION_OP)
8240174267aSFredrik Holmqvist             {
8250174267aSFredrik Holmqvist                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
8260174267aSFredrik Holmqvist                     "Executing DataTableRegion Strings Op=%p\n", Op));
8270174267aSFredrik Holmqvist 
8280174267aSFredrik Holmqvist                 Status = AcpiDsEvalTableRegionOperands (WalkState, Op);
8290174267aSFredrik Holmqvist                 if (ACPI_FAILURE (Status))
8300174267aSFredrik Holmqvist                 {
8310174267aSFredrik Holmqvist                     break;
8320174267aSFredrik Holmqvist                 }
8330174267aSFredrik Holmqvist             }
8340174267aSFredrik Holmqvist             else if (Op->Common.AmlOpcode == AML_BANK_FIELD_OP)
8350174267aSFredrik Holmqvist             {
8360174267aSFredrik Holmqvist                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
8370174267aSFredrik Holmqvist                     "Executing BankField Op=%p\n", Op));
8380174267aSFredrik Holmqvist 
8390174267aSFredrik Holmqvist                 Status = AcpiDsEvalBankFieldOperands (WalkState, Op);
8400174267aSFredrik Holmqvist                 if (ACPI_FAILURE (Status))
8410174267aSFredrik Holmqvist                 {
8420174267aSFredrik Holmqvist                     break;
8430174267aSFredrik Holmqvist                 }
8440174267aSFredrik Holmqvist             }
8450174267aSFredrik Holmqvist             break;
8460174267aSFredrik Holmqvist 
8470174267aSFredrik Holmqvist         case AML_TYPE_UNDEFINED:
8480174267aSFredrik Holmqvist 
8490174267aSFredrik Holmqvist             ACPI_ERROR ((AE_INFO,
8500174267aSFredrik Holmqvist                 "Undefined opcode type Op=%p", Op));
8510174267aSFredrik Holmqvist             return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
8520174267aSFredrik Holmqvist 
8530174267aSFredrik Holmqvist         case AML_TYPE_BOGUS:
8540174267aSFredrik Holmqvist 
8550174267aSFredrik Holmqvist             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
8560174267aSFredrik Holmqvist                 "Internal opcode=%X type Op=%p\n",
8570174267aSFredrik Holmqvist                 WalkState->Opcode, Op));
8580174267aSFredrik Holmqvist             break;
8590174267aSFredrik Holmqvist 
8600174267aSFredrik Holmqvist         default:
8610174267aSFredrik Holmqvist 
8620174267aSFredrik Holmqvist             ACPI_ERROR ((AE_INFO,
863b64e8511SFredrik Holmqvist                 "Unimplemented opcode, class=0x%X "
864b64e8511SFredrik Holmqvist                 "type=0x%X Opcode=0x%X Op=%p",
8650174267aSFredrik Holmqvist                 OpClass, OpType, Op->Common.AmlOpcode, Op));
8660174267aSFredrik Holmqvist 
8670174267aSFredrik Holmqvist             Status = AE_NOT_IMPLEMENTED;
8680174267aSFredrik Holmqvist             break;
8690174267aSFredrik Holmqvist         }
8700174267aSFredrik Holmqvist     }
8710174267aSFredrik Holmqvist 
8720174267aSFredrik Holmqvist     /*
8730174267aSFredrik Holmqvist      * ACPI 2.0 support for 64-bit integers: Truncate numeric
8740174267aSFredrik Holmqvist      * result value if we are executing from a 32-bit ACPI table
8750174267aSFredrik Holmqvist      */
876c70258b7SJérôme Duval     (void) AcpiExTruncateFor32bitTable (WalkState->ResultObj);
8770174267aSFredrik Holmqvist 
8780174267aSFredrik Holmqvist     /*
8790174267aSFredrik Holmqvist      * Check if we just completed the evaluation of a
8800174267aSFredrik Holmqvist      * conditional predicate
8810174267aSFredrik Holmqvist      */
8820174267aSFredrik Holmqvist     if ((ACPI_SUCCESS (Status)) &&
8830174267aSFredrik Holmqvist         (WalkState->ControlState) &&
8840174267aSFredrik Holmqvist         (WalkState->ControlState->Common.State ==
8850174267aSFredrik Holmqvist             ACPI_CONTROL_PREDICATE_EXECUTING) &&
8860174267aSFredrik Holmqvist         (WalkState->ControlState->Control.PredicateOp == Op))
8870174267aSFredrik Holmqvist     {
8880174267aSFredrik Holmqvist         Status = AcpiDsGetPredicateValue (WalkState, WalkState->ResultObj);
8890174267aSFredrik Holmqvist         WalkState->ResultObj = NULL;
8900174267aSFredrik Holmqvist     }
8910174267aSFredrik Holmqvist 
8920174267aSFredrik Holmqvist 
8930174267aSFredrik Holmqvist Cleanup:
8940174267aSFredrik Holmqvist 
8950174267aSFredrik Holmqvist     if (WalkState->ResultObj)
8960174267aSFredrik Holmqvist     {
8970174267aSFredrik Holmqvist         /* Break to debugger to display result */
8980174267aSFredrik Holmqvist 
899b64e8511SFredrik Holmqvist         AcpiDbDisplayResultObject (WalkState->ResultObj,WalkState);
9000174267aSFredrik Holmqvist 
9010174267aSFredrik Holmqvist         /*
9020174267aSFredrik Holmqvist          * Delete the result op if and only if:
9030174267aSFredrik Holmqvist          * Parent will not use the result -- such as any
9040174267aSFredrik Holmqvist          * non-nested type2 op in a method (parent will be method)
9050174267aSFredrik Holmqvist          */
9060174267aSFredrik Holmqvist         AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState);
9070174267aSFredrik Holmqvist     }
9080174267aSFredrik Holmqvist 
9090174267aSFredrik Holmqvist #ifdef _UNDER_DEVELOPMENT
9100174267aSFredrik Holmqvist 
9110174267aSFredrik Holmqvist     if (WalkState->ParserState.Aml == WalkState->ParserState.AmlEnd)
9120174267aSFredrik Holmqvist     {
9130174267aSFredrik Holmqvist         AcpiDbMethodEnd (WalkState);
9140174267aSFredrik Holmqvist     }
9150174267aSFredrik Holmqvist #endif
9160174267aSFredrik Holmqvist 
9170174267aSFredrik Holmqvist     /* Invoke exception handler on error */
9180174267aSFredrik Holmqvist 
9190174267aSFredrik Holmqvist     if (ACPI_FAILURE (Status))
9200174267aSFredrik Holmqvist     {
9210174267aSFredrik Holmqvist         Status = AcpiDsMethodError (Status, WalkState);
9220174267aSFredrik Holmqvist     }
9230174267aSFredrik Holmqvist 
9240174267aSFredrik Holmqvist     /* Always clear the object stack */
9250174267aSFredrik Holmqvist 
9260174267aSFredrik Holmqvist     WalkState->NumOperands = 0;
9270174267aSFredrik Holmqvist     return_ACPI_STATUS (Status);
9280174267aSFredrik Holmqvist }
929