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