Home | History | Annotate | Line # | Download | only in dispatcher
dsobject.c revision 1.1.1.12
      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.9  christos  * 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 
     56       1.1    jruoho #ifndef ACPI_NO_METHOD_EXECUTION
     57       1.1    jruoho /*******************************************************************************
     58       1.1    jruoho  *
     59       1.1    jruoho  * FUNCTION:    AcpiDsBuildInternalObject
     60       1.1    jruoho  *
     61       1.1    jruoho  * PARAMETERS:  WalkState       - Current walk state
     62       1.1    jruoho  *              Op              - Parser object to be translated
     63       1.1    jruoho  *              ObjDescPtr      - Where the ACPI internal object is returned
     64       1.1    jruoho  *
     65       1.1    jruoho  * RETURN:      Status
     66       1.1    jruoho  *
     67       1.1    jruoho  * DESCRIPTION: Translate a parser Op object to the equivalent namespace object
     68       1.1    jruoho  *              Simple objects are any objects other than a package object!
     69       1.1    jruoho  *
     70       1.1    jruoho  ******************************************************************************/
     71       1.1    jruoho 
     72  1.1.1.11  christos ACPI_STATUS
     73       1.1    jruoho AcpiDsBuildInternalObject (
     74       1.1    jruoho     ACPI_WALK_STATE         *WalkState,
     75       1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
     76       1.1    jruoho     ACPI_OPERAND_OBJECT     **ObjDescPtr)
     77       1.1    jruoho {
     78       1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
     79       1.1    jruoho     ACPI_STATUS             Status;
     80       1.1    jruoho 
     81       1.1    jruoho 
     82       1.1    jruoho     ACPI_FUNCTION_TRACE (DsBuildInternalObject);
     83       1.1    jruoho 
     84       1.1    jruoho 
     85       1.1    jruoho     *ObjDescPtr = NULL;
     86       1.1    jruoho     if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP)
     87       1.1    jruoho     {
     88       1.1    jruoho         /*
     89       1.1    jruoho          * This is a named object reference. If this name was
     90  1.1.1.11  christos          * previously looked up in the namespace, it was stored in
     91  1.1.1.11  christos          * this op. Otherwise, go ahead and look it up now
     92       1.1    jruoho          */
     93       1.1    jruoho         if (!Op->Common.Node)
     94       1.1    jruoho         {
     95  1.1.1.11  christos             /* Check if we are resolving a named reference within a package */
     96       1.1    jruoho 
     97  1.1.1.11  christos             if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
     98  1.1.1.11  christos                 (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
     99       1.1    jruoho             {
    100       1.1    jruoho                 /*
    101  1.1.1.11  christos                  * We won't resolve package elements here, we will do this
    102  1.1.1.11  christos                  * after all ACPI tables are loaded into the namespace. This
    103  1.1.1.11  christos                  * behavior supports both forward references to named objects
    104  1.1.1.11  christos                  * and external references to objects in other tables.
    105       1.1    jruoho                  */
    106  1.1.1.11  christos                 goto CreateNewObject;
    107  1.1.1.11  christos             }
    108  1.1.1.11  christos             else
    109  1.1.1.11  christos             {
    110  1.1.1.11  christos                 Status = AcpiNsLookup (WalkState->ScopeInfo,
    111  1.1.1.11  christos                     Op->Common.Value.String,
    112  1.1.1.11  christos                     ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
    113  1.1.1.11  christos                     ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL,
    114  1.1.1.11  christos                     ACPI_CAST_INDIRECT_PTR (
    115  1.1.1.11  christos                         ACPI_NAMESPACE_NODE, &(Op->Common.Node)));
    116  1.1.1.11  christos                 if (ACPI_FAILURE (Status))
    117  1.1.1.11  christos                 {
    118  1.1.1.12  christos                     ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
    119  1.1.1.12  christos                         Op->Common.Value.String, Status);
    120  1.1.1.11  christos                     return_ACPI_STATUS (Status);
    121  1.1.1.11  christos                 }
    122       1.1    jruoho             }
    123       1.1    jruoho         }
    124       1.1    jruoho     }
    125       1.1    jruoho 
    126  1.1.1.11  christos CreateNewObject:
    127  1.1.1.11  christos 
    128       1.1    jruoho     /* Create and init a new internal ACPI object */
    129       1.1    jruoho 
    130       1.1    jruoho     ObjDesc = AcpiUtCreateInternalObject (
    131   1.1.1.7  christos         (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType);
    132       1.1    jruoho     if (!ObjDesc)
    133       1.1    jruoho     {
    134       1.1    jruoho         return_ACPI_STATUS (AE_NO_MEMORY);
    135       1.1    jruoho     }
    136       1.1    jruoho 
    137   1.1.1.7  christos     Status = AcpiDsInitObjectFromOp (
    138   1.1.1.7  christos         WalkState, Op, Op->Common.AmlOpcode, &ObjDesc);
    139       1.1    jruoho     if (ACPI_FAILURE (Status))
    140       1.1    jruoho     {
    141       1.1    jruoho         AcpiUtRemoveReference (ObjDesc);
    142       1.1    jruoho         return_ACPI_STATUS (Status);
    143       1.1    jruoho     }
    144       1.1    jruoho 
    145  1.1.1.11  christos     /*
    146  1.1.1.11  christos      * Handling for unresolved package reference elements.
    147  1.1.1.11  christos      * These are elements that are namepaths.
    148  1.1.1.11  christos      */
    149  1.1.1.11  christos     if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
    150  1.1.1.11  christos         (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
    151  1.1.1.11  christos     {
    152  1.1.1.11  christos         ObjDesc->Reference.Resolved = TRUE;
    153  1.1.1.11  christos 
    154  1.1.1.11  christos         if ((Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
    155  1.1.1.11  christos             !ObjDesc->Reference.Node)
    156  1.1.1.11  christos         {
    157  1.1.1.11  christos             /*
    158  1.1.1.11  christos              * Name was unresolved above.
    159  1.1.1.11  christos              * Get the prefix node for later lookup
    160  1.1.1.11  christos              */
    161  1.1.1.11  christos             ObjDesc->Reference.Node = WalkState->ScopeInfo->Scope.Node;
    162  1.1.1.11  christos             ObjDesc->Reference.Aml = Op->Common.Aml;
    163  1.1.1.11  christos             ObjDesc->Reference.Resolved = FALSE;
    164  1.1.1.11  christos         }
    165  1.1.1.11  christos     }
    166  1.1.1.11  christos 
    167       1.1    jruoho     *ObjDescPtr = ObjDesc;
    168       1.1    jruoho     return_ACPI_STATUS (Status);
    169       1.1    jruoho }
    170       1.1    jruoho 
    171       1.1    jruoho 
    172       1.1    jruoho /*******************************************************************************
    173       1.1    jruoho  *
    174       1.1    jruoho  * FUNCTION:    AcpiDsBuildInternalBufferObj
    175       1.1    jruoho  *
    176       1.1    jruoho  * PARAMETERS:  WalkState       - Current walk state
    177       1.1    jruoho  *              Op              - Parser object to be translated
    178       1.1    jruoho  *              BufferLength    - Length of the buffer
    179       1.1    jruoho  *              ObjDescPtr      - Where the ACPI internal object is returned
    180       1.1    jruoho  *
    181       1.1    jruoho  * RETURN:      Status
    182       1.1    jruoho  *
    183       1.1    jruoho  * DESCRIPTION: Translate a parser Op package object to the equivalent
    184       1.1    jruoho  *              namespace object
    185       1.1    jruoho  *
    186       1.1    jruoho  ******************************************************************************/
    187       1.1    jruoho 
    188       1.1    jruoho ACPI_STATUS
    189       1.1    jruoho AcpiDsBuildInternalBufferObj (
    190       1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    191       1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    192       1.1    jruoho     UINT32                  BufferLength,
    193       1.1    jruoho     ACPI_OPERAND_OBJECT     **ObjDescPtr)
    194       1.1    jruoho {
    195       1.1    jruoho     ACPI_PARSE_OBJECT       *Arg;
    196       1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
    197       1.1    jruoho     ACPI_PARSE_OBJECT       *ByteList;
    198       1.1    jruoho     UINT32                  ByteListLength = 0;
    199       1.1    jruoho 
    200       1.1    jruoho 
    201       1.1    jruoho     ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj);
    202       1.1    jruoho 
    203       1.1    jruoho 
    204       1.1    jruoho     /*
    205       1.1    jruoho      * If we are evaluating a Named buffer object "Name (xxxx, Buffer)".
    206       1.1    jruoho      * The buffer object already exists (from the NS node), otherwise it must
    207       1.1    jruoho      * be created.
    208       1.1    jruoho      */
    209       1.1    jruoho     ObjDesc = *ObjDescPtr;
    210       1.1    jruoho     if (!ObjDesc)
    211       1.1    jruoho     {
    212       1.1    jruoho         /* Create a new buffer object */
    213       1.1    jruoho 
    214       1.1    jruoho         ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
    215       1.1    jruoho         *ObjDescPtr = ObjDesc;
    216       1.1    jruoho         if (!ObjDesc)
    217       1.1    jruoho         {
    218       1.1    jruoho             return_ACPI_STATUS (AE_NO_MEMORY);
    219       1.1    jruoho         }
    220       1.1    jruoho     }
    221       1.1    jruoho 
    222       1.1    jruoho     /*
    223       1.1    jruoho      * Second arg is the buffer data (optional) ByteList can be either
    224   1.1.1.3  christos      * individual bytes or a string initializer. In either case, a
    225       1.1    jruoho      * ByteList appears in the AML.
    226       1.1    jruoho      */
    227       1.1    jruoho     Arg = Op->Common.Value.Arg;         /* skip first arg */
    228       1.1    jruoho 
    229       1.1    jruoho     ByteList = Arg->Named.Next;
    230       1.1    jruoho     if (ByteList)
    231       1.1    jruoho     {
    232       1.1    jruoho         if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP)
    233       1.1    jruoho         {
    234       1.1    jruoho             ACPI_ERROR ((AE_INFO,
    235       1.1    jruoho                 "Expecting bytelist, found AML opcode 0x%X in op %p",
    236       1.1    jruoho                 ByteList->Common.AmlOpcode, ByteList));
    237       1.1    jruoho 
    238       1.1    jruoho             AcpiUtRemoveReference (ObjDesc);
    239       1.1    jruoho             return (AE_TYPE);
    240       1.1    jruoho         }
    241       1.1    jruoho 
    242       1.1    jruoho         ByteListLength = (UINT32) ByteList->Common.Value.Integer;
    243       1.1    jruoho     }
    244       1.1    jruoho 
    245       1.1    jruoho     /*
    246       1.1    jruoho      * The buffer length (number of bytes) will be the larger of:
    247       1.1    jruoho      * 1) The specified buffer length and
    248       1.1    jruoho      * 2) The length of the initializer byte list
    249       1.1    jruoho      */
    250       1.1    jruoho     ObjDesc->Buffer.Length = BufferLength;
    251       1.1    jruoho     if (ByteListLength > BufferLength)
    252       1.1    jruoho     {
    253       1.1    jruoho         ObjDesc->Buffer.Length = ByteListLength;
    254       1.1    jruoho     }
    255       1.1    jruoho 
    256       1.1    jruoho     /* Allocate the buffer */
    257       1.1    jruoho 
    258       1.1    jruoho     if (ObjDesc->Buffer.Length == 0)
    259       1.1    jruoho     {
    260       1.1    jruoho         ObjDesc->Buffer.Pointer = NULL;
    261       1.1    jruoho         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
    262       1.1    jruoho             "Buffer defined with zero length in AML, creating\n"));
    263       1.1    jruoho     }
    264       1.1    jruoho     else
    265       1.1    jruoho     {
    266   1.1.1.7  christos         ObjDesc->Buffer.Pointer =
    267   1.1.1.7  christos             ACPI_ALLOCATE_ZEROED (ObjDesc->Buffer.Length);
    268       1.1    jruoho         if (!ObjDesc->Buffer.Pointer)
    269       1.1    jruoho         {
    270       1.1    jruoho             AcpiUtDeleteObjectDesc (ObjDesc);
    271       1.1    jruoho             return_ACPI_STATUS (AE_NO_MEMORY);
    272       1.1    jruoho         }
    273       1.1    jruoho 
    274       1.1    jruoho         /* Initialize buffer from the ByteList (if present) */
    275       1.1    jruoho 
    276       1.1    jruoho         if (ByteList)
    277       1.1    jruoho         {
    278   1.1.1.6  christos             memcpy (ObjDesc->Buffer.Pointer, ByteList->Named.Data,
    279   1.1.1.7  christos                 ByteListLength);
    280       1.1    jruoho         }
    281       1.1    jruoho     }
    282       1.1    jruoho 
    283       1.1    jruoho     ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID;
    284       1.1    jruoho     Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc);
    285       1.1    jruoho     return_ACPI_STATUS (AE_OK);
    286       1.1    jruoho }
    287       1.1    jruoho 
    288       1.1    jruoho /*******************************************************************************
    289       1.1    jruoho  *
    290       1.1    jruoho  * FUNCTION:    AcpiDsCreateNode
    291       1.1    jruoho  *
    292       1.1    jruoho  * PARAMETERS:  WalkState       - Current walk state
    293       1.1    jruoho  *              Node            - NS Node to be initialized
    294       1.1    jruoho  *              Op              - Parser object to be translated
    295       1.1    jruoho  *
    296       1.1    jruoho  * RETURN:      Status
    297       1.1    jruoho  *
    298       1.1    jruoho  * DESCRIPTION: Create the object to be associated with a namespace node
    299       1.1    jruoho  *
    300       1.1    jruoho  ******************************************************************************/
    301       1.1    jruoho 
    302       1.1    jruoho ACPI_STATUS
    303       1.1    jruoho AcpiDsCreateNode (
    304       1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    305       1.1    jruoho     ACPI_NAMESPACE_NODE     *Node,
    306       1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
    307       1.1    jruoho {
    308       1.1    jruoho     ACPI_STATUS             Status;
    309       1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
    310       1.1    jruoho 
    311       1.1    jruoho 
    312       1.1    jruoho     ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op);
    313       1.1    jruoho 
    314       1.1    jruoho 
    315       1.1    jruoho     /*
    316       1.1    jruoho      * Because of the execution pass through the non-control-method
    317   1.1.1.3  christos      * parts of the table, we can arrive here twice. Only init
    318       1.1    jruoho      * the named object node the first time through
    319       1.1    jruoho      */
    320       1.1    jruoho     if (AcpiNsGetAttachedObject (Node))
    321       1.1    jruoho     {
    322       1.1    jruoho         return_ACPI_STATUS (AE_OK);
    323       1.1    jruoho     }
    324       1.1    jruoho 
    325       1.1    jruoho     if (!Op->Common.Value.Arg)
    326       1.1    jruoho     {
    327       1.1    jruoho         /* No arguments, there is nothing to do */
    328       1.1    jruoho 
    329       1.1    jruoho         return_ACPI_STATUS (AE_OK);
    330       1.1    jruoho     }
    331       1.1    jruoho 
    332       1.1    jruoho     /* Build an internal object for the argument(s) */
    333       1.1    jruoho 
    334   1.1.1.7  christos     Status = AcpiDsBuildInternalObject (
    335   1.1.1.7  christos         WalkState, Op->Common.Value.Arg, &ObjDesc);
    336       1.1    jruoho     if (ACPI_FAILURE (Status))
    337       1.1    jruoho     {
    338       1.1    jruoho         return_ACPI_STATUS (Status);
    339       1.1    jruoho     }
    340       1.1    jruoho 
    341       1.1    jruoho     /* Re-type the object according to its argument */
    342       1.1    jruoho 
    343       1.1    jruoho     Node->Type = ObjDesc->Common.Type;
    344       1.1    jruoho 
    345       1.1    jruoho     /* Attach obj to node */
    346       1.1    jruoho 
    347       1.1    jruoho     Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type);
    348       1.1    jruoho 
    349       1.1    jruoho     /* Remove local reference to the object */
    350       1.1    jruoho 
    351       1.1    jruoho     AcpiUtRemoveReference (ObjDesc);
    352       1.1    jruoho     return_ACPI_STATUS (Status);
    353       1.1    jruoho }
    354       1.1    jruoho 
    355       1.1    jruoho #endif /* ACPI_NO_METHOD_EXECUTION */
    356       1.1    jruoho 
    357       1.1    jruoho 
    358       1.1    jruoho /*******************************************************************************
    359       1.1    jruoho  *
    360       1.1    jruoho  * FUNCTION:    AcpiDsInitObjectFromOp
    361       1.1    jruoho  *
    362       1.1    jruoho  * PARAMETERS:  WalkState       - Current walk state
    363       1.1    jruoho  *              Op              - Parser op used to init the internal object
    364       1.1    jruoho  *              Opcode          - AML opcode associated with the object
    365       1.1    jruoho  *              RetObjDesc      - Namespace object to be initialized
    366       1.1    jruoho  *
    367       1.1    jruoho  * RETURN:      Status
    368       1.1    jruoho  *
    369       1.1    jruoho  * DESCRIPTION: Initialize a namespace object from a parser Op and its
    370   1.1.1.3  christos  *              associated arguments. The namespace object is a more compact
    371       1.1    jruoho  *              representation of the Op and its arguments.
    372       1.1    jruoho  *
    373       1.1    jruoho  ******************************************************************************/
    374       1.1    jruoho 
    375       1.1    jruoho ACPI_STATUS
    376       1.1    jruoho AcpiDsInitObjectFromOp (
    377       1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    378       1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    379       1.1    jruoho     UINT16                  Opcode,
    380       1.1    jruoho     ACPI_OPERAND_OBJECT     **RetObjDesc)
    381       1.1    jruoho {
    382       1.1    jruoho     const ACPI_OPCODE_INFO  *OpInfo;
    383       1.1    jruoho     ACPI_OPERAND_OBJECT     *ObjDesc;
    384       1.1    jruoho     ACPI_STATUS             Status = AE_OK;
    385       1.1    jruoho 
    386       1.1    jruoho 
    387       1.1    jruoho     ACPI_FUNCTION_TRACE (DsInitObjectFromOp);
    388       1.1    jruoho 
    389       1.1    jruoho 
    390       1.1    jruoho     ObjDesc = *RetObjDesc;
    391       1.1    jruoho     OpInfo = AcpiPsGetOpcodeInfo (Opcode);
    392       1.1    jruoho     if (OpInfo->Class == AML_CLASS_UNKNOWN)
    393       1.1    jruoho     {
    394       1.1    jruoho         /* Unknown opcode */
    395       1.1    jruoho 
    396       1.1    jruoho         return_ACPI_STATUS (AE_TYPE);
    397       1.1    jruoho     }
    398       1.1    jruoho 
    399       1.1    jruoho     /* Perform per-object initialization */
    400       1.1    jruoho 
    401       1.1    jruoho     switch (ObjDesc->Common.Type)
    402       1.1    jruoho     {
    403       1.1    jruoho     case ACPI_TYPE_BUFFER:
    404       1.1    jruoho         /*
    405       1.1    jruoho          * Defer evaluation of Buffer TermArg operand
    406       1.1    jruoho          */
    407   1.1.1.7  christos         ObjDesc->Buffer.Node = ACPI_CAST_PTR (
    408   1.1.1.7  christos             ACPI_NAMESPACE_NODE, WalkState->Operands[0]);
    409   1.1.1.7  christos         ObjDesc->Buffer.AmlStart = Op->Named.Data;
    410       1.1    jruoho         ObjDesc->Buffer.AmlLength = Op->Named.Length;
    411       1.1    jruoho         break;
    412       1.1    jruoho 
    413       1.1    jruoho     case ACPI_TYPE_PACKAGE:
    414       1.1    jruoho         /*
    415  1.1.1.11  christos          * Defer evaluation of Package TermArg operand and all
    416  1.1.1.11  christos          * package elements. (01/2017): We defer the element
    417  1.1.1.11  christos          * resolution to allow forward references from the package
    418  1.1.1.11  christos          * in order to provide compatibility with other ACPI
    419  1.1.1.11  christos          * implementations.
    420       1.1    jruoho          */
    421   1.1.1.7  christos         ObjDesc->Package.Node = ACPI_CAST_PTR (
    422   1.1.1.7  christos             ACPI_NAMESPACE_NODE, WalkState->Operands[0]);
    423  1.1.1.11  christos 
    424  1.1.1.11  christos         if (!Op->Named.Data)
    425  1.1.1.11  christos         {
    426  1.1.1.11  christos             return_ACPI_STATUS (AE_OK);
    427  1.1.1.11  christos         }
    428  1.1.1.11  christos 
    429   1.1.1.7  christos         ObjDesc->Package.AmlStart = Op->Named.Data;
    430       1.1    jruoho         ObjDesc->Package.AmlLength = Op->Named.Length;
    431       1.1    jruoho         break;
    432       1.1    jruoho 
    433       1.1    jruoho     case ACPI_TYPE_INTEGER:
    434       1.1    jruoho 
    435       1.1    jruoho         switch (OpInfo->Type)
    436       1.1    jruoho         {
    437       1.1    jruoho         case AML_TYPE_CONSTANT:
    438       1.1    jruoho             /*
    439       1.1    jruoho              * Resolve AML Constants here - AND ONLY HERE!
    440       1.1    jruoho              * All constants are integers.
    441       1.1    jruoho              * We mark the integer with a flag that indicates that it started
    442       1.1    jruoho              * life as a constant -- so that stores to constants will perform
    443       1.1    jruoho              * as expected (noop). ZeroOp is used as a placeholder for optional
    444       1.1    jruoho              * target operands.
    445       1.1    jruoho              */
    446       1.1    jruoho             ObjDesc->Common.Flags = AOPOBJ_AML_CONSTANT;
    447       1.1    jruoho 
    448       1.1    jruoho             switch (Opcode)
    449       1.1    jruoho             {
    450       1.1    jruoho             case AML_ZERO_OP:
    451       1.1    jruoho 
    452       1.1    jruoho                 ObjDesc->Integer.Value = 0;
    453       1.1    jruoho                 break;
    454       1.1    jruoho 
    455       1.1    jruoho             case AML_ONE_OP:
    456       1.1    jruoho 
    457       1.1    jruoho                 ObjDesc->Integer.Value = 1;
    458       1.1    jruoho                 break;
    459       1.1    jruoho 
    460       1.1    jruoho             case AML_ONES_OP:
    461       1.1    jruoho 
    462       1.1    jruoho                 ObjDesc->Integer.Value = ACPI_UINT64_MAX;
    463       1.1    jruoho 
    464       1.1    jruoho                 /* Truncate value if we are executing from a 32-bit ACPI table */
    465       1.1    jruoho 
    466       1.1    jruoho #ifndef ACPI_NO_METHOD_EXECUTION
    467   1.1.1.3  christos                 (void) AcpiExTruncateFor32bitTable (ObjDesc);
    468       1.1    jruoho #endif
    469       1.1    jruoho                 break;
    470       1.1    jruoho 
    471       1.1    jruoho             case AML_REVISION_OP:
    472       1.1    jruoho 
    473       1.1    jruoho                 ObjDesc->Integer.Value = ACPI_CA_VERSION;
    474       1.1    jruoho                 break;
    475       1.1    jruoho 
    476       1.1    jruoho             default:
    477       1.1    jruoho 
    478       1.1    jruoho                 ACPI_ERROR ((AE_INFO,
    479       1.1    jruoho                     "Unknown constant opcode 0x%X", Opcode));
    480       1.1    jruoho                 Status = AE_AML_OPERAND_TYPE;
    481       1.1    jruoho                 break;
    482       1.1    jruoho             }
    483       1.1    jruoho             break;
    484       1.1    jruoho 
    485       1.1    jruoho         case AML_TYPE_LITERAL:
    486       1.1    jruoho 
    487       1.1    jruoho             ObjDesc->Integer.Value = Op->Common.Value.Integer;
    488   1.1.1.3  christos 
    489       1.1    jruoho #ifndef ACPI_NO_METHOD_EXECUTION
    490   1.1.1.3  christos             if (AcpiExTruncateFor32bitTable (ObjDesc))
    491   1.1.1.3  christos             {
    492   1.1.1.3  christos                 /* Warn if we found a 64-bit constant in a 32-bit table */
    493   1.1.1.3  christos 
    494   1.1.1.3  christos                 ACPI_WARNING ((AE_INFO,
    495   1.1.1.3  christos                     "Truncated 64-bit constant found in 32-bit table: %8.8X%8.8X => %8.8X",
    496   1.1.1.3  christos                     ACPI_FORMAT_UINT64 (Op->Common.Value.Integer),
    497   1.1.1.3  christos                     (UINT32) ObjDesc->Integer.Value));
    498   1.1.1.3  christos             }
    499       1.1    jruoho #endif
    500       1.1    jruoho             break;
    501       1.1    jruoho 
    502       1.1    jruoho         default:
    503   1.1.1.3  christos 
    504       1.1    jruoho             ACPI_ERROR ((AE_INFO, "Unknown Integer type 0x%X",
    505       1.1    jruoho                 OpInfo->Type));
    506       1.1    jruoho             Status = AE_AML_OPERAND_TYPE;
    507       1.1    jruoho             break;
    508       1.1    jruoho         }
    509       1.1    jruoho         break;
    510       1.1    jruoho 
    511       1.1    jruoho     case ACPI_TYPE_STRING:
    512       1.1    jruoho 
    513       1.1    jruoho         ObjDesc->String.Pointer = Op->Common.Value.String;
    514   1.1.1.6  christos         ObjDesc->String.Length = (UINT32) strlen (Op->Common.Value.String);
    515       1.1    jruoho 
    516       1.1    jruoho         /*
    517       1.1    jruoho          * The string is contained in the ACPI table, don't ever try
    518       1.1    jruoho          * to delete it
    519       1.1    jruoho          */
    520       1.1    jruoho         ObjDesc->Common.Flags |= AOPOBJ_STATIC_POINTER;
    521       1.1    jruoho         break;
    522       1.1    jruoho 
    523       1.1    jruoho     case ACPI_TYPE_METHOD:
    524       1.1    jruoho         break;
    525       1.1    jruoho 
    526       1.1    jruoho     case ACPI_TYPE_LOCAL_REFERENCE:
    527       1.1    jruoho 
    528       1.1    jruoho         switch (OpInfo->Type)
    529       1.1    jruoho         {
    530       1.1    jruoho         case AML_TYPE_LOCAL_VARIABLE:
    531       1.1    jruoho 
    532  1.1.1.10  christos             /* Local ID (0-7) is (AML opcode - base AML_FIRST_LOCAL_OP) */
    533       1.1    jruoho 
    534  1.1.1.10  christos             ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_FIRST_LOCAL_OP;
    535       1.1    jruoho             ObjDesc->Reference.Class = ACPI_REFCLASS_LOCAL;
    536       1.1    jruoho 
    537       1.1    jruoho #ifndef ACPI_NO_METHOD_EXECUTION
    538       1.1    jruoho             Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_LOCAL,
    539   1.1.1.7  christos                 ObjDesc->Reference.Value, WalkState,
    540   1.1.1.7  christos                 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
    541   1.1.1.7  christos                     &ObjDesc->Reference.Object));
    542       1.1    jruoho #endif
    543       1.1    jruoho             break;
    544       1.1    jruoho 
    545       1.1    jruoho         case AML_TYPE_METHOD_ARGUMENT:
    546       1.1    jruoho 
    547  1.1.1.10  christos             /* Arg ID (0-6) is (AML opcode - base AML_FIRST_ARG_OP) */
    548       1.1    jruoho 
    549  1.1.1.10  christos             ObjDesc->Reference.Value = ((UINT32) Opcode) - AML_FIRST_ARG_OP;
    550       1.1    jruoho             ObjDesc->Reference.Class = ACPI_REFCLASS_ARG;
    551       1.1    jruoho 
    552       1.1    jruoho #ifndef ACPI_NO_METHOD_EXECUTION
    553       1.1    jruoho             Status = AcpiDsMethodDataGetNode (ACPI_REFCLASS_ARG,
    554   1.1.1.7  christos                 ObjDesc->Reference.Value, WalkState,
    555   1.1.1.7  christos                 ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE,
    556   1.1.1.7  christos                     &ObjDesc->Reference.Object));
    557       1.1    jruoho #endif
    558       1.1    jruoho             break;
    559       1.1    jruoho 
    560       1.1    jruoho         default: /* Object name or Debug object */
    561       1.1    jruoho 
    562       1.1    jruoho             switch (Op->Common.AmlOpcode)
    563       1.1    jruoho             {
    564       1.1    jruoho             case AML_INT_NAMEPATH_OP:
    565       1.1    jruoho 
    566       1.1    jruoho                 /* Node was saved in Op */
    567       1.1    jruoho 
    568       1.1    jruoho                 ObjDesc->Reference.Node = Op->Common.Node;
    569       1.1    jruoho                 ObjDesc->Reference.Class = ACPI_REFCLASS_NAME;
    570  1.1.1.11  christos                 if (Op->Common.Node)
    571  1.1.1.11  christos                 {
    572  1.1.1.11  christos                     ObjDesc->Reference.Object = Op->Common.Node->Object;
    573  1.1.1.11  christos                 }
    574       1.1    jruoho                 break;
    575       1.1    jruoho 
    576       1.1    jruoho             case AML_DEBUG_OP:
    577       1.1    jruoho 
    578       1.1    jruoho                 ObjDesc->Reference.Class = ACPI_REFCLASS_DEBUG;
    579       1.1    jruoho                 break;
    580       1.1    jruoho 
    581       1.1    jruoho             default:
    582       1.1    jruoho 
    583       1.1    jruoho                 ACPI_ERROR ((AE_INFO,
    584       1.1    jruoho                     "Unimplemented reference type for AML opcode: 0x%4.4X", Opcode));
    585       1.1    jruoho                 return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
    586       1.1    jruoho             }
    587       1.1    jruoho             break;
    588       1.1    jruoho         }
    589       1.1    jruoho         break;
    590       1.1    jruoho 
    591       1.1    jruoho     default:
    592       1.1    jruoho 
    593       1.1    jruoho         ACPI_ERROR ((AE_INFO, "Unimplemented data type: 0x%X",
    594       1.1    jruoho             ObjDesc->Common.Type));
    595       1.1    jruoho 
    596       1.1    jruoho         Status = AE_AML_OPERAND_TYPE;
    597       1.1    jruoho         break;
    598       1.1    jruoho     }
    599       1.1    jruoho 
    600       1.1    jruoho     return_ACPI_STATUS (Status);
    601       1.1    jruoho }
    602