Home | History | Annotate | Line # | Download | only in compiler
aslwalks.c revision 1.1.1.6
      1      1.1    jruoho /******************************************************************************
      2      1.1    jruoho  *
      3  1.1.1.3  christos  * Module Name: aslwalks.c - Miscellaneous analytical parse tree walks
      4      1.1    jruoho  *
      5      1.1    jruoho  *****************************************************************************/
      6      1.1    jruoho 
      7      1.1    jruoho /*
      8  1.1.1.6  christos  * Copyright (C) 2000 - 2016, Intel Corp.
      9      1.1    jruoho  * All rights reserved.
     10      1.1    jruoho  *
     11      1.1    jruoho  * Redistribution and use in source and binary forms, with or without
     12      1.1    jruoho  * modification, are permitted provided that the following conditions
     13      1.1    jruoho  * are met:
     14      1.1    jruoho  * 1. Redistributions of source code must retain the above copyright
     15      1.1    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16      1.1    jruoho  *    without modification.
     17      1.1    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18      1.1    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19      1.1    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20      1.1    jruoho  *    including a substantially similar Disclaimer requirement for further
     21      1.1    jruoho  *    binary redistribution.
     22      1.1    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23      1.1    jruoho  *    of any contributors may be used to endorse or promote products derived
     24      1.1    jruoho  *    from this software without specific prior written permission.
     25      1.1    jruoho  *
     26      1.1    jruoho  * Alternatively, this software may be distributed under the terms of the
     27      1.1    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28      1.1    jruoho  * Software Foundation.
     29      1.1    jruoho  *
     30      1.1    jruoho  * NO WARRANTY
     31      1.1    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32      1.1    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33      1.1    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34      1.1    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35      1.1    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36      1.1    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37      1.1    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38      1.1    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39      1.1    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40      1.1    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41      1.1    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42      1.1    jruoho  */
     43      1.1    jruoho 
     44      1.1    jruoho #include "aslcompiler.h"
     45      1.1    jruoho #include "aslcompiler.y.h"
     46      1.1    jruoho #include "acparser.h"
     47      1.1    jruoho #include "amlcode.h"
     48      1.1    jruoho 
     49      1.1    jruoho 
     50      1.1    jruoho #define _COMPONENT          ACPI_COMPILER
     51      1.1    jruoho         ACPI_MODULE_NAME    ("aslwalks")
     52      1.1    jruoho 
     53      1.1    jruoho 
     54  1.1.1.6  christos /* Local prototypes */
     55  1.1.1.6  christos 
     56  1.1.1.6  christos static void
     57  1.1.1.6  christos AnAnalyzeStoreOperator (
     58  1.1.1.6  christos     ACPI_PARSE_OBJECT       *Op);
     59  1.1.1.6  christos 
     60  1.1.1.6  christos 
     61      1.1    jruoho /*******************************************************************************
     62      1.1    jruoho  *
     63      1.1    jruoho  * FUNCTION:    AnMethodTypingWalkEnd
     64      1.1    jruoho  *
     65      1.1    jruoho  * PARAMETERS:  ASL_WALK_CALLBACK
     66      1.1    jruoho  *
     67      1.1    jruoho  * RETURN:      Status
     68      1.1    jruoho  *
     69      1.1    jruoho  * DESCRIPTION: Ascending callback for typing walk. Complete the method
     70      1.1    jruoho  *              return analysis. Check methods for:
     71      1.1    jruoho  *              1) Initialized local variables
     72      1.1    jruoho  *              2) Valid arguments
     73      1.1    jruoho  *              3) Return types
     74      1.1    jruoho  *
     75      1.1    jruoho  ******************************************************************************/
     76      1.1    jruoho 
     77      1.1    jruoho ACPI_STATUS
     78      1.1    jruoho AnMethodTypingWalkEnd (
     79      1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
     80      1.1    jruoho     UINT32                  Level,
     81      1.1    jruoho     void                    *Context)
     82      1.1    jruoho {
     83  1.1.1.6  christos     UINT32                  ThisOpBtype;
     84      1.1    jruoho 
     85      1.1    jruoho 
     86      1.1    jruoho     switch (Op->Asl.ParseOpcode)
     87      1.1    jruoho     {
     88      1.1    jruoho     case PARSEOP_METHOD:
     89      1.1    jruoho 
     90      1.1    jruoho         Op->Asl.CompileFlags |= NODE_METHOD_TYPED;
     91      1.1    jruoho         break;
     92      1.1    jruoho 
     93      1.1    jruoho     case PARSEOP_RETURN:
     94      1.1    jruoho 
     95      1.1    jruoho         if ((Op->Asl.Child) &&
     96      1.1    jruoho             (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
     97      1.1    jruoho         {
     98  1.1.1.6  christos             ThisOpBtype = AnGetBtype (Op->Asl.Child);
     99      1.1    jruoho 
    100      1.1    jruoho             if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) &&
    101  1.1.1.6  christos                 (ThisOpBtype == (ACPI_UINT32_MAX -1)))
    102      1.1    jruoho             {
    103      1.1    jruoho                 /*
    104      1.1    jruoho                  * The called method is untyped at this time (typically a
    105      1.1    jruoho                  * forward reference).
    106      1.1    jruoho                  *
    107      1.1    jruoho                  * Check for a recursive method call first.
    108      1.1    jruoho                  */
    109      1.1    jruoho                 if (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op)
    110      1.1    jruoho                 {
    111      1.1    jruoho                     /* We must type the method here */
    112      1.1    jruoho 
    113      1.1    jruoho                     TrWalkParseTree (Op->Asl.Child->Asl.Node->Op,
    114      1.1    jruoho                         ASL_WALK_VISIT_UPWARD, NULL,
    115      1.1    jruoho                         AnMethodTypingWalkEnd, NULL);
    116      1.1    jruoho 
    117  1.1.1.6  christos                     ThisOpBtype = AnGetBtype (Op->Asl.Child);
    118      1.1    jruoho                 }
    119      1.1    jruoho             }
    120      1.1    jruoho 
    121      1.1    jruoho             /* Returns a value, save the value type */
    122      1.1    jruoho 
    123      1.1    jruoho             if (Op->Asl.ParentMethod)
    124      1.1    jruoho             {
    125  1.1.1.6  christos                 Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisOpBtype;
    126      1.1    jruoho             }
    127      1.1    jruoho         }
    128      1.1    jruoho         break;
    129      1.1    jruoho 
    130      1.1    jruoho     default:
    131  1.1.1.3  christos 
    132      1.1    jruoho         break;
    133      1.1    jruoho     }
    134      1.1    jruoho 
    135      1.1    jruoho     return (AE_OK);
    136      1.1    jruoho }
    137      1.1    jruoho 
    138      1.1    jruoho 
    139      1.1    jruoho /*******************************************************************************
    140      1.1    jruoho  *
    141      1.1    jruoho  * FUNCTION:    AnOperandTypecheckWalkEnd
    142      1.1    jruoho  *
    143      1.1    jruoho  * PARAMETERS:  ASL_WALK_CALLBACK
    144      1.1    jruoho  *
    145      1.1    jruoho  * RETURN:      Status
    146      1.1    jruoho  *
    147      1.1    jruoho  * DESCRIPTION: Ascending callback for analysis walk. Complete method
    148      1.1    jruoho  *              return analysis.
    149      1.1    jruoho  *
    150      1.1    jruoho  ******************************************************************************/
    151      1.1    jruoho 
    152      1.1    jruoho ACPI_STATUS
    153      1.1    jruoho AnOperandTypecheckWalkEnd (
    154      1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    155      1.1    jruoho     UINT32                  Level,
    156      1.1    jruoho     void                    *Context)
    157      1.1    jruoho {
    158      1.1    jruoho     const ACPI_OPCODE_INFO  *OpInfo;
    159      1.1    jruoho     UINT32                  RuntimeArgTypes;
    160      1.1    jruoho     UINT32                  RuntimeArgTypes2;
    161      1.1    jruoho     UINT32                  RequiredBtypes;
    162      1.1    jruoho     UINT32                  ThisNodeBtype;
    163      1.1    jruoho     UINT32                  CommonBtypes;
    164      1.1    jruoho     UINT32                  OpcodeClass;
    165      1.1    jruoho     ACPI_PARSE_OBJECT       *ArgOp;
    166      1.1    jruoho     UINT32                  ArgType;
    167      1.1    jruoho 
    168      1.1    jruoho 
    169      1.1    jruoho     switch (Op->Asl.AmlOpcode)
    170      1.1    jruoho     {
    171      1.1    jruoho     case AML_RAW_DATA_BYTE:
    172      1.1    jruoho     case AML_RAW_DATA_WORD:
    173      1.1    jruoho     case AML_RAW_DATA_DWORD:
    174      1.1    jruoho     case AML_RAW_DATA_QWORD:
    175      1.1    jruoho     case AML_RAW_DATA_BUFFER:
    176      1.1    jruoho     case AML_RAW_DATA_CHAIN:
    177      1.1    jruoho     case AML_PACKAGE_LENGTH:
    178      1.1    jruoho     case AML_UNASSIGNED_OPCODE:
    179      1.1    jruoho     case AML_DEFAULT_ARG_OP:
    180      1.1    jruoho 
    181      1.1    jruoho         /* Ignore the internal (compiler-only) AML opcodes */
    182      1.1    jruoho 
    183      1.1    jruoho         return (AE_OK);
    184      1.1    jruoho 
    185      1.1    jruoho     default:
    186  1.1.1.3  christos 
    187      1.1    jruoho         break;
    188      1.1    jruoho     }
    189      1.1    jruoho 
    190      1.1    jruoho     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
    191      1.1    jruoho     if (!OpInfo)
    192      1.1    jruoho     {
    193      1.1    jruoho         return (AE_OK);
    194      1.1    jruoho     }
    195      1.1    jruoho 
    196  1.1.1.6  christos     ArgOp = Op->Asl.Child;
    197  1.1.1.6  christos     OpcodeClass = OpInfo->Class;
    198      1.1    jruoho     RuntimeArgTypes = OpInfo->RuntimeArgs;
    199      1.1    jruoho 
    200      1.1    jruoho #ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE
    201      1.1    jruoho     /*
    202      1.1    jruoho      * Update 11/2008: In practice, we can't perform this check. A simple
    203      1.1    jruoho      * analysis is not sufficient. Also, it can cause errors when compiling
    204      1.1    jruoho      * disassembled code because of the way Switch operators are implemented
    205      1.1    jruoho      * (a While(One) loop with a named temp variable created within.)
    206      1.1    jruoho      */
    207      1.1    jruoho 
    208      1.1    jruoho     /*
    209      1.1    jruoho      * If we are creating a named object, check if we are within a while loop
    210      1.1    jruoho      * by checking if the parent is a WHILE op. This is a simple analysis, but
    211      1.1    jruoho      * probably sufficient for many cases.
    212      1.1    jruoho      *
    213      1.1    jruoho      * Allow Scope(), Buffer(), and Package().
    214      1.1    jruoho      */
    215      1.1    jruoho     if (((OpcodeClass == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_SCOPE_OP)) ||
    216      1.1    jruoho         ((OpcodeClass == AML_CLASS_CREATE) && (OpInfo->Flags & AML_NSNODE)))
    217      1.1    jruoho     {
    218      1.1    jruoho         if (Op->Asl.Parent->Asl.AmlOpcode == AML_WHILE_OP)
    219      1.1    jruoho         {
    220      1.1    jruoho             AslError (ASL_ERROR, ASL_MSG_NAMED_OBJECT_IN_WHILE, Op, NULL);
    221      1.1    jruoho         }
    222      1.1    jruoho     }
    223      1.1    jruoho #endif
    224      1.1    jruoho 
    225      1.1    jruoho     /*
    226      1.1    jruoho      * Special case for control opcodes IF/RETURN/WHILE since they
    227      1.1    jruoho      * have no runtime arg list (at this time)
    228      1.1    jruoho      */
    229      1.1    jruoho     switch (Op->Asl.AmlOpcode)
    230      1.1    jruoho     {
    231      1.1    jruoho     case AML_IF_OP:
    232      1.1    jruoho     case AML_WHILE_OP:
    233      1.1    jruoho     case AML_RETURN_OP:
    234      1.1    jruoho 
    235      1.1    jruoho         if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
    236      1.1    jruoho         {
    237      1.1    jruoho             /* Check for an internal method */
    238      1.1    jruoho 
    239      1.1    jruoho             if (AnIsInternalMethod (ArgOp))
    240      1.1    jruoho             {
    241      1.1    jruoho                 return (AE_OK);
    242      1.1    jruoho             }
    243      1.1    jruoho 
    244      1.1    jruoho             /* The lone arg is a method call, check it */
    245      1.1    jruoho 
    246      1.1    jruoho             RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER);
    247      1.1    jruoho             if (Op->Asl.AmlOpcode == AML_RETURN_OP)
    248      1.1    jruoho             {
    249      1.1    jruoho                 RequiredBtypes = 0xFFFFFFFF;
    250      1.1    jruoho             }
    251      1.1    jruoho 
    252      1.1    jruoho             ThisNodeBtype = AnGetBtype (ArgOp);
    253      1.1    jruoho             if (ThisNodeBtype == ACPI_UINT32_MAX)
    254      1.1    jruoho             {
    255      1.1    jruoho                 return (AE_OK);
    256      1.1    jruoho             }
    257  1.1.1.6  christos 
    258      1.1    jruoho             AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
    259      1.1    jruoho                 RequiredBtypes, ThisNodeBtype);
    260      1.1    jruoho         }
    261      1.1    jruoho         return (AE_OK);
    262      1.1    jruoho 
    263  1.1.1.5  christos     case AML_EXTERNAL_OP:
    264  1.1.1.5  christos         /*
    265  1.1.1.5  christos          * Not really a "runtime" opcode since it used by disassembler only.
    266  1.1.1.5  christos          * The parser will find any issues with the operands.
    267  1.1.1.5  christos          */
    268  1.1.1.5  christos         return (AE_OK);
    269  1.1.1.5  christos 
    270      1.1    jruoho     default:
    271  1.1.1.3  christos 
    272      1.1    jruoho         break;
    273      1.1    jruoho     }
    274      1.1    jruoho 
    275      1.1    jruoho     /* Ignore the non-executable opcodes */
    276      1.1    jruoho 
    277      1.1    jruoho     if (RuntimeArgTypes == ARGI_INVALID_OPCODE)
    278      1.1    jruoho     {
    279      1.1    jruoho         return (AE_OK);
    280      1.1    jruoho     }
    281      1.1    jruoho 
    282  1.1.1.6  christos     /*
    283  1.1.1.6  christos      * Special handling for certain opcodes.
    284  1.1.1.6  christos      */
    285  1.1.1.6  christos     switch (Op->Asl.AmlOpcode)
    286  1.1.1.6  christos     {
    287  1.1.1.6  christos         /* BankField has one TermArg */
    288  1.1.1.6  christos 
    289  1.1.1.6  christos     case AML_BANK_FIELD_OP:
    290  1.1.1.6  christos 
    291  1.1.1.6  christos         OpcodeClass = AML_CLASS_EXECUTE;
    292  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;
    293  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;
    294  1.1.1.6  christos         break;
    295  1.1.1.6  christos 
    296  1.1.1.6  christos         /* Operation Region has 2 TermArgs */
    297  1.1.1.6  christos 
    298  1.1.1.6  christos     case AML_REGION_OP:
    299  1.1.1.6  christos 
    300  1.1.1.6  christos         OpcodeClass = AML_CLASS_EXECUTE;
    301  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;
    302  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;
    303  1.1.1.6  christos         break;
    304  1.1.1.6  christos 
    305  1.1.1.6  christos         /* DataTableRegion has 3 TermArgs */
    306  1.1.1.6  christos 
    307  1.1.1.6  christos     case AML_DATA_REGION_OP:
    308  1.1.1.6  christos 
    309  1.1.1.6  christos         OpcodeClass = AML_CLASS_EXECUTE;
    310  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;
    311  1.1.1.6  christos         break;
    312  1.1.1.6  christos 
    313  1.1.1.6  christos         /* Buffers/Packages have a length that is a TermArg */
    314  1.1.1.6  christos 
    315  1.1.1.6  christos     case AML_BUFFER_OP:
    316  1.1.1.6  christos     case AML_PACKAGE_OP:
    317  1.1.1.6  christos     case AML_VAR_PACKAGE_OP:
    318  1.1.1.6  christos 
    319  1.1.1.6  christos             /* If length is a constant, we are done */
    320  1.1.1.6  christos 
    321  1.1.1.6  christos         if ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
    322  1.1.1.6  christos             (ArgOp->Asl.ParseOpcode == PARSEOP_RAW_DATA))
    323  1.1.1.6  christos         {
    324  1.1.1.6  christos             return (AE_OK);
    325  1.1.1.6  christos         }
    326  1.1.1.6  christos         break;
    327  1.1.1.6  christos 
    328  1.1.1.6  christos         /* Store can write any object to the Debug object */
    329  1.1.1.6  christos 
    330  1.1.1.6  christos     case AML_STORE_OP:
    331  1.1.1.6  christos         /*
    332  1.1.1.6  christos          * If this is a Store() to the Debug object, we don't need
    333  1.1.1.6  christos          * to perform any further validation -- because a Store of
    334  1.1.1.6  christos          * any object to Debug is permitted and supported.
    335  1.1.1.6  christos          */
    336  1.1.1.6  christos         if (ArgOp->Asl.Next->Asl.AmlOpcode == AML_DEBUG_OP)
    337  1.1.1.6  christos         {
    338  1.1.1.6  christos             return (AE_OK);
    339  1.1.1.6  christos         }
    340  1.1.1.6  christos         break;
    341  1.1.1.6  christos 
    342  1.1.1.6  christos     default:
    343  1.1.1.6  christos         break;
    344  1.1.1.6  christos     }
    345  1.1.1.6  christos 
    346      1.1    jruoho     switch (OpcodeClass)
    347      1.1    jruoho     {
    348      1.1    jruoho     case AML_CLASS_EXECUTE:
    349      1.1    jruoho     case AML_CLASS_CREATE:
    350      1.1    jruoho     case AML_CLASS_CONTROL:
    351      1.1    jruoho     case AML_CLASS_RETURN_VALUE:
    352      1.1    jruoho 
    353      1.1    jruoho         /* Reverse the runtime argument list */
    354      1.1    jruoho 
    355      1.1    jruoho         RuntimeArgTypes2 = 0;
    356      1.1    jruoho         while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes)))
    357      1.1    jruoho         {
    358      1.1    jruoho             RuntimeArgTypes2 <<= ARG_TYPE_WIDTH;
    359      1.1    jruoho             RuntimeArgTypes2 |= ArgType;
    360      1.1    jruoho             INCREMENT_ARG_LIST (RuntimeArgTypes);
    361      1.1    jruoho         }
    362      1.1    jruoho 
    363  1.1.1.6  christos         /* Typecheck each argument */
    364  1.1.1.6  christos 
    365      1.1    jruoho         while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2)))
    366      1.1    jruoho         {
    367  1.1.1.6  christos             /* Get the required type(s) for the argument */
    368  1.1.1.6  christos 
    369      1.1    jruoho             RequiredBtypes = AnMapArgTypeToBtype (ArgType);
    370      1.1    jruoho 
    371  1.1.1.5  christos             if (!ArgOp)
    372  1.1.1.5  christos             {
    373  1.1.1.5  christos                 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
    374  1.1.1.5  christos                     "Null ArgOp in argument loop");
    375  1.1.1.5  christos                 AslAbort ();
    376  1.1.1.5  christos             }
    377  1.1.1.5  christos 
    378  1.1.1.6  christos             /* Get the actual type of the argument */
    379  1.1.1.6  christos 
    380      1.1    jruoho             ThisNodeBtype = AnGetBtype (ArgOp);
    381      1.1    jruoho             if (ThisNodeBtype == ACPI_UINT32_MAX)
    382      1.1    jruoho             {
    383      1.1    jruoho                 goto NextArgument;
    384      1.1    jruoho             }
    385      1.1    jruoho 
    386      1.1    jruoho             /* Examine the arg based on the required type of the arg */
    387      1.1    jruoho 
    388      1.1    jruoho             switch (ArgType)
    389      1.1    jruoho             {
    390      1.1    jruoho             case ARGI_TARGETREF:
    391      1.1    jruoho 
    392      1.1    jruoho                 if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO)
    393      1.1    jruoho                 {
    394      1.1    jruoho                     /* ZERO is the placeholder for "don't store result" */
    395      1.1    jruoho 
    396      1.1    jruoho                     ThisNodeBtype = RequiredBtypes;
    397      1.1    jruoho                     break;
    398      1.1    jruoho                 }
    399      1.1    jruoho 
    400  1.1.1.6  christos             /* Fallthrough */
    401  1.1.1.6  christos 
    402  1.1.1.6  christos             case ARGI_STORE_TARGET:
    403  1.1.1.6  christos 
    404      1.1    jruoho                 if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)
    405      1.1    jruoho                 {
    406      1.1    jruoho                     /*
    407      1.1    jruoho                      * This is the case where an original reference to a resource
    408      1.1    jruoho                      * descriptor field has been replaced by an (Integer) offset.
    409      1.1    jruoho                      * These named fields are supported at compile-time only;
    410      1.1    jruoho                      * the names are not passed to the interpreter (via the AML).
    411      1.1    jruoho                      */
    412      1.1    jruoho                     if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
    413      1.1    jruoho                         (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
    414      1.1    jruoho                     {
    415  1.1.1.6  christos                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD,
    416  1.1.1.6  christos                             ArgOp, NULL);
    417      1.1    jruoho                     }
    418      1.1    jruoho                     else
    419      1.1    jruoho                     {
    420  1.1.1.6  christos                         AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE,
    421  1.1.1.6  christos                             ArgOp, NULL);
    422      1.1    jruoho                     }
    423      1.1    jruoho                 }
    424      1.1    jruoho                 break;
    425      1.1    jruoho 
    426      1.1    jruoho 
    427  1.1.1.6  christos #ifdef __FUTURE_IMPLEMENTATION
    428  1.1.1.6  christos /*
    429  1.1.1.6  christos  * Possible future typechecking support
    430  1.1.1.6  christos  */
    431      1.1    jruoho             case ARGI_REFERENCE:            /* References */
    432      1.1    jruoho             case ARGI_INTEGER_REF:
    433      1.1    jruoho             case ARGI_OBJECT_REF:
    434      1.1    jruoho             case ARGI_DEVICE_REF:
    435      1.1    jruoho 
    436      1.1    jruoho                 switch (ArgOp->Asl.ParseOpcode)
    437      1.1    jruoho                 {
    438      1.1    jruoho                 case PARSEOP_LOCAL0:
    439      1.1    jruoho                 case PARSEOP_LOCAL1:
    440      1.1    jruoho                 case PARSEOP_LOCAL2:
    441      1.1    jruoho                 case PARSEOP_LOCAL3:
    442      1.1    jruoho                 case PARSEOP_LOCAL4:
    443      1.1    jruoho                 case PARSEOP_LOCAL5:
    444      1.1    jruoho                 case PARSEOP_LOCAL6:
    445      1.1    jruoho                 case PARSEOP_LOCAL7:
    446      1.1    jruoho 
    447      1.1    jruoho                     /* TBD: implement analysis of current value (type) of the local */
    448      1.1    jruoho                     /* For now, just treat any local as a typematch */
    449      1.1    jruoho 
    450      1.1    jruoho                     /*ThisNodeBtype = RequiredBtypes;*/
    451      1.1    jruoho                     break;
    452      1.1    jruoho 
    453      1.1    jruoho                 case PARSEOP_ARG0:
    454      1.1    jruoho                 case PARSEOP_ARG1:
    455      1.1    jruoho                 case PARSEOP_ARG2:
    456      1.1    jruoho                 case PARSEOP_ARG3:
    457      1.1    jruoho                 case PARSEOP_ARG4:
    458      1.1    jruoho                 case PARSEOP_ARG5:
    459      1.1    jruoho                 case PARSEOP_ARG6:
    460      1.1    jruoho 
    461  1.1.1.6  christos                     /* Hard to analyze argument types, so we won't */
    462  1.1.1.6  christos                     /* for now. Just treat any arg as a typematch */
    463      1.1    jruoho 
    464      1.1    jruoho                     /* ThisNodeBtype = RequiredBtypes; */
    465      1.1    jruoho                     break;
    466      1.1    jruoho 
    467      1.1    jruoho                 case PARSEOP_DEBUG:
    468      1.1    jruoho                 case PARSEOP_REFOF:
    469      1.1    jruoho                 case PARSEOP_INDEX:
    470      1.1    jruoho                 default:
    471  1.1.1.3  christos 
    472      1.1    jruoho                     break;
    473      1.1    jruoho                 }
    474      1.1    jruoho                 break;
    475  1.1.1.6  christos #endif
    476      1.1    jruoho             case ARGI_INTEGER:
    477      1.1    jruoho             default:
    478  1.1.1.3  christos 
    479      1.1    jruoho                 break;
    480      1.1    jruoho             }
    481      1.1    jruoho 
    482      1.1    jruoho 
    483  1.1.1.6  christos             /* Check for a type mismatch (required versus actual) */
    484  1.1.1.6  christos 
    485      1.1    jruoho             CommonBtypes = ThisNodeBtype & RequiredBtypes;
    486      1.1    jruoho 
    487      1.1    jruoho             if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
    488      1.1    jruoho             {
    489      1.1    jruoho                 if (AnIsInternalMethod (ArgOp))
    490      1.1    jruoho                 {
    491      1.1    jruoho                     return (AE_OK);
    492      1.1    jruoho                 }
    493      1.1    jruoho 
    494      1.1    jruoho                 /* Check a method call for a valid return value */
    495      1.1    jruoho 
    496      1.1    jruoho                 AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
    497      1.1    jruoho                     RequiredBtypes, ThisNodeBtype);
    498      1.1    jruoho             }
    499      1.1    jruoho 
    500      1.1    jruoho             /*
    501      1.1    jruoho              * Now check if the actual type(s) match at least one
    502      1.1    jruoho              * bit to the required type
    503      1.1    jruoho              */
    504      1.1    jruoho             else if (!CommonBtypes)
    505      1.1    jruoho             {
    506      1.1    jruoho                 /* No match -- this is a type mismatch error */
    507      1.1    jruoho 
    508      1.1    jruoho                 AnFormatBtype (StringBuffer, ThisNodeBtype);
    509      1.1    jruoho                 AnFormatBtype (StringBuffer2, RequiredBtypes);
    510      1.1    jruoho 
    511      1.1    jruoho                 sprintf (MsgBuffer, "[%s] found, %s operator requires [%s]",
    512  1.1.1.6  christos                     StringBuffer, OpInfo->Name, StringBuffer2);
    513      1.1    jruoho 
    514  1.1.1.6  christos                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE,
    515  1.1.1.6  christos                     ArgOp, MsgBuffer);
    516      1.1    jruoho             }
    517      1.1    jruoho 
    518      1.1    jruoho         NextArgument:
    519      1.1    jruoho             ArgOp = ArgOp->Asl.Next;
    520      1.1    jruoho             INCREMENT_ARG_LIST (RuntimeArgTypes2);
    521      1.1    jruoho         }
    522      1.1    jruoho         break;
    523      1.1    jruoho 
    524      1.1    jruoho     default:
    525  1.1.1.3  christos 
    526      1.1    jruoho         break;
    527      1.1    jruoho     }
    528      1.1    jruoho 
    529      1.1    jruoho     return (AE_OK);
    530      1.1    jruoho }
    531      1.1    jruoho 
    532      1.1    jruoho 
    533      1.1    jruoho /*******************************************************************************
    534      1.1    jruoho  *
    535      1.1    jruoho  * FUNCTION:    AnOtherSemanticAnalysisWalkBegin
    536      1.1    jruoho  *
    537      1.1    jruoho  * PARAMETERS:  ASL_WALK_CALLBACK
    538      1.1    jruoho  *
    539      1.1    jruoho  * RETURN:      Status
    540      1.1    jruoho  *
    541      1.1    jruoho  * DESCRIPTION: Descending callback for the analysis walk. Checks for
    542      1.1    jruoho  *              miscellaneous issues in the code.
    543      1.1    jruoho  *
    544      1.1    jruoho  ******************************************************************************/
    545      1.1    jruoho 
    546      1.1    jruoho ACPI_STATUS
    547      1.1    jruoho AnOtherSemanticAnalysisWalkBegin (
    548      1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    549      1.1    jruoho     UINT32                  Level,
    550      1.1    jruoho     void                    *Context)
    551      1.1    jruoho {
    552  1.1.1.6  christos     ACPI_PARSE_OBJECT       *ArgOp;
    553  1.1.1.6  christos     ACPI_PARSE_OBJECT       *PrevArgOp = NULL;
    554      1.1    jruoho     const ACPI_OPCODE_INFO  *OpInfo;
    555  1.1.1.3  christos     ACPI_NAMESPACE_NODE     *Node;
    556      1.1    jruoho 
    557      1.1    jruoho 
    558      1.1    jruoho     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
    559      1.1    jruoho 
    560  1.1.1.6  christos 
    561      1.1    jruoho     /*
    562      1.1    jruoho      * Determine if an execution class operator actually does something by
    563      1.1    jruoho      * checking if it has a target and/or the function return value is used.
    564      1.1    jruoho      * (Target is optional, so a standalone statement can actually do nothing.)
    565      1.1    jruoho      */
    566      1.1    jruoho     if ((OpInfo->Class == AML_CLASS_EXECUTE) &&
    567      1.1    jruoho         (OpInfo->Flags & AML_HAS_RETVAL) &&
    568      1.1    jruoho         (!AnIsResultUsed (Op)))
    569      1.1    jruoho     {
    570      1.1    jruoho         if (OpInfo->Flags & AML_HAS_TARGET)
    571      1.1    jruoho         {
    572      1.1    jruoho             /*
    573  1.1.1.6  christos              * Find the target node, it is always the last child. If the target
    574      1.1    jruoho              * is not specified in the ASL, a default node of type Zero was
    575      1.1    jruoho              * created by the parser.
    576      1.1    jruoho              */
    577  1.1.1.6  christos             ArgOp = Op->Asl.Child;
    578  1.1.1.6  christos             while (ArgOp->Asl.Next)
    579      1.1    jruoho             {
    580  1.1.1.6  christos                 PrevArgOp = ArgOp;
    581  1.1.1.6  christos                 ArgOp = ArgOp->Asl.Next;
    582      1.1    jruoho             }
    583      1.1    jruoho 
    584      1.1    jruoho             /* Divide() is the only weird case, it has two targets */
    585      1.1    jruoho 
    586      1.1    jruoho             if (Op->Asl.AmlOpcode == AML_DIVIDE_OP)
    587      1.1    jruoho             {
    588  1.1.1.6  christos                 if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) &&
    589  1.1.1.6  christos                     (PrevArgOp) &&
    590  1.1.1.6  christos                     (PrevArgOp->Asl.ParseOpcode == PARSEOP_ZERO))
    591      1.1    jruoho                 {
    592  1.1.1.3  christos                     AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED,
    593      1.1    jruoho                         Op, Op->Asl.ExternalName);
    594      1.1    jruoho                 }
    595      1.1    jruoho             }
    596  1.1.1.6  christos 
    597  1.1.1.6  christos             else if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO)
    598      1.1    jruoho             {
    599  1.1.1.3  christos                 AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED,
    600      1.1    jruoho                     Op, Op->Asl.ExternalName);
    601      1.1    jruoho             }
    602      1.1    jruoho         }
    603      1.1    jruoho         else
    604      1.1    jruoho         {
    605      1.1    jruoho             /*
    606      1.1    jruoho              * Has no target and the result is not used. Only a couple opcodes
    607      1.1    jruoho              * can have this combination.
    608      1.1    jruoho              */
    609      1.1    jruoho             switch (Op->Asl.ParseOpcode)
    610      1.1    jruoho             {
    611      1.1    jruoho             case PARSEOP_ACQUIRE:
    612      1.1    jruoho             case PARSEOP_WAIT:
    613      1.1    jruoho             case PARSEOP_LOADTABLE:
    614  1.1.1.3  christos 
    615      1.1    jruoho                 break;
    616      1.1    jruoho 
    617      1.1    jruoho             default:
    618  1.1.1.3  christos 
    619  1.1.1.3  christos                 AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED,
    620      1.1    jruoho                     Op, Op->Asl.ExternalName);
    621      1.1    jruoho                 break;
    622      1.1    jruoho             }
    623      1.1    jruoho         }
    624      1.1    jruoho     }
    625      1.1    jruoho 
    626      1.1    jruoho 
    627      1.1    jruoho     /*
    628      1.1    jruoho      * Semantic checks for individual ASL operators
    629      1.1    jruoho      */
    630      1.1    jruoho     switch (Op->Asl.ParseOpcode)
    631      1.1    jruoho     {
    632  1.1.1.6  christos     case PARSEOP_STORE:
    633  1.1.1.6  christos 
    634  1.1.1.6  christos         if (Gbl_DoTypechecking)
    635  1.1.1.6  christos         {
    636  1.1.1.6  christos             AnAnalyzeStoreOperator (Op);
    637  1.1.1.6  christos         }
    638  1.1.1.6  christos         break;
    639  1.1.1.6  christos 
    640  1.1.1.6  christos 
    641      1.1    jruoho     case PARSEOP_ACQUIRE:
    642      1.1    jruoho     case PARSEOP_WAIT:
    643      1.1    jruoho         /*
    644      1.1    jruoho          * Emit a warning if the timeout parameter for these operators is not
    645      1.1    jruoho          * ACPI_WAIT_FOREVER, and the result value from the operator is not
    646      1.1    jruoho          * checked, meaning that a timeout could happen, but the code
    647      1.1    jruoho          * would not know about it.
    648      1.1    jruoho          */
    649      1.1    jruoho 
    650      1.1    jruoho         /* First child is the namepath, 2nd child is timeout */
    651      1.1    jruoho 
    652  1.1.1.6  christos         ArgOp = Op->Asl.Child;
    653  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;
    654      1.1    jruoho 
    655      1.1    jruoho         /*
    656      1.1    jruoho          * Check for the WAIT_FOREVER case - defined by the ACPI spec to be
    657      1.1    jruoho          * 0xFFFF or greater
    658      1.1    jruoho          */
    659  1.1.1.6  christos         if (((ArgOp->Asl.ParseOpcode == PARSEOP_WORDCONST) ||
    660  1.1.1.6  christos              (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER))  &&
    661  1.1.1.6  christos              (ArgOp->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER))
    662      1.1    jruoho         {
    663      1.1    jruoho             break;
    664      1.1    jruoho         }
    665      1.1    jruoho 
    666      1.1    jruoho         /*
    667      1.1    jruoho          * The operation could timeout. If the return value is not used
    668      1.1    jruoho          * (indicates timeout occurred), issue a warning
    669      1.1    jruoho          */
    670      1.1    jruoho         if (!AnIsResultUsed (Op))
    671      1.1    jruoho         {
    672  1.1.1.6  christos             AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgOp,
    673      1.1    jruoho                 Op->Asl.ExternalName);
    674      1.1    jruoho         }
    675      1.1    jruoho         break;
    676      1.1    jruoho 
    677      1.1    jruoho     case PARSEOP_CREATEFIELD:
    678      1.1    jruoho         /*
    679      1.1    jruoho          * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand
    680      1.1    jruoho          */
    681  1.1.1.6  christos         ArgOp = Op->Asl.Child;
    682  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;
    683  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;
    684  1.1.1.6  christos 
    685  1.1.1.6  christos         if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) ||
    686  1.1.1.6  christos            ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) &&
    687  1.1.1.6  christos             (ArgOp->Asl.Value.Integer == 0)))
    688      1.1    jruoho         {
    689  1.1.1.6  christos             AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgOp, NULL);
    690      1.1    jruoho         }
    691      1.1    jruoho         break;
    692      1.1    jruoho 
    693  1.1.1.3  christos     case PARSEOP_CONNECTION:
    694  1.1.1.3  christos         /*
    695  1.1.1.3  christos          * Ensure that the referenced operation region has the correct SPACE_ID.
    696  1.1.1.3  christos          * From the grammar/parser, we know the parent is a FIELD definition.
    697  1.1.1.3  christos          */
    698  1.1.1.6  christos         ArgOp = Op->Asl.Parent;     /* Field definition */
    699  1.1.1.6  christos         ArgOp = ArgOp->Asl.Child;   /* First child is the OpRegion Name */
    700  1.1.1.6  christos         Node = ArgOp->Asl.Node;     /* OpRegion namespace node */
    701  1.1.1.4  christos         if (!Node)
    702  1.1.1.4  christos         {
    703  1.1.1.4  christos             break;
    704  1.1.1.4  christos         }
    705  1.1.1.3  christos 
    706  1.1.1.6  christos         ArgOp = Node->Op;           /* OpRegion definition */
    707  1.1.1.6  christos         ArgOp = ArgOp->Asl.Child;   /* First child is the OpRegion Name */
    708  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;    /* Next peer is the SPACE_ID (what we want) */
    709  1.1.1.3  christos 
    710  1.1.1.3  christos         /*
    711  1.1.1.3  christos          * The Connection() operator is only valid for the following operation
    712  1.1.1.3  christos          * region SpaceIds: GeneralPurposeIo and GenericSerialBus.
    713  1.1.1.3  christos          */
    714  1.1.1.6  christos         if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) &&
    715  1.1.1.6  christos             (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS))
    716  1.1.1.3  christos         {
    717  1.1.1.3  christos             AslError (ASL_ERROR, ASL_MSG_CONNECTION_INVALID, Op, NULL);
    718  1.1.1.3  christos         }
    719  1.1.1.3  christos         break;
    720  1.1.1.3  christos 
    721  1.1.1.3  christos     case PARSEOP_FIELD:
    722  1.1.1.3  christos         /*
    723  1.1.1.3  christos          * Ensure that fields for GeneralPurposeIo and GenericSerialBus
    724  1.1.1.3  christos          * contain at least one Connection() operator
    725  1.1.1.3  christos          */
    726  1.1.1.6  christos         ArgOp = Op->Asl.Child;      /* 1st child is the OpRegion Name */
    727  1.1.1.6  christos         Node = ArgOp->Asl.Node;     /* OpRegion namespace node */
    728  1.1.1.3  christos         if (!Node)
    729  1.1.1.3  christos         {
    730  1.1.1.3  christos             break;
    731  1.1.1.3  christos         }
    732  1.1.1.3  christos 
    733  1.1.1.6  christos         ArgOp = Node->Op;           /* OpRegion definition */
    734  1.1.1.6  christos         ArgOp = ArgOp->Asl.Child;   /* First child is the OpRegion Name */
    735  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;    /* Next peer is the SPACE_ID (what we want) */
    736  1.1.1.3  christos 
    737  1.1.1.3  christos         /* We are only interested in GeneralPurposeIo and GenericSerialBus */
    738  1.1.1.3  christos 
    739  1.1.1.6  christos         if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) &&
    740  1.1.1.6  christos             (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS))
    741  1.1.1.3  christos         {
    742  1.1.1.3  christos             break;
    743  1.1.1.3  christos         }
    744  1.1.1.3  christos 
    745  1.1.1.6  christos         ArgOp = Op->Asl.Child;      /* 1st child is the OpRegion Name */
    746  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;    /* AccessType */
    747  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;    /* LockRule */
    748  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;    /* UpdateRule */
    749  1.1.1.6  christos         ArgOp = ArgOp->Asl.Next;    /* Start of FieldUnitList */
    750  1.1.1.3  christos 
    751  1.1.1.3  christos         /* Walk the FieldUnitList */
    752  1.1.1.3  christos 
    753  1.1.1.6  christos         while (ArgOp)
    754  1.1.1.3  christos         {
    755  1.1.1.6  christos             if (ArgOp->Asl.ParseOpcode == PARSEOP_CONNECTION)
    756  1.1.1.3  christos             {
    757  1.1.1.3  christos                 break;
    758  1.1.1.3  christos             }
    759  1.1.1.6  christos             else if (ArgOp->Asl.ParseOpcode == PARSEOP_NAMESEG)
    760  1.1.1.3  christos             {
    761  1.1.1.6  christos                 AslError (ASL_ERROR, ASL_MSG_CONNECTION_MISSING, ArgOp, NULL);
    762  1.1.1.3  christos                 break;
    763  1.1.1.3  christos             }
    764  1.1.1.3  christos 
    765  1.1.1.6  christos             ArgOp = ArgOp->Asl.Next;
    766  1.1.1.3  christos         }
    767  1.1.1.3  christos         break;
    768  1.1.1.3  christos 
    769      1.1    jruoho     default:
    770  1.1.1.3  christos 
    771      1.1    jruoho         break;
    772      1.1    jruoho     }
    773      1.1    jruoho 
    774      1.1    jruoho     return (AE_OK);
    775      1.1    jruoho }
    776  1.1.1.6  christos 
    777  1.1.1.6  christos 
    778  1.1.1.6  christos /*******************************************************************************
    779  1.1.1.6  christos  *
    780  1.1.1.6  christos  * FUNCTION:    AnAnalyzeStoreOperator
    781  1.1.1.6  christos  *
    782  1.1.1.6  christos  * PARAMETERS:  Op                  - Store() operator
    783  1.1.1.6  christos  *
    784  1.1.1.6  christos  * RETURN:      None
    785  1.1.1.6  christos  *
    786  1.1.1.6  christos  * DESCRIPTION: Analyze a store operator. Mostly for stores to/from package
    787  1.1.1.6  christos  *              objects where there are more restrictions than other data
    788  1.1.1.6  christos  *              types.
    789  1.1.1.6  christos  *
    790  1.1.1.6  christos  ******************************************************************************/
    791  1.1.1.6  christos 
    792  1.1.1.6  christos static void
    793  1.1.1.6  christos AnAnalyzeStoreOperator (
    794  1.1.1.6  christos     ACPI_PARSE_OBJECT       *Op)
    795  1.1.1.6  christos {
    796  1.1.1.6  christos     ACPI_NAMESPACE_NODE     *SourceNode;
    797  1.1.1.6  christos     ACPI_NAMESPACE_NODE     *TargetNode;
    798  1.1.1.6  christos     ACPI_PARSE_OBJECT       *SourceOperandOp;
    799  1.1.1.6  christos     ACPI_PARSE_OBJECT       *TargetOperandOp;
    800  1.1.1.6  christos     UINT32                  SourceOperandBtype;
    801  1.1.1.6  christos     UINT32                  TargetOperandBtype;
    802  1.1.1.6  christos 
    803  1.1.1.6  christos 
    804  1.1.1.6  christos     /* Extract the two operands for STORE */
    805  1.1.1.6  christos 
    806  1.1.1.6  christos     SourceOperandOp = Op->Asl.Child;
    807  1.1.1.6  christos     TargetOperandOp = SourceOperandOp->Asl.Next;
    808  1.1.1.6  christos 
    809  1.1.1.6  christos     /*
    810  1.1.1.6  christos      * Ignore these Source operand opcodes, they cannot be typechecked,
    811  1.1.1.6  christos      * the actual result is unknown here.
    812  1.1.1.6  christos      */
    813  1.1.1.6  christos     switch (SourceOperandOp->Asl.ParseOpcode)
    814  1.1.1.6  christos     {
    815  1.1.1.6  christos     /* For these, type of the returned value is unknown at compile time */
    816  1.1.1.6  christos 
    817  1.1.1.6  christos     case PARSEOP_DEREFOF:
    818  1.1.1.6  christos     case PARSEOP_METHODCALL:
    819  1.1.1.6  christos     case PARSEOP_STORE:
    820  1.1.1.6  christos     case PARSEOP_COPYOBJECT:
    821  1.1.1.6  christos 
    822  1.1.1.6  christos         return;
    823  1.1.1.6  christos 
    824  1.1.1.6  christos     case PARSEOP_INDEX:
    825  1.1.1.6  christos     case PARSEOP_REFOF:
    826  1.1.1.6  christos 
    827  1.1.1.6  christos         if (!Gbl_EnableReferenceTypechecking)
    828  1.1.1.6  christos         {
    829  1.1.1.6  christos             return;
    830  1.1.1.6  christos         }
    831  1.1.1.6  christos 
    832  1.1.1.6  christos         /*
    833  1.1.1.6  christos          * These opcodes always return an object reference, and thus
    834  1.1.1.6  christos          * the result can only be stored to a Local, Arg, or Debug.
    835  1.1.1.6  christos          */
    836  1.1.1.6  christos         if (TargetOperandOp->Asl.AmlOpcode == AML_DEBUG_OP)
    837  1.1.1.6  christos         {
    838  1.1.1.6  christos             return;
    839  1.1.1.6  christos         }
    840  1.1.1.6  christos 
    841  1.1.1.6  christos         if ((TargetOperandOp->Asl.AmlOpcode < AML_LOCAL0) ||
    842  1.1.1.6  christos             (TargetOperandOp->Asl.AmlOpcode > AML_ARG6))
    843  1.1.1.6  christos         {
    844  1.1.1.6  christos             AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp,
    845  1.1.1.6  christos                 "Source [Reference], Target must be [Local/Arg/Debug]");
    846  1.1.1.6  christos         }
    847  1.1.1.6  christos         return;
    848  1.1.1.6  christos 
    849  1.1.1.6  christos     default:
    850  1.1.1.6  christos         break;
    851  1.1.1.6  christos     }
    852  1.1.1.6  christos 
    853  1.1.1.6  christos     /*
    854  1.1.1.6  christos      * Ignore these Target operand opcodes, they cannot be typechecked
    855  1.1.1.6  christos      */
    856  1.1.1.6  christos     switch (TargetOperandOp->Asl.ParseOpcode)
    857  1.1.1.6  christos     {
    858  1.1.1.6  christos     case PARSEOP_DEBUG:
    859  1.1.1.6  christos     case PARSEOP_DEREFOF:
    860  1.1.1.6  christos     case PARSEOP_REFOF:
    861  1.1.1.6  christos     case PARSEOP_INDEX:
    862  1.1.1.6  christos     case PARSEOP_METHODCALL:
    863  1.1.1.6  christos 
    864  1.1.1.6  christos         return;
    865  1.1.1.6  christos 
    866  1.1.1.6  christos     default:
    867  1.1.1.6  christos         break;
    868  1.1.1.6  christos     }
    869  1.1.1.6  christos 
    870  1.1.1.6  christos     /*
    871  1.1.1.6  christos      * Ignore typecheck for External() operands of type "UnknownObj",
    872  1.1.1.6  christos      * we don't know the actual type (source or target).
    873  1.1.1.6  christos      */
    874  1.1.1.6  christos     SourceNode = SourceOperandOp->Asl.Node;
    875  1.1.1.6  christos     if (SourceNode &&
    876  1.1.1.6  christos         (SourceNode->Flags & ANOBJ_IS_EXTERNAL) &&
    877  1.1.1.6  christos         (SourceNode->Type == ACPI_TYPE_ANY))
    878  1.1.1.6  christos     {
    879  1.1.1.6  christos         return;
    880  1.1.1.6  christos     }
    881  1.1.1.6  christos 
    882  1.1.1.6  christos     TargetNode = TargetOperandOp->Asl.Node;
    883  1.1.1.6  christos     if (TargetNode &&
    884  1.1.1.6  christos         (TargetNode->Flags & ANOBJ_IS_EXTERNAL) &&
    885  1.1.1.6  christos         (TargetNode->Type == ACPI_TYPE_ANY))
    886  1.1.1.6  christos     {
    887  1.1.1.6  christos         return;
    888  1.1.1.6  christos     }
    889  1.1.1.6  christos 
    890  1.1.1.6  christos     /*
    891  1.1.1.6  christos      * A NULL node with a namepath AML opcode indicates non-existent
    892  1.1.1.6  christos      * name. Just return, the error message is generated elsewhere.
    893  1.1.1.6  christos      */
    894  1.1.1.6  christos     if ((!SourceNode && (SourceOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)) ||
    895  1.1.1.6  christos         (!TargetNode && (TargetOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)))
    896  1.1.1.6  christos     {
    897  1.1.1.6  christos         return;
    898  1.1.1.6  christos     }
    899  1.1.1.6  christos 
    900  1.1.1.6  christos     /*
    901  1.1.1.6  christos      * Simple check for source same as target via NS node.
    902  1.1.1.6  christos      * -- Could be expanded to locals and args.
    903  1.1.1.6  christos      */
    904  1.1.1.6  christos     if (SourceNode && TargetNode)
    905  1.1.1.6  christos     {
    906  1.1.1.6  christos         if (SourceNode == TargetNode)
    907  1.1.1.6  christos         {
    908  1.1.1.6  christos             AslError (ASL_WARNING, ASL_MSG_DUPLICATE_ITEM,
    909  1.1.1.6  christos                 TargetOperandOp, "Source is the same as Target");
    910  1.1.1.6  christos             return;
    911  1.1.1.6  christos         }
    912  1.1.1.6  christos     }
    913  1.1.1.6  christos 
    914  1.1.1.6  christos     /* Ignore typecheck if either source or target is a local or arg */
    915  1.1.1.6  christos 
    916  1.1.1.6  christos     if ((SourceOperandOp->Asl.AmlOpcode >= AML_LOCAL0) &&
    917  1.1.1.6  christos         (SourceOperandOp->Asl.AmlOpcode <= AML_ARG6))
    918  1.1.1.6  christos     {
    919  1.1.1.6  christos         return; /* Cannot type a local/arg at compile time */
    920  1.1.1.6  christos     }
    921  1.1.1.6  christos 
    922  1.1.1.6  christos     if ((TargetOperandOp->Asl.AmlOpcode >= AML_LOCAL0) &&
    923  1.1.1.6  christos         (TargetOperandOp->Asl.AmlOpcode <= AML_ARG6))
    924  1.1.1.6  christos     {
    925  1.1.1.6  christos         return; /* Cannot type a local/arg at compile time */
    926  1.1.1.6  christos     }
    927  1.1.1.6  christos 
    928  1.1.1.6  christos     /*
    929  1.1.1.6  christos      * Package objects are a special case because they cannot by implicitly
    930  1.1.1.6  christos      * converted to/from anything. Check for these two illegal cases:
    931  1.1.1.6  christos      *
    932  1.1.1.6  christos      *      Store (non-package, package)
    933  1.1.1.6  christos      *      Store (package, non-package)
    934  1.1.1.6  christos      */
    935  1.1.1.6  christos     SourceOperandBtype = AnGetBtype (SourceOperandOp);
    936  1.1.1.6  christos     TargetOperandBtype = AnGetBtype (TargetOperandOp);
    937  1.1.1.6  christos 
    938  1.1.1.6  christos     /* Check source first for (package, non-package) case */
    939  1.1.1.6  christos 
    940  1.1.1.6  christos     if (SourceOperandBtype & ACPI_BTYPE_PACKAGE)
    941  1.1.1.6  christos     {
    942  1.1.1.6  christos         /* If Source is PACKAGE-->Target must be PACKAGE */
    943  1.1.1.6  christos 
    944  1.1.1.6  christos         if (!(TargetOperandBtype & ACPI_BTYPE_PACKAGE))
    945  1.1.1.6  christos         {
    946  1.1.1.6  christos             AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp,
    947  1.1.1.6  christos                 "Source is [Package], Target must be a package also");
    948  1.1.1.6  christos         }
    949  1.1.1.6  christos     }
    950  1.1.1.6  christos 
    951  1.1.1.6  christos     /* Else check target for (non-package, package) case */
    952  1.1.1.6  christos 
    953  1.1.1.6  christos     else if (TargetOperandBtype & ACPI_BTYPE_PACKAGE)
    954  1.1.1.6  christos     {
    955  1.1.1.6  christos         /* If Target is PACKAGE, Source must be PACKAGE */
    956  1.1.1.6  christos 
    957  1.1.1.6  christos         if (!(SourceOperandBtype & ACPI_BTYPE_PACKAGE))
    958  1.1.1.6  christos         {
    959  1.1.1.6  christos             AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, SourceOperandOp,
    960  1.1.1.6  christos                 "Target is [Package], Source must be a package also");
    961  1.1.1.6  christos         }
    962  1.1.1.6  christos     }
    963  1.1.1.6  christos }
    964