Home | History | Annotate | Line # | Download | only in dispatcher
dsobject.c revision 1.1.1.8.4.1
      1          1.1    jruoho /******************************************************************************
      2          1.1    jruoho  *
      3          1.1    jruoho  * Module Name: dsobject - Dispatcher object management routines
      4          1.1    jruoho  *
      5          1.1    jruoho  *****************************************************************************/
      6          1.1    jruoho 
      7      1.1.1.2    jruoho /*
      8  1.1.1.8.4.1    bouyer  * Copyright (C) 2000 - 2017, Intel Corp.
      9          1.1    jruoho  * All rights reserved.
     10          1.1    jruoho  *
     11      1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     12      1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     13      1.1.1.2    jruoho  * are met:
     14      1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     15      1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16      1.1.1.2    jruoho  *    without modification.
     17      1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18      1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19      1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20      1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     21      1.1.1.2    jruoho  *    binary redistribution.
     22      1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23      1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     24      1.1.1.2    jruoho  *    from this software without specific prior written permission.
     25      1.1.1.2    jruoho  *
     26      1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     27      1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28      1.1.1.2    jruoho  * Software Foundation.
     29      1.1.1.2    jruoho  *
     30      1.1.1.2    jruoho  * NO WARRANTY
     31      1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32      1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33      1.1.1.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34      1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35      1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36      1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37      1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38      1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39      1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40      1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41      1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42      1.1.1.2    jruoho  */
     43          1.1    jruoho 
     44          1.1    jruoho #include "acpi.h"
     45          1.1    jruoho #include "accommon.h"
     46          1.1    jruoho #include "acparser.h"
     47          1.1    jruoho #include "amlcode.h"
     48          1.1    jruoho #include "acdispat.h"
     49          1.1    jruoho #include "acnamesp.h"
     50          1.1    jruoho #include "acinterp.h"
     51          1.1    jruoho 
     52          1.1    jruoho #define _COMPONENT          ACPI_DISPATCHER
     53          1.1    jruoho         ACPI_MODULE_NAME    ("dsobject")
     54          1.1    jruoho 
     55          1.1    jruoho /* Local prototypes */
     56          1.1    jruoho 
     57          1.1    jruoho static ACPI_STATUS
     58          1.1    jruoho AcpiDsBuildInternalObject (
     59          1.1    jruoho     ACPI_WALK_STATE         *WalkState,
     60          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
     61          1.1    jruoho     ACPI_OPERAND_OBJECT     **ObjDescPtr);
     62          1.1    jruoho 
     63          1.1    jruoho 
     64          1.1    jruoho #ifndef ACPI_NO_METHOD_EXECUTION
     65          1.1    jruoho /*******************************************************************************
     66          1.1    jruoho  *
     67          1.1    jruoho  * FUNCTION:    AcpiDsBuildInternalObject
     68          1.1    jruoho  *
     69          1.1    jruoho  * PARAMETERS:  WalkState       - Current walk state
     70          1.1    jruoho  *              Op              - Parser object to be translated
     71          1.1    jruoho  *              ObjDescPtr      - Where the ACPI internal object is returned
     72          1.1    jruoho  *
     73          1.1    jruoho  * RETURN:      Status
     74          1.1    jruoho  *
     75          1.1    jruoho  * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
     76          1.1    jruoho  *              Simple objects are any objects other than a package object!
     77          1.1    jruoho  *
     78          1.1    jruoho  ******************************************************************************/
     79          1.1    jruoho 
     80          1.1    jruoho static ACPI_STATUS
     81          1.1    jruoho AcpiDsBuildInternalObject (
     82          1.1    jruoho     ACPI_WALK_STATE         *WalkState,
     83          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
     84          1.1    jruoho     ACPI_OPERAND_OBJECT     **ObjDescPtr)
     85          1.1    jruoho {
     86          1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
     87          1.1    jruoho     ACPI_STATUS             Status;
     88      1.1.1.2    jruoho     ACPI_OBJECT_TYPE        Type;
     89          1.1    jruoho 
     90          1.1    jruoho 
     91          1.1    jruoho     ACPI_FUNCTION_TRACE (DsBuildInternalObject);
     92          1.1    jruoho 
     93          1.1    jruoho 
     94          1.1    jruoho     *ObjDescPtr = NULL;
     95          1.1    jruoho     if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
     96          1.1    jruoho     {
     97          1.1    jruoho         /*
     98          1.1    jruoho          * This is a named object reference. If this name was
     99          1.1    jruoho          * previously looked up in the namespace, it was stored in this op.
    100          1.1    jruoho          * Otherwise, go ahead and look it up now
    101          1.1    jruoho          */
    102          1.1    jruoho         if (!Op->Common.Node)
    103          1.1    jruoho         {
    104          1.1    jruoho             Status = AcpiNsLookup (WalkState->ScopeInfo,
    105      1.1.1.7  christos                 Op->Common.Value.String,
    106      1.1.1.7  christos                 ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
    107      1.1.1.7  christos                 ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
    108      1.1.1.7  christos                 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &(Op->Common.Node)));
    109          1.1    jruoho             if (ACPI_FAILURE (Status))
    110          1.1    jruoho             {
    111          1.1    jruoho                 /* Check if we are resolving a named reference within a package */
    112          1.1    jruoho 
    113          1.1    jruoho                 if ((Status == AE_NOT_FOUND) && (AcpiGbl_EnableInterpreterSlack) &&
    114          1.1    jruoho 
    115          1.1    jruoho                     ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
    116          1.1    jruoho                      (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
    117          1.1    jruoho                 {
    118          1.1    jruoho                     /*
    119          1.1    jruoho                      * We didn't find the target and we are populating elements
    120          1.1    jruoho                      * of a package - ignore if slack enabled. Some ASL code
    121          1.1    jruoho                      * contains dangling invalid references in packages and
    122          1.1    jruoho                      * expects that no exception will be issued. Leave the
    123          1.1    jruoho                      * element as a null element. It cannot be used, but it
    124          1.1    jruoho                      * can be overwritten by subsequent ASL code - this is
    125          1.1    jruoho                      * typically the case.
    126          1.1    jruoho                      */
    127          1.1    jruoho                     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
    128          1.1    jruoho                         "Ignoring unresolved reference in package [%4.4s]\n",
    129          1.1    jruoho                         WalkState->ScopeInfo->Scope.Node->Name.Ascii));
    130          1.1    jruoho 
    131          1.1    jruoho                     return_ACPI_STATUS (AE_OK);
    132          1.1    jruoho                 }
    133          1.1    jruoho                 else
    134          1.1    jruoho                 {
    135          1.1    jruoho                     ACPI_ERROR_NAMESPACE (Op->Common.Value.String, Status);
    136          1.1    jruoho                 }
    137          1.1    jruoho 
    138          1.1    jruoho                 return_ACPI_STATUS (Status);
    139          1.1    jruoho             }
    140          1.1    jruoho         }
    141          1.1    jruoho 
    142          1.1    jruoho         /* Special object resolution for elements of a package */
    143          1.1    jruoho 
    144          1.1    jruoho         if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
    145          1.1    jruoho             (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
    146          1.1    jruoho         {
    147          1.1    jruoho             /*
    148          1.1    jruoho              * Attempt to resolve the node to a value before we insert it into
    149          1.1    jruoho              * the package. If this is a reference to a common data type,
    150          1.1    jruoho              * resolve it immediately. According to the ACPI spec, package
    151          1.1    jruoho              * elements can only be "data objects" or method references.
    152          1.1    jruoho              * Attempt to resolve to an Integer, Buffer, String or Package.
    153          1.1    jruoho              * If cannot, return the named reference (for things like Devices,
    154          1.1    jruoho              * Methods, etc.) Buffer Fields and Fields will resolve to simple
    155          1.1    jruoho              * objects (int/buf/str/pkg).
    156          1.1    jruoho              *
    157          1.1    jruoho              * NOTE: References to things like Devices, Methods, Mutexes, etc.
    158          1.1    jruoho              * will remain as named references. This behavior is not described
    159          1.1    jruoho              * in the ACPI spec, but it appears to be an oversight.
    160          1.1    jruoho              */
    161          1.1    jruoho             ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Op->Common.Node);
    162          1.1    jruoho 
    163          1.1    jruoho             Status = AcpiExResolveNodeToValue (
    164      1.1.1.7  christos                 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &ObjDesc),
    165      1.1.1.7  christos                 WalkState);
    166          1.1    jruoho             if (ACPI_FAILURE (Status))
    167          1.1    jruoho             {
    168          1.1    jruoho                 return_ACPI_STATUS (Status);
    169          1.1    jruoho             }
    170          1.1    jruoho 
    171      1.1.1.2    jruoho             /*
    172      1.1.1.2    jruoho              * Special handling for Alias objects. We need to setup the type
    173      1.1.1.2    jruoho              * and the Op->Common.Node to point to the Alias target. Note,
    174      1.1.1.2    jruoho              * Alias has at most one level of indirection internally.
    175      1.1.1.2    jruoho              */
    176      1.1.1.2    jruoho             Type = Op->Common.Node->Type;
    177      1.1.1.2    jruoho             if (Type == ACPI_TYPE_LOCAL_ALIAS)
    178      1.1.1.2    jruoho             {
    179      1.1.1.2    jruoho                 Type = ObjDesc->Common.Type;
    180      1.1.1.2    jruoho                 Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
    181      1.1.1.2    jruoho                     Op->Common.Node->Object);
    182      1.1.1.2    jruoho             }
    183      1.1.1.2    jruoho 
    184      1.1.1.2    jruoho             switch (Type)
    185          1.1    jruoho             {
    186          1.1    jruoho             /*
    187          1.1    jruoho              * For these types, we need the actual node, not the subobject.
    188          1.1    jruoho              * However, the subobject did not get an extra reference count above.
    189          1.1    jruoho              *
    190          1.1    jruoho              * TBD: should ExResolveNodeToValue be changed to fix this?
    191          1.1    jruoho              */
    192          1.1    jruoho             case ACPI_TYPE_DEVICE:
    193          1.1    jruoho             case ACPI_TYPE_THERMAL:
    194          1.1    jruoho 
    195          1.1    jruoho                 AcpiUtAddReference (Op->Common.Node->Object);
    196          1.1    jruoho 
    197          1.1    jruoho                 /*lint -fallthrough */
    198          1.1    jruoho             /*
    199          1.1    jruoho              * For these types, we need the actual node, not the subobject.
    200          1.1    jruoho              * The subobject got an extra reference count in ExResolveNodeToValue.
    201          1.1    jruoho              */
    202          1.1    jruoho             case ACPI_TYPE_MUTEX:
    203          1.1    jruoho             case ACPI_TYPE_METHOD:
    204          1.1    jruoho             case ACPI_TYPE_POWER:
    205          1.1    jruoho             case ACPI_TYPE_PROCESSOR:
    206          1.1    jruoho             case ACPI_TYPE_EVENT:
    207          1.1    jruoho             case ACPI_TYPE_REGION:
    208          1.1    jruoho 
    209          1.1    jruoho                 /* We will create a reference object for these types below */
    210          1.1    jruoho                 break;
    211          1.1    jruoho 
    212          1.1    jruoho             default:
    213          1.1    jruoho                 /*
    214          1.1    jruoho                  * All other types - the node was resolved to an actual
    215          1.1    jruoho                  * object, we are done.
    216          1.1    jruoho                  */
    217          1.1    jruoho                 goto Exit;
    218          1.1    jruoho             }
    219          1.1    jruoho         }
    220          1.1    jruoho     }
    221          1.1    jruoho 
    222          1.1    jruoho     /* Create and init a new internal ACPI object */
    223          1.1    jruoho 
    224          1.1    jruoho     ObjDesc = AcpiUtCreateInternalObject (
    225      1.1.1.7  christos         (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType);
    226          1.1    jruoho     if (!ObjDesc)
    227          1.1    jruoho     {
    228          1.1    jruoho         return_ACPI_STATUS (AE_NO_MEMORY);
    229          1.1    jruoho     }
    230          1.1    jruoho 
    231      1.1.1.7  christos     Status = AcpiDsInitObjectFromOp (
    232      1.1.1.7  christos         WalkState, Op, Op->Common.AmlOpcode, &ObjDesc);
    233          1.1    jruoho     if (ACPI_FAILURE (Status))
    234          1.1    jruoho     {
    235          1.1    jruoho         AcpiUtRemoveReference (ObjDesc);
    236          1.1    jruoho         return_ACPI_STATUS (Status);
    237          1.1    jruoho     }
    238          1.1    jruoho 
    239          1.1    jruoho Exit:
    240          1.1    jruoho     *ObjDescPtr = ObjDesc;
    241          1.1    jruoho     return_ACPI_STATUS (Status);
    242          1.1    jruoho }
    243          1.1    jruoho 
    244          1.1    jruoho 
    245          1.1    jruoho /*******************************************************************************
    246          1.1    jruoho  *
    247          1.1    jruoho  * FUNCTION:    AcpiDsBuildInternalBufferObj
    248          1.1    jruoho  *
    249          1.1    jruoho  * PARAMETERS:  WalkState       - Current walk state
    250          1.1    jruoho  *              Op              - Parser object to be translated
    251          1.1    jruoho  *              BufferLength    - Length of the buffer
    252          1.1    jruoho  *              ObjDescPtr      - Where the ACPI internal object is returned
    253          1.1    jruoho  *
    254          1.1    jruoho  * RETURN:      Status
    255          1.1    jruoho  *
    256          1.1    jruoho  * DESCRIPTION: Translate a parser Op package object to the equivalent
    257          1.1    jruoho  *              namespace object
    258          1.1    jruoho  *
    259          1.1    jruoho  ******************************************************************************/
    260          1.1    jruoho 
    261          1.1    jruoho ACPI_STATUS
    262          1.1    jruoho AcpiDsBuildInternalBufferObj (
    263          1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    264          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    265          1.1    jruoho     UINT32                  BufferLength,
    266          1.1    jruoho     ACPI_OPERAND_OBJECT     **ObjDescPtr)
    267          1.1    jruoho {
    268          1.1    jruoho     ACPI_PARSE_OBJECT       *Arg;
    269          1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
    270          1.1    jruoho     ACPI_PARSE_OBJECT       *ByteList;
    271          1.1    jruoho     UINT32                  ByteListLength = 0;
    272          1.1    jruoho 
    273          1.1    jruoho 
    274          1.1    jruoho     ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj);
    275          1.1    jruoho 
    276          1.1    jruoho 
    277          1.1    jruoho     /*
    278          1.1    jruoho      * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
    279          1.1    jruoho      * The buffer object already exists (from the NS node), otherwise it must
    280          1.1    jruoho      * be created.
    281          1.1    jruoho      */
    282          1.1    jruoho     ObjDesc = *ObjDescPtr;
    283          1.1    jruoho     if (!ObjDesc)
    284          1.1    jruoho     {
    285          1.1    jruoho         /* Create a new buffer object */
    286          1.1    jruoho 
    287          1.1    jruoho         ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
    288          1.1    jruoho         *ObjDescPtr = ObjDesc;
    289          1.1    jruoho         if (!ObjDesc)
    290          1.1    jruoho         {
    291          1.1    jruoho             return_ACPI_STATUS (AE_NO_MEMORY);
    292          1.1    jruoho         }
    293          1.1    jruoho     }
    294          1.1    jruoho 
    295          1.1    jruoho     /*
    296          1.1    jruoho      * Second arg is the buffer data (optional) ByteList can be either
    297      1.1.1.3  christos      * individual bytes or a string initializer. In either case, a
    298          1.1    jruoho      * ByteList appears in the AML.
    299          1.1    jruoho      */
    300          1.1    jruoho     Arg = Op->Common.Value.Arg;         /* skip first arg */
    301          1.1    jruoho 
    302          1.1    jruoho     ByteList = Arg->Named.Next;
    303          1.1    jruoho     if (ByteList)
    304          1.1    jruoho     {
    305          1.1    jruoho         if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP)
    306          1.1    jruoho         {
    307          1.1    jruoho             ACPI_ERROR ((AE_INFO,
    308          1.1    jruoho                 "Expecting bytelist, found AML opcode 0x%X in op %p",
    309          1.1    jruoho                 ByteList->Common.AmlOpcode, ByteList));
    310          1.1    jruoho 
    311          1.1    jruoho             AcpiUtRemoveReference (ObjDesc);
    312          1.1    jruoho             return (AE_TYPE);
    313          1.1    jruoho         }
    314          1.1    jruoho 
    315          1.1    jruoho         ByteListLength = (UINT32) ByteList->Common.Value.Integer;
    316          1.1    jruoho     }
    317          1.1    jruoho 
    318          1.1    jruoho     /*
    319          1.1    jruoho      * The buffer length (number of bytes) will be the larger of:
    320          1.1    jruoho      * 1) The specified buffer length and
    321          1.1    jruoho      * 2) The length of the initializer byte list
    322          1.1    jruoho      */
    323          1.1    jruoho     ObjDesc->Buffer.Length = BufferLength;
    324          1.1    jruoho     if (ByteListLength > BufferLength)
    325          1.1    jruoho     {
    326          1.1    jruoho         ObjDesc->Buffer.Length = ByteListLength;
    327          1.1    jruoho     }
    328          1.1    jruoho 
    329          1.1    jruoho     /* Allocate the buffer */
    330          1.1    jruoho 
    331          1.1    jruoho     if (ObjDesc->Buffer.Length == 0)
    332          1.1    jruoho     {
    333          1.1    jruoho         ObjDesc->Buffer.Pointer = NULL;
    334          1.1    jruoho         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
    335          1.1    jruoho             "Buffer defined with zero length in AML, creating\n"));
    336          1.1    jruoho     }
    337          1.1    jruoho     else
    338          1.1    jruoho     {
    339      1.1.1.7  christos         ObjDesc->Buffer.Pointer =
    340      1.1.1.7  christos             ACPI_ALLOCATE_ZEROED (ObjDesc->Buffer.Length);
    341          1.1    jruoho         if (!ObjDesc->Buffer.Pointer)
    342          1.1    jruoho         {
    343          1.1    jruoho             AcpiUtDeleteObjectDesc (ObjDesc);
    344          1.1    jruoho             return_ACPI_STATUS (AE_NO_MEMORY);
    345          1.1    jruoho         }
    346          1.1    jruoho 
    347          1.1    jruoho         /* Initialize buffer from the ByteList (if present) */
    348          1.1    jruoho 
    349          1.1    jruoho         if (ByteList)
    350          1.1    jruoho         {
    351      1.1.1.6  christos             memcpy (ObjDesc->Buffer.Pointer, ByteList->Named.Data,
    352      1.1.1.7  christos                 ByteListLength);
    353          1.1    jruoho         }
    354          1.1    jruoho     }
    355          1.1    jruoho 
    356          1.1    jruoho     ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
    357          1.1    jruoho     Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
    358          1.1    jruoho     return_ACPI_STATUS (AE_OK);
    359          1.1    jruoho }
    360          1.1    jruoho 
    361          1.1    jruoho 
    362          1.1    jruoho /*******************************************************************************
    363          1.1    jruoho  *
    364          1.1    jruoho  * FUNCTION:    AcpiDsBuildInternalPackageObj
    365          1.1    jruoho  *
    366          1.1    jruoho  * PARAMETERS:  WalkState       - Current walk state
    367          1.1    jruoho  *              Op              - Parser object to be translated
    368          1.1    jruoho  *              ElementCount    - Number of elements in the package - this is
    369          1.1    jruoho  *                                the NumElements argument to Package()
    370          1.1    jruoho  *              ObjDescPtr      - Where the ACPI internal object is returned
    371          1.1    jruoho  *
    372          1.1    jruoho  * RETURN:      Status
    373          1.1    jruoho  *
    374          1.1    jruoho  * DESCRIPTION: Translate a parser Op package object to the equivalent
    375          1.1    jruoho  *              namespace object
    376          1.1    jruoho  *
    377          1.1    jruoho  * NOTE: The number of elements in the package will be always be the NumElements
    378          1.1    jruoho  * count, regardless of the number of elements in the package list. If
    379          1.1    jruoho  * NumElements is smaller, only that many package list elements are used.
    380          1.1    jruoho  * if NumElements is larger, the Package object is padded out with
    381          1.1    jruoho  * objects of type Uninitialized (as per ACPI spec.)
    382          1.1    jruoho  *
    383          1.1    jruoho  * Even though the ASL compilers do not allow NumElements to be smaller
    384          1.1    jruoho  * than the Package list length (for the fixed length package opcode), some
    385          1.1    jruoho  * BIOS code modifies the AML on the fly to adjust the NumElements, and
    386          1.1    jruoho  * this code compensates for that. This also provides compatibility with
    387          1.1    jruoho  * other AML interpreters.
    388          1.1    jruoho  *
    389          1.1    jruoho  ******************************************************************************/
    390          1.1    jruoho 
    391          1.1    jruoho ACPI_STATUS
    392          1.1    jruoho AcpiDsBuildInternalPackageObj (
    393          1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    394          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    395          1.1    jruoho     UINT32                  ElementCount,
    396          1.1    jruoho     ACPI_OPERAND_OBJECT     **ObjDescPtr)
    397          1.1    jruoho {
    398          1.1    jruoho     ACPI_PARSE_OBJECT       *Arg;
    399          1.1    jruoho     ACPI_PARSE_OBJECT       *Parent;
    400          1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
    401          1.1    jruoho     ACPI_STATUS             Status = AE_OK;
    402          1.1    jruoho     UINT32                  i;
    403          1.1    jruoho     UINT16                  Index;
    404          1.1    jruoho     UINT16                  ReferenceCount;
    405          1.1    jruoho 
    406          1.1    jruoho 
    407          1.1    jruoho     ACPI_FUNCTION_TRACE (DsBuildInternalPackageObj);
    408          1.1    jruoho 
    409          1.1    jruoho 
    410          1.1    jruoho     /* Find the parent of a possibly nested package */
    411          1.1    jruoho 
    412          1.1    jruoho     Parent = Op->Common.Parent;
    413          1.1    jruoho     while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
    414          1.1    jruoho            (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
    415          1.1    jruoho     {
    416          1.1    jruoho         Parent = Parent->Common.Parent;
    417          1.1    jruoho     }
    418          1.1    jruoho 
    419          1.1    jruoho     /*
    420          1.1    jruoho      * If we are evaluating a Named package object "Name (xxxx, Package)",
    421          1.1    jruoho      * the package object already exists, otherwise it must be created.
    422          1.1    jruoho      */
    423          1.1    jruoho     ObjDesc = *ObjDescPtr;
    424          1.1    jruoho     if (!ObjDesc)
    425          1.1    jruoho     {
    426          1.1    jruoho         ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
    427          1.1    jruoho         *ObjDescPtr = ObjDesc;
    428          1.1    jruoho         if (!ObjDesc)
    429          1.1    jruoho         {
    430          1.1    jruoho             return_ACPI_STATUS (AE_NO_MEMORY);
    431          1.1    jruoho         }
    432          1.1    jruoho 
    433          1.1    jruoho         ObjDesc->Package.Node = Parent->Common.Node;
    434          1.1    jruoho     }
    435          1.1    jruoho 
    436          1.1    jruoho     /*
    437          1.1    jruoho      * Allocate the element array (array of pointers to the individual
    438          1.1    jruoho      * objects) based on the NumElements parameter. Add an extra pointer slot
    439          1.1    jruoho      * so that the list is always null terminated.
    440          1.1    jruoho      */
    441          1.1    jruoho     ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED (
    442          1.1    jruoho         ((ACPI_SIZE) ElementCount + 1) * sizeof (void *));
    443          1.1    jruoho 
    444          1.1    jruoho     if (!ObjDesc->Package.Elements)
    445          1.1    jruoho     {
    446          1.1    jruoho         AcpiUtDeleteObjectDesc (ObjDesc);
    447          1.1    jruoho         return_ACPI_STATUS (AE_NO_MEMORY);
    448          1.1    jruoho     }
    449          1.1    jruoho 
    450          1.1    jruoho     ObjDesc->Package.Count = ElementCount;
    451          1.1    jruoho 
    452          1.1    jruoho     /*
    453          1.1    jruoho      * Initialize the elements of the package, up to the NumElements count.
    454          1.1    jruoho      * Package is automatically padded with uninitialized (NULL) elements
    455          1.1    jruoho      * if NumElements is greater than the package list length. Likewise,
    456          1.1    jruoho      * Package is truncated if NumElements is less than the list length.
    457          1.1    jruoho      */
    458          1.1    jruoho     Arg = Op->Common.Value.Arg;
    459          1.1    jruoho     Arg = Arg->Common.Next;
    460          1.1    jruoho     for (i = 0; Arg && (i < ElementCount); i++)
    461          1.1    jruoho     {
    462          1.1    jruoho         if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP)
    463          1.1    jruoho         {
    464          1.1    jruoho             if (Arg->Common.Node->Type == ACPI_TYPE_METHOD)
    465          1.1    jruoho             {
    466          1.1    jruoho                 /*
    467          1.1    jruoho                  * A method reference "looks" to the parser to be a method
    468          1.1    jruoho                  * invocation, so we special case it here
    469          1.1    jruoho                  */
    470          1.1    jruoho                 Arg->Common.AmlOpcode = AML_INT_NAMEPATH_OP;
    471      1.1.1.7  christos                 Status = AcpiDsBuildInternalObject (
    472      1.1.1.7  christos                     WalkState, Arg, &ObjDesc->Package.Elements[i]);
    473          1.1    jruoho             }
    474          1.1    jruoho             else
    475          1.1    jruoho             {
    476          1.1    jruoho                 /* This package element is already built, just get it */
    477          1.1    jruoho 
    478          1.1    jruoho                 ObjDesc->Package.Elements[i] =
    479          1.1    jruoho                     ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node);
    480          1.1    jruoho             }
    481          1.1    jruoho         }
    482          1.1    jruoho         else
    483          1.1    jruoho         {
    484      1.1.1.7  christos             Status = AcpiDsBuildInternalObject (
    485      1.1.1.7  christos                 WalkState, Arg, &ObjDesc->Package.Elements[i]);
    486          1.1    jruoho         }
    487          1.1    jruoho 
    488          1.1    jruoho         if (*ObjDescPtr)
    489          1.1    jruoho         {
    490          1.1    jruoho             /* Existing package, get existing reference count */
    491          1.1    jruoho 
    492          1.1    jruoho             ReferenceCount = (*ObjDescPtr)->Common.ReferenceCount;
    493          1.1    jruoho             if (ReferenceCount > 1)
    494          1.1    jruoho             {
    495          1.1    jruoho                 /* Make new element ref count match original ref count */
    496          1.1    jruoho 
    497          1.1    jruoho                 for (Index = 0; Index < (ReferenceCount - 1); Index++)
    498          1.1    jruoho                 {
    499          1.1    jruoho                     AcpiUtAddReference ((ObjDesc->Package.Elements[i]));
    500          1.1    jruoho                 }
    501          1.1    jruoho             }
    502          1.1    jruoho         }
    503          1.1    jruoho 
    504          1.1    jruoho         Arg = Arg->Common.Next;
    505          1.1    jruoho     }
    506          1.1    jruoho 
    507          1.1    jruoho     /* Check for match between NumElements and actual length of PackageList */
    508          1.1    jruoho 
    509          1.1    jruoho     if (Arg)
    510          1.1    jruoho     {
    511          1.1    jruoho         /*
    512          1.1    jruoho          * NumElements was exhausted, but there are remaining elements in the
    513          1.1    jruoho          * PackageList. Truncate the package to NumElements.
    514          1.1    jruoho          *
    515          1.1    jruoho          * Note: technically, this is an error, from ACPI spec: "It is an error
    516          1.1    jruoho          * for NumElements to be less than the number of elements in the
    517          1.1    jruoho          * PackageList". However, we just print a message and
    518          1.1    jruoho          * no exception is returned. This provides Windows compatibility. Some
    519          1.1    jruoho          * BIOSs will alter the NumElements on the fly, creating this type
    520          1.1    jruoho          * of ill-formed package object.
    521          1.1    jruoho          */
    522          1.1    jruoho         while (Arg)
    523          1.1    jruoho         {
    524          1.1    jruoho             /*
    525          1.1    jruoho              * We must delete any package elements that were created earlier
    526          1.1    jruoho              * and are not going to be used because of the package truncation.
    527          1.1    jruoho              */
    528          1.1    jruoho             if (Arg->Common.Node)
    529          1.1    jruoho             {
    530          1.1    jruoho                 AcpiUtRemoveReference (
    531          1.1    jruoho                     ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node));
    532          1.1    jruoho                 Arg->Common.Node = NULL;
    533          1.1    jruoho             }
    534          1.1    jruoho 
    535          1.1    jruoho             /* Find out how many elements there really are */
    536          1.1    jruoho 
    537          1.1    jruoho             i++;
    538          1.1    jruoho             Arg = Arg->Common.Next;
    539          1.1    jruoho         }
    540          1.1    jruoho 
    541      1.1.1.8  christos         ACPI_INFO ((
    542      1.1.1.7  christos             "Actual Package length (%u) is larger than "
    543      1.1.1.7  christos             "NumElements field (%u), truncated",
    544          1.1    jruoho             i, ElementCount));
    545          1.1    jruoho     }
    546          1.1    jruoho     else if (i < ElementCount)
    547          1.1    jruoho     {
    548          1.1    jruoho         /*
    549          1.1    jruoho          * Arg list (elements) was exhausted, but we did not reach NumElements count.
    550          1.1    jruoho          * Note: this is not an error, the package is padded out with NULLs.
    551          1.1    jruoho          */
    552          1.1    jruoho         ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
    553      1.1.1.7  christos             "Package List length (%u) smaller than NumElements "
    554      1.1.1.7  christos             "count (%u), padded with null elements\n",
    555          1.1    jruoho             i, ElementCount));
    556          1.1    jruoho     }
    557          1.1    jruoho 
    558          1.1    jruoho     ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID;
    559          1.1    jruoho     Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
    560          1.1    jruoho     return_ACPI_STATUS (Status);
    561          1.1    jruoho }
    562          1.1    jruoho 
    563          1.1    jruoho 
    564          1.1    jruoho /*******************************************************************************
    565          1.1    jruoho  *
    566          1.1    jruoho  * FUNCTION:    AcpiDsCreateNode
    567          1.1    jruoho  *
    568          1.1    jruoho  * PARAMETERS:  WalkState       - Current walk state
    569          1.1    jruoho  *              Node            - NS Node to be initialized
    570          1.1    jruoho  *              Op              - Parser object to be translated
    571          1.1    jruoho  *
    572          1.1    jruoho  * RETURN:      Status
    573          1.1    jruoho  *
    574          1.1    jruoho  * DESCRIPTION: Create the object to be associated with a namespace node
    575          1.1    jruoho  *
    576          1.1    jruoho  ******************************************************************************/
    577          1.1    jruoho 
    578          1.1    jruoho ACPI_STATUS
    579          1.1    jruoho AcpiDsCreateNode (
    580          1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    581          1.1    jruoho     ACPI_NAMESPACE_NODE     *Node,
    582          1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    583          1.1    jruoho {
    584          1.1    jruoho     ACPI_STATUS             Status;
    585          1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
    586          1.1    jruoho 
    587          1.1    jruoho 
    588          1.1    jruoho     ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op);
    589          1.1    jruoho 
    590          1.1    jruoho 
    591          1.1    jruoho     /*
    592          1.1    jruoho      * Because of the execution pass through the non-control-method
    593      1.1.1.3  christos      * parts of the table, we can arrive here twice. Only init
    594          1.1    jruoho      * the named object node the first time through
    595          1.1    jruoho      */
    596          1.1    jruoho     if (AcpiNsGetAttachedObject (Node))
    597          1.1    jruoho     {
    598          1.1    jruoho         return_ACPI_STATUS (AE_OK);
    599          1.1    jruoho     }
    600          1.1    jruoho 
    601          1.1    jruoho     if (!Op->Common.Value.Arg)
    602          1.1    jruoho     {
    603          1.1    jruoho         /* No arguments, there is nothing to do */
    604          1.1    jruoho 
    605          1.1    jruoho         return_ACPI_STATUS (AE_OK);
    606          1.1    jruoho     }
    607          1.1    jruoho 
    608          1.1    jruoho     /* Build an internal object for the argument(s) */
    609          1.1    jruoho 
    610      1.1.1.7  christos     Status = AcpiDsBuildInternalObject (
    611      1.1.1.7  christos         WalkState, Op->Common.Value.Arg, &ObjDesc);
    612          1.1    jruoho     if (ACPI_FAILURE (Status))
    613          1.1    jruoho     {
    614          1.1    jruoho         return_ACPI_STATUS (Status);
    615          1.1    jruoho     }
    616          1.1    jruoho 
    617          1.1    jruoho     /* Re-type the object according to its argument */
    618          1.1    jruoho 
    619          1.1    jruoho     Node->Type = ObjDesc->Common.Type;
    620          1.1    jruoho 
    621          1.1    jruoho     /* Attach obj to node */
    622          1.1    jruoho 
    623          1.1    jruoho     Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type);
    624          1.1    jruoho 
    625          1.1    jruoho     /* Remove local reference to the object */
    626          1.1    jruoho 
    627          1.1    jruoho     AcpiUtRemoveReference (ObjDesc);
    628          1.1    jruoho     return_ACPI_STATUS (Status);
    629          1.1    jruoho }
    630          1.1    jruoho 
    631          1.1    jruoho #endif /* ACPI_NO_METHOD_EXECUTION */
    632          1.1    jruoho 
    633          1.1    jruoho 
    634          1.1    jruoho /*******************************************************************************
    635          1.1    jruoho  *
    636          1.1    jruoho  * FUNCTION:    AcpiDsInitObjectFromOp
    637          1.1    jruoho  *
    638          1.1    jruoho  * PARAMETERS:  WalkState       - Current walk state
    639          1.1    jruoho  *              Op              - Parser op used to init the internal object
    640          1.1    jruoho  *              Opcode          - AML opcode associated with the object
    641          1.1    jruoho  *              RetObjDesc      - Namespace object to be initialized
    642          1.1    jruoho  *
    643          1.1    jruoho  * RETURN:      Status
    644          1.1    jruoho  *
    645          1.1    jruoho  * DESCRIPTION: Initialize a namespace object from a parser Op and its
    646      1.1.1.3  christos  *              associated arguments. The namespace object is a more compact
    647          1.1    jruoho  *              representation of the Op and its arguments.
    648          1.1    jruoho  *
    649          1.1    jruoho  ******************************************************************************/
    650          1.1    jruoho 
    651          1.1    jruoho ACPI_STATUS
    652          1.1    jruoho AcpiDsInitObjectFromOp (
    653          1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    654          1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    655          1.1    jruoho     UINT16                  Opcode,
    656          1.1    jruoho     ACPI_OPERAND_OBJECT     **RetObjDesc)
    657          1.1    jruoho {
    658          1.1    jruoho     const ACPI_OPCODE_INFO  *OpInfo;
    659          1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
    660          1.1    jruoho     ACPI_STATUS             Status = AE_OK;
    661          1.1    jruoho 
    662          1.1    jruoho 
    663          1.1    jruoho     ACPI_FUNCTION_TRACE (DsInitObjectFromOp);
    664          1.1    jruoho 
    665          1.1    jruoho 
    666          1.1    jruoho     ObjDesc = *RetObjDesc;
    667          1.1    jruoho     OpInfo = AcpiPsGetOpcodeInfo (Opcode);
    668          1.1    jruoho     if (OpInfo->Class == AML_CLASS_UNKNOWN)
    669          1.1    jruoho     {
    670          1.1    jruoho         /* Unknown opcode */
    671          1.1    jruoho 
    672          1.1    jruoho         return_ACPI_STATUS (AE_TYPE);
    673          1.1    jruoho     }
    674          1.1    jruoho 
    675          1.1    jruoho     /* Perform per-object initialization */
    676          1.1    jruoho 
    677          1.1    jruoho     switch (ObjDesc->Common.Type)
    678          1.1    jruoho     {
    679          1.1    jruoho     case ACPI_TYPE_BUFFER:
    680          1.1    jruoho         /*
    681          1.1    jruoho          * Defer evaluation of Buffer TermArg operand
    682          1.1    jruoho          */
    683      1.1.1.7  christos         ObjDesc->Buffer.Node = ACPI_CAST_PTR (
    684      1.1.1.7  christos             ACPI_NAMESPACE_NODE, WalkState->Operands[0]);
    685      1.1.1.7  christos         ObjDesc->Buffer.AmlStart = Op->Named.Data;
    686          1.1    jruoho         ObjDesc->Buffer.AmlLength = Op->Named.Length;
    687          1.1    jruoho         break;
    688          1.1    jruoho 
    689          1.1    jruoho     case ACPI_TYPE_PACKAGE:
    690          1.1    jruoho         /*
    691          1.1    jruoho          * Defer evaluation of Package TermArg operand
    692          1.1    jruoho          */
    693      1.1.1.7  christos         ObjDesc->Package.Node = ACPI_CAST_PTR (
    694      1.1.1.7  christos             ACPI_NAMESPACE_NODE, WalkState->Operands[0]);
    695      1.1.1.7  christos         ObjDesc->Package.AmlStart = Op->Named.Data;
    696          1.1    jruoho         ObjDesc->Package.AmlLength = Op->Named.Length;
    697          1.1    jruoho         break;
    698          1.1    jruoho 
    699          1.1    jruoho     case ACPI_TYPE_INTEGER:
    700          1.1    jruoho 
    701          1.1    jruoho         switch (OpInfo->Type)
    702          1.1    jruoho         {
    703          1.1    jruoho         case AML_TYPE_CONSTANT:
    704          1.1    jruoho             /*
    705          1.1    jruoho              * Resolve AML Constants here - AND ONLY HERE!
    706          1.1    jruoho              * All constants are integers.
    707          1.1    jruoho              * We mark the integer with a flag that indicates that it started
    708          1.1    jruoho              * life as a constant -- so that stores to constants will perform
    709          1.1    jruoho              * as expected (noop). ZeroOp is used as a placeholder for optional
    710          1.1    jruoho              * target operands.
    711          1.1    jruoho              */
    712          1.1    jruoho             ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT;
    713          1.1    jruoho 
    714          1.1    jruoho             switch (Opcode)
    715          1.1    jruoho             {
    716          1.1    jruoho             case AML_ZERO_OP:
    717          1.1    jruoho 
    718          1.1    jruoho                 ObjDesc->Integer.Value = 0;
    719          1.1    jruoho                 break;
    720          1.1    jruoho 
    721          1.1    jruoho             case AML_ONE_OP:
    722          1.1    jruoho 
    723          1.1    jruoho                 ObjDesc->Integer.Value = 1;
    724          1.1    jruoho                 break;
    725          1.1    jruoho 
    726          1.1    jruoho             case AML_ONES_OP:
    727          1.1    jruoho 
    728          1.1    jruoho                 ObjDesc->Integer.Value = ACPI_UINT64_MAX;
    729          1.1    jruoho 
    730          1.1    jruoho                 /* Truncate value if we are executing from a 32-bit ACPI table */
    731          1.1    jruoho 
    732          1.1    jruoho #ifndef ACPI_NO_METHOD_EXECUTION
    733      1.1.1.3  christos                 (void) AcpiExTruncateFor32bitTable (ObjDesc);
    734          1.1    jruoho #endif
    735          1.1    jruoho                 break;
    736          1.1    jruoho 
    737          1.1    jruoho             case AML_REVISION_OP:
    738          1.1    jruoho 
    739          1.1    jruoho                 ObjDesc->Integer.Value = ACPI_CA_VERSION;
    740          1.1    jruoho                 break;
    741          1.1    jruoho 
    742          1.1    jruoho             default:
    743          1.1    jruoho 
    744          1.1    jruoho                 ACPI_ERROR ((AE_INFO,
    745          1.1    jruoho                     "Unknown constant opcode 0x%X", Opcode));
    746          1.1    jruoho                 Status = AE_AML_OPERAND_TYPE;
    747          1.1    jruoho                 break;
    748          1.1    jruoho             }
    749          1.1    jruoho             break;
    750          1.1    jruoho 
    751          1.1    jruoho         case AML_TYPE_LITERAL:
    752          1.1    jruoho 
    753          1.1    jruoho             ObjDesc->Integer.Value = Op->Common.Value.Integer;
    754      1.1.1.3  christos 
    755          1.1    jruoho #ifndef ACPI_NO_METHOD_EXECUTION
    756      1.1.1.3  christos             if (AcpiExTruncateFor32bitTable (ObjDesc))
    757      1.1.1.3  christos             {
    758      1.1.1.3  christos                 /* Warn if we found a 64-bit constant in a 32-bit table */
    759      1.1.1.3  christos 
    760      1.1.1.3  christos                 ACPI_WARNING ((AE_INFO,
    761      1.1.1.3  christos                     "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
    762      1.1.1.3  christos                     ACPI_FORMAT_UINT64 (Op->Common.Value.Integer),
    763      1.1.1.3  christos                     (UINT32) ObjDesc->Integer.Value));
    764      1.1.1.3  christos             }
    765          1.1    jruoho #endif
    766          1.1    jruoho             break;
    767          1.1    jruoho 
    768          1.1    jruoho         default:
    769      1.1.1.3  christos 
    770          1.1    jruoho             ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X",
    771          1.1    jruoho                 OpInfo->Type));
    772          1.1    jruoho             Status = AE_AML_OPERAND_TYPE;
    773          1.1    jruoho             break;
    774          1.1    jruoho         }
    775          1.1    jruoho         break;
    776          1.1    jruoho 
    777          1.1    jruoho     case ACPI_TYPE_STRING:
    778          1.1    jruoho 
    779          1.1    jruoho         ObjDesc->String.Pointer = Op->Common.Value.String;
    780      1.1.1.6  christos         ObjDesc->String.Length = (UINT32) strlen (Op->Common.Value.String);
    781          1.1    jruoho 
    782          1.1    jruoho         /*
    783          1.1    jruoho          * The string is contained in the ACPI table, don't ever try
    784          1.1    jruoho          * to delete it
    785          1.1    jruoho          */
    786          1.1    jruoho         ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
    787          1.1    jruoho         break;
    788          1.1    jruoho 
    789          1.1    jruoho     case ACPI_TYPE_METHOD:
    790          1.1    jruoho         break;
    791          1.1    jruoho 
    792          1.1    jruoho     case ACPI_TYPE_LOCAL_REFERENCE:
    793          1.1    jruoho 
    794          1.1    jruoho         switch (OpInfo->Type)
    795          1.1    jruoho         {
    796          1.1    jruoho         case AML_TYPE_LOCAL_VARIABLE:
    797          1.1    jruoho 
    798          1.1    jruoho             /* Local ID (0-7) is (AML opcode - base AML_LOCAL_OP) */
    799          1.1    jruoho 
    800          1.1    jruoho             ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_LOCAL_OP;
    801          1.1    jruoho             ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL;
    802          1.1    jruoho 
    803          1.1    jruoho #ifndef ACPI_NO_METHOD_EXECUTION
    804          1.1    jruoho             Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL,
    805      1.1.1.7  christos                 ObjDesc->Reference.Value, WalkState,
    806      1.1.1.7  christos                 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
    807      1.1.1.7  christos                     &ObjDesc->Reference.Object));
    808          1.1    jruoho #endif
    809          1.1    jruoho             break;
    810          1.1    jruoho 
    811          1.1    jruoho         case AML_TYPE_METHOD_ARGUMENT:
    812          1.1    jruoho 
    813          1.1    jruoho             /* Arg ID (0-6) is (AML opcode - base AML_ARG_OP) */
    814          1.1    jruoho 
    815          1.1    jruoho             ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_ARG_OP;
    816          1.1    jruoho             ObjDesc->Reference.Class = ACPI_REFCLASS_ARG;
    817          1.1    jruoho 
    818          1.1    jruoho #ifndef ACPI_NO_METHOD_EXECUTION
    819          1.1    jruoho             Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG,
    820      1.1.1.7  christos                 ObjDesc->Reference.Value, WalkState,
    821      1.1.1.7  christos                 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
    822      1.1.1.7  christos                     &ObjDesc->Reference.Object));
    823          1.1    jruoho #endif
    824          1.1    jruoho             break;
    825          1.1    jruoho 
    826          1.1    jruoho         default: /* Object name or Debug object */
    827          1.1    jruoho 
    828          1.1    jruoho             switch (Op->Common.AmlOpcode)
    829          1.1    jruoho             {
    830          1.1    jruoho             case AML_INT_NAMEPATH_OP:
    831          1.1    jruoho 
    832          1.1    jruoho                 /* Node was saved in Op */
    833          1.1    jruoho 
    834          1.1    jruoho                 ObjDesc->Reference.Node = Op->Common.Node;
    835          1.1    jruoho                 ObjDesc->Reference.Object = Op->Common.Node->Object;
    836          1.1    jruoho                 ObjDesc->Reference.Class = ACPI_REFCLASS_NAME;
    837          1.1    jruoho                 break;
    838          1.1    jruoho 
    839          1.1    jruoho             case AML_DEBUG_OP:
    840          1.1    jruoho 
    841          1.1    jruoho                 ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG;
    842          1.1    jruoho                 break;
    843          1.1    jruoho 
    844          1.1    jruoho             default:
    845          1.1    jruoho 
    846          1.1    jruoho                 ACPI_ERROR ((AE_INFO,
    847          1.1    jruoho                     "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode));
    848          1.1    jruoho                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
    849          1.1    jruoho             }
    850          1.1    jruoho             break;
    851          1.1    jruoho         }
    852          1.1    jruoho         break;
    853          1.1    jruoho 
    854          1.1    jruoho     default:
    855          1.1    jruoho 
    856          1.1    jruoho         ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X",
    857          1.1    jruoho             ObjDesc->Common.Type));
    858          1.1    jruoho 
    859          1.1    jruoho         Status = AE_AML_OPERAND_TYPE;
    860          1.1    jruoho         break;
    861          1.1    jruoho     }
    862          1.1    jruoho 
    863          1.1    jruoho     return_ACPI_STATUS (Status);
    864          1.1    jruoho }
    865