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