10b94ba42SJung-uk Kim /******************************************************************************
20b94ba42SJung-uk Kim  *
3efcc2a30SJung-uk Kim  * Module Name: aslwalks.c - Miscellaneous analytical parse tree walks
40b94ba42SJung-uk Kim  *
50b94ba42SJung-uk Kim  *****************************************************************************/
60b94ba42SJung-uk Kim 
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim  *
90d84335fSJung-uk Kim  * 1. Copyright Notice
100d84335fSJung-uk Kim  *
110d84335fSJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
120b94ba42SJung-uk Kim  * All rights reserved.
130b94ba42SJung-uk Kim  *
140d84335fSJung-uk Kim  * 2. License
150d84335fSJung-uk Kim  *
160d84335fSJung-uk Kim  * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim  * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim  * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim  * property rights.
200d84335fSJung-uk Kim  *
210d84335fSJung-uk Kim  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim  * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim  * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim  * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim  * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim  *
280d84335fSJung-uk Kim  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim  * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim  * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim  * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim  * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim  * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim  * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim  * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim  *
370d84335fSJung-uk Kim  * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim  * conditions are met:
390d84335fSJung-uk Kim  *
400d84335fSJung-uk Kim  * 3. Conditions
410d84335fSJung-uk Kim  *
420d84335fSJung-uk Kim  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim  * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim  * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim  * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim  * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim  * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim  * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim  * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim  * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim  * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim  *
540d84335fSJung-uk Kim  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim  * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim  * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim  * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim  * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim  * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim  * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim  * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim  * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim  * make.
650d84335fSJung-uk Kim  *
660d84335fSJung-uk Kim  * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim  * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim  * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim  * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim  * distribution.
710d84335fSJung-uk Kim  *
720d84335fSJung-uk Kim  * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim  * Intel Code.
740d84335fSJung-uk Kim  *
750d84335fSJung-uk Kim  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim  * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim  * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim  * without prior written authorization from Intel.
790d84335fSJung-uk Kim  *
800d84335fSJung-uk Kim  * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim  *
820d84335fSJung-uk Kim  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim  * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim  *
900d84335fSJung-uk Kim  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim  * LIMITED REMEDY.
980d84335fSJung-uk Kim  *
990d84335fSJung-uk Kim  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim  * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim  * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim  * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim  * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim  * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim  * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim  * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim  * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim  * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim  * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim  * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim  * such license, approval or letter.
1130d84335fSJung-uk Kim  *
1140d84335fSJung-uk Kim  *****************************************************************************
1150d84335fSJung-uk Kim  *
1160d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim  * following license:
1180d84335fSJung-uk Kim  *
1190b94ba42SJung-uk Kim  * Redistribution and use in source and binary forms, with or without
1200b94ba42SJung-uk Kim  * modification, are permitted provided that the following conditions
1210b94ba42SJung-uk Kim  * are met:
1220b94ba42SJung-uk Kim  * 1. Redistributions of source code must retain the above copyright
1230b94ba42SJung-uk Kim  *    notice, this list of conditions, and the following disclaimer,
1240b94ba42SJung-uk Kim  *    without modification.
1250b94ba42SJung-uk Kim  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1260b94ba42SJung-uk Kim  *    substantially similar to the "NO WARRANTY" disclaimer below
1270b94ba42SJung-uk Kim  *    ("Disclaimer") and any redistribution must be conditioned upon
1280b94ba42SJung-uk Kim  *    including a substantially similar Disclaimer requirement for further
1290b94ba42SJung-uk Kim  *    binary redistribution.
1300b94ba42SJung-uk Kim  * 3. Neither the names of the above-listed copyright holders nor the names
1310b94ba42SJung-uk Kim  *    of any contributors may be used to endorse or promote products derived
1320b94ba42SJung-uk Kim  *    from this software without specific prior written permission.
1330b94ba42SJung-uk Kim  *
1340d84335fSJung-uk Kim  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim  *
1460d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
1470b94ba42SJung-uk Kim  * GNU General Public License ("GPL") version 2 as published by the Free
1480b94ba42SJung-uk Kim  * Software Foundation.
1490b94ba42SJung-uk Kim  *
1500d84335fSJung-uk Kim  *****************************************************************************/
1510b94ba42SJung-uk Kim 
1520b94ba42SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h>
1530b94ba42SJung-uk Kim #include "aslcompiler.y.h"
1540b94ba42SJung-uk Kim #include <contrib/dev/acpica/include/acparser.h>
1550b94ba42SJung-uk Kim #include <contrib/dev/acpica/include/amlcode.h>
1560b94ba42SJung-uk Kim 
1570b94ba42SJung-uk Kim 
1580b94ba42SJung-uk Kim #define _COMPONENT          ACPI_COMPILER
1590b94ba42SJung-uk Kim         ACPI_MODULE_NAME    ("aslwalks")
1600b94ba42SJung-uk Kim 
1610b94ba42SJung-uk Kim 
162f8146b88SJung-uk Kim /* Local prototypes */
163f8146b88SJung-uk Kim 
164f8146b88SJung-uk Kim static void
165f8146b88SJung-uk Kim AnAnalyzeStoreOperator (
166f8146b88SJung-uk Kim     ACPI_PARSE_OBJECT       *Op);
167f8146b88SJung-uk Kim 
168f8146b88SJung-uk Kim 
1690b94ba42SJung-uk Kim /*******************************************************************************
1700b94ba42SJung-uk Kim  *
1710b94ba42SJung-uk Kim  * FUNCTION:    AnMethodTypingWalkEnd
1720b94ba42SJung-uk Kim  *
1730b94ba42SJung-uk Kim  * PARAMETERS:  ASL_WALK_CALLBACK
1740b94ba42SJung-uk Kim  *
1750b94ba42SJung-uk Kim  * RETURN:      Status
1760b94ba42SJung-uk Kim  *
1770b94ba42SJung-uk Kim  * DESCRIPTION: Ascending callback for typing walk. Complete the method
1780b94ba42SJung-uk Kim  *              return analysis. Check methods for:
1790b94ba42SJung-uk Kim  *              1) Initialized local variables
1800b94ba42SJung-uk Kim  *              2) Valid arguments
1810b94ba42SJung-uk Kim  *              3) Return types
1820b94ba42SJung-uk Kim  *
1830b94ba42SJung-uk Kim  ******************************************************************************/
1840b94ba42SJung-uk Kim 
1850b94ba42SJung-uk Kim ACPI_STATUS
1860b94ba42SJung-uk Kim AnMethodTypingWalkEnd (
1870b94ba42SJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
1880b94ba42SJung-uk Kim     UINT32                  Level,
1890b94ba42SJung-uk Kim     void                    *Context)
1900b94ba42SJung-uk Kim {
191f8146b88SJung-uk Kim     UINT32                  ThisOpBtype;
1920b94ba42SJung-uk Kim 
1930b94ba42SJung-uk Kim 
1940b94ba42SJung-uk Kim     switch (Op->Asl.ParseOpcode)
1950b94ba42SJung-uk Kim     {
1960b94ba42SJung-uk Kim     case PARSEOP_METHOD:
1970b94ba42SJung-uk Kim 
1985f9b24faSJung-uk Kim         Op->Asl.CompileFlags |= OP_METHOD_TYPED;
1990b94ba42SJung-uk Kim         break;
2000b94ba42SJung-uk Kim 
2010b94ba42SJung-uk Kim     case PARSEOP_RETURN:
2020b94ba42SJung-uk Kim 
2030b94ba42SJung-uk Kim         if ((Op->Asl.Child) &&
2040b94ba42SJung-uk Kim             (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
2050b94ba42SJung-uk Kim         {
206f8146b88SJung-uk Kim             ThisOpBtype = AnGetBtype (Op->Asl.Child);
2070b94ba42SJung-uk Kim 
2080b94ba42SJung-uk Kim             if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) &&
209f8146b88SJung-uk Kim                 (ThisOpBtype == (ACPI_UINT32_MAX -1)))
2100b94ba42SJung-uk Kim             {
2110b94ba42SJung-uk Kim                 /*
2120b94ba42SJung-uk Kim                  * The called method is untyped at this time (typically a
2130b94ba42SJung-uk Kim                  * forward reference).
2140b94ba42SJung-uk Kim                  *
215f8146b88SJung-uk Kim                  * Check for a recursive method call first. Note: the
216f8146b88SJung-uk Kim                  * Child->Node will be null if the method has not been
217f8146b88SJung-uk Kim                  * resolved.
2180b94ba42SJung-uk Kim                  */
219f8146b88SJung-uk Kim                 if (Op->Asl.Child->Asl.Node &&
220f8146b88SJung-uk Kim                     (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op))
2210b94ba42SJung-uk Kim                 {
2220b94ba42SJung-uk Kim                     /* We must type the method here */
2230b94ba42SJung-uk Kim 
2240b94ba42SJung-uk Kim                     TrWalkParseTree (Op->Asl.Child->Asl.Node->Op,
2250b94ba42SJung-uk Kim                         ASL_WALK_VISIT_UPWARD, NULL,
2260b94ba42SJung-uk Kim                         AnMethodTypingWalkEnd, NULL);
2270b94ba42SJung-uk Kim 
228f8146b88SJung-uk Kim                     ThisOpBtype = AnGetBtype (Op->Asl.Child);
2290b94ba42SJung-uk Kim                 }
2300b94ba42SJung-uk Kim             }
2310b94ba42SJung-uk Kim 
2320b94ba42SJung-uk Kim             /* Returns a value, save the value type */
2330b94ba42SJung-uk Kim 
2340b94ba42SJung-uk Kim             if (Op->Asl.ParentMethod)
2350b94ba42SJung-uk Kim             {
236f8146b88SJung-uk Kim                 Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisOpBtype;
2370b94ba42SJung-uk Kim             }
2380b94ba42SJung-uk Kim         }
2390b94ba42SJung-uk Kim         break;
2400b94ba42SJung-uk Kim 
2410b94ba42SJung-uk Kim     default:
242a9d8d09cSJung-uk Kim 
2430b94ba42SJung-uk Kim         break;
2440b94ba42SJung-uk Kim     }
2450b94ba42SJung-uk Kim 
2460b94ba42SJung-uk Kim     return (AE_OK);
2470b94ba42SJung-uk Kim }
2480b94ba42SJung-uk Kim 
2490b94ba42SJung-uk Kim 
2500b94ba42SJung-uk Kim /*******************************************************************************
2510b94ba42SJung-uk Kim  *
2520b94ba42SJung-uk Kim  * FUNCTION:    AnOperandTypecheckWalkEnd
2530b94ba42SJung-uk Kim  *
2540b94ba42SJung-uk Kim  * PARAMETERS:  ASL_WALK_CALLBACK
2550b94ba42SJung-uk Kim  *
2560b94ba42SJung-uk Kim  * RETURN:      Status
2570b94ba42SJung-uk Kim  *
2580b94ba42SJung-uk Kim  * DESCRIPTION: Ascending callback for analysis walk. Complete method
2590b94ba42SJung-uk Kim  *              return analysis.
2600b94ba42SJung-uk Kim  *
2610b94ba42SJung-uk Kim  ******************************************************************************/
2620b94ba42SJung-uk Kim 
2630b94ba42SJung-uk Kim ACPI_STATUS
2640b94ba42SJung-uk Kim AnOperandTypecheckWalkEnd (
2650b94ba42SJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
2660b94ba42SJung-uk Kim     UINT32                  Level,
2670b94ba42SJung-uk Kim     void                    *Context)
2680b94ba42SJung-uk Kim {
2690b94ba42SJung-uk Kim     const ACPI_OPCODE_INFO  *OpInfo;
2700b94ba42SJung-uk Kim     UINT32                  RuntimeArgTypes;
2710b94ba42SJung-uk Kim     UINT32                  RuntimeArgTypes2;
2720b94ba42SJung-uk Kim     UINT32                  RequiredBtypes;
2730b94ba42SJung-uk Kim     UINT32                  ThisNodeBtype;
2740b94ba42SJung-uk Kim     UINT32                  CommonBtypes;
2750b94ba42SJung-uk Kim     UINT32                  OpcodeClass;
2760b94ba42SJung-uk Kim     ACPI_PARSE_OBJECT       *ArgOp;
2770b94ba42SJung-uk Kim     UINT32                  ArgType;
2780b94ba42SJung-uk Kim 
2790b94ba42SJung-uk Kim 
2800b94ba42SJung-uk Kim     switch (Op->Asl.AmlOpcode)
2810b94ba42SJung-uk Kim     {
2820b94ba42SJung-uk Kim     case AML_RAW_DATA_BYTE:
2830b94ba42SJung-uk Kim     case AML_RAW_DATA_WORD:
2840b94ba42SJung-uk Kim     case AML_RAW_DATA_DWORD:
2850b94ba42SJung-uk Kim     case AML_RAW_DATA_QWORD:
2860b94ba42SJung-uk Kim     case AML_RAW_DATA_BUFFER:
2870b94ba42SJung-uk Kim     case AML_RAW_DATA_CHAIN:
2880b94ba42SJung-uk Kim     case AML_PACKAGE_LENGTH:
2890b94ba42SJung-uk Kim     case AML_UNASSIGNED_OPCODE:
2900b94ba42SJung-uk Kim     case AML_DEFAULT_ARG_OP:
2910b94ba42SJung-uk Kim 
2920b94ba42SJung-uk Kim         /* Ignore the internal (compiler-only) AML opcodes */
2930b94ba42SJung-uk Kim 
2940b94ba42SJung-uk Kim         return (AE_OK);
2950b94ba42SJung-uk Kim 
2960b94ba42SJung-uk Kim     default:
297a9d8d09cSJung-uk Kim 
2980b94ba42SJung-uk Kim         break;
2990b94ba42SJung-uk Kim     }
3000b94ba42SJung-uk Kim 
3010b94ba42SJung-uk Kim     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
3020b94ba42SJung-uk Kim     if (!OpInfo)
3030b94ba42SJung-uk Kim     {
3040b94ba42SJung-uk Kim         return (AE_OK);
3050b94ba42SJung-uk Kim     }
3060b94ba42SJung-uk Kim 
3070b94ba42SJung-uk Kim     ArgOp = Op->Asl.Child;
3080b94ba42SJung-uk Kim     OpcodeClass = OpInfo->Class;
309f8146b88SJung-uk Kim     RuntimeArgTypes = OpInfo->RuntimeArgs;
3100b94ba42SJung-uk Kim 
3110b94ba42SJung-uk Kim #ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE
3120b94ba42SJung-uk Kim     /*
3130b94ba42SJung-uk Kim      * Update 11/2008: In practice, we can't perform this check. A simple
3140b94ba42SJung-uk Kim      * analysis is not sufficient. Also, it can cause errors when compiling
3150b94ba42SJung-uk Kim      * disassembled code because of the way Switch operators are implemented
3160b94ba42SJung-uk Kim      * (a While(One) loop with a named temp variable created within.)
3170b94ba42SJung-uk Kim      */
3180b94ba42SJung-uk Kim 
3190b94ba42SJung-uk Kim     /*
3200b94ba42SJung-uk Kim      * If we are creating a named object, check if we are within a while loop
3210b94ba42SJung-uk Kim      * by checking if the parent is a WHILE op. This is a simple analysis, but
3220b94ba42SJung-uk Kim      * probably sufficient for many cases.
3230b94ba42SJung-uk Kim      *
3240b94ba42SJung-uk Kim      * Allow Scope(), Buffer(), and Package().
3250b94ba42SJung-uk Kim      */
3260b94ba42SJung-uk Kim     if (((OpcodeClass == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_SCOPE_OP)) ||
3270b94ba42SJung-uk Kim         ((OpcodeClass == AML_CLASS_CREATE) && (OpInfo->Flags & AML_NSNODE)))
3280b94ba42SJung-uk Kim     {
3290b94ba42SJung-uk Kim         if (Op->Asl.Parent->Asl.AmlOpcode == AML_WHILE_OP)
3300b94ba42SJung-uk Kim         {
3310b94ba42SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_NAMED_OBJECT_IN_WHILE, Op, NULL);
3320b94ba42SJung-uk Kim         }
3330b94ba42SJung-uk Kim     }
3340b94ba42SJung-uk Kim #endif
3350b94ba42SJung-uk Kim 
3360b94ba42SJung-uk Kim     /*
3370b94ba42SJung-uk Kim      * Special case for control opcodes IF/RETURN/WHILE since they
3380b94ba42SJung-uk Kim      * have no runtime arg list (at this time)
3390b94ba42SJung-uk Kim      */
3400b94ba42SJung-uk Kim     switch (Op->Asl.AmlOpcode)
3410b94ba42SJung-uk Kim     {
3420b94ba42SJung-uk Kim     case AML_IF_OP:
3430b94ba42SJung-uk Kim     case AML_WHILE_OP:
3440b94ba42SJung-uk Kim     case AML_RETURN_OP:
3450b94ba42SJung-uk Kim 
3460b94ba42SJung-uk Kim         if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
3470b94ba42SJung-uk Kim         {
3480b94ba42SJung-uk Kim             /* Check for an internal method */
3490b94ba42SJung-uk Kim 
3500b94ba42SJung-uk Kim             if (AnIsInternalMethod (ArgOp))
3510b94ba42SJung-uk Kim             {
3520b94ba42SJung-uk Kim                 return (AE_OK);
3530b94ba42SJung-uk Kim             }
3540b94ba42SJung-uk Kim 
3550b94ba42SJung-uk Kim             /* The lone arg is a method call, check it */
3560b94ba42SJung-uk Kim 
3570b94ba42SJung-uk Kim             RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER);
3580b94ba42SJung-uk Kim             if (Op->Asl.AmlOpcode == AML_RETURN_OP)
3590b94ba42SJung-uk Kim             {
3600b94ba42SJung-uk Kim                 RequiredBtypes = 0xFFFFFFFF;
3610b94ba42SJung-uk Kim             }
3620b94ba42SJung-uk Kim 
3630b94ba42SJung-uk Kim             ThisNodeBtype = AnGetBtype (ArgOp);
3640b94ba42SJung-uk Kim             if (ThisNodeBtype == ACPI_UINT32_MAX)
3650b94ba42SJung-uk Kim             {
3660b94ba42SJung-uk Kim                 return (AE_OK);
3670b94ba42SJung-uk Kim             }
368f8146b88SJung-uk Kim 
3690b94ba42SJung-uk Kim             AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
3700b94ba42SJung-uk Kim                 RequiredBtypes, ThisNodeBtype);
3710b94ba42SJung-uk Kim         }
3720b94ba42SJung-uk Kim         return (AE_OK);
3730b94ba42SJung-uk Kim 
3747cf3e94aSJung-uk Kim     case AML_EXTERNAL_OP:
3757cf3e94aSJung-uk Kim         /*
3767cf3e94aSJung-uk Kim          * Not really a "runtime" opcode since it used by disassembler only.
3777cf3e94aSJung-uk Kim          * The parser will find any issues with the operands.
3787cf3e94aSJung-uk Kim          */
3797cf3e94aSJung-uk Kim         return (AE_OK);
3807cf3e94aSJung-uk Kim 
3810b94ba42SJung-uk Kim     default:
382a9d8d09cSJung-uk Kim 
3830b94ba42SJung-uk Kim         break;
3840b94ba42SJung-uk Kim     }
3850b94ba42SJung-uk Kim 
3860b94ba42SJung-uk Kim     /* Ignore the non-executable opcodes */
3870b94ba42SJung-uk Kim 
3880b94ba42SJung-uk Kim     if (RuntimeArgTypes == ARGI_INVALID_OPCODE)
3890b94ba42SJung-uk Kim     {
3900b94ba42SJung-uk Kim         return (AE_OK);
3910b94ba42SJung-uk Kim     }
3920b94ba42SJung-uk Kim 
393f8146b88SJung-uk Kim     /*
394f8146b88SJung-uk Kim      * Special handling for certain opcodes.
395f8146b88SJung-uk Kim      */
396f8146b88SJung-uk Kim     switch (Op->Asl.AmlOpcode)
397f8146b88SJung-uk Kim     {
398f8146b88SJung-uk Kim         /* BankField has one TermArg */
399f8146b88SJung-uk Kim 
400f8146b88SJung-uk Kim     case AML_BANK_FIELD_OP:
401f8146b88SJung-uk Kim 
402f8146b88SJung-uk Kim         OpcodeClass = AML_CLASS_EXECUTE;
403f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;
404f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;
405f8146b88SJung-uk Kim         break;
406f8146b88SJung-uk Kim 
407f8146b88SJung-uk Kim         /* Operation Region has 2 TermArgs */
408f8146b88SJung-uk Kim 
409f8146b88SJung-uk Kim     case AML_REGION_OP:
410f8146b88SJung-uk Kim 
411f8146b88SJung-uk Kim         OpcodeClass = AML_CLASS_EXECUTE;
412f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;
413f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;
414f8146b88SJung-uk Kim         break;
415f8146b88SJung-uk Kim 
416f8146b88SJung-uk Kim         /* DataTableRegion has 3 TermArgs */
417f8146b88SJung-uk Kim 
418f8146b88SJung-uk Kim     case AML_DATA_REGION_OP:
419f8146b88SJung-uk Kim 
420f8146b88SJung-uk Kim         OpcodeClass = AML_CLASS_EXECUTE;
421f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;
422f8146b88SJung-uk Kim         break;
423f8146b88SJung-uk Kim 
424f8146b88SJung-uk Kim         /* Buffers/Packages have a length that is a TermArg */
425f8146b88SJung-uk Kim 
426f8146b88SJung-uk Kim     case AML_BUFFER_OP:
427f8146b88SJung-uk Kim     case AML_PACKAGE_OP:
4280d84335fSJung-uk Kim     case AML_VARIABLE_PACKAGE_OP:
429f8146b88SJung-uk Kim 
430f8146b88SJung-uk Kim             /* If length is a constant, we are done */
431f8146b88SJung-uk Kim 
432f8146b88SJung-uk Kim         if ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) ||
433f8146b88SJung-uk Kim             (ArgOp->Asl.ParseOpcode == PARSEOP_RAW_DATA))
434f8146b88SJung-uk Kim         {
435f8146b88SJung-uk Kim             return (AE_OK);
436f8146b88SJung-uk Kim         }
437f8146b88SJung-uk Kim         break;
438f8146b88SJung-uk Kim 
439f8146b88SJung-uk Kim         /* Store can write any object to the Debug object */
440f8146b88SJung-uk Kim 
441f8146b88SJung-uk Kim     case AML_STORE_OP:
442f8146b88SJung-uk Kim         /*
443f8146b88SJung-uk Kim          * If this is a Store() to the Debug object, we don't need
444f8146b88SJung-uk Kim          * to perform any further validation -- because a Store of
445f8146b88SJung-uk Kim          * any object to Debug is permitted and supported.
446f8146b88SJung-uk Kim          */
447f8146b88SJung-uk Kim         if (ArgOp->Asl.Next->Asl.AmlOpcode == AML_DEBUG_OP)
448f8146b88SJung-uk Kim         {
449f8146b88SJung-uk Kim             return (AE_OK);
450f8146b88SJung-uk Kim         }
451f8146b88SJung-uk Kim         break;
452f8146b88SJung-uk Kim 
453f8146b88SJung-uk Kim     default:
454f8146b88SJung-uk Kim         break;
455f8146b88SJung-uk Kim     }
456f8146b88SJung-uk Kim 
4570b94ba42SJung-uk Kim     switch (OpcodeClass)
4580b94ba42SJung-uk Kim     {
4590b94ba42SJung-uk Kim     case AML_CLASS_EXECUTE:
4600b94ba42SJung-uk Kim     case AML_CLASS_CREATE:
4610b94ba42SJung-uk Kim     case AML_CLASS_CONTROL:
4620b94ba42SJung-uk Kim     case AML_CLASS_RETURN_VALUE:
4630b94ba42SJung-uk Kim 
4640b94ba42SJung-uk Kim         /* Reverse the runtime argument list */
4650b94ba42SJung-uk Kim 
4660b94ba42SJung-uk Kim         RuntimeArgTypes2 = 0;
4670b94ba42SJung-uk Kim         while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes)))
4680b94ba42SJung-uk Kim         {
4690b94ba42SJung-uk Kim             RuntimeArgTypes2 <<= ARG_TYPE_WIDTH;
4700b94ba42SJung-uk Kim             RuntimeArgTypes2 |= ArgType;
4710b94ba42SJung-uk Kim             INCREMENT_ARG_LIST (RuntimeArgTypes);
4720b94ba42SJung-uk Kim         }
4730b94ba42SJung-uk Kim 
474f8146b88SJung-uk Kim         /* Typecheck each argument */
475f8146b88SJung-uk Kim 
4760b94ba42SJung-uk Kim         while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2)))
4770b94ba42SJung-uk Kim         {
478f8146b88SJung-uk Kim             /* Get the required type(s) for the argument */
479f8146b88SJung-uk Kim 
4800b94ba42SJung-uk Kim             RequiredBtypes = AnMapArgTypeToBtype (ArgType);
4810b94ba42SJung-uk Kim 
4821c0e1b6dSJung-uk Kim             if (!ArgOp)
4831c0e1b6dSJung-uk Kim             {
4841c0e1b6dSJung-uk Kim                 AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
4851c0e1b6dSJung-uk Kim                     "Null ArgOp in argument loop");
4861c0e1b6dSJung-uk Kim                 AslAbort ();
4871c0e1b6dSJung-uk Kim             }
4881c0e1b6dSJung-uk Kim 
489f8146b88SJung-uk Kim             /* Get the actual type of the argument */
490f8146b88SJung-uk Kim 
4910b94ba42SJung-uk Kim             ThisNodeBtype = AnGetBtype (ArgOp);
4920b94ba42SJung-uk Kim             if (ThisNodeBtype == ACPI_UINT32_MAX)
4930b94ba42SJung-uk Kim             {
4940b94ba42SJung-uk Kim                 goto NextArgument;
4950b94ba42SJung-uk Kim             }
4960b94ba42SJung-uk Kim 
4970b94ba42SJung-uk Kim             /* Examine the arg based on the required type of the arg */
4980b94ba42SJung-uk Kim 
4990b94ba42SJung-uk Kim             switch (ArgType)
5000b94ba42SJung-uk Kim             {
5010b94ba42SJung-uk Kim             case ARGI_TARGETREF:
5020b94ba42SJung-uk Kim 
5030b94ba42SJung-uk Kim                 if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO)
5040b94ba42SJung-uk Kim                 {
5050b94ba42SJung-uk Kim                     /* ZERO is the placeholder for "don't store result" */
5060b94ba42SJung-uk Kim 
5070b94ba42SJung-uk Kim                     ThisNodeBtype = RequiredBtypes;
5080b94ba42SJung-uk Kim                     break;
5090b94ba42SJung-uk Kim                 }
5100b94ba42SJung-uk Kim 
511f8146b88SJung-uk Kim             /* Fallthrough */
512f8146b88SJung-uk Kim 
513f8146b88SJung-uk Kim             case ARGI_STORE_TARGET:
514f8146b88SJung-uk Kim 
5150b94ba42SJung-uk Kim                 if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)
5160b94ba42SJung-uk Kim                 {
5170b94ba42SJung-uk Kim                     /*
5180b94ba42SJung-uk Kim                      * This is the case where an original reference to a resource
5190b94ba42SJung-uk Kim                      * descriptor field has been replaced by an (Integer) offset.
5200b94ba42SJung-uk Kim                      * These named fields are supported at compile-time only;
5210b94ba42SJung-uk Kim                      * the names are not passed to the interpreter (via the AML).
5220b94ba42SJung-uk Kim                      */
5230b94ba42SJung-uk Kim                     if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) ||
5240b94ba42SJung-uk Kim                         (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE))
5250b94ba42SJung-uk Kim                     {
526f8146b88SJung-uk Kim                         AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD,
527f8146b88SJung-uk Kim                             ArgOp, NULL);
5280b94ba42SJung-uk Kim                     }
5290b94ba42SJung-uk Kim                     else
5300b94ba42SJung-uk Kim                     {
531f8146b88SJung-uk Kim                         AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE,
532f8146b88SJung-uk Kim                             ArgOp, NULL);
533f8146b88SJung-uk Kim                     }
5340b94ba42SJung-uk Kim                 }
5350b94ba42SJung-uk Kim                 break;
5360b94ba42SJung-uk Kim 
5370b94ba42SJung-uk Kim 
538f8146b88SJung-uk Kim #ifdef __FUTURE_IMPLEMENTATION
539f8146b88SJung-uk Kim /*
540f8146b88SJung-uk Kim  * Possible future typechecking support
541f8146b88SJung-uk Kim  */
5420b94ba42SJung-uk Kim             case ARGI_REFERENCE:            /* References */
5430b94ba42SJung-uk Kim             case ARGI_INTEGER_REF:
5440b94ba42SJung-uk Kim             case ARGI_OBJECT_REF:
5450b94ba42SJung-uk Kim             case ARGI_DEVICE_REF:
5460b94ba42SJung-uk Kim 
5470b94ba42SJung-uk Kim                 switch (ArgOp->Asl.ParseOpcode)
5480b94ba42SJung-uk Kim                 {
5490b94ba42SJung-uk Kim                 case PARSEOP_LOCAL0:
5500b94ba42SJung-uk Kim                 case PARSEOP_LOCAL1:
5510b94ba42SJung-uk Kim                 case PARSEOP_LOCAL2:
5520b94ba42SJung-uk Kim                 case PARSEOP_LOCAL3:
5530b94ba42SJung-uk Kim                 case PARSEOP_LOCAL4:
5540b94ba42SJung-uk Kim                 case PARSEOP_LOCAL5:
5550b94ba42SJung-uk Kim                 case PARSEOP_LOCAL6:
5560b94ba42SJung-uk Kim                 case PARSEOP_LOCAL7:
5570b94ba42SJung-uk Kim 
5580b94ba42SJung-uk Kim                     /* TBD: implement analysis of current value (type) of the local */
5590b94ba42SJung-uk Kim                     /* For now, just treat any local as a typematch */
5600b94ba42SJung-uk Kim 
5610b94ba42SJung-uk Kim                     /*ThisNodeBtype = RequiredBtypes;*/
5620b94ba42SJung-uk Kim                     break;
5630b94ba42SJung-uk Kim 
5640b94ba42SJung-uk Kim                 case PARSEOP_ARG0:
5650b94ba42SJung-uk Kim                 case PARSEOP_ARG1:
5660b94ba42SJung-uk Kim                 case PARSEOP_ARG2:
5670b94ba42SJung-uk Kim                 case PARSEOP_ARG3:
5680b94ba42SJung-uk Kim                 case PARSEOP_ARG4:
5690b94ba42SJung-uk Kim                 case PARSEOP_ARG5:
5700b94ba42SJung-uk Kim                 case PARSEOP_ARG6:
5710b94ba42SJung-uk Kim 
572f8146b88SJung-uk Kim                     /* Hard to analyze argument types, so we won't */
573f8146b88SJung-uk Kim                     /* for now. Just treat any arg as a typematch */
5740b94ba42SJung-uk Kim 
5750b94ba42SJung-uk Kim                     /* ThisNodeBtype = RequiredBtypes; */
5760b94ba42SJung-uk Kim                     break;
5770b94ba42SJung-uk Kim 
5780b94ba42SJung-uk Kim                 case PARSEOP_DEBUG:
5790b94ba42SJung-uk Kim                 case PARSEOP_REFOF:
5800b94ba42SJung-uk Kim                 case PARSEOP_INDEX:
5810b94ba42SJung-uk Kim                 default:
582a9d8d09cSJung-uk Kim 
5830b94ba42SJung-uk Kim                     break;
5840b94ba42SJung-uk Kim                 }
5850b94ba42SJung-uk Kim                 break;
586f8146b88SJung-uk Kim #endif
5870b94ba42SJung-uk Kim             case ARGI_INTEGER:
5880b94ba42SJung-uk Kim             default:
589a9d8d09cSJung-uk Kim 
5900b94ba42SJung-uk Kim                 break;
5910b94ba42SJung-uk Kim             }
5920b94ba42SJung-uk Kim 
5930b94ba42SJung-uk Kim 
594f8146b88SJung-uk Kim             /* Check for a type mismatch (required versus actual) */
595f8146b88SJung-uk Kim 
5960b94ba42SJung-uk Kim             CommonBtypes = ThisNodeBtype & RequiredBtypes;
5970b94ba42SJung-uk Kim 
5980b94ba42SJung-uk Kim             if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL)
5990b94ba42SJung-uk Kim             {
6000b94ba42SJung-uk Kim                 if (AnIsInternalMethod (ArgOp))
6010b94ba42SJung-uk Kim                 {
6020b94ba42SJung-uk Kim                     return (AE_OK);
6030b94ba42SJung-uk Kim                 }
6040b94ba42SJung-uk Kim 
6050b94ba42SJung-uk Kim                 /* Check a method call for a valid return value */
6060b94ba42SJung-uk Kim 
6070b94ba42SJung-uk Kim                 AnCheckMethodReturnValue (Op, OpInfo, ArgOp,
6080b94ba42SJung-uk Kim                     RequiredBtypes, ThisNodeBtype);
6090b94ba42SJung-uk Kim             }
6100b94ba42SJung-uk Kim 
6110b94ba42SJung-uk Kim             /*
6120b94ba42SJung-uk Kim              * Now check if the actual type(s) match at least one
6130b94ba42SJung-uk Kim              * bit to the required type
6140b94ba42SJung-uk Kim              */
6150b94ba42SJung-uk Kim             else if (!CommonBtypes)
6160b94ba42SJung-uk Kim             {
6170b94ba42SJung-uk Kim                 /* No match -- this is a type mismatch error */
6180b94ba42SJung-uk Kim 
6190b94ba42SJung-uk Kim                 AnFormatBtype (StringBuffer, ThisNodeBtype);
6200b94ba42SJung-uk Kim                 AnFormatBtype (StringBuffer2, RequiredBtypes);
6210b94ba42SJung-uk Kim 
6220b94ba42SJung-uk Kim                 sprintf (MsgBuffer, "[%s] found, %s operator requires [%s]",
6230b94ba42SJung-uk Kim                     StringBuffer, OpInfo->Name, StringBuffer2);
6240b94ba42SJung-uk Kim 
625f8146b88SJung-uk Kim                 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE,
626f8146b88SJung-uk Kim                     ArgOp, MsgBuffer);
6270b94ba42SJung-uk Kim             }
6280b94ba42SJung-uk Kim 
6290b94ba42SJung-uk Kim         NextArgument:
6300b94ba42SJung-uk Kim             ArgOp = ArgOp->Asl.Next;
6310b94ba42SJung-uk Kim             INCREMENT_ARG_LIST (RuntimeArgTypes2);
6320b94ba42SJung-uk Kim         }
6330b94ba42SJung-uk Kim         break;
6340b94ba42SJung-uk Kim 
6350b94ba42SJung-uk Kim     default:
636a9d8d09cSJung-uk Kim 
6370b94ba42SJung-uk Kim         break;
6380b94ba42SJung-uk Kim     }
6390b94ba42SJung-uk Kim 
6400b94ba42SJung-uk Kim     return (AE_OK);
6410b94ba42SJung-uk Kim }
6420b94ba42SJung-uk Kim 
6430b94ba42SJung-uk Kim 
6440b94ba42SJung-uk Kim /*******************************************************************************
6450b94ba42SJung-uk Kim  *
6460b94ba42SJung-uk Kim  * FUNCTION:    AnOtherSemanticAnalysisWalkBegin
6470b94ba42SJung-uk Kim  *
6480b94ba42SJung-uk Kim  * PARAMETERS:  ASL_WALK_CALLBACK
6490b94ba42SJung-uk Kim  *
6500b94ba42SJung-uk Kim  * RETURN:      Status
6510b94ba42SJung-uk Kim  *
6520b94ba42SJung-uk Kim  * DESCRIPTION: Descending callback for the analysis walk. Checks for
6530b94ba42SJung-uk Kim  *              miscellaneous issues in the code.
6540b94ba42SJung-uk Kim  *
6550b94ba42SJung-uk Kim  ******************************************************************************/
6560b94ba42SJung-uk Kim 
6570b94ba42SJung-uk Kim ACPI_STATUS
6580b94ba42SJung-uk Kim AnOtherSemanticAnalysisWalkBegin (
6590b94ba42SJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
6600b94ba42SJung-uk Kim     UINT32                  Level,
6610b94ba42SJung-uk Kim     void                    *Context)
6620b94ba42SJung-uk Kim {
663f8146b88SJung-uk Kim     ACPI_PARSE_OBJECT       *ArgOp;
664f8146b88SJung-uk Kim     ACPI_PARSE_OBJECT       *PrevArgOp = NULL;
6650b94ba42SJung-uk Kim     const ACPI_OPCODE_INFO  *OpInfo;
6663f0275a0SJung-uk Kim     ACPI_NAMESPACE_NODE     *Node;
6670b94ba42SJung-uk Kim 
6680b94ba42SJung-uk Kim 
6690b94ba42SJung-uk Kim     OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
6700b94ba42SJung-uk Kim 
671f8146b88SJung-uk Kim 
6720b94ba42SJung-uk Kim     /*
6730b94ba42SJung-uk Kim      * Determine if an execution class operator actually does something by
6740b94ba42SJung-uk Kim      * checking if it has a target and/or the function return value is used.
6750b94ba42SJung-uk Kim      * (Target is optional, so a standalone statement can actually do nothing.)
6760b94ba42SJung-uk Kim      */
6770b94ba42SJung-uk Kim     if ((OpInfo->Class == AML_CLASS_EXECUTE) &&
6780b94ba42SJung-uk Kim         (OpInfo->Flags & AML_HAS_RETVAL) &&
6790b94ba42SJung-uk Kim         (!AnIsResultUsed (Op)))
6800b94ba42SJung-uk Kim     {
6810b94ba42SJung-uk Kim         if (OpInfo->Flags & AML_HAS_TARGET)
6820b94ba42SJung-uk Kim         {
6830b94ba42SJung-uk Kim             /*
684f8146b88SJung-uk Kim              * Find the target node, it is always the last child. If the target
6850b94ba42SJung-uk Kim              * is not specified in the ASL, a default node of type Zero was
6860b94ba42SJung-uk Kim              * created by the parser.
6870b94ba42SJung-uk Kim              */
688f8146b88SJung-uk Kim             ArgOp = Op->Asl.Child;
689f8146b88SJung-uk Kim             while (ArgOp->Asl.Next)
6900b94ba42SJung-uk Kim             {
691f8146b88SJung-uk Kim                 PrevArgOp = ArgOp;
692f8146b88SJung-uk Kim                 ArgOp = ArgOp->Asl.Next;
6930b94ba42SJung-uk Kim             }
6940b94ba42SJung-uk Kim 
6950b94ba42SJung-uk Kim             /* Divide() is the only weird case, it has two targets */
6960b94ba42SJung-uk Kim 
6970b94ba42SJung-uk Kim             if (Op->Asl.AmlOpcode == AML_DIVIDE_OP)
6980b94ba42SJung-uk Kim             {
699f8146b88SJung-uk Kim                 if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) &&
700f8146b88SJung-uk Kim                     (PrevArgOp) &&
701f8146b88SJung-uk Kim                     (PrevArgOp->Asl.ParseOpcode == PARSEOP_ZERO))
7020b94ba42SJung-uk Kim                 {
7039c7c683cSJung-uk Kim                     AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED,
7040b94ba42SJung-uk Kim                         Op, Op->Asl.ExternalName);
7050b94ba42SJung-uk Kim                 }
7060b94ba42SJung-uk Kim             }
707f8146b88SJung-uk Kim 
708f8146b88SJung-uk Kim             else if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO)
7090b94ba42SJung-uk Kim             {
7109c7c683cSJung-uk Kim                 AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED,
7110b94ba42SJung-uk Kim                     Op, Op->Asl.ExternalName);
7120b94ba42SJung-uk Kim             }
7130b94ba42SJung-uk Kim         }
7140b94ba42SJung-uk Kim         else
7150b94ba42SJung-uk Kim         {
7160b94ba42SJung-uk Kim             /*
7170b94ba42SJung-uk Kim              * Has no target and the result is not used. Only a couple opcodes
7180b94ba42SJung-uk Kim              * can have this combination.
7190b94ba42SJung-uk Kim              */
7200b94ba42SJung-uk Kim             switch (Op->Asl.ParseOpcode)
7210b94ba42SJung-uk Kim             {
7220b94ba42SJung-uk Kim             case PARSEOP_ACQUIRE:
7230b94ba42SJung-uk Kim             case PARSEOP_WAIT:
7240b94ba42SJung-uk Kim             case PARSEOP_LOADTABLE:
725a9d8d09cSJung-uk Kim 
7260b94ba42SJung-uk Kim                 break;
7270b94ba42SJung-uk Kim 
7280b94ba42SJung-uk Kim             default:
729a9d8d09cSJung-uk Kim 
7309c7c683cSJung-uk Kim                 AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED,
7310b94ba42SJung-uk Kim                     Op, Op->Asl.ExternalName);
7320b94ba42SJung-uk Kim                 break;
7330b94ba42SJung-uk Kim             }
7340b94ba42SJung-uk Kim         }
7350b94ba42SJung-uk Kim     }
7360b94ba42SJung-uk Kim 
7370b94ba42SJung-uk Kim 
7380b94ba42SJung-uk Kim     /*
7390b94ba42SJung-uk Kim      * Semantic checks for individual ASL operators
7400b94ba42SJung-uk Kim      */
7410b94ba42SJung-uk Kim     switch (Op->Asl.ParseOpcode)
7420b94ba42SJung-uk Kim     {
743f8146b88SJung-uk Kim     case PARSEOP_STORE:
744f8146b88SJung-uk Kim 
745f8146b88SJung-uk Kim         if (Gbl_DoTypechecking)
746f8146b88SJung-uk Kim         {
747f8146b88SJung-uk Kim             AnAnalyzeStoreOperator (Op);
748f8146b88SJung-uk Kim         }
749f8146b88SJung-uk Kim         break;
750f8146b88SJung-uk Kim 
751f8146b88SJung-uk Kim 
7520b94ba42SJung-uk Kim     case PARSEOP_ACQUIRE:
7530b94ba42SJung-uk Kim     case PARSEOP_WAIT:
7540b94ba42SJung-uk Kim         /*
7550b94ba42SJung-uk Kim          * Emit a warning if the timeout parameter for these operators is not
7560b94ba42SJung-uk Kim          * ACPI_WAIT_FOREVER, and the result value from the operator is not
7570b94ba42SJung-uk Kim          * checked, meaning that a timeout could happen, but the code
7580b94ba42SJung-uk Kim          * would not know about it.
7590b94ba42SJung-uk Kim          */
7600b94ba42SJung-uk Kim 
7610b94ba42SJung-uk Kim         /* First child is the namepath, 2nd child is timeout */
7620b94ba42SJung-uk Kim 
763f8146b88SJung-uk Kim         ArgOp = Op->Asl.Child;
764f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;
7650b94ba42SJung-uk Kim 
7660b94ba42SJung-uk Kim         /*
7670b94ba42SJung-uk Kim          * Check for the WAIT_FOREVER case - defined by the ACPI spec to be
7680b94ba42SJung-uk Kim          * 0xFFFF or greater
7690b94ba42SJung-uk Kim          */
770f8146b88SJung-uk Kim         if (((ArgOp->Asl.ParseOpcode == PARSEOP_WORDCONST) ||
771f8146b88SJung-uk Kim              (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER))  &&
772f8146b88SJung-uk Kim              (ArgOp->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER))
7730b94ba42SJung-uk Kim         {
7740b94ba42SJung-uk Kim             break;
7750b94ba42SJung-uk Kim         }
7760b94ba42SJung-uk Kim 
7770b94ba42SJung-uk Kim         /*
7780b94ba42SJung-uk Kim          * The operation could timeout. If the return value is not used
7790b94ba42SJung-uk Kim          * (indicates timeout occurred), issue a warning
7800b94ba42SJung-uk Kim          */
7810b94ba42SJung-uk Kim         if (!AnIsResultUsed (Op))
7820b94ba42SJung-uk Kim         {
783f8146b88SJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgOp,
7840b94ba42SJung-uk Kim                 Op->Asl.ExternalName);
7850b94ba42SJung-uk Kim         }
7860b94ba42SJung-uk Kim         break;
7870b94ba42SJung-uk Kim 
7880b94ba42SJung-uk Kim     case PARSEOP_CREATEFIELD:
7890b94ba42SJung-uk Kim         /*
7900b94ba42SJung-uk Kim          * Check for a zero Length (NumBits) operand. NumBits is the 3rd operand
7910b94ba42SJung-uk Kim          */
792f8146b88SJung-uk Kim         ArgOp = Op->Asl.Child;
793f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;
794f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;
7950b94ba42SJung-uk Kim 
796f8146b88SJung-uk Kim         if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) ||
797f8146b88SJung-uk Kim            ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) &&
798f8146b88SJung-uk Kim             (ArgOp->Asl.Value.Integer == 0)))
7990b94ba42SJung-uk Kim         {
800f8146b88SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_NON_ZERO, ArgOp, NULL);
8010b94ba42SJung-uk Kim         }
8020b94ba42SJung-uk Kim         break;
8030b94ba42SJung-uk Kim 
8043f0275a0SJung-uk Kim     case PARSEOP_CONNECTION:
8053f0275a0SJung-uk Kim         /*
8063f0275a0SJung-uk Kim          * Ensure that the referenced operation region has the correct SPACE_ID.
8073f0275a0SJung-uk Kim          * From the grammar/parser, we know the parent is a FIELD definition.
8083f0275a0SJung-uk Kim          */
809f8146b88SJung-uk Kim         ArgOp = Op->Asl.Parent;     /* Field definition */
810f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Child;   /* First child is the OpRegion Name */
811f8146b88SJung-uk Kim         Node = ArgOp->Asl.Node;     /* OpRegion namespace node */
812313a0c13SJung-uk Kim         if (!Node)
813313a0c13SJung-uk Kim         {
814313a0c13SJung-uk Kim             break;
815313a0c13SJung-uk Kim         }
8163f0275a0SJung-uk Kim 
817f8146b88SJung-uk Kim         ArgOp = Node->Op;           /* OpRegion definition */
818f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Child;   /* First child is the OpRegion Name */
819f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;    /* Next peer is the SPACE_ID (what we want) */
8203f0275a0SJung-uk Kim 
8213f0275a0SJung-uk Kim         /*
8223f0275a0SJung-uk Kim          * The Connection() operator is only valid for the following operation
8233f0275a0SJung-uk Kim          * region SpaceIds: GeneralPurposeIo and GenericSerialBus.
8243f0275a0SJung-uk Kim          */
825f8146b88SJung-uk Kim         if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) &&
826f8146b88SJung-uk Kim             (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS))
8273f0275a0SJung-uk Kim         {
8283f0275a0SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_CONNECTION_INVALID, Op, NULL);
8293f0275a0SJung-uk Kim         }
8303f0275a0SJung-uk Kim         break;
8313f0275a0SJung-uk Kim 
8323f0275a0SJung-uk Kim     case PARSEOP_FIELD:
8333f0275a0SJung-uk Kim         /*
8343f0275a0SJung-uk Kim          * Ensure that fields for GeneralPurposeIo and GenericSerialBus
8353f0275a0SJung-uk Kim          * contain at least one Connection() operator
8363f0275a0SJung-uk Kim          */
837f8146b88SJung-uk Kim         ArgOp = Op->Asl.Child;      /* 1st child is the OpRegion Name */
838f8146b88SJung-uk Kim         Node = ArgOp->Asl.Node;     /* OpRegion namespace node */
8393f0275a0SJung-uk Kim         if (!Node)
8403f0275a0SJung-uk Kim         {
8413f0275a0SJung-uk Kim             break;
8423f0275a0SJung-uk Kim         }
8433f0275a0SJung-uk Kim 
844f8146b88SJung-uk Kim         ArgOp = Node->Op;           /* OpRegion definition */
845f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Child;   /* First child is the OpRegion Name */
846f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;    /* Next peer is the SPACE_ID (what we want) */
8473f0275a0SJung-uk Kim 
8483f0275a0SJung-uk Kim         /* We are only interested in GeneralPurposeIo and GenericSerialBus */
8493f0275a0SJung-uk Kim 
850f8146b88SJung-uk Kim         if ((ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GPIO) &&
851f8146b88SJung-uk Kim             (ArgOp->Asl.Value.Integer != ACPI_ADR_SPACE_GSBUS))
8523f0275a0SJung-uk Kim         {
8533f0275a0SJung-uk Kim             break;
8543f0275a0SJung-uk Kim         }
8553f0275a0SJung-uk Kim 
856f8146b88SJung-uk Kim         ArgOp = Op->Asl.Child;      /* 1st child is the OpRegion Name */
857f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;    /* AccessType */
858f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;    /* LockRule */
859f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;    /* UpdateRule */
860f8146b88SJung-uk Kim         ArgOp = ArgOp->Asl.Next;    /* Start of FieldUnitList */
8613f0275a0SJung-uk Kim 
8623f0275a0SJung-uk Kim         /* Walk the FieldUnitList */
8633f0275a0SJung-uk Kim 
864f8146b88SJung-uk Kim         while (ArgOp)
8653f0275a0SJung-uk Kim         {
866f8146b88SJung-uk Kim             if (ArgOp->Asl.ParseOpcode == PARSEOP_CONNECTION)
8673f0275a0SJung-uk Kim             {
8683f0275a0SJung-uk Kim                 break;
8693f0275a0SJung-uk Kim             }
870f8146b88SJung-uk Kim             else if (ArgOp->Asl.ParseOpcode == PARSEOP_NAMESEG)
8713f0275a0SJung-uk Kim             {
872f8146b88SJung-uk Kim                 AslError (ASL_ERROR, ASL_MSG_CONNECTION_MISSING, ArgOp, NULL);
8733f0275a0SJung-uk Kim                 break;
8743f0275a0SJung-uk Kim             }
8753f0275a0SJung-uk Kim 
876f8146b88SJung-uk Kim             ArgOp = ArgOp->Asl.Next;
8773f0275a0SJung-uk Kim         }
8783f0275a0SJung-uk Kim         break;
8793f0275a0SJung-uk Kim 
8800b94ba42SJung-uk Kim     default:
881a9d8d09cSJung-uk Kim 
8820b94ba42SJung-uk Kim         break;
8830b94ba42SJung-uk Kim     }
8840b94ba42SJung-uk Kim 
8850b94ba42SJung-uk Kim     return (AE_OK);
8860b94ba42SJung-uk Kim }
887f8146b88SJung-uk Kim 
888f8146b88SJung-uk Kim 
889f8146b88SJung-uk Kim /*******************************************************************************
890f8146b88SJung-uk Kim  *
891f8146b88SJung-uk Kim  * FUNCTION:    AnAnalyzeStoreOperator
892f8146b88SJung-uk Kim  *
893f8146b88SJung-uk Kim  * PARAMETERS:  Op                  - Store() operator
894f8146b88SJung-uk Kim  *
895f8146b88SJung-uk Kim  * RETURN:      None
896f8146b88SJung-uk Kim  *
897f8146b88SJung-uk Kim  * DESCRIPTION: Analyze a store operator. Mostly for stores to/from package
898f8146b88SJung-uk Kim  *              objects where there are more restrictions than other data
899f8146b88SJung-uk Kim  *              types.
900f8146b88SJung-uk Kim  *
901f8146b88SJung-uk Kim  ******************************************************************************/
902f8146b88SJung-uk Kim 
903f8146b88SJung-uk Kim static void
904f8146b88SJung-uk Kim AnAnalyzeStoreOperator (
905f8146b88SJung-uk Kim     ACPI_PARSE_OBJECT       *Op)
906f8146b88SJung-uk Kim {
907f8146b88SJung-uk Kim     ACPI_NAMESPACE_NODE     *SourceNode;
908f8146b88SJung-uk Kim     ACPI_NAMESPACE_NODE     *TargetNode;
909f8146b88SJung-uk Kim     ACPI_PARSE_OBJECT       *SourceOperandOp;
910f8146b88SJung-uk Kim     ACPI_PARSE_OBJECT       *TargetOperandOp;
911f8146b88SJung-uk Kim     UINT32                  SourceOperandBtype;
912f8146b88SJung-uk Kim     UINT32                  TargetOperandBtype;
913f8146b88SJung-uk Kim 
914f8146b88SJung-uk Kim 
915f8146b88SJung-uk Kim     /* Extract the two operands for STORE */
916f8146b88SJung-uk Kim 
917f8146b88SJung-uk Kim     SourceOperandOp = Op->Asl.Child;
918f8146b88SJung-uk Kim     TargetOperandOp = SourceOperandOp->Asl.Next;
919f8146b88SJung-uk Kim 
920f8146b88SJung-uk Kim     /*
921f8146b88SJung-uk Kim      * Ignore these Source operand opcodes, they cannot be typechecked,
922f8146b88SJung-uk Kim      * the actual result is unknown here.
923f8146b88SJung-uk Kim      */
924f8146b88SJung-uk Kim     switch (SourceOperandOp->Asl.ParseOpcode)
925f8146b88SJung-uk Kim     {
926f8146b88SJung-uk Kim     /* For these, type of the returned value is unknown at compile time */
927f8146b88SJung-uk Kim 
928f8146b88SJung-uk Kim     case PARSEOP_DEREFOF:
929f8146b88SJung-uk Kim     case PARSEOP_METHODCALL:
930f8146b88SJung-uk Kim     case PARSEOP_STORE:
931f8146b88SJung-uk Kim     case PARSEOP_COPYOBJECT:
932f8146b88SJung-uk Kim 
933f8146b88SJung-uk Kim         return;
934f8146b88SJung-uk Kim 
935f8146b88SJung-uk Kim     case PARSEOP_INDEX:
936f8146b88SJung-uk Kim     case PARSEOP_REFOF:
937f8146b88SJung-uk Kim 
938f8146b88SJung-uk Kim         if (!Gbl_EnableReferenceTypechecking)
939f8146b88SJung-uk Kim         {
940f8146b88SJung-uk Kim             return;
941f8146b88SJung-uk Kim         }
942f8146b88SJung-uk Kim 
943f8146b88SJung-uk Kim         /*
944f8146b88SJung-uk Kim          * These opcodes always return an object reference, and thus
945f8146b88SJung-uk Kim          * the result can only be stored to a Local, Arg, or Debug.
946f8146b88SJung-uk Kim          */
947f8146b88SJung-uk Kim         if (TargetOperandOp->Asl.AmlOpcode == AML_DEBUG_OP)
948f8146b88SJung-uk Kim         {
949f8146b88SJung-uk Kim             return;
950f8146b88SJung-uk Kim         }
951f8146b88SJung-uk Kim 
952f8146b88SJung-uk Kim         if ((TargetOperandOp->Asl.AmlOpcode < AML_LOCAL0) ||
953f8146b88SJung-uk Kim             (TargetOperandOp->Asl.AmlOpcode > AML_ARG6))
954f8146b88SJung-uk Kim         {
955f8146b88SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp,
956f8146b88SJung-uk Kim                 "Source [Reference], Target must be [Local/Arg/Debug]");
957f8146b88SJung-uk Kim         }
958f8146b88SJung-uk Kim         return;
959f8146b88SJung-uk Kim 
960f8146b88SJung-uk Kim     default:
961f8146b88SJung-uk Kim         break;
962f8146b88SJung-uk Kim     }
963f8146b88SJung-uk Kim 
964f8146b88SJung-uk Kim     /*
965f8146b88SJung-uk Kim      * Ignore these Target operand opcodes, they cannot be typechecked
966f8146b88SJung-uk Kim      */
967f8146b88SJung-uk Kim     switch (TargetOperandOp->Asl.ParseOpcode)
968f8146b88SJung-uk Kim     {
969f8146b88SJung-uk Kim     case PARSEOP_DEBUG:
970f8146b88SJung-uk Kim     case PARSEOP_DEREFOF:
971f8146b88SJung-uk Kim     case PARSEOP_REFOF:
972f8146b88SJung-uk Kim     case PARSEOP_INDEX:
9731cc50d6bSJung-uk Kim     case PARSEOP_STORE:
974f8146b88SJung-uk Kim 
975f8146b88SJung-uk Kim         return;
976f8146b88SJung-uk Kim 
977f8146b88SJung-uk Kim     default:
978f8146b88SJung-uk Kim         break;
979f8146b88SJung-uk Kim     }
980f8146b88SJung-uk Kim 
981f8146b88SJung-uk Kim     /*
982f8146b88SJung-uk Kim      * Ignore typecheck for External() operands of type "UnknownObj",
983f8146b88SJung-uk Kim      * we don't know the actual type (source or target).
984f8146b88SJung-uk Kim      */
985f8146b88SJung-uk Kim     SourceNode = SourceOperandOp->Asl.Node;
986f8146b88SJung-uk Kim     if (SourceNode &&
987f8146b88SJung-uk Kim         (SourceNode->Flags & ANOBJ_IS_EXTERNAL) &&
988f8146b88SJung-uk Kim         (SourceNode->Type == ACPI_TYPE_ANY))
989f8146b88SJung-uk Kim     {
990f8146b88SJung-uk Kim         return;
991f8146b88SJung-uk Kim     }
992f8146b88SJung-uk Kim 
993f8146b88SJung-uk Kim     TargetNode = TargetOperandOp->Asl.Node;
994f8146b88SJung-uk Kim     if (TargetNode &&
995f8146b88SJung-uk Kim         (TargetNode->Flags & ANOBJ_IS_EXTERNAL) &&
996f8146b88SJung-uk Kim         (TargetNode->Type == ACPI_TYPE_ANY))
997f8146b88SJung-uk Kim     {
998f8146b88SJung-uk Kim         return;
999f8146b88SJung-uk Kim     }
1000f8146b88SJung-uk Kim 
1001f8146b88SJung-uk Kim     /*
1002f8146b88SJung-uk Kim      * A NULL node with a namepath AML opcode indicates non-existent
1003f8146b88SJung-uk Kim      * name. Just return, the error message is generated elsewhere.
1004f8146b88SJung-uk Kim      */
1005f8146b88SJung-uk Kim     if ((!SourceNode && (SourceOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)) ||
1006f8146b88SJung-uk Kim         (!TargetNode && (TargetOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)))
1007f8146b88SJung-uk Kim     {
1008f8146b88SJung-uk Kim         return;
1009f8146b88SJung-uk Kim     }
1010f8146b88SJung-uk Kim 
1011f8146b88SJung-uk Kim     /*
1012f8146b88SJung-uk Kim      * Simple check for source same as target via NS node.
1013f8146b88SJung-uk Kim      * -- Could be expanded to locals and args.
1014f8146b88SJung-uk Kim      */
1015f8146b88SJung-uk Kim     if (SourceNode && TargetNode)
1016f8146b88SJung-uk Kim     {
1017f8146b88SJung-uk Kim         if (SourceNode == TargetNode)
1018f8146b88SJung-uk Kim         {
1019f8146b88SJung-uk Kim             AslError (ASL_WARNING, ASL_MSG_DUPLICATE_ITEM,
1020f8146b88SJung-uk Kim                 TargetOperandOp, "Source is the same as Target");
1021f8146b88SJung-uk Kim             return;
1022f8146b88SJung-uk Kim         }
1023f8146b88SJung-uk Kim     }
1024f8146b88SJung-uk Kim 
1025f8146b88SJung-uk Kim     /* Ignore typecheck if either source or target is a local or arg */
1026f8146b88SJung-uk Kim 
1027f8146b88SJung-uk Kim     if ((SourceOperandOp->Asl.AmlOpcode >= AML_LOCAL0) &&
1028f8146b88SJung-uk Kim         (SourceOperandOp->Asl.AmlOpcode <= AML_ARG6))
1029f8146b88SJung-uk Kim     {
1030f8146b88SJung-uk Kim         return; /* Cannot type a local/arg at compile time */
1031f8146b88SJung-uk Kim     }
1032f8146b88SJung-uk Kim 
1033f8146b88SJung-uk Kim     if ((TargetOperandOp->Asl.AmlOpcode >= AML_LOCAL0) &&
1034f8146b88SJung-uk Kim         (TargetOperandOp->Asl.AmlOpcode <= AML_ARG6))
1035f8146b88SJung-uk Kim     {
1036f8146b88SJung-uk Kim         return; /* Cannot type a local/arg at compile time */
1037f8146b88SJung-uk Kim     }
1038f8146b88SJung-uk Kim 
1039f8146b88SJung-uk Kim     /*
1040f8146b88SJung-uk Kim      * Package objects are a special case because they cannot by implicitly
1041f8146b88SJung-uk Kim      * converted to/from anything. Check for these two illegal cases:
1042f8146b88SJung-uk Kim      *
1043f8146b88SJung-uk Kim      *      Store (non-package, package)
1044f8146b88SJung-uk Kim      *      Store (package, non-package)
1045f8146b88SJung-uk Kim      */
1046f8146b88SJung-uk Kim     SourceOperandBtype = AnGetBtype (SourceOperandOp);
1047f8146b88SJung-uk Kim     TargetOperandBtype = AnGetBtype (TargetOperandOp);
1048f8146b88SJung-uk Kim 
1049f8146b88SJung-uk Kim     /* Check source first for (package, non-package) case */
1050f8146b88SJung-uk Kim 
1051f8146b88SJung-uk Kim     if (SourceOperandBtype & ACPI_BTYPE_PACKAGE)
1052f8146b88SJung-uk Kim     {
1053f8146b88SJung-uk Kim         /* If Source is PACKAGE-->Target must be PACKAGE */
1054f8146b88SJung-uk Kim 
1055f8146b88SJung-uk Kim         if (!(TargetOperandBtype & ACPI_BTYPE_PACKAGE))
1056f8146b88SJung-uk Kim         {
1057f8146b88SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp,
1058f8146b88SJung-uk Kim                 "Source is [Package], Target must be a package also");
1059f8146b88SJung-uk Kim         }
1060f8146b88SJung-uk Kim     }
1061f8146b88SJung-uk Kim 
1062f8146b88SJung-uk Kim     /* Else check target for (non-package, package) case */
1063f8146b88SJung-uk Kim 
1064f8146b88SJung-uk Kim     else if (TargetOperandBtype & ACPI_BTYPE_PACKAGE)
1065f8146b88SJung-uk Kim     {
1066f8146b88SJung-uk Kim         /* If Target is PACKAGE, Source must be PACKAGE */
1067f8146b88SJung-uk Kim 
1068f8146b88SJung-uk Kim         if (!(SourceOperandBtype & ACPI_BTYPE_PACKAGE))
1069f8146b88SJung-uk Kim         {
1070f8146b88SJung-uk Kim             AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, SourceOperandOp,
1071f8146b88SJung-uk Kim                 "Target is [Package], Source must be a package also");
1072f8146b88SJung-uk Kim         }
1073f8146b88SJung-uk Kim     }
1074f8146b88SJung-uk Kim }
1075