17c478bd9Sstevel@tonic-gate /******************************************************************************
27c478bd9Sstevel@tonic-gate  *
37c478bd9Sstevel@tonic-gate  * Module Name: exoparg1 - AML execution - opcodes with 1 argument
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  *****************************************************************************/
67c478bd9Sstevel@tonic-gate 
7*35786f68SRobert Mustacchi /******************************************************************************
8*35786f68SRobert Mustacchi  *
9*35786f68SRobert Mustacchi  * 1. Copyright Notice
10*35786f68SRobert Mustacchi  *
11*35786f68SRobert Mustacchi  * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
127c478bd9Sstevel@tonic-gate  * All rights reserved.
137c478bd9Sstevel@tonic-gate  *
14*35786f68SRobert Mustacchi  * 2. License
15*35786f68SRobert Mustacchi  *
16*35786f68SRobert Mustacchi  * 2.1. This is your license from Intel Corp. under its intellectual property
17*35786f68SRobert Mustacchi  * rights. You may have additional license terms from the party that provided
18*35786f68SRobert Mustacchi  * you this software, covering your right to use that party's intellectual
19*35786f68SRobert Mustacchi  * property rights.
20*35786f68SRobert Mustacchi  *
21*35786f68SRobert Mustacchi  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*35786f68SRobert Mustacchi  * copy of the source code appearing in this file ("Covered Code") an
23*35786f68SRobert Mustacchi  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*35786f68SRobert Mustacchi  * base code distributed originally by Intel ("Original Intel Code") to copy,
25*35786f68SRobert Mustacchi  * make derivatives, distribute, use and display any portion of the Covered
26*35786f68SRobert Mustacchi  * Code in any form, with the right to sublicense such rights; and
27*35786f68SRobert Mustacchi  *
28*35786f68SRobert Mustacchi  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*35786f68SRobert Mustacchi  * license (with the right to sublicense), under only those claims of Intel
30*35786f68SRobert Mustacchi  * patents that are infringed by the Original Intel Code, to make, use, sell,
31*35786f68SRobert Mustacchi  * offer to sell, and import the Covered Code and derivative works thereof
32*35786f68SRobert Mustacchi  * solely to the minimum extent necessary to exercise the above copyright
33*35786f68SRobert Mustacchi  * license, and in no event shall the patent license extend to any additions
34*35786f68SRobert Mustacchi  * to or modifications of the Original Intel Code. No other license or right
35*35786f68SRobert Mustacchi  * is granted directly or by implication, estoppel or otherwise;
36*35786f68SRobert Mustacchi  *
37*35786f68SRobert Mustacchi  * The above copyright and patent license is granted only if the following
38*35786f68SRobert Mustacchi  * conditions are met:
39*35786f68SRobert Mustacchi  *
40*35786f68SRobert Mustacchi  * 3. Conditions
41*35786f68SRobert Mustacchi  *
42*35786f68SRobert Mustacchi  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*35786f68SRobert Mustacchi  * Redistribution of source code of any substantial portion of the Covered
44*35786f68SRobert Mustacchi  * Code or modification with rights to further distribute source must include
45*35786f68SRobert Mustacchi  * the above Copyright Notice, the above License, this list of Conditions,
46*35786f68SRobert Mustacchi  * and the following Disclaimer and Export Compliance provision. In addition,
47*35786f68SRobert Mustacchi  * Licensee must cause all Covered Code to which Licensee contributes to
48*35786f68SRobert Mustacchi  * contain a file documenting the changes Licensee made to create that Covered
49*35786f68SRobert Mustacchi  * Code and the date of any change. Licensee must include in that file the
50*35786f68SRobert Mustacchi  * documentation of any changes made by any predecessor Licensee. Licensee
51*35786f68SRobert Mustacchi  * must include a prominent statement that the modification is derived,
52*35786f68SRobert Mustacchi  * directly or indirectly, from Original Intel Code.
53*35786f68SRobert Mustacchi  *
54*35786f68SRobert Mustacchi  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*35786f68SRobert Mustacchi  * Redistribution of source code of any substantial portion of the Covered
56*35786f68SRobert Mustacchi  * Code or modification without rights to further distribute source must
57*35786f68SRobert Mustacchi  * include the following Disclaimer and Export Compliance provision in the
58*35786f68SRobert Mustacchi  * documentation and/or other materials provided with distribution. In
59*35786f68SRobert Mustacchi  * addition, Licensee may not authorize further sublicense of source of any
60*35786f68SRobert Mustacchi  * portion of the Covered Code, and must include terms to the effect that the
61*35786f68SRobert Mustacchi  * license from Licensee to its licensee is limited to the intellectual
62*35786f68SRobert Mustacchi  * property embodied in the software Licensee provides to its licensee, and
63*35786f68SRobert Mustacchi  * not to intellectual property embodied in modifications its licensee may
64*35786f68SRobert Mustacchi  * make.
65*35786f68SRobert Mustacchi  *
66*35786f68SRobert Mustacchi  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*35786f68SRobert Mustacchi  * substantial portion of the Covered Code or modification must reproduce the
68*35786f68SRobert Mustacchi  * above Copyright Notice, and the following Disclaimer and Export Compliance
69*35786f68SRobert Mustacchi  * provision in the documentation and/or other materials provided with the
70*35786f68SRobert Mustacchi  * distribution.
71*35786f68SRobert Mustacchi  *
72*35786f68SRobert Mustacchi  * 3.4. Intel retains all right, title, and interest in and to the Original
73*35786f68SRobert Mustacchi  * Intel Code.
74*35786f68SRobert Mustacchi  *
75*35786f68SRobert Mustacchi  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*35786f68SRobert Mustacchi  * Intel shall be used in advertising or otherwise to promote the sale, use or
77*35786f68SRobert Mustacchi  * other dealings in products derived from or relating to the Covered Code
78*35786f68SRobert Mustacchi  * without prior written authorization from Intel.
79*35786f68SRobert Mustacchi  *
80*35786f68SRobert Mustacchi  * 4. Disclaimer and Export Compliance
81*35786f68SRobert Mustacchi  *
82*35786f68SRobert Mustacchi  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*35786f68SRobert Mustacchi  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*35786f68SRobert Mustacchi  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*35786f68SRobert Mustacchi  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*35786f68SRobert Mustacchi  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*35786f68SRobert Mustacchi  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*35786f68SRobert Mustacchi  * PARTICULAR PURPOSE.
89*35786f68SRobert Mustacchi  *
90*35786f68SRobert Mustacchi  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*35786f68SRobert Mustacchi  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*35786f68SRobert Mustacchi  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*35786f68SRobert Mustacchi  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*35786f68SRobert Mustacchi  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*35786f68SRobert Mustacchi  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*35786f68SRobert Mustacchi  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*35786f68SRobert Mustacchi  * LIMITED REMEDY.
98*35786f68SRobert Mustacchi  *
99*35786f68SRobert Mustacchi  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*35786f68SRobert Mustacchi  * software or system incorporating such software without first obtaining any
101*35786f68SRobert Mustacchi  * required license or other approval from the U. S. Department of Commerce or
102*35786f68SRobert Mustacchi  * any other agency or department of the United States Government. In the
103*35786f68SRobert Mustacchi  * event Licensee exports any such software from the United States or
104*35786f68SRobert Mustacchi  * re-exports any such software from a foreign destination, Licensee shall
105*35786f68SRobert Mustacchi  * ensure that the distribution and export/re-export of the software is in
106*35786f68SRobert Mustacchi  * compliance with all laws, regulations, orders, or other restrictions of the
107*35786f68SRobert Mustacchi  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*35786f68SRobert Mustacchi  * any of its subsidiaries will export/re-export any technical data, process,
109*35786f68SRobert Mustacchi  * software, or service, directly or indirectly, to any country for which the
110*35786f68SRobert Mustacchi  * United States government or any agency thereof requires an export license,
111*35786f68SRobert Mustacchi  * other governmental approval, or letter of assurance, without first obtaining
112*35786f68SRobert Mustacchi  * such license, approval or letter.
113*35786f68SRobert Mustacchi  *
114*35786f68SRobert Mustacchi  *****************************************************************************
115*35786f68SRobert Mustacchi  *
116*35786f68SRobert Mustacchi  * Alternatively, you may choose to be licensed under the terms of the
117*35786f68SRobert Mustacchi  * following license:
118*35786f68SRobert Mustacchi  *
11926f3cdf0SGordon Ross  * Redistribution and use in source and binary forms, with or without
12026f3cdf0SGordon Ross  * modification, are permitted provided that the following conditions
12126f3cdf0SGordon Ross  * are met:
12226f3cdf0SGordon Ross  * 1. Redistributions of source code must retain the above copyright
12326f3cdf0SGordon Ross  *    notice, this list of conditions, and the following disclaimer,
12426f3cdf0SGordon Ross  *    without modification.
12526f3cdf0SGordon Ross  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12626f3cdf0SGordon Ross  *    substantially similar to the "NO WARRANTY" disclaimer below
12726f3cdf0SGordon Ross  *    ("Disclaimer") and any redistribution must be conditioned upon
12826f3cdf0SGordon Ross  *    including a substantially similar Disclaimer requirement for further
12926f3cdf0SGordon Ross  *    binary redistribution.
13026f3cdf0SGordon Ross  * 3. Neither the names of the above-listed copyright holders nor the names
13126f3cdf0SGordon Ross  *    of any contributors may be used to endorse or promote products derived
13226f3cdf0SGordon Ross  *    from this software without specific prior written permission.
1337c478bd9Sstevel@tonic-gate  *
13426f3cdf0SGordon Ross  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13526f3cdf0SGordon Ross  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*35786f68SRobert Mustacchi  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
13726f3cdf0SGordon Ross  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*35786f68SRobert Mustacchi  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*35786f68SRobert Mustacchi  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*35786f68SRobert Mustacchi  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*35786f68SRobert Mustacchi  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*35786f68SRobert Mustacchi  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*35786f68SRobert Mustacchi  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*35786f68SRobert Mustacchi  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*35786f68SRobert Mustacchi  *
146*35786f68SRobert Mustacchi  * Alternatively, you may choose to be licensed under the terms of the
147*35786f68SRobert Mustacchi  * GNU General Public License ("GPL") version 2 as published by the Free
148*35786f68SRobert Mustacchi  * Software Foundation.
149*35786f68SRobert Mustacchi  *
150*35786f68SRobert Mustacchi  *****************************************************************************/
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate #include "acpi.h"
153aa2aa9a6SDana Myers #include "accommon.h"
1547c478bd9Sstevel@tonic-gate #include "acparser.h"
1557c478bd9Sstevel@tonic-gate #include "acdispat.h"
1567c478bd9Sstevel@tonic-gate #include "acinterp.h"
1577c478bd9Sstevel@tonic-gate #include "amlcode.h"
1587c478bd9Sstevel@tonic-gate #include "acnamesp.h"
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #define _COMPONENT          ACPI_EXECUTER
1627c478bd9Sstevel@tonic-gate         ACPI_MODULE_NAME    ("exoparg1")
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate /*!
1667c478bd9Sstevel@tonic-gate  * Naming convention for AML interpreter execution routines.
1677c478bd9Sstevel@tonic-gate  *
1687c478bd9Sstevel@tonic-gate  * The routines that begin execution of AML opcodes are named with a common
1697c478bd9Sstevel@tonic-gate  * convention based upon the number of arguments, the number of target operands,
1707c478bd9Sstevel@tonic-gate  * and whether or not a value is returned:
1717c478bd9Sstevel@tonic-gate  *
1727c478bd9Sstevel@tonic-gate  *      AcpiExOpcode_xA_yT_zR
1737c478bd9Sstevel@tonic-gate  *
1747c478bd9Sstevel@tonic-gate  * Where:
1757c478bd9Sstevel@tonic-gate  *
1767c478bd9Sstevel@tonic-gate  * xA - ARGUMENTS:    The number of arguments (input operands) that are
1777c478bd9Sstevel@tonic-gate  *                    required for this opcode type (0 through 6 args).
1787c478bd9Sstevel@tonic-gate  * yT - TARGETS:      The number of targets (output operands) that are required
1797c478bd9Sstevel@tonic-gate  *                    for this opcode type (0, 1, or 2 targets).
1807c478bd9Sstevel@tonic-gate  * zR - RETURN VALUE: Indicates whether this opcode type returns a value
1817c478bd9Sstevel@tonic-gate  *                    as the function return (0 or 1).
1827c478bd9Sstevel@tonic-gate  *
1837c478bd9Sstevel@tonic-gate  * The AcpiExOpcode* functions are called via the Dispatcher component with
1847c478bd9Sstevel@tonic-gate  * fully resolved operands.
1857c478bd9Sstevel@tonic-gate !*/
1867c478bd9Sstevel@tonic-gate 
1877c478bd9Sstevel@tonic-gate /*******************************************************************************
1887c478bd9Sstevel@tonic-gate  *
1897c478bd9Sstevel@tonic-gate  * FUNCTION:    AcpiExOpcode_0A_0T_1R
1907c478bd9Sstevel@tonic-gate  *
1917c478bd9Sstevel@tonic-gate  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
1927c478bd9Sstevel@tonic-gate  *
1937c478bd9Sstevel@tonic-gate  * RETURN:      Status
1947c478bd9Sstevel@tonic-gate  *
1957c478bd9Sstevel@tonic-gate  * DESCRIPTION: Execute operator with no operands, one return value
1967c478bd9Sstevel@tonic-gate  *
1977c478bd9Sstevel@tonic-gate  ******************************************************************************/
1987c478bd9Sstevel@tonic-gate 
1997c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiExOpcode_0A_0T_1R(ACPI_WALK_STATE * WalkState)2007c478bd9Sstevel@tonic-gate AcpiExOpcode_0A_0T_1R (
2017c478bd9Sstevel@tonic-gate     ACPI_WALK_STATE         *WalkState)
2027c478bd9Sstevel@tonic-gate {
2037c478bd9Sstevel@tonic-gate     ACPI_STATUS             Status = AE_OK;
2047c478bd9Sstevel@tonic-gate     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate 
20727f7c583Smyers     ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R,
2087c478bd9Sstevel@tonic-gate         AcpiPsGetOpcodeName (WalkState->Opcode));
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate     /* Examine the AML opcode */
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate     switch (WalkState->Opcode)
2147c478bd9Sstevel@tonic-gate     {
2157c478bd9Sstevel@tonic-gate     case AML_TIMER_OP:      /*  Timer () */
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate         /* Create a return object of type Integer */
2187c478bd9Sstevel@tonic-gate 
21957190917SDana Myers         ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ());
2207c478bd9Sstevel@tonic-gate         if (!ReturnDesc)
2217c478bd9Sstevel@tonic-gate         {
2227c478bd9Sstevel@tonic-gate             Status = AE_NO_MEMORY;
2237c478bd9Sstevel@tonic-gate             goto Cleanup;
2247c478bd9Sstevel@tonic-gate         }
2257c478bd9Sstevel@tonic-gate         break;
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate     default:                /*  Unknown opcode  */
2287c478bd9Sstevel@tonic-gate 
22926f3cdf0SGordon Ross         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
2307c478bd9Sstevel@tonic-gate             WalkState->Opcode));
2317c478bd9Sstevel@tonic-gate         Status = AE_AML_BAD_OPCODE;
2327c478bd9Sstevel@tonic-gate         break;
2337c478bd9Sstevel@tonic-gate     }
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate Cleanup:
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate     /* Delete return object on error */
2387c478bd9Sstevel@tonic-gate 
239450d6964Smyers     if ((ACPI_FAILURE (Status)) || WalkState->ResultObj)
2407c478bd9Sstevel@tonic-gate     {
2417c478bd9Sstevel@tonic-gate         AcpiUtRemoveReference (ReturnDesc);
242db2bae30SDana Myers         WalkState->ResultObj = NULL;
2437c478bd9Sstevel@tonic-gate     }
244450d6964Smyers     else
245450d6964Smyers     {
246450d6964Smyers         /* Save the return value */
247450d6964Smyers 
248450d6964Smyers         WalkState->ResultObj = ReturnDesc;
249450d6964Smyers     }
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate     return_ACPI_STATUS (Status);
2527c478bd9Sstevel@tonic-gate }
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate 
2557c478bd9Sstevel@tonic-gate /*******************************************************************************
2567c478bd9Sstevel@tonic-gate  *
2577c478bd9Sstevel@tonic-gate  * FUNCTION:    AcpiExOpcode_1A_0T_0R
2587c478bd9Sstevel@tonic-gate  *
2597c478bd9Sstevel@tonic-gate  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
2607c478bd9Sstevel@tonic-gate  *
2617c478bd9Sstevel@tonic-gate  * RETURN:      Status
2627c478bd9Sstevel@tonic-gate  *
2637c478bd9Sstevel@tonic-gate  * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
2647c478bd9Sstevel@tonic-gate  *              object stack
2657c478bd9Sstevel@tonic-gate  *
2667c478bd9Sstevel@tonic-gate  ******************************************************************************/
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiExOpcode_1A_0T_0R(ACPI_WALK_STATE * WalkState)2697c478bd9Sstevel@tonic-gate AcpiExOpcode_1A_0T_0R (
2707c478bd9Sstevel@tonic-gate     ACPI_WALK_STATE         *WalkState)
2717c478bd9Sstevel@tonic-gate {
2727c478bd9Sstevel@tonic-gate     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
2737c478bd9Sstevel@tonic-gate     ACPI_STATUS             Status = AE_OK;
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate 
27627f7c583Smyers     ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
2777c478bd9Sstevel@tonic-gate         AcpiPsGetOpcodeName (WalkState->Opcode));
2787c478bd9Sstevel@tonic-gate 
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate     /* Examine the AML opcode */
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate     switch (WalkState->Opcode)
2837c478bd9Sstevel@tonic-gate     {
2847c478bd9Sstevel@tonic-gate     case AML_RELEASE_OP:    /*  Release (MutexObject) */
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate         Status = AcpiExReleaseMutex (Operand[0], WalkState);
2877c478bd9Sstevel@tonic-gate         break;
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate     case AML_RESET_OP:      /*  Reset (EventObject) */
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate         Status = AcpiExSystemResetEvent (Operand[0]);
2927c478bd9Sstevel@tonic-gate         break;
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate     case AML_SIGNAL_OP:     /*  Signal (EventObject) */
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate         Status = AcpiExSystemSignalEvent (Operand[0]);
2977c478bd9Sstevel@tonic-gate         break;
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate     case AML_SLEEP_OP:      /*  Sleep (MsecTime) */
3007c478bd9Sstevel@tonic-gate 
30126f3cdf0SGordon Ross         Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
3027c478bd9Sstevel@tonic-gate         break;
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate     case AML_STALL_OP:      /*  Stall (UsecTime) */
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate         Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
3077c478bd9Sstevel@tonic-gate         break;
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate     case AML_UNLOAD_OP:     /*  Unload (Handle) */
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate         Status = AcpiExUnloadTable (Operand[0]);
3127c478bd9Sstevel@tonic-gate         break;
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate     default:                /*  Unknown opcode  */
3157c478bd9Sstevel@tonic-gate 
31626f3cdf0SGordon Ross         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
3177c478bd9Sstevel@tonic-gate             WalkState->Opcode));
3187c478bd9Sstevel@tonic-gate         Status = AE_AML_BAD_OPCODE;
3197c478bd9Sstevel@tonic-gate         break;
3207c478bd9Sstevel@tonic-gate     }
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate     return_ACPI_STATUS (Status);
3237c478bd9Sstevel@tonic-gate }
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate /*******************************************************************************
3277c478bd9Sstevel@tonic-gate  *
3287c478bd9Sstevel@tonic-gate  * FUNCTION:    AcpiExOpcode_1A_1T_0R
3297c478bd9Sstevel@tonic-gate  *
3307c478bd9Sstevel@tonic-gate  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
3317c478bd9Sstevel@tonic-gate  *
3327c478bd9Sstevel@tonic-gate  * RETURN:      Status
3337c478bd9Sstevel@tonic-gate  *
3347c478bd9Sstevel@tonic-gate  * DESCRIPTION: Execute opcode with one argument, one target, and no
3357c478bd9Sstevel@tonic-gate  *              return value.
3367c478bd9Sstevel@tonic-gate  *
3377c478bd9Sstevel@tonic-gate  ******************************************************************************/
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiExOpcode_1A_1T_0R(ACPI_WALK_STATE * WalkState)3407c478bd9Sstevel@tonic-gate AcpiExOpcode_1A_1T_0R (
3417c478bd9Sstevel@tonic-gate     ACPI_WALK_STATE         *WalkState)
3427c478bd9Sstevel@tonic-gate {
3437c478bd9Sstevel@tonic-gate     ACPI_STATUS             Status = AE_OK;
3447c478bd9Sstevel@tonic-gate     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate 
34727f7c583Smyers     ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R,
3487c478bd9Sstevel@tonic-gate         AcpiPsGetOpcodeName (WalkState->Opcode));
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate     /* Examine the AML opcode */
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate     switch (WalkState->Opcode)
3547c478bd9Sstevel@tonic-gate     {
3557c478bd9Sstevel@tonic-gate     case AML_LOAD_OP:
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate         Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
3587c478bd9Sstevel@tonic-gate         break;
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate     default:                        /* Unknown opcode */
3617c478bd9Sstevel@tonic-gate 
36226f3cdf0SGordon Ross         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
3637c478bd9Sstevel@tonic-gate             WalkState->Opcode));
3647c478bd9Sstevel@tonic-gate         Status = AE_AML_BAD_OPCODE;
3657c478bd9Sstevel@tonic-gate         goto Cleanup;
3667c478bd9Sstevel@tonic-gate     }
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate Cleanup:
3707c478bd9Sstevel@tonic-gate 
3717c478bd9Sstevel@tonic-gate     return_ACPI_STATUS (Status);
3727c478bd9Sstevel@tonic-gate }
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate 
3757c478bd9Sstevel@tonic-gate /*******************************************************************************
3767c478bd9Sstevel@tonic-gate  *
3777c478bd9Sstevel@tonic-gate  * FUNCTION:    AcpiExOpcode_1A_1T_1R
3787c478bd9Sstevel@tonic-gate  *
3797c478bd9Sstevel@tonic-gate  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
3807c478bd9Sstevel@tonic-gate  *
3817c478bd9Sstevel@tonic-gate  * RETURN:      Status
3827c478bd9Sstevel@tonic-gate  *
3837c478bd9Sstevel@tonic-gate  * DESCRIPTION: Execute opcode with one argument, one target, and a
3847c478bd9Sstevel@tonic-gate  *              return value.
3857c478bd9Sstevel@tonic-gate  *
3867c478bd9Sstevel@tonic-gate  ******************************************************************************/
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiExOpcode_1A_1T_1R(ACPI_WALK_STATE * WalkState)3897c478bd9Sstevel@tonic-gate AcpiExOpcode_1A_1T_1R (
3907c478bd9Sstevel@tonic-gate     ACPI_WALK_STATE         *WalkState)
3917c478bd9Sstevel@tonic-gate {
3927c478bd9Sstevel@tonic-gate     ACPI_STATUS             Status = AE_OK;
3937c478bd9Sstevel@tonic-gate     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
3947c478bd9Sstevel@tonic-gate     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
3957c478bd9Sstevel@tonic-gate     ACPI_OPERAND_OBJECT     *ReturnDesc2 = NULL;
3967c478bd9Sstevel@tonic-gate     UINT32                  Temp32;
3977c478bd9Sstevel@tonic-gate     UINT32                  i;
39826f3cdf0SGordon Ross     UINT64                  PowerOfTen;
39926f3cdf0SGordon Ross     UINT64                  Digit;
4007c478bd9Sstevel@tonic-gate 
4017c478bd9Sstevel@tonic-gate 
40227f7c583Smyers     ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R,
4037c478bd9Sstevel@tonic-gate         AcpiPsGetOpcodeName (WalkState->Opcode));
4047c478bd9Sstevel@tonic-gate 
4057c478bd9Sstevel@tonic-gate 
4067c478bd9Sstevel@tonic-gate     /* Examine the AML opcode */
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate     switch (WalkState->Opcode)
4097c478bd9Sstevel@tonic-gate     {
4107c478bd9Sstevel@tonic-gate     case AML_BIT_NOT_OP:
4117c478bd9Sstevel@tonic-gate     case AML_FIND_SET_LEFT_BIT_OP:
4127c478bd9Sstevel@tonic-gate     case AML_FIND_SET_RIGHT_BIT_OP:
4137c478bd9Sstevel@tonic-gate     case AML_FROM_BCD_OP:
4147c478bd9Sstevel@tonic-gate     case AML_TO_BCD_OP:
415*35786f68SRobert Mustacchi     case AML_CONDITIONAL_REF_OF_OP:
4167c478bd9Sstevel@tonic-gate 
4177c478bd9Sstevel@tonic-gate         /* Create a return object of type Integer for these opcodes */
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
4207c478bd9Sstevel@tonic-gate         if (!ReturnDesc)
4217c478bd9Sstevel@tonic-gate         {
4227c478bd9Sstevel@tonic-gate             Status = AE_NO_MEMORY;
4237c478bd9Sstevel@tonic-gate             goto Cleanup;
4247c478bd9Sstevel@tonic-gate         }
4257c478bd9Sstevel@tonic-gate 
4267c478bd9Sstevel@tonic-gate         switch (WalkState->Opcode)
4277c478bd9Sstevel@tonic-gate         {
4287c478bd9Sstevel@tonic-gate         case AML_BIT_NOT_OP:            /* Not (Operand, Result)  */
4297c478bd9Sstevel@tonic-gate 
4307c478bd9Sstevel@tonic-gate             ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
4317c478bd9Sstevel@tonic-gate             break;
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate         case AML_FIND_SET_LEFT_BIT_OP:  /* FindSetLeftBit (Operand, Result) */
4347c478bd9Sstevel@tonic-gate 
4357c478bd9Sstevel@tonic-gate             ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
4367c478bd9Sstevel@tonic-gate 
4377c478bd9Sstevel@tonic-gate             /*
4387c478bd9Sstevel@tonic-gate              * Acpi specification describes Integer type as a little
4397c478bd9Sstevel@tonic-gate              * endian unsigned value, so this boundary condition is valid.
4407c478bd9Sstevel@tonic-gate              */
4417c478bd9Sstevel@tonic-gate             for (Temp32 = 0; ReturnDesc->Integer.Value &&
4427b1019a6SJerry Jelinek                     Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
4437c478bd9Sstevel@tonic-gate             {
4447c478bd9Sstevel@tonic-gate                 ReturnDesc->Integer.Value >>= 1;
4457c478bd9Sstevel@tonic-gate             }
4467c478bd9Sstevel@tonic-gate 
4477c478bd9Sstevel@tonic-gate             ReturnDesc->Integer.Value = Temp32;
4487c478bd9Sstevel@tonic-gate             break;
4497c478bd9Sstevel@tonic-gate 
4507c478bd9Sstevel@tonic-gate         case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
4517c478bd9Sstevel@tonic-gate 
4527c478bd9Sstevel@tonic-gate             ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
4537c478bd9Sstevel@tonic-gate 
4547c478bd9Sstevel@tonic-gate             /*
4557c478bd9Sstevel@tonic-gate              * The Acpi specification describes Integer type as a little
4567c478bd9Sstevel@tonic-gate              * endian unsigned value, so this boundary condition is valid.
4577c478bd9Sstevel@tonic-gate              */
4587c478bd9Sstevel@tonic-gate             for (Temp32 = 0; ReturnDesc->Integer.Value &&
4597b1019a6SJerry Jelinek                      Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
4607c478bd9Sstevel@tonic-gate             {
4617c478bd9Sstevel@tonic-gate                 ReturnDesc->Integer.Value <<= 1;
4627c478bd9Sstevel@tonic-gate             }
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate             /* Since the bit position is one-based, subtract from 33 (65) */
4657c478bd9Sstevel@tonic-gate 
46627f7c583Smyers             ReturnDesc->Integer.Value =
46727f7c583Smyers                 Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
4687c478bd9Sstevel@tonic-gate             break;
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate         case AML_FROM_BCD_OP:           /* FromBcd (BCDValue, Result)  */
4717c478bd9Sstevel@tonic-gate             /*
4727c478bd9Sstevel@tonic-gate              * The 64-bit ACPI integer can hold 16 4-bit BCD characters
4737c478bd9Sstevel@tonic-gate              * (if table is 32-bit, integer can hold 8 BCD characters)
4747c478bd9Sstevel@tonic-gate              * Convert each 4-bit BCD value
4757c478bd9Sstevel@tonic-gate              */
4767c478bd9Sstevel@tonic-gate             PowerOfTen = 1;
4777c478bd9Sstevel@tonic-gate             ReturnDesc->Integer.Value = 0;
4787c478bd9Sstevel@tonic-gate             Digit = Operand[0]->Integer.Value;
4797c478bd9Sstevel@tonic-gate 
4807c478bd9Sstevel@tonic-gate             /* Convert each BCD digit (each is one nybble wide) */
4817c478bd9Sstevel@tonic-gate 
4827c478bd9Sstevel@tonic-gate             for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
4837c478bd9Sstevel@tonic-gate             {
4847c478bd9Sstevel@tonic-gate                 /* Get the least significant 4-bit BCD digit */
4857c478bd9Sstevel@tonic-gate 
4867c478bd9Sstevel@tonic-gate                 Temp32 = ((UINT32) Digit) & 0xF;
4877c478bd9Sstevel@tonic-gate 
4887c478bd9Sstevel@tonic-gate                 /* Check the range of the digit */
4897c478bd9Sstevel@tonic-gate 
4907c478bd9Sstevel@tonic-gate                 if (Temp32 > 9)
4917c478bd9Sstevel@tonic-gate                 {
49230082d0cSmyers                     ACPI_ERROR ((AE_INFO,
49330082d0cSmyers                         "BCD digit too large (not decimal): 0x%X",
4947c478bd9Sstevel@tonic-gate                         Temp32));
4957c478bd9Sstevel@tonic-gate 
4967c478bd9Sstevel@tonic-gate                     Status = AE_AML_NUMERIC_OVERFLOW;
4977c478bd9Sstevel@tonic-gate                     goto Cleanup;
4987c478bd9Sstevel@tonic-gate                 }
4997c478bd9Sstevel@tonic-gate 
5007c478bd9Sstevel@tonic-gate                 /* Sum the digit into the result with the current power of 10 */
5017c478bd9Sstevel@tonic-gate 
50227f7c583Smyers                 ReturnDesc->Integer.Value +=
50326f3cdf0SGordon Ross                     (((UINT64) Temp32) * PowerOfTen);
5047c478bd9Sstevel@tonic-gate 
5057c478bd9Sstevel@tonic-gate                 /* Shift to next BCD digit */
5067c478bd9Sstevel@tonic-gate 
5077c478bd9Sstevel@tonic-gate                 Digit >>= 4;
5087c478bd9Sstevel@tonic-gate 
5097c478bd9Sstevel@tonic-gate                 /* Next power of 10 */
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate                 PowerOfTen *= 10;
5127c478bd9Sstevel@tonic-gate             }
5137c478bd9Sstevel@tonic-gate             break;
5147c478bd9Sstevel@tonic-gate 
5157c478bd9Sstevel@tonic-gate         case AML_TO_BCD_OP:             /* ToBcd (Operand, Result)  */
5167c478bd9Sstevel@tonic-gate 
5177c478bd9Sstevel@tonic-gate             ReturnDesc->Integer.Value = 0;
5187c478bd9Sstevel@tonic-gate             Digit = Operand[0]->Integer.Value;
5197c478bd9Sstevel@tonic-gate 
5207c478bd9Sstevel@tonic-gate             /* Each BCD digit is one nybble wide */
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate             for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
5237c478bd9Sstevel@tonic-gate             {
5247c478bd9Sstevel@tonic-gate                 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
5257c478bd9Sstevel@tonic-gate 
5267c478bd9Sstevel@tonic-gate                 /*
5277c478bd9Sstevel@tonic-gate                  * Insert the BCD digit that resides in the
5287c478bd9Sstevel@tonic-gate                  * remainder from above
5297c478bd9Sstevel@tonic-gate                  */
53027f7c583Smyers                 ReturnDesc->Integer.Value |=
53126f3cdf0SGordon Ross                     (((UINT64) Temp32) << ACPI_MUL_4 (i));
5327c478bd9Sstevel@tonic-gate             }
5337c478bd9Sstevel@tonic-gate 
5347c478bd9Sstevel@tonic-gate             /* Overflow if there is any data left in Digit */
5357c478bd9Sstevel@tonic-gate 
5367c478bd9Sstevel@tonic-gate             if (Digit > 0)
5377c478bd9Sstevel@tonic-gate             {
53830082d0cSmyers                 ACPI_ERROR ((AE_INFO,
53926f3cdf0SGordon Ross                     "Integer too large to convert to BCD: 0x%8.8X%8.8X",
5407c478bd9Sstevel@tonic-gate                     ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
5417c478bd9Sstevel@tonic-gate                 Status = AE_AML_NUMERIC_OVERFLOW;
5427c478bd9Sstevel@tonic-gate                 goto Cleanup;
5437c478bd9Sstevel@tonic-gate             }
5447c478bd9Sstevel@tonic-gate             break;
5457c478bd9Sstevel@tonic-gate 
546*35786f68SRobert Mustacchi         case AML_CONDITIONAL_REF_OF_OP:     /* CondRefOf (SourceObject, Result)  */
5477c478bd9Sstevel@tonic-gate             /*
5487c478bd9Sstevel@tonic-gate              * This op is a little strange because the internal return value is
5497c478bd9Sstevel@tonic-gate              * different than the return value stored in the result descriptor
5507c478bd9Sstevel@tonic-gate              * (There are really two return values)
5517c478bd9Sstevel@tonic-gate              */
5527c478bd9Sstevel@tonic-gate             if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
5537c478bd9Sstevel@tonic-gate             {
5547c478bd9Sstevel@tonic-gate                 /*
5557c478bd9Sstevel@tonic-gate                  * This means that the object does not exist in the namespace,
5567c478bd9Sstevel@tonic-gate                  * return FALSE
5577c478bd9Sstevel@tonic-gate                  */
5587c478bd9Sstevel@tonic-gate                 ReturnDesc->Integer.Value = 0;
5597c478bd9Sstevel@tonic-gate                 goto Cleanup;
5607c478bd9Sstevel@tonic-gate             }
5617c478bd9Sstevel@tonic-gate 
5627c478bd9Sstevel@tonic-gate             /* Get the object reference, store it, and remove our reference */
5637c478bd9Sstevel@tonic-gate 
5647c478bd9Sstevel@tonic-gate             Status = AcpiExGetObjectReference (Operand[0],
5657b1019a6SJerry Jelinek                 &ReturnDesc2, WalkState);
5667c478bd9Sstevel@tonic-gate             if (ACPI_FAILURE (Status))
5677c478bd9Sstevel@tonic-gate             {
5687c478bd9Sstevel@tonic-gate                 goto Cleanup;
5697c478bd9Sstevel@tonic-gate             }
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate             Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
5727c478bd9Sstevel@tonic-gate             AcpiUtRemoveReference (ReturnDesc2);
5737c478bd9Sstevel@tonic-gate 
5747c478bd9Sstevel@tonic-gate             /* The object exists in the namespace, return TRUE */
5757c478bd9Sstevel@tonic-gate 
57626f3cdf0SGordon Ross             ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
5777c478bd9Sstevel@tonic-gate             goto Cleanup;
5787c478bd9Sstevel@tonic-gate 
5797c478bd9Sstevel@tonic-gate 
5807c478bd9Sstevel@tonic-gate         default:
5817b1019a6SJerry Jelinek 
5827c478bd9Sstevel@tonic-gate             /* No other opcodes get here */
5837b1019a6SJerry Jelinek 
5847c478bd9Sstevel@tonic-gate             break;
5857c478bd9Sstevel@tonic-gate         }
5867c478bd9Sstevel@tonic-gate         break;
5877c478bd9Sstevel@tonic-gate 
5887c478bd9Sstevel@tonic-gate     case AML_STORE_OP:              /* Store (Source, Target) */
5897c478bd9Sstevel@tonic-gate         /*
5907c478bd9Sstevel@tonic-gate          * A store operand is typically a number, string, buffer or lvalue
5917c478bd9Sstevel@tonic-gate          * Be careful about deleting the source object,
5927c478bd9Sstevel@tonic-gate          * since the object itself may have been stored.
5937c478bd9Sstevel@tonic-gate          */
5947c478bd9Sstevel@tonic-gate         Status = AcpiExStore (Operand[0], Operand[1], WalkState);
5957c478bd9Sstevel@tonic-gate         if (ACPI_FAILURE (Status))
5967c478bd9Sstevel@tonic-gate         {
5977c478bd9Sstevel@tonic-gate             return_ACPI_STATUS (Status);
5987c478bd9Sstevel@tonic-gate         }
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate         /* It is possible that the Store already produced a return object */
6017c478bd9Sstevel@tonic-gate 
6027c478bd9Sstevel@tonic-gate         if (!WalkState->ResultObj)
6037c478bd9Sstevel@tonic-gate         {
6047c478bd9Sstevel@tonic-gate             /*
6057c478bd9Sstevel@tonic-gate              * Normally, we would remove a reference on the Operand[0]
6067c478bd9Sstevel@tonic-gate              * parameter; But since it is being used as the internal return
6077c478bd9Sstevel@tonic-gate              * object (meaning we would normally increment it), the two
6087c478bd9Sstevel@tonic-gate              * cancel out, and we simply don't do anything.
6097c478bd9Sstevel@tonic-gate              */
6107c478bd9Sstevel@tonic-gate             WalkState->ResultObj = Operand[0];
6117c478bd9Sstevel@tonic-gate             WalkState->Operands[0] = NULL;  /* Prevent deletion */
6127c478bd9Sstevel@tonic-gate         }
6137c478bd9Sstevel@tonic-gate         return_ACPI_STATUS (Status);
6147c478bd9Sstevel@tonic-gate 
6157c478bd9Sstevel@tonic-gate     /*
6167c478bd9Sstevel@tonic-gate      * ACPI 2.0 Opcodes
6177c478bd9Sstevel@tonic-gate      */
618*35786f68SRobert Mustacchi     case AML_COPY_OBJECT_OP:        /* CopyObject (Source, Target) */
6197c478bd9Sstevel@tonic-gate 
6207b1019a6SJerry Jelinek         Status = AcpiUtCopyIobjectToIobject (
6217b1019a6SJerry Jelinek             Operand[0], &ReturnDesc, WalkState);
6227c478bd9Sstevel@tonic-gate         break;
6237c478bd9Sstevel@tonic-gate 
624*35786f68SRobert Mustacchi     case AML_TO_DECIMAL_STRING_OP:  /* ToDecimalString (Data, Result) */
6257c478bd9Sstevel@tonic-gate 
6267b1019a6SJerry Jelinek         Status = AcpiExConvertToString (
6277b1019a6SJerry Jelinek             Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_DECIMAL);
6287c478bd9Sstevel@tonic-gate         if (ReturnDesc == Operand[0])
6297c478bd9Sstevel@tonic-gate         {
6307c478bd9Sstevel@tonic-gate             /* No conversion performed, add ref to handle return value */
6317b1019a6SJerry Jelinek 
6327c478bd9Sstevel@tonic-gate             AcpiUtAddReference (ReturnDesc);
6337c478bd9Sstevel@tonic-gate         }
6347c478bd9Sstevel@tonic-gate         break;
6357c478bd9Sstevel@tonic-gate 
636*35786f68SRobert Mustacchi     case AML_TO_HEX_STRING_OP:      /* ToHexString (Data, Result) */
6377c478bd9Sstevel@tonic-gate 
6387b1019a6SJerry Jelinek         Status = AcpiExConvertToString (
6397b1019a6SJerry Jelinek             Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_HEX);
6407c478bd9Sstevel@tonic-gate         if (ReturnDesc == Operand[0])
6417c478bd9Sstevel@tonic-gate         {
6427c478bd9Sstevel@tonic-gate             /* No conversion performed, add ref to handle return value */
6437b1019a6SJerry Jelinek 
6447c478bd9Sstevel@tonic-gate             AcpiUtAddReference (ReturnDesc);
6457c478bd9Sstevel@tonic-gate         }
6467c478bd9Sstevel@tonic-gate         break;
6477c478bd9Sstevel@tonic-gate 
6487c478bd9Sstevel@tonic-gate     case AML_TO_BUFFER_OP:          /* ToBuffer (Data, Result) */
6497c478bd9Sstevel@tonic-gate 
6507c478bd9Sstevel@tonic-gate         Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
6517c478bd9Sstevel@tonic-gate         if (ReturnDesc == Operand[0])
6527c478bd9Sstevel@tonic-gate         {
6537c478bd9Sstevel@tonic-gate             /* No conversion performed, add ref to handle return value */
6547b1019a6SJerry Jelinek 
6557c478bd9Sstevel@tonic-gate             AcpiUtAddReference (ReturnDesc);
6567c478bd9Sstevel@tonic-gate         }
6577c478bd9Sstevel@tonic-gate         break;
6587c478bd9Sstevel@tonic-gate 
6597c478bd9Sstevel@tonic-gate     case AML_TO_INTEGER_OP:         /* ToInteger (Data, Result) */
6607c478bd9Sstevel@tonic-gate 
661*35786f68SRobert Mustacchi         /* Perform "explicit" conversion */
662*35786f68SRobert Mustacchi 
663*35786f68SRobert Mustacchi         Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, 0);
6647c478bd9Sstevel@tonic-gate         if (ReturnDesc == Operand[0])
6657c478bd9Sstevel@tonic-gate         {
6667c478bd9Sstevel@tonic-gate             /* No conversion performed, add ref to handle return value */
6677b1019a6SJerry Jelinek 
6687c478bd9Sstevel@tonic-gate             AcpiUtAddReference (ReturnDesc);
6697c478bd9Sstevel@tonic-gate         }
6707c478bd9Sstevel@tonic-gate         break;
6717c478bd9Sstevel@tonic-gate 
6727c478bd9Sstevel@tonic-gate     case AML_SHIFT_LEFT_BIT_OP:     /* ShiftLeftBit (Source, BitNum)  */
6737c478bd9Sstevel@tonic-gate     case AML_SHIFT_RIGHT_BIT_OP:    /* ShiftRightBit (Source, BitNum) */
6747c478bd9Sstevel@tonic-gate 
6757c478bd9Sstevel@tonic-gate         /* These are two obsolete opcodes */
6767c478bd9Sstevel@tonic-gate 
67730082d0cSmyers         ACPI_ERROR ((AE_INFO,
67830082d0cSmyers             "%s is obsolete and not implemented",
6797c478bd9Sstevel@tonic-gate             AcpiPsGetOpcodeName (WalkState->Opcode)));
6807c478bd9Sstevel@tonic-gate         Status = AE_SUPPORT;
6817c478bd9Sstevel@tonic-gate         goto Cleanup;
6827c478bd9Sstevel@tonic-gate 
6837c478bd9Sstevel@tonic-gate     default:                        /* Unknown opcode */
6847c478bd9Sstevel@tonic-gate 
68526f3cdf0SGordon Ross         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
6867c478bd9Sstevel@tonic-gate             WalkState->Opcode));
6877c478bd9Sstevel@tonic-gate         Status = AE_AML_BAD_OPCODE;
6887c478bd9Sstevel@tonic-gate         goto Cleanup;
6897c478bd9Sstevel@tonic-gate     }
6907c478bd9Sstevel@tonic-gate 
6917c478bd9Sstevel@tonic-gate     if (ACPI_SUCCESS (Status))
6927c478bd9Sstevel@tonic-gate     {
6937c478bd9Sstevel@tonic-gate         /* Store the return value computed above into the target object */
6947c478bd9Sstevel@tonic-gate 
6957c478bd9Sstevel@tonic-gate         Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
6967c478bd9Sstevel@tonic-gate     }
6977c478bd9Sstevel@tonic-gate 
6987c478bd9Sstevel@tonic-gate 
6997c478bd9Sstevel@tonic-gate Cleanup:
7007c478bd9Sstevel@tonic-gate 
7017c478bd9Sstevel@tonic-gate     /* Delete return object on error */
7027c478bd9Sstevel@tonic-gate 
7037c478bd9Sstevel@tonic-gate     if (ACPI_FAILURE (Status))
7047c478bd9Sstevel@tonic-gate     {
7057c478bd9Sstevel@tonic-gate         AcpiUtRemoveReference (ReturnDesc);
7067c478bd9Sstevel@tonic-gate     }
7077c478bd9Sstevel@tonic-gate 
70827f7c583Smyers     /* Save return object on success */
70927f7c583Smyers 
71027f7c583Smyers     else if (!WalkState->ResultObj)
71127f7c583Smyers     {
71227f7c583Smyers         WalkState->ResultObj = ReturnDesc;
71327f7c583Smyers     }
71427f7c583Smyers 
7157c478bd9Sstevel@tonic-gate     return_ACPI_STATUS (Status);
7167c478bd9Sstevel@tonic-gate }
7177c478bd9Sstevel@tonic-gate 
7187c478bd9Sstevel@tonic-gate 
7197c478bd9Sstevel@tonic-gate /*******************************************************************************
7207c478bd9Sstevel@tonic-gate  *
7217c478bd9Sstevel@tonic-gate  * FUNCTION:    AcpiExOpcode_1A_0T_1R
7227c478bd9Sstevel@tonic-gate  *
7237c478bd9Sstevel@tonic-gate  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
7247c478bd9Sstevel@tonic-gate  *
7257c478bd9Sstevel@tonic-gate  * RETURN:      Status
7267c478bd9Sstevel@tonic-gate  *
7277c478bd9Sstevel@tonic-gate  * DESCRIPTION: Execute opcode with one argument, no target, and a return value
7287c478bd9Sstevel@tonic-gate  *
7297c478bd9Sstevel@tonic-gate  ******************************************************************************/
7307c478bd9Sstevel@tonic-gate 
7317c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiExOpcode_1A_0T_1R(ACPI_WALK_STATE * WalkState)7327c478bd9Sstevel@tonic-gate AcpiExOpcode_1A_0T_1R (
7337c478bd9Sstevel@tonic-gate     ACPI_WALK_STATE         *WalkState)
7347c478bd9Sstevel@tonic-gate {
7357c478bd9Sstevel@tonic-gate     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
7367c478bd9Sstevel@tonic-gate     ACPI_OPERAND_OBJECT     *TempDesc;
7377c478bd9Sstevel@tonic-gate     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
7387c478bd9Sstevel@tonic-gate     ACPI_STATUS             Status = AE_OK;
7397c478bd9Sstevel@tonic-gate     UINT32                  Type;
74026f3cdf0SGordon Ross     UINT64                  Value;
7417c478bd9Sstevel@tonic-gate 
7427c478bd9Sstevel@tonic-gate 
74327f7c583Smyers     ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R,
7447c478bd9Sstevel@tonic-gate         AcpiPsGetOpcodeName (WalkState->Opcode));
7457c478bd9Sstevel@tonic-gate 
7467c478bd9Sstevel@tonic-gate 
7477c478bd9Sstevel@tonic-gate     /* Examine the AML opcode */
7487c478bd9Sstevel@tonic-gate 
7497c478bd9Sstevel@tonic-gate     switch (WalkState->Opcode)
7507c478bd9Sstevel@tonic-gate     {
751*35786f68SRobert Mustacchi     case AML_LOGICAL_NOT_OP:        /* LNot (Operand) */
7527c478bd9Sstevel@tonic-gate 
75357190917SDana Myers         ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
7547c478bd9Sstevel@tonic-gate         if (!ReturnDesc)
7557c478bd9Sstevel@tonic-gate         {
7567c478bd9Sstevel@tonic-gate             Status = AE_NO_MEMORY;
7577c478bd9Sstevel@tonic-gate             goto Cleanup;
7587c478bd9Sstevel@tonic-gate         }
7597c478bd9Sstevel@tonic-gate 
7607c478bd9Sstevel@tonic-gate         /*
7617b1019a6SJerry Jelinek          * Set result to ONES (TRUE) if Value == 0. Note:
7627c478bd9Sstevel@tonic-gate          * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
7637c478bd9Sstevel@tonic-gate          */
7647c478bd9Sstevel@tonic-gate         if (!Operand[0]->Integer.Value)
7657c478bd9Sstevel@tonic-gate         {
76626f3cdf0SGordon Ross             ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
7677c478bd9Sstevel@tonic-gate         }
7687c478bd9Sstevel@tonic-gate         break;
7697c478bd9Sstevel@tonic-gate 
7707c478bd9Sstevel@tonic-gate     case AML_DECREMENT_OP:          /* Decrement (Operand)  */
7717c478bd9Sstevel@tonic-gate     case AML_INCREMENT_OP:          /* Increment (Operand)  */
7727c478bd9Sstevel@tonic-gate         /*
7737b1019a6SJerry Jelinek          * Create a new integer. Can't just get the base integer and
7747c478bd9Sstevel@tonic-gate          * increment it because it may be an Arg or Field.
7757c478bd9Sstevel@tonic-gate          */
7767c478bd9Sstevel@tonic-gate         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
7777c478bd9Sstevel@tonic-gate         if (!ReturnDesc)
7787c478bd9Sstevel@tonic-gate         {
7797c478bd9Sstevel@tonic-gate             Status = AE_NO_MEMORY;
7807c478bd9Sstevel@tonic-gate             goto Cleanup;
7817c478bd9Sstevel@tonic-gate         }
7827c478bd9Sstevel@tonic-gate 
7837c478bd9Sstevel@tonic-gate         /*
7847c478bd9Sstevel@tonic-gate          * Since we are expecting a Reference operand, it can be either a
7857c478bd9Sstevel@tonic-gate          * NS Node or an internal object.
7867c478bd9Sstevel@tonic-gate          */
7877c478bd9Sstevel@tonic-gate         TempDesc = Operand[0];
7887c478bd9Sstevel@tonic-gate         if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
7897c478bd9Sstevel@tonic-gate         {
7907c478bd9Sstevel@tonic-gate             /* Internal reference object - prevent deletion */
7917c478bd9Sstevel@tonic-gate 
7927c478bd9Sstevel@tonic-gate             AcpiUtAddReference (TempDesc);
7937c478bd9Sstevel@tonic-gate         }
7947c478bd9Sstevel@tonic-gate 
7957c478bd9Sstevel@tonic-gate         /*
7967c478bd9Sstevel@tonic-gate          * Convert the Reference operand to an Integer (This removes a
7977c478bd9Sstevel@tonic-gate          * reference on the Operand[0] object)
7987c478bd9Sstevel@tonic-gate          *
7997c478bd9Sstevel@tonic-gate          * NOTE:  We use LNOT_OP here in order to force resolution of the
8007c478bd9Sstevel@tonic-gate          * reference operand to an actual integer.
8017c478bd9Sstevel@tonic-gate          */
802*35786f68SRobert Mustacchi         Status = AcpiExResolveOperands (AML_LOGICAL_NOT_OP,
803*35786f68SRobert Mustacchi             &TempDesc, WalkState);
8047c478bd9Sstevel@tonic-gate         if (ACPI_FAILURE (Status))
8057c478bd9Sstevel@tonic-gate         {
80630082d0cSmyers             ACPI_EXCEPTION ((AE_INFO, Status,
80730082d0cSmyers                 "While resolving operands for [%s]",
80830082d0cSmyers                 AcpiPsGetOpcodeName (WalkState->Opcode)));
8097c478bd9Sstevel@tonic-gate 
8107c478bd9Sstevel@tonic-gate             goto Cleanup;
8117c478bd9Sstevel@tonic-gate         }
8127c478bd9Sstevel@tonic-gate 
8137c478bd9Sstevel@tonic-gate         /*
8147c478bd9Sstevel@tonic-gate          * TempDesc is now guaranteed to be an Integer object --
8157c478bd9Sstevel@tonic-gate          * Perform the actual increment or decrement
8167c478bd9Sstevel@tonic-gate          */
8177c478bd9Sstevel@tonic-gate         if (WalkState->Opcode == AML_INCREMENT_OP)
8187c478bd9Sstevel@tonic-gate         {
8197b1019a6SJerry Jelinek             ReturnDesc->Integer.Value = TempDesc->Integer.Value + 1;
8207c478bd9Sstevel@tonic-gate         }
8217c478bd9Sstevel@tonic-gate         else
8227c478bd9Sstevel@tonic-gate         {
8237b1019a6SJerry Jelinek             ReturnDesc->Integer.Value = TempDesc->Integer.Value - 1;
8247c478bd9Sstevel@tonic-gate         }
8257c478bd9Sstevel@tonic-gate 
8267c478bd9Sstevel@tonic-gate         /* Finished with this Integer object */
8277c478bd9Sstevel@tonic-gate 
8287c478bd9Sstevel@tonic-gate         AcpiUtRemoveReference (TempDesc);
8297c478bd9Sstevel@tonic-gate 
8307c478bd9Sstevel@tonic-gate         /*
8317c478bd9Sstevel@tonic-gate          * Store the result back (indirectly) through the original
8327c478bd9Sstevel@tonic-gate          * Reference object
8337c478bd9Sstevel@tonic-gate          */
8347c478bd9Sstevel@tonic-gate         Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
8357c478bd9Sstevel@tonic-gate         break;
8367c478bd9Sstevel@tonic-gate 
8377b1019a6SJerry Jelinek     case AML_OBJECT_TYPE_OP:            /* ObjectType (SourceObject) */
8387c478bd9Sstevel@tonic-gate         /*
8397c478bd9Sstevel@tonic-gate          * Note: The operand is not resolved at this point because we want to
8407b1019a6SJerry Jelinek          * get the associated object, not its value. For example, we don't
8417c478bd9Sstevel@tonic-gate          * want to resolve a FieldUnit to its value, we want the actual
8427c478bd9Sstevel@tonic-gate          * FieldUnit object.
8437c478bd9Sstevel@tonic-gate          */
8447c478bd9Sstevel@tonic-gate 
8457c478bd9Sstevel@tonic-gate         /* Get the type of the base object */
8467c478bd9Sstevel@tonic-gate 
8477c478bd9Sstevel@tonic-gate         Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
8487c478bd9Sstevel@tonic-gate         if (ACPI_FAILURE (Status))
8497c478bd9Sstevel@tonic-gate         {
8507c478bd9Sstevel@tonic-gate             goto Cleanup;
8517c478bd9Sstevel@tonic-gate         }
85227f7c583Smyers 
8537c478bd9Sstevel@tonic-gate         /* Allocate a descriptor to hold the type. */
8547c478bd9Sstevel@tonic-gate 
85557190917SDana Myers         ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type);
8567c478bd9Sstevel@tonic-gate         if (!ReturnDesc)
8577c478bd9Sstevel@tonic-gate         {
8587c478bd9Sstevel@tonic-gate             Status = AE_NO_MEMORY;
8597c478bd9Sstevel@tonic-gate             goto Cleanup;
8607c478bd9Sstevel@tonic-gate         }
8617c478bd9Sstevel@tonic-gate         break;
8627c478bd9Sstevel@tonic-gate 
8637c478bd9Sstevel@tonic-gate     case AML_SIZE_OF_OP:            /* SizeOf (SourceObject)  */
8647c478bd9Sstevel@tonic-gate         /*
8657c478bd9Sstevel@tonic-gate          * Note: The operand is not resolved at this point because we want to
8667c478bd9Sstevel@tonic-gate          * get the associated object, not its value.
8677c478bd9Sstevel@tonic-gate          */
8687c478bd9Sstevel@tonic-gate 
8697c478bd9Sstevel@tonic-gate         /* Get the base object */
8707c478bd9Sstevel@tonic-gate 
8717b1019a6SJerry Jelinek         Status = AcpiExResolveMultiple (
8727b1019a6SJerry Jelinek             WalkState, Operand[0], &Type, &TempDesc);
8737c478bd9Sstevel@tonic-gate         if (ACPI_FAILURE (Status))
8747c478bd9Sstevel@tonic-gate         {
8757c478bd9Sstevel@tonic-gate             goto Cleanup;
8767c478bd9Sstevel@tonic-gate         }
8777c478bd9Sstevel@tonic-gate 
8787c478bd9Sstevel@tonic-gate         /*
8797c478bd9Sstevel@tonic-gate          * The type of the base object must be integer, buffer, string, or
8807b1019a6SJerry Jelinek          * package. All others are not supported.
8817c478bd9Sstevel@tonic-gate          *
8827c478bd9Sstevel@tonic-gate          * NOTE: Integer is not specifically supported by the ACPI spec,
8837c478bd9Sstevel@tonic-gate          * but is supported implicitly via implicit operand conversion.
8847c478bd9Sstevel@tonic-gate          * rather than bother with conversion, we just use the byte width
8857c478bd9Sstevel@tonic-gate          * global (4 or 8 bytes).
8867c478bd9Sstevel@tonic-gate          */
8877c478bd9Sstevel@tonic-gate         switch (Type)
8887c478bd9Sstevel@tonic-gate         {
8897c478bd9Sstevel@tonic-gate         case ACPI_TYPE_INTEGER:
8907b1019a6SJerry Jelinek 
8917c478bd9Sstevel@tonic-gate             Value = AcpiGbl_IntegerByteWidth;
8927c478bd9Sstevel@tonic-gate             break;
8937c478bd9Sstevel@tonic-gate 
8947c478bd9Sstevel@tonic-gate         case ACPI_TYPE_STRING:
8957b1019a6SJerry Jelinek 
8967c478bd9Sstevel@tonic-gate             Value = TempDesc->String.Length;
8977c478bd9Sstevel@tonic-gate             break;
8987c478bd9Sstevel@tonic-gate 
899db2bae30SDana Myers         case ACPI_TYPE_BUFFER:
900db2bae30SDana Myers 
901db2bae30SDana Myers             /* Buffer arguments may not be evaluated at this point */
902db2bae30SDana Myers 
903db2bae30SDana Myers             Status = AcpiDsGetBufferArguments (TempDesc);
904db2bae30SDana Myers             Value = TempDesc->Buffer.Length;
905db2bae30SDana Myers             break;
906db2bae30SDana Myers 
9077c478bd9Sstevel@tonic-gate         case ACPI_TYPE_PACKAGE:
908db2bae30SDana Myers 
909db2bae30SDana Myers             /* Package arguments may not be evaluated at this point */
910db2bae30SDana Myers 
911db2bae30SDana Myers             Status = AcpiDsGetPackageArguments (TempDesc);
9127c478bd9Sstevel@tonic-gate             Value = TempDesc->Package.Count;
9137c478bd9Sstevel@tonic-gate             break;
9147c478bd9Sstevel@tonic-gate 
9157c478bd9Sstevel@tonic-gate         default:
9167b1019a6SJerry Jelinek 
91730082d0cSmyers             ACPI_ERROR ((AE_INFO,
9187b1019a6SJerry Jelinek                 "Operand must be Buffer/Integer/String/Package"
9197b1019a6SJerry Jelinek                 " - found type %s",
9207c478bd9Sstevel@tonic-gate                 AcpiUtGetTypeName (Type)));
9217b1019a6SJerry Jelinek 
9227c478bd9Sstevel@tonic-gate             Status = AE_AML_OPERAND_TYPE;
9237c478bd9Sstevel@tonic-gate             goto Cleanup;
9247c478bd9Sstevel@tonic-gate         }
9257c478bd9Sstevel@tonic-gate 
926db2bae30SDana Myers         if (ACPI_FAILURE (Status))
927db2bae30SDana Myers         {
928db2bae30SDana Myers             goto Cleanup;
929db2bae30SDana Myers         }
930db2bae30SDana Myers 
9317c478bd9Sstevel@tonic-gate         /*
9327c478bd9Sstevel@tonic-gate          * Now that we have the size of the object, create a result
9337c478bd9Sstevel@tonic-gate          * object to hold the value
9347c478bd9Sstevel@tonic-gate          */
93557190917SDana Myers         ReturnDesc = AcpiUtCreateIntegerObject (Value);
9367c478bd9Sstevel@tonic-gate         if (!ReturnDesc)
9377c478bd9Sstevel@tonic-gate         {
9387c478bd9Sstevel@tonic-gate             Status = AE_NO_MEMORY;
9397c478bd9Sstevel@tonic-gate             goto Cleanup;
9407c478bd9Sstevel@tonic-gate         }
9417c478bd9Sstevel@tonic-gate         break;
9427c478bd9Sstevel@tonic-gate 
9437c478bd9Sstevel@tonic-gate 
9447c478bd9Sstevel@tonic-gate     case AML_REF_OF_OP:             /* RefOf (SourceObject) */
9457c478bd9Sstevel@tonic-gate 
9467b1019a6SJerry Jelinek         Status = AcpiExGetObjectReference (
9477b1019a6SJerry Jelinek             Operand[0], &ReturnDesc, WalkState);
9487c478bd9Sstevel@tonic-gate         if (ACPI_FAILURE (Status))
9497c478bd9Sstevel@tonic-gate         {
9507c478bd9Sstevel@tonic-gate             goto Cleanup;
9517c478bd9Sstevel@tonic-gate         }
9527c478bd9Sstevel@tonic-gate         break;
9537c478bd9Sstevel@tonic-gate 
9547c478bd9Sstevel@tonic-gate 
9557c478bd9Sstevel@tonic-gate     case AML_DEREF_OF_OP:           /* DerefOf (ObjReference | String) */
9567c478bd9Sstevel@tonic-gate 
9577c478bd9Sstevel@tonic-gate         /* Check for a method local or argument, or standalone String */
9587c478bd9Sstevel@tonic-gate 
95930082d0cSmyers         if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
96030082d0cSmyers         {
96130082d0cSmyers             TempDesc = AcpiNsGetAttachedObject (
962*35786f68SRobert Mustacchi                 (ACPI_NAMESPACE_NODE *) Operand[0]);
96330082d0cSmyers             if (TempDesc &&
964aa2aa9a6SDana Myers                  ((TempDesc->Common.Type == ACPI_TYPE_STRING) ||
965aa2aa9a6SDana Myers                   (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)))
96630082d0cSmyers             {
96730082d0cSmyers                 Operand[0] = TempDesc;
96830082d0cSmyers                 AcpiUtAddReference (TempDesc);
96930082d0cSmyers             }
97030082d0cSmyers             else
97130082d0cSmyers             {
97230082d0cSmyers                 Status = AE_AML_OPERAND_TYPE;
97330082d0cSmyers                 goto Cleanup;
97430082d0cSmyers             }
97530082d0cSmyers         }
97630082d0cSmyers         else
9777c478bd9Sstevel@tonic-gate         {
978aa2aa9a6SDana Myers             switch ((Operand[0])->Common.Type)
9797c478bd9Sstevel@tonic-gate             {
9807c478bd9Sstevel@tonic-gate             case ACPI_TYPE_LOCAL_REFERENCE:
9817c478bd9Sstevel@tonic-gate                 /*
9827c478bd9Sstevel@tonic-gate                  * This is a DerefOf (LocalX | ArgX)
9837c478bd9Sstevel@tonic-gate                  *
9847c478bd9Sstevel@tonic-gate                  * Must resolve/dereference the local/arg reference first
9857c478bd9Sstevel@tonic-gate                  */
986db2bae30SDana Myers                 switch (Operand[0]->Reference.Class)
9877c478bd9Sstevel@tonic-gate                 {
988db2bae30SDana Myers                 case ACPI_REFCLASS_LOCAL:
989db2bae30SDana Myers                 case ACPI_REFCLASS_ARG:
9907c478bd9Sstevel@tonic-gate 
9917c478bd9Sstevel@tonic-gate                     /* Set Operand[0] to the value of the local/arg */
9927c478bd9Sstevel@tonic-gate 
9937c478bd9Sstevel@tonic-gate                     Status = AcpiDsMethodDataGetValue (
9947b1019a6SJerry Jelinek                         Operand[0]->Reference.Class,
9957b1019a6SJerry Jelinek                         Operand[0]->Reference.Value,
9967b1019a6SJerry Jelinek                         WalkState, &TempDesc);
9977c478bd9Sstevel@tonic-gate                     if (ACPI_FAILURE (Status))
9987c478bd9Sstevel@tonic-gate                     {
9997c478bd9Sstevel@tonic-gate                         goto Cleanup;
10007c478bd9Sstevel@tonic-gate                     }
10017c478bd9Sstevel@tonic-gate 
10027c478bd9Sstevel@tonic-gate                     /*
10037c478bd9Sstevel@tonic-gate                      * Delete our reference to the input object and
10047c478bd9Sstevel@tonic-gate                      * point to the object just retrieved
10057c478bd9Sstevel@tonic-gate                      */
10067c478bd9Sstevel@tonic-gate                     AcpiUtRemoveReference (Operand[0]);
10077c478bd9Sstevel@tonic-gate                     Operand[0] = TempDesc;
10087c478bd9Sstevel@tonic-gate                     break;
10097c478bd9Sstevel@tonic-gate 
1010db2bae30SDana Myers                 case ACPI_REFCLASS_REFOF:
10117c478bd9Sstevel@tonic-gate 
10127c478bd9Sstevel@tonic-gate                     /* Get the object to which the reference refers */
10137c478bd9Sstevel@tonic-gate 
10147c478bd9Sstevel@tonic-gate                     TempDesc = Operand[0]->Reference.Object;
10157c478bd9Sstevel@tonic-gate                     AcpiUtRemoveReference (Operand[0]);
10167c478bd9Sstevel@tonic-gate                     Operand[0] = TempDesc;
10177c478bd9Sstevel@tonic-gate                     break;
10187c478bd9Sstevel@tonic-gate 
10197c478bd9Sstevel@tonic-gate                 default:
10207c478bd9Sstevel@tonic-gate 
10217c478bd9Sstevel@tonic-gate                     /* Must be an Index op - handled below */
10227c478bd9Sstevel@tonic-gate                     break;
10237c478bd9Sstevel@tonic-gate                 }
10247c478bd9Sstevel@tonic-gate                 break;
10257c478bd9Sstevel@tonic-gate 
10267c478bd9Sstevel@tonic-gate             case ACPI_TYPE_STRING:
10277b1019a6SJerry Jelinek 
102830082d0cSmyers                 break;
10297c478bd9Sstevel@tonic-gate 
103030082d0cSmyers             default:
10317b1019a6SJerry Jelinek 
103230082d0cSmyers                 Status = AE_AML_OPERAND_TYPE;
103330082d0cSmyers                 goto Cleanup;
103430082d0cSmyers             }
103530082d0cSmyers         }
103630082d0cSmyers 
103730082d0cSmyers         if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
103830082d0cSmyers         {
1039aa2aa9a6SDana Myers             if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
104030082d0cSmyers             {
10417c478bd9Sstevel@tonic-gate                 /*
104230082d0cSmyers                  * This is a DerefOf (String). The string is a reference
10437c478bd9Sstevel@tonic-gate                  * to a named ACPI object.
10447c478bd9Sstevel@tonic-gate                  *
10457c478bd9Sstevel@tonic-gate                  * 1) Find the owning Node
104630082d0cSmyers                  * 2) Dereference the node to an actual object. Could be a
10477c478bd9Sstevel@tonic-gate                  *    Field, so we need to resolve the node to a value.
10487c478bd9Sstevel@tonic-gate                  */
1049*35786f68SRobert Mustacchi                 Status = AcpiNsGetNodeUnlocked (WalkState->ScopeInfo->Scope.Node,
10507b1019a6SJerry Jelinek                     Operand[0]->String.Pointer,
10517b1019a6SJerry Jelinek                     ACPI_NS_SEARCH_PARENT,
10527b1019a6SJerry Jelinek                     ACPI_CAST_INDIRECT_PTR (
10537b1019a6SJerry Jelinek                         ACPI_NAMESPACE_NODE, &ReturnDesc));
10547c478bd9Sstevel@tonic-gate                 if (ACPI_FAILURE (Status))
10557c478bd9Sstevel@tonic-gate                 {
10567c478bd9Sstevel@tonic-gate                     goto Cleanup;
10577c478bd9Sstevel@tonic-gate                 }
10587c478bd9Sstevel@tonic-gate 
10597c478bd9Sstevel@tonic-gate                 Status = AcpiExResolveNodeToValue (
10607b1019a6SJerry Jelinek                     ACPI_CAST_INDIRECT_PTR (
10617b1019a6SJerry Jelinek                         ACPI_NAMESPACE_NODE, &ReturnDesc),
10627b1019a6SJerry Jelinek                     WalkState);
10637c478bd9Sstevel@tonic-gate                 goto Cleanup;
10647c478bd9Sstevel@tonic-gate             }
10657c478bd9Sstevel@tonic-gate         }
10667c478bd9Sstevel@tonic-gate 
10677c478bd9Sstevel@tonic-gate         /* Operand[0] may have changed from the code above */
10687c478bd9Sstevel@tonic-gate 
10697c478bd9Sstevel@tonic-gate         if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
10707c478bd9Sstevel@tonic-gate         {
10717c478bd9Sstevel@tonic-gate             /*
10727c478bd9Sstevel@tonic-gate              * This is a DerefOf (ObjectReference)
10737c478bd9Sstevel@tonic-gate              * Get the actual object from the Node (This is the dereference).
10747c478bd9Sstevel@tonic-gate              * This case may only happen when a LocalX or ArgX is
1075*35786f68SRobert Mustacchi              * dereferenced above, or for references to device and
1076*35786f68SRobert Mustacchi              * thermal objects.
10777c478bd9Sstevel@tonic-gate              */
1078*35786f68SRobert Mustacchi             switch (((ACPI_NAMESPACE_NODE *) Operand[0])->Type)
1079*35786f68SRobert Mustacchi             {
1080*35786f68SRobert Mustacchi             case ACPI_TYPE_DEVICE:
1081*35786f68SRobert Mustacchi             case ACPI_TYPE_THERMAL:
1082*35786f68SRobert Mustacchi 
1083*35786f68SRobert Mustacchi                 /* These types have no node subobject, return the NS node */
1084*35786f68SRobert Mustacchi 
1085*35786f68SRobert Mustacchi                 ReturnDesc = Operand[0];
1086*35786f68SRobert Mustacchi                 break;
1087*35786f68SRobert Mustacchi 
1088*35786f68SRobert Mustacchi             default:
1089*35786f68SRobert Mustacchi                 /* For most types, get the object attached to the node */
1090*35786f68SRobert Mustacchi 
1091*35786f68SRobert Mustacchi                 ReturnDesc = AcpiNsGetAttachedObject (
1092*35786f68SRobert Mustacchi                     (ACPI_NAMESPACE_NODE *) Operand[0]);
1093*35786f68SRobert Mustacchi                 AcpiUtAddReference (ReturnDesc);
1094*35786f68SRobert Mustacchi                 break;
1095*35786f68SRobert Mustacchi             }
10967c478bd9Sstevel@tonic-gate         }
10977c478bd9Sstevel@tonic-gate         else
10987c478bd9Sstevel@tonic-gate         {
10997c478bd9Sstevel@tonic-gate             /*
11007c478bd9Sstevel@tonic-gate              * This must be a reference object produced by either the
11017c478bd9Sstevel@tonic-gate              * Index() or RefOf() operator
11027c478bd9Sstevel@tonic-gate              */
1103db2bae30SDana Myers             switch (Operand[0]->Reference.Class)
11047c478bd9Sstevel@tonic-gate             {
1105db2bae30SDana Myers             case ACPI_REFCLASS_INDEX:
11067c478bd9Sstevel@tonic-gate                 /*
11077c478bd9Sstevel@tonic-gate                  * The target type for the Index operator must be
11087c478bd9Sstevel@tonic-gate                  * either a Buffer or a Package
11097c478bd9Sstevel@tonic-gate                  */
11107c478bd9Sstevel@tonic-gate                 switch (Operand[0]->Reference.TargetType)
11117c478bd9Sstevel@tonic-gate                 {
11127c478bd9Sstevel@tonic-gate                 case ACPI_TYPE_BUFFER_FIELD:
11137c478bd9Sstevel@tonic-gate 
11147c478bd9Sstevel@tonic-gate                     TempDesc = Operand[0]->Reference.Object;
11157c478bd9Sstevel@tonic-gate 
11167c478bd9Sstevel@tonic-gate                     /*
11177c478bd9Sstevel@tonic-gate                      * Create a new object that contains one element of the
11187c478bd9Sstevel@tonic-gate                      * buffer -- the element pointed to by the index.
11197c478bd9Sstevel@tonic-gate                      *
11207c478bd9Sstevel@tonic-gate                      * NOTE: index into a buffer is NOT a pointer to a
11217c478bd9Sstevel@tonic-gate                      * sub-buffer of the main buffer, it is only a pointer to a
11227c478bd9Sstevel@tonic-gate                      * single element (byte) of the buffer!
112357190917SDana Myers                      *
112457190917SDana Myers                      * Since we are returning the value of the buffer at the
112557190917SDana Myers                      * indexed location, we don't need to add an additional
112657190917SDana Myers                      * reference to the buffer itself.
11277c478bd9Sstevel@tonic-gate                      */
112857190917SDana Myers                     ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
112957190917SDana Myers                         TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
11307c478bd9Sstevel@tonic-gate                     if (!ReturnDesc)
11317c478bd9Sstevel@tonic-gate                     {
11327c478bd9Sstevel@tonic-gate                         Status = AE_NO_MEMORY;
11337c478bd9Sstevel@tonic-gate                         goto Cleanup;
11347c478bd9Sstevel@tonic-gate                     }
11357c478bd9Sstevel@tonic-gate                     break;
11367c478bd9Sstevel@tonic-gate 
11377c478bd9Sstevel@tonic-gate                 case ACPI_TYPE_PACKAGE:
11387c478bd9Sstevel@tonic-gate                     /*
11397b1019a6SJerry Jelinek                      * Return the referenced element of the package. We must
11407c478bd9Sstevel@tonic-gate                      * add another reference to the referenced object, however.
11417c478bd9Sstevel@tonic-gate                      */
11427c478bd9Sstevel@tonic-gate                     ReturnDesc = *(Operand[0]->Reference.Where);
11437b1019a6SJerry Jelinek                     if (!ReturnDesc)
11447c478bd9Sstevel@tonic-gate                     {
11457b1019a6SJerry Jelinek                         /*
11467b1019a6SJerry Jelinek                          * Element is NULL, do not allow the dereference.
11477b1019a6SJerry Jelinek                          * This provides compatibility with other ACPI
11487b1019a6SJerry Jelinek                          * implementations.
11497b1019a6SJerry Jelinek                          */
11507b1019a6SJerry Jelinek                         return_ACPI_STATUS (AE_AML_UNINITIALIZED_ELEMENT);
11517c478bd9Sstevel@tonic-gate                     }
11527c478bd9Sstevel@tonic-gate 
11537b1019a6SJerry Jelinek                     AcpiUtAddReference (ReturnDesc);
11547b1019a6SJerry Jelinek                     break;
11557c478bd9Sstevel@tonic-gate 
11567c478bd9Sstevel@tonic-gate                 default:
11577c478bd9Sstevel@tonic-gate 
115830082d0cSmyers                     ACPI_ERROR ((AE_INFO,
115926f3cdf0SGordon Ross                         "Unknown Index TargetType 0x%X in reference object %p",
11607c478bd9Sstevel@tonic-gate                         Operand[0]->Reference.TargetType, Operand[0]));
11617b1019a6SJerry Jelinek 
11627c478bd9Sstevel@tonic-gate                     Status = AE_AML_OPERAND_TYPE;
11637c478bd9Sstevel@tonic-gate                     goto Cleanup;
11647c478bd9Sstevel@tonic-gate                 }
11657c478bd9Sstevel@tonic-gate                 break;
11667c478bd9Sstevel@tonic-gate 
1167db2bae30SDana Myers             case ACPI_REFCLASS_REFOF:
11687c478bd9Sstevel@tonic-gate 
11697c478bd9Sstevel@tonic-gate                 ReturnDesc = Operand[0]->Reference.Object;
11707c478bd9Sstevel@tonic-gate 
11717c478bd9Sstevel@tonic-gate                 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
11727b1019a6SJerry Jelinek                     ACPI_DESC_TYPE_NAMED)
11737c478bd9Sstevel@tonic-gate                 {
11747c478bd9Sstevel@tonic-gate                     ReturnDesc = AcpiNsGetAttachedObject (
11757b1019a6SJerry Jelinek                         (ACPI_NAMESPACE_NODE *) ReturnDesc);
11767b1019a6SJerry Jelinek                     if (!ReturnDesc)
11777b1019a6SJerry Jelinek                     {
11787b1019a6SJerry Jelinek                         break;
11797b1019a6SJerry Jelinek                     }
11807c478bd9Sstevel@tonic-gate 
11817b1019a6SJerry Jelinek                    /*
11827b1019a6SJerry Jelinek                     * June 2013:
11837b1019a6SJerry Jelinek                     * BufferFields/FieldUnits require additional resolution
11847b1019a6SJerry Jelinek                     */
11857b1019a6SJerry Jelinek                     switch (ReturnDesc->Common.Type)
11867b1019a6SJerry Jelinek                     {
11877b1019a6SJerry Jelinek                     case ACPI_TYPE_BUFFER_FIELD:
11887b1019a6SJerry Jelinek                     case ACPI_TYPE_LOCAL_REGION_FIELD:
11897b1019a6SJerry Jelinek                     case ACPI_TYPE_LOCAL_BANK_FIELD:
11907b1019a6SJerry Jelinek                     case ACPI_TYPE_LOCAL_INDEX_FIELD:
11917c478bd9Sstevel@tonic-gate 
11927b1019a6SJerry Jelinek                         Status = AcpiExReadDataFromField (
11937b1019a6SJerry Jelinek                             WalkState, ReturnDesc, &TempDesc);
11947b1019a6SJerry Jelinek                         if (ACPI_FAILURE (Status))
11957b1019a6SJerry Jelinek                         {
11967b1019a6SJerry Jelinek                             goto Cleanup;
11977b1019a6SJerry Jelinek                         }
11987b1019a6SJerry Jelinek 
11997b1019a6SJerry Jelinek                         ReturnDesc = TempDesc;
12007b1019a6SJerry Jelinek                         break;
12017c478bd9Sstevel@tonic-gate 
12027b1019a6SJerry Jelinek                     default:
12037b1019a6SJerry Jelinek 
12047b1019a6SJerry Jelinek                         /* Add another reference to the object */
12057b1019a6SJerry Jelinek 
12067b1019a6SJerry Jelinek                         AcpiUtAddReference (ReturnDesc);
12077b1019a6SJerry Jelinek                         break;
12087b1019a6SJerry Jelinek                     }
12097b1019a6SJerry Jelinek                 }
12107b1019a6SJerry Jelinek                 break;
12117c478bd9Sstevel@tonic-gate 
12127c478bd9Sstevel@tonic-gate             default:
12137b1019a6SJerry Jelinek 
121430082d0cSmyers                 ACPI_ERROR ((AE_INFO,
121526f3cdf0SGordon Ross                     "Unknown class in reference(%p) - 0x%2.2X",
1216db2bae30SDana Myers                     Operand[0], Operand[0]->Reference.Class));
12177c478bd9Sstevel@tonic-gate 
12187c478bd9Sstevel@tonic-gate                 Status = AE_TYPE;
12197c478bd9Sstevel@tonic-gate                 goto Cleanup;
12207c478bd9Sstevel@tonic-gate             }
12217c478bd9Sstevel@tonic-gate         }
12227c478bd9Sstevel@tonic-gate         break;
12237c478bd9Sstevel@tonic-gate 
12247c478bd9Sstevel@tonic-gate     default:
12257c478bd9Sstevel@tonic-gate 
122626f3cdf0SGordon Ross         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
12277c478bd9Sstevel@tonic-gate             WalkState->Opcode));
12287b1019a6SJerry Jelinek 
12297c478bd9Sstevel@tonic-gate         Status = AE_AML_BAD_OPCODE;
12307c478bd9Sstevel@tonic-gate         goto Cleanup;
12317c478bd9Sstevel@tonic-gate     }
12327c478bd9Sstevel@tonic-gate 
12337c478bd9Sstevel@tonic-gate 
12347c478bd9Sstevel@tonic-gate Cleanup:
12357c478bd9Sstevel@tonic-gate 
12367c478bd9Sstevel@tonic-gate     /* Delete return object on error */
12377c478bd9Sstevel@tonic-gate 
12387c478bd9Sstevel@tonic-gate     if (ACPI_FAILURE (Status))
12397c478bd9Sstevel@tonic-gate     {
12407c478bd9Sstevel@tonic-gate         AcpiUtRemoveReference (ReturnDesc);
12417c478bd9Sstevel@tonic-gate     }
12427c478bd9Sstevel@tonic-gate 
124327f7c583Smyers     /* Save return object on success */
124427f7c583Smyers 
124527f7c583Smyers     else
124627f7c583Smyers     {
124727f7c583Smyers         WalkState->ResultObj = ReturnDesc;
124827f7c583Smyers     }
124927f7c583Smyers 
12507c478bd9Sstevel@tonic-gate     return_ACPI_STATUS (Status);
12517c478bd9Sstevel@tonic-gate }
1252