Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/exoparg1.c need to be fixed.

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