Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:02

0001 /******************************************************************************
0002  *
0003  * Module Name: exoparg1 - AML execution - opcodes with 1 argument
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights. You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code. No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision. In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change. Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee. Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution. In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government. In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************
0115  *
0116  * Alternatively, you may choose to be licensed under the terms of the
0117  * following license:
0118  *
0119  * Redistribution and use in source and binary forms, with or without
0120  * modification, are permitted provided that the following conditions
0121  * are met:
0122  * 1. Redistributions of source code must retain the above copyright
0123  *    notice, this list of conditions, and the following disclaimer,
0124  *    without modification.
0125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0126  *    substantially similar to the "NO WARRANTY" disclaimer below
0127  *    ("Disclaimer") and any redistribution must be conditioned upon
0128  *    including a substantially similar Disclaimer requirement for further
0129  *    binary redistribution.
0130  * 3. Neither the names of the above-listed copyright holders nor the names
0131  *    of any contributors may be used to endorse or promote products derived
0132  *    from this software without specific prior written permission.
0133  *
0134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0145  *
0146  * Alternatively, you may choose to be licensed under the terms of the
0147  * GNU General Public License ("GPL") version 2 as published by the Free
0148  * Software Foundation.
0149  *
0150  *****************************************************************************/
0151 
0152 #include "acpi.h"
0153 #include "accommon.h"
0154 #include "acparser.h"
0155 #include "acdispat.h"
0156 #include "acinterp.h"
0157 #include "amlcode.h"
0158 #include "acnamesp.h"
0159 
0160 
0161 #define _COMPONENT          ACPI_EXECUTER
0162         ACPI_MODULE_NAME    ("exoparg1")
0163 
0164 
0165 /*!
0166  * Naming convention for AML interpreter execution routines.
0167  *
0168  * The routines that begin execution of AML opcodes are named with a common
0169  * convention based upon the number of arguments, the number of target operands,
0170  * and whether or not a value is returned:
0171  *
0172  *      AcpiExOpcode_xA_yT_zR
0173  *
0174  * Where:
0175  *
0176  * xA - ARGUMENTS:    The number of arguments (input operands) that are
0177  *                    required for this opcode type (0 through 6 args).
0178  * yT - TARGETS:      The number of targets (output operands) that are required
0179  *                    for this opcode type (0, 1, or 2 targets).
0180  * zR - RETURN VALUE: Indicates whether this opcode type returns a value
0181  *                    as the function return (0 or 1).
0182  *
0183  * The AcpiExOpcode* functions are called via the Dispatcher component with
0184  * fully resolved operands.
0185 !*/
0186 
0187 /*******************************************************************************
0188  *
0189  * FUNCTION:    AcpiExOpcode_0A_0T_1R
0190  *
0191  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
0192  *
0193  * RETURN:      Status
0194  *
0195  * DESCRIPTION: Execute operator with no operands, one return value
0196  *
0197  ******************************************************************************/
0198 
0199 ACPI_STATUS
0200 AcpiExOpcode_0A_0T_1R (
0201     ACPI_WALK_STATE         *WalkState)
0202 {
0203     ACPI_STATUS             Status = AE_OK;
0204     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
0205 
0206 
0207     ACPI_FUNCTION_TRACE_STR (ExOpcode_0A_0T_1R,
0208         AcpiPsGetOpcodeName (WalkState->Opcode));
0209 
0210 
0211     /* Examine the AML opcode */
0212 
0213     switch (WalkState->Opcode)
0214     {
0215     case AML_TIMER_OP:      /*  Timer () */
0216 
0217         /* Create a return object of type Integer */
0218 
0219         ReturnDesc = AcpiUtCreateIntegerObject (AcpiOsGetTimer ());
0220         if (!ReturnDesc)
0221         {
0222             Status = AE_NO_MEMORY;
0223             goto Cleanup;
0224         }
0225         break;
0226 
0227     default:                /*  Unknown opcode  */
0228 
0229         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
0230             WalkState->Opcode));
0231         Status = AE_AML_BAD_OPCODE;
0232         break;
0233     }
0234 
0235 Cleanup:
0236 
0237     /* Delete return object on error */
0238 
0239     if ((ACPI_FAILURE (Status)) || WalkState->ResultObj)
0240     {
0241         AcpiUtRemoveReference (ReturnDesc);
0242         WalkState->ResultObj = NULL;
0243     }
0244     else
0245     {
0246         /* Save the return value */
0247 
0248         WalkState->ResultObj = ReturnDesc;
0249     }
0250 
0251     return_ACPI_STATUS (Status);
0252 }
0253 
0254 
0255 /*******************************************************************************
0256  *
0257  * FUNCTION:    AcpiExOpcode_1A_0T_0R
0258  *
0259  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
0260  *
0261  * RETURN:      Status
0262  *
0263  * DESCRIPTION: Execute Type 1 monadic operator with numeric operand on
0264  *              object stack
0265  *
0266  ******************************************************************************/
0267 
0268 ACPI_STATUS
0269 AcpiExOpcode_1A_0T_0R (
0270     ACPI_WALK_STATE         *WalkState)
0271 {
0272     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
0273     ACPI_STATUS             Status = AE_OK;
0274 
0275 
0276     ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
0277         AcpiPsGetOpcodeName (WalkState->Opcode));
0278 
0279 
0280     /* Examine the AML opcode */
0281 
0282     switch (WalkState->Opcode)
0283     {
0284     case AML_RELEASE_OP:    /*  Release (MutexObject) */
0285 
0286         Status = AcpiExReleaseMutex (Operand[0], WalkState);
0287         break;
0288 
0289     case AML_RESET_OP:      /*  Reset (EventObject) */
0290 
0291         Status = AcpiExSystemResetEvent (Operand[0]);
0292         break;
0293 
0294     case AML_SIGNAL_OP:     /*  Signal (EventObject) */
0295 
0296         Status = AcpiExSystemSignalEvent (Operand[0]);
0297         break;
0298 
0299     case AML_SLEEP_OP:      /*  Sleep (MsecTime) */
0300 
0301         Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
0302         break;
0303 
0304     case AML_STALL_OP:      /*  Stall (UsecTime) */
0305 
0306         Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
0307         break;
0308 
0309     case AML_UNLOAD_OP:     /*  Unload (Handle) */
0310 
0311         Status = AcpiExUnloadTable (Operand[0]);
0312         break;
0313 
0314     default:                /*  Unknown opcode  */
0315 
0316         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
0317             WalkState->Opcode));
0318         Status = AE_AML_BAD_OPCODE;
0319         break;
0320     }
0321 
0322     return_ACPI_STATUS (Status);
0323 }
0324 
0325 
0326 #ifdef _OBSOLETE_CODE /* Was originally used for Load() operator */
0327 /*******************************************************************************
0328  *
0329  * FUNCTION:    AcpiExOpcode_1A_1T_0R
0330  *
0331  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
0332  *
0333  * RETURN:      Status
0334  *
0335  * DESCRIPTION: Execute opcode with one argument, one target, and no
0336  *              return value.
0337  *
0338  ******************************************************************************/
0339 
0340 ACPI_STATUS
0341 AcpiExOpcode_1A_1T_0R (
0342     ACPI_WALK_STATE         *WalkState)
0343 {
0344     ACPI_STATUS             Status = AE_OK;
0345     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
0346 
0347 
0348     ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R,
0349         AcpiPsGetOpcodeName (WalkState->Opcode));
0350 
0351 
0352     /* Examine the AML opcode */
0353 
0354     switch (WalkState->Opcode)
0355     {
0356 #ifdef _OBSOLETE_CODE
0357     case AML_LOAD_OP:
0358 
0359         Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
0360         break;
0361 #endif
0362 
0363     default:                        /* Unknown opcode */
0364 
0365         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
0366             WalkState->Opcode));
0367         Status = AE_AML_BAD_OPCODE;
0368         goto Cleanup;
0369     }
0370 
0371 
0372 Cleanup:
0373 
0374     return_ACPI_STATUS (Status);
0375 }
0376 #endif
0377 
0378 /*******************************************************************************
0379  *
0380  * FUNCTION:    AcpiExOpcode_1A_1T_1R
0381  *
0382  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
0383  *
0384  * RETURN:      Status
0385  *
0386  * DESCRIPTION: Execute opcode with one argument, one target, and a
0387  *              return value.
0388  *              January 2022: Added Load operator, with new ACPI 6.4
0389  *              semantics.
0390  *
0391  ******************************************************************************/
0392 
0393 ACPI_STATUS
0394 AcpiExOpcode_1A_1T_1R (
0395     ACPI_WALK_STATE         *WalkState)
0396 {
0397     ACPI_STATUS             Status = AE_OK;
0398     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
0399     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
0400     ACPI_OPERAND_OBJECT     *ReturnDesc2 = NULL;
0401     UINT32                  Temp32;
0402     UINT32                  i;
0403     UINT64                  PowerOfTen;
0404     UINT64                  Digit;
0405 
0406 
0407     ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_1R,
0408         AcpiPsGetOpcodeName (WalkState->Opcode));
0409 
0410 
0411     /* Examine the AML opcode */
0412 
0413     switch (WalkState->Opcode)
0414     {
0415     case AML_BIT_NOT_OP:
0416     case AML_FIND_SET_LEFT_BIT_OP:
0417     case AML_FIND_SET_RIGHT_BIT_OP:
0418     case AML_FROM_BCD_OP:
0419     case AML_LOAD_OP:
0420     case AML_TO_BCD_OP:
0421     case AML_CONDITIONAL_REF_OF_OP:
0422 
0423         /* Create a return object of type Integer for these opcodes */
0424 
0425         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
0426         if (!ReturnDesc)
0427         {
0428             Status = AE_NO_MEMORY;
0429             goto Cleanup;
0430         }
0431 
0432         switch (WalkState->Opcode)
0433         {
0434         case AML_BIT_NOT_OP:            /* Not (Operand, Result)  */
0435 
0436             ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
0437             break;
0438 
0439         case AML_FIND_SET_LEFT_BIT_OP:  /* FindSetLeftBit (Operand, Result) */
0440 
0441             ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
0442 
0443             /*
0444              * Acpi specification describes Integer type as a little
0445              * endian unsigned value, so this boundary condition is valid.
0446              */
0447             for (Temp32 = 0; ReturnDesc->Integer.Value &&
0448                     Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
0449             {
0450                 ReturnDesc->Integer.Value >>= 1;
0451             }
0452 
0453             ReturnDesc->Integer.Value = Temp32;
0454             break;
0455 
0456         case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
0457 
0458             ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
0459 
0460             /*
0461              * The Acpi specification describes Integer type as a little
0462              * endian unsigned value, so this boundary condition is valid.
0463              */
0464             for (Temp32 = 0; ReturnDesc->Integer.Value &&
0465                      Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
0466             {
0467                 ReturnDesc->Integer.Value <<= 1;
0468             }
0469 
0470             /* Since the bit position is one-based, subtract from 33 (65) */
0471 
0472             ReturnDesc->Integer.Value =
0473                 Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
0474             break;
0475 
0476         case AML_FROM_BCD_OP:           /* FromBcd (BCDValue, Result)  */
0477             /*
0478              * The 64-bit ACPI integer can hold 16 4-bit BCD characters
0479              * (if table is 32-bit, integer can hold 8 BCD characters)
0480              * Convert each 4-bit BCD value
0481              */
0482             PowerOfTen = 1;
0483             ReturnDesc->Integer.Value = 0;
0484             Digit = Operand[0]->Integer.Value;
0485 
0486             /* Convert each BCD digit (each is one nybble wide) */
0487 
0488             for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
0489             {
0490                 /* Get the least significant 4-bit BCD digit */
0491 
0492                 Temp32 = ((UINT32) Digit) & 0xF;
0493 
0494                 /* Check the range of the digit */
0495 
0496                 if (Temp32 > 9)
0497                 {
0498                     ACPI_ERROR ((AE_INFO,
0499                         "BCD digit too large (not decimal): 0x%X",
0500                         Temp32));
0501 
0502                     Status = AE_AML_NUMERIC_OVERFLOW;
0503                     goto Cleanup;
0504                 }
0505 
0506                 /* Sum the digit into the result with the current power of 10 */
0507 
0508                 ReturnDesc->Integer.Value +=
0509                     (((UINT64) Temp32) * PowerOfTen);
0510 
0511                 /* Shift to next BCD digit */
0512 
0513                 Digit >>= 4;
0514 
0515                 /* Next power of 10 */
0516 
0517                 PowerOfTen *= 10;
0518             }
0519             break;
0520 
0521         case AML_LOAD_OP:               /* Result1 = Load (Operand[0], Result1) */
0522 
0523             ReturnDesc->Integer.Value = 0;
0524             Status = AcpiExLoadOp (Operand[0], ReturnDesc, WalkState);
0525             if (ACPI_SUCCESS (Status))
0526             {
0527                 /* Return -1 (non-zero) indicates success */
0528 
0529                 ReturnDesc->Integer.Value = 0xFFFFFFFFFFFFFFFF;
0530             }
0531             break;
0532 
0533         case AML_TO_BCD_OP:             /* ToBcd (Operand, Result)  */
0534 
0535             ReturnDesc->Integer.Value = 0;
0536             Digit = Operand[0]->Integer.Value;
0537 
0538             /* Each BCD digit is one nybble wide */
0539 
0540             for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
0541             {
0542                 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
0543 
0544                 /*
0545                  * Insert the BCD digit that resides in the
0546                  * remainder from above
0547                  */
0548                 ReturnDesc->Integer.Value |=
0549                     (((UINT64) Temp32) << ACPI_MUL_4 (i));
0550             }
0551 
0552             /* Overflow if there is any data left in Digit */
0553 
0554             if (Digit > 0)
0555             {
0556                 ACPI_ERROR ((AE_INFO,
0557                     "Integer too large to convert to BCD: 0x%8.8X%8.8X",
0558                     ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
0559                 Status = AE_AML_NUMERIC_OVERFLOW;
0560                 goto Cleanup;
0561             }
0562             break;
0563 
0564         case AML_CONDITIONAL_REF_OF_OP:     /* CondRefOf (SourceObject, Result)  */
0565             /*
0566              * This op is a little strange because the internal return value is
0567              * different than the return value stored in the result descriptor
0568              * (There are really two return values)
0569              */
0570             if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
0571             {
0572                 /*
0573                  * This means that the object does not exist in the namespace,
0574                  * return FALSE
0575                  */
0576                 ReturnDesc->Integer.Value = 0;
0577                 goto Cleanup;
0578             }
0579 
0580             /* Get the object reference, store it, and remove our reference */
0581 
0582             Status = AcpiExGetObjectReference (Operand[0],
0583                 &ReturnDesc2, WalkState);
0584             if (ACPI_FAILURE (Status))
0585             {
0586                 goto Cleanup;
0587             }
0588 
0589             Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
0590             AcpiUtRemoveReference (ReturnDesc2);
0591 
0592             /* The object exists in the namespace, return TRUE */
0593 
0594             ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
0595             goto Cleanup;
0596 
0597 
0598         default:
0599 
0600             /* No other opcodes get here */
0601 
0602             break;
0603         }
0604         break;
0605 
0606     case AML_STORE_OP:              /* Store (Source, Target) */
0607         /*
0608          * A store operand is typically a number, string, buffer or lvalue
0609          * Be careful about deleting the source object,
0610          * since the object itself may have been stored.
0611          */
0612         Status = AcpiExStore (Operand[0], Operand[1], WalkState);
0613         if (ACPI_FAILURE (Status))
0614         {
0615             return_ACPI_STATUS (Status);
0616         }
0617 
0618         /* It is possible that the Store already produced a return object */
0619 
0620         if (!WalkState->ResultObj)
0621         {
0622             /*
0623              * Normally, we would remove a reference on the Operand[0]
0624              * parameter; But since it is being used as the internal return
0625              * object (meaning we would normally increment it), the two
0626              * cancel out, and we simply don't do anything.
0627              */
0628             WalkState->ResultObj = Operand[0];
0629             WalkState->Operands[0] = NULL;  /* Prevent deletion */
0630         }
0631         return_ACPI_STATUS (Status);
0632 
0633     /*
0634      * ACPI 2.0 Opcodes
0635      */
0636     case AML_COPY_OBJECT_OP:        /* CopyObject (Source, Target) */
0637 
0638         Status = AcpiUtCopyIobjectToIobject (
0639             Operand[0], &ReturnDesc, WalkState);
0640         break;
0641 
0642     case AML_TO_DECIMAL_STRING_OP:  /* ToDecimalString (Data, Result) */
0643 
0644         Status = AcpiExConvertToString (
0645             Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_DECIMAL);
0646         if (ReturnDesc == Operand[0])
0647         {
0648             /* No conversion performed, add ref to handle return value */
0649 
0650             AcpiUtAddReference (ReturnDesc);
0651         }
0652         break;
0653 
0654     case AML_TO_HEX_STRING_OP:      /* ToHexString (Data, Result) */
0655 
0656         Status = AcpiExConvertToString (
0657             Operand[0], &ReturnDesc, ACPI_EXPLICIT_CONVERT_HEX);
0658         if (ReturnDesc == Operand[0])
0659         {
0660             /* No conversion performed, add ref to handle return value */
0661 
0662             AcpiUtAddReference (ReturnDesc);
0663         }
0664         break;
0665 
0666     case AML_TO_BUFFER_OP:          /* ToBuffer (Data, Result) */
0667 
0668         Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
0669         if (ReturnDesc == Operand[0])
0670         {
0671             /* No conversion performed, add ref to handle return value */
0672 
0673             AcpiUtAddReference (ReturnDesc);
0674         }
0675         break;
0676 
0677     case AML_TO_INTEGER_OP:         /* ToInteger (Data, Result) */
0678 
0679         /* Perform "explicit" conversion */
0680 
0681         Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc, 0);
0682         if (ReturnDesc == Operand[0])
0683         {
0684             /* No conversion performed, add ref to handle return value */
0685 
0686             AcpiUtAddReference (ReturnDesc);
0687         }
0688         break;
0689 
0690     case AML_SHIFT_LEFT_BIT_OP:     /* ShiftLeftBit (Source, BitNum)  */
0691     case AML_SHIFT_RIGHT_BIT_OP:    /* ShiftRightBit (Source, BitNum) */
0692 
0693         /* These are two obsolete opcodes */
0694 
0695         ACPI_ERROR ((AE_INFO,
0696             "%s is obsolete and not implemented",
0697             AcpiPsGetOpcodeName (WalkState->Opcode)));
0698         Status = AE_SUPPORT;
0699         goto Cleanup;
0700 
0701     default:                        /* Unknown opcode */
0702 
0703         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
0704             WalkState->Opcode));
0705         Status = AE_AML_BAD_OPCODE;
0706         goto Cleanup;
0707     }
0708 
0709     if (ACPI_SUCCESS (Status))
0710     {
0711         /* Store the return value computed above into the target object */
0712 
0713         Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
0714     }
0715 
0716 
0717 Cleanup:
0718 
0719     /* Delete return object on error */
0720 
0721     if (ACPI_FAILURE (Status))
0722     {
0723         AcpiUtRemoveReference (ReturnDesc);
0724     }
0725 
0726     /* Save return object on success */
0727 
0728     else if (!WalkState->ResultObj)
0729     {
0730         WalkState->ResultObj = ReturnDesc;
0731     }
0732 
0733     return_ACPI_STATUS (Status);
0734 }
0735 
0736 
0737 /*******************************************************************************
0738  *
0739  * FUNCTION:    AcpiExOpcode_1A_0T_1R
0740  *
0741  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
0742  *
0743  * RETURN:      Status
0744  *
0745  * DESCRIPTION: Execute opcode with one argument, no target, and a return value
0746  *
0747  ******************************************************************************/
0748 
0749 ACPI_STATUS
0750 AcpiExOpcode_1A_0T_1R (
0751     ACPI_WALK_STATE         *WalkState)
0752 {
0753     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
0754     ACPI_OPERAND_OBJECT     *TempDesc;
0755     ACPI_OPERAND_OBJECT     *ReturnDesc = NULL;
0756     ACPI_STATUS             Status = AE_OK;
0757     UINT32                  Type;
0758     UINT64                  Value;
0759 
0760 
0761     ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_1R,
0762         AcpiPsGetOpcodeName (WalkState->Opcode));
0763 
0764 
0765     /* Examine the AML opcode */
0766 
0767     switch (WalkState->Opcode)
0768     {
0769     case AML_LOGICAL_NOT_OP:        /* LNot (Operand) */
0770 
0771         ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
0772         if (!ReturnDesc)
0773         {
0774             Status = AE_NO_MEMORY;
0775             goto Cleanup;
0776         }
0777 
0778         /*
0779          * Set result to ONES (TRUE) if Value == 0. Note:
0780          * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
0781          */
0782         if (!Operand[0]->Integer.Value)
0783         {
0784             ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
0785         }
0786         break;
0787 
0788     case AML_DECREMENT_OP:          /* Decrement (Operand)  */
0789     case AML_INCREMENT_OP:          /* Increment (Operand)  */
0790         /*
0791          * Create a new integer. Can't just get the base integer and
0792          * increment it because it may be an Arg or Field.
0793          */
0794         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
0795         if (!ReturnDesc)
0796         {
0797             Status = AE_NO_MEMORY;
0798             goto Cleanup;
0799         }
0800 
0801         /*
0802          * Since we are expecting a Reference operand, it can be either a
0803          * NS Node or an internal object.
0804          */
0805         TempDesc = Operand[0];
0806         if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
0807         {
0808             /* Internal reference object - prevent deletion */
0809 
0810             AcpiUtAddReference (TempDesc);
0811         }
0812 
0813         /*
0814          * Convert the Reference operand to an Integer (This removes a
0815          * reference on the Operand[0] object)
0816          *
0817          * NOTE:  We use LNOT_OP here in order to force resolution of the
0818          * reference operand to an actual integer.
0819          */
0820         Status = AcpiExResolveOperands (AML_LOGICAL_NOT_OP,
0821             &TempDesc, WalkState);
0822         if (ACPI_FAILURE (Status))
0823         {
0824             ACPI_EXCEPTION ((AE_INFO, Status,
0825                 "While resolving operands for [%s]",
0826                 AcpiPsGetOpcodeName (WalkState->Opcode)));
0827 
0828             goto Cleanup;
0829         }
0830 
0831         /*
0832          * TempDesc is now guaranteed to be an Integer object --
0833          * Perform the actual increment or decrement
0834          */
0835         if (WalkState->Opcode == AML_INCREMENT_OP)
0836         {
0837             ReturnDesc->Integer.Value = TempDesc->Integer.Value + 1;
0838         }
0839         else
0840         {
0841             ReturnDesc->Integer.Value = TempDesc->Integer.Value - 1;
0842         }
0843 
0844         /* Finished with this Integer object */
0845 
0846         AcpiUtRemoveReference (TempDesc);
0847 
0848         /*
0849          * Store the result back (indirectly) through the original
0850          * Reference object
0851          */
0852         Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
0853         break;
0854 
0855     case AML_OBJECT_TYPE_OP:            /* ObjectType (SourceObject) */
0856         /*
0857          * Note: The operand is not resolved at this point because we want to
0858          * get the associated object, not its value. For example, we don't
0859          * want to resolve a FieldUnit to its value, we want the actual
0860          * FieldUnit object.
0861          */
0862 
0863         /* Get the type of the base object */
0864 
0865         Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
0866         if (ACPI_FAILURE (Status))
0867         {
0868             goto Cleanup;
0869         }
0870 
0871         /* Allocate a descriptor to hold the type. */
0872 
0873         ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type);
0874         if (!ReturnDesc)
0875         {
0876             Status = AE_NO_MEMORY;
0877             goto Cleanup;
0878         }
0879         break;
0880 
0881     case AML_SIZE_OF_OP:            /* SizeOf (SourceObject)  */
0882         /*
0883          * Note: The operand is not resolved at this point because we want to
0884          * get the associated object, not its value.
0885          */
0886 
0887         /* Get the base object */
0888 
0889         Status = AcpiExResolveMultiple (
0890             WalkState, Operand[0], &Type, &TempDesc);
0891         if (ACPI_FAILURE (Status))
0892         {
0893             goto Cleanup;
0894         }
0895 
0896         /*
0897          * The type of the base object must be integer, buffer, string, or
0898          * package. All others are not supported.
0899          *
0900          * NOTE: Integer is not specifically supported by the ACPI spec,
0901          * but is supported implicitly via implicit operand conversion.
0902          * rather than bother with conversion, we just use the byte width
0903          * global (4 or 8 bytes).
0904          */
0905         switch (Type)
0906         {
0907         case ACPI_TYPE_INTEGER:
0908 
0909             Value = AcpiGbl_IntegerByteWidth;
0910             break;
0911 
0912         case ACPI_TYPE_STRING:
0913 
0914             Value = TempDesc->String.Length;
0915             break;
0916 
0917         case ACPI_TYPE_BUFFER:
0918 
0919             /* Buffer arguments may not be evaluated at this point */
0920 
0921             Status = AcpiDsGetBufferArguments (TempDesc);
0922             Value = TempDesc->Buffer.Length;
0923             break;
0924 
0925         case ACPI_TYPE_PACKAGE:
0926 
0927             /* Package arguments may not be evaluated at this point */
0928 
0929             Status = AcpiDsGetPackageArguments (TempDesc);
0930             Value = TempDesc->Package.Count;
0931             break;
0932 
0933         default:
0934 
0935             ACPI_ERROR ((AE_INFO,
0936                 "Operand must be Buffer/Integer/String/Package"
0937                 " - found type %s",
0938                 AcpiUtGetTypeName (Type)));
0939 
0940             Status = AE_AML_OPERAND_TYPE;
0941             goto Cleanup;
0942         }
0943 
0944         if (ACPI_FAILURE (Status))
0945         {
0946             goto Cleanup;
0947         }
0948 
0949         /*
0950          * Now that we have the size of the object, create a result
0951          * object to hold the value
0952          */
0953         ReturnDesc = AcpiUtCreateIntegerObject (Value);
0954         if (!ReturnDesc)
0955         {
0956             Status = AE_NO_MEMORY;
0957             goto Cleanup;
0958         }
0959         break;
0960 
0961 
0962     case AML_REF_OF_OP:             /* RefOf (SourceObject) */
0963 
0964         Status = AcpiExGetObjectReference (
0965             Operand[0], &ReturnDesc, WalkState);
0966         if (ACPI_FAILURE (Status))
0967         {
0968             goto Cleanup;
0969         }
0970         break;
0971 
0972 
0973     case AML_DEREF_OF_OP:           /* DerefOf (ObjReference | String) */
0974 
0975         /* Check for a method local or argument, or standalone String */
0976 
0977         if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
0978         {
0979             TempDesc = AcpiNsGetAttachedObject (
0980                 (ACPI_NAMESPACE_NODE *) Operand[0]);
0981             if (TempDesc &&
0982                  ((TempDesc->Common.Type == ACPI_TYPE_STRING) ||
0983                   (TempDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)))
0984             {
0985                 Operand[0] = TempDesc;
0986                 AcpiUtAddReference (TempDesc);
0987             }
0988             else
0989             {
0990                 Status = AE_AML_OPERAND_TYPE;
0991                 goto Cleanup;
0992             }
0993         }
0994         else
0995         {
0996             switch ((Operand[0])->Common.Type)
0997             {
0998             case ACPI_TYPE_LOCAL_REFERENCE:
0999                 /*
1000                  * This is a DerefOf (LocalX | ArgX)
1001                  *
1002                  * Must resolve/dereference the local/arg reference first
1003                  */
1004                 switch (Operand[0]->Reference.Class)
1005                 {
1006                 case ACPI_REFCLASS_LOCAL:
1007                 case ACPI_REFCLASS_ARG:
1008 
1009                     /* Set Operand[0] to the value of the local/arg */
1010 
1011                     Status = AcpiDsMethodDataGetValue (
1012                         Operand[0]->Reference.Class,
1013                         Operand[0]->Reference.Value,
1014                         WalkState, &TempDesc);
1015                     if (ACPI_FAILURE (Status))
1016                     {
1017                         goto Cleanup;
1018                     }
1019 
1020                     /*
1021                      * Delete our reference to the input object and
1022                      * point to the object just retrieved
1023                      */
1024                     AcpiUtRemoveReference (Operand[0]);
1025                     Operand[0] = TempDesc;
1026                     break;
1027 
1028                 case ACPI_REFCLASS_REFOF:
1029 
1030                     /* Get the object to which the reference refers */
1031 
1032                     TempDesc = Operand[0]->Reference.Object;
1033                     AcpiUtRemoveReference (Operand[0]);
1034                     Operand[0] = TempDesc;
1035                     break;
1036 
1037                 default:
1038 
1039                     /* Must be an Index op - handled below */
1040                     break;
1041                 }
1042                 break;
1043 
1044             case ACPI_TYPE_STRING:
1045 
1046                 break;
1047 
1048             default:
1049 
1050                 Status = AE_AML_OPERAND_TYPE;
1051                 goto Cleanup;
1052             }
1053         }
1054 
1055         if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
1056         {
1057             if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
1058             {
1059                 /*
1060                  * This is a DerefOf (String). The string is a reference
1061                  * to a named ACPI object.
1062                  *
1063                  * 1) Find the owning Node
1064                  * 2) Dereference the node to an actual object. Could be a
1065                  *    Field, so we need to resolve the node to a value.
1066                  */
1067                 Status = AcpiNsGetNodeUnlocked (WalkState->ScopeInfo->Scope.Node,
1068                     Operand[0]->String.Pointer,
1069                     ACPI_NS_SEARCH_PARENT,
1070                     ACPI_CAST_INDIRECT_PTR (
1071                         ACPI_NAMESPACE_NODE, &ReturnDesc));
1072                 if (ACPI_FAILURE (Status))
1073                 {
1074                     goto Cleanup;
1075                 }
1076 
1077                 Status = AcpiExResolveNodeToValue (
1078                     ACPI_CAST_INDIRECT_PTR (
1079                         ACPI_NAMESPACE_NODE, &ReturnDesc),
1080                     WalkState);
1081                 goto Cleanup;
1082             }
1083         }
1084 
1085         /* Operand[0] may have changed from the code above */
1086 
1087         if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) == ACPI_DESC_TYPE_NAMED)
1088         {
1089             /*
1090              * This is a DerefOf (ObjectReference)
1091              * Get the actual object from the Node (This is the dereference).
1092              * This case may only happen when a LocalX or ArgX is
1093              * dereferenced above, or for references to device and
1094              * thermal objects.
1095              */
1096             switch (((ACPI_NAMESPACE_NODE *) Operand[0])->Type)
1097             {
1098             case ACPI_TYPE_DEVICE:
1099             case ACPI_TYPE_THERMAL:
1100 
1101                 /* These types have no node subobject, return the NS node */
1102 
1103                 ReturnDesc = Operand[0];
1104                 break;
1105 
1106             default:
1107                 /* For most types, get the object attached to the node */
1108 
1109                 ReturnDesc = AcpiNsGetAttachedObject (
1110                     (ACPI_NAMESPACE_NODE *) Operand[0]);
1111                 AcpiUtAddReference (ReturnDesc);
1112                 break;
1113             }
1114         }
1115         else
1116         {
1117             /*
1118              * This must be a reference object produced by either the
1119              * Index() or RefOf() operator
1120              */
1121             switch (Operand[0]->Reference.Class)
1122             {
1123             case ACPI_REFCLASS_INDEX:
1124                 /*
1125                  * The target type for the Index operator must be
1126                  * either a Buffer or a Package
1127                  */
1128                 switch (Operand[0]->Reference.TargetType)
1129                 {
1130                 case ACPI_TYPE_BUFFER_FIELD:
1131 
1132                     TempDesc = Operand[0]->Reference.Object;
1133 
1134                     /*
1135                      * Create a new object that contains one element of the
1136                      * buffer -- the element pointed to by the index.
1137                      *
1138                      * NOTE: index into a buffer is NOT a pointer to a
1139                      * sub-buffer of the main buffer, it is only a pointer to a
1140                      * single element (byte) of the buffer!
1141                      *
1142                      * Since we are returning the value of the buffer at the
1143                      * indexed location, we don't need to add an additional
1144                      * reference to the buffer itself.
1145                      */
1146                     ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
1147                         TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
1148                     if (!ReturnDesc)
1149                     {
1150                         Status = AE_NO_MEMORY;
1151                         goto Cleanup;
1152                     }
1153                     break;
1154 
1155                 case ACPI_TYPE_PACKAGE:
1156                     /*
1157                      * Return the referenced element of the package. We must
1158                      * add another reference to the referenced object, however.
1159                      */
1160                     ReturnDesc = *(Operand[0]->Reference.Where);
1161                     if (!ReturnDesc)
1162                     {
1163                         /*
1164                          * Element is NULL, do not allow the dereference.
1165                          * This provides compatibility with other ACPI
1166                          * implementations.
1167                          */
1168                         return_ACPI_STATUS (AE_AML_UNINITIALIZED_ELEMENT);
1169                     }
1170 
1171                     AcpiUtAddReference (ReturnDesc);
1172                     break;
1173 
1174                 default:
1175 
1176                     ACPI_ERROR ((AE_INFO,
1177                         "Unknown Index TargetType 0x%X in reference object %p",
1178                         Operand[0]->Reference.TargetType, Operand[0]));
1179 
1180                     Status = AE_AML_OPERAND_TYPE;
1181                     goto Cleanup;
1182                 }
1183                 break;
1184 
1185             case ACPI_REFCLASS_REFOF:
1186 
1187                 ReturnDesc = Operand[0]->Reference.Object;
1188 
1189                 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
1190                     ACPI_DESC_TYPE_NAMED)
1191                 {
1192                     ReturnDesc = AcpiNsGetAttachedObject (
1193                         (ACPI_NAMESPACE_NODE *) ReturnDesc);
1194                     if (!ReturnDesc)
1195                     {
1196                         break;
1197                     }
1198 
1199                    /*
1200                     * June 2013:
1201                     * BufferFields/FieldUnits require additional resolution
1202                     */
1203                     switch (ReturnDesc->Common.Type)
1204                     {
1205                     case ACPI_TYPE_BUFFER_FIELD:
1206                     case ACPI_TYPE_LOCAL_REGION_FIELD:
1207                     case ACPI_TYPE_LOCAL_BANK_FIELD:
1208                     case ACPI_TYPE_LOCAL_INDEX_FIELD:
1209 
1210                         Status = AcpiExReadDataFromField (
1211                             WalkState, ReturnDesc, &TempDesc);
1212                         if (ACPI_FAILURE (Status))
1213                         {
1214                             return_ACPI_STATUS (Status);
1215                         }
1216 
1217                         ReturnDesc = TempDesc;
1218                         break;
1219 
1220                     default:
1221 
1222                         /* Add another reference to the object */
1223 
1224                         AcpiUtAddReference (ReturnDesc);
1225                         break;
1226                     }
1227                 }
1228                 break;
1229 
1230             default:
1231 
1232                 ACPI_ERROR ((AE_INFO,
1233                     "Unknown class in reference(%p) - 0x%2.2X",
1234                     Operand[0], Operand[0]->Reference.Class));
1235 
1236                 Status = AE_TYPE;
1237                 goto Cleanup;
1238             }
1239         }
1240         break;
1241 
1242     default:
1243 
1244         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
1245             WalkState->Opcode));
1246 
1247         Status = AE_AML_BAD_OPCODE;
1248         goto Cleanup;
1249     }
1250 
1251 
1252 Cleanup:
1253 
1254     /* Delete return object on error */
1255 
1256     if (ACPI_FAILURE (Status))
1257     {
1258         AcpiUtRemoveReference (ReturnDesc);
1259     }
1260 
1261     /* Save return object on success */
1262 
1263     else
1264     {
1265         WalkState->ResultObj = ReturnDesc;
1266     }
1267 
1268     return_ACPI_STATUS (Status);
1269 }