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 * 11f425b8beSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2020, 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 1689ad8b64eSJung-uk Kim static BOOLEAN 1699ad8b64eSJung-uk Kim AnIsValidBufferConstant ( 1709ad8b64eSJung-uk Kim ACPI_PARSE_OBJECT *Op); 1719ad8b64eSJung-uk Kim 1729ad8b64eSJung-uk Kim static void 1739ad8b64eSJung-uk Kim AnValidateCreateBufferField ( 1749ad8b64eSJung-uk Kim ACPI_PARSE_OBJECT *CreateBufferFieldOp); 1759ad8b64eSJung-uk Kim 176f8146b88SJung-uk Kim 1770b94ba42SJung-uk Kim /******************************************************************************* 1780b94ba42SJung-uk Kim * 1790b94ba42SJung-uk Kim * FUNCTION: AnMethodTypingWalkEnd 1800b94ba42SJung-uk Kim * 1810b94ba42SJung-uk Kim * PARAMETERS: ASL_WALK_CALLBACK 1820b94ba42SJung-uk Kim * 1830b94ba42SJung-uk Kim * RETURN: Status 1840b94ba42SJung-uk Kim * 1850b94ba42SJung-uk Kim * DESCRIPTION: Ascending callback for typing walk. Complete the method 1860b94ba42SJung-uk Kim * return analysis. Check methods for: 1870b94ba42SJung-uk Kim * 1) Initialized local variables 1880b94ba42SJung-uk Kim * 2) Valid arguments 1890b94ba42SJung-uk Kim * 3) Return types 1900b94ba42SJung-uk Kim * 1910b94ba42SJung-uk Kim ******************************************************************************/ 1920b94ba42SJung-uk Kim 1930b94ba42SJung-uk Kim ACPI_STATUS 1940b94ba42SJung-uk Kim AnMethodTypingWalkEnd ( 1950b94ba42SJung-uk Kim ACPI_PARSE_OBJECT *Op, 1960b94ba42SJung-uk Kim UINT32 Level, 1970b94ba42SJung-uk Kim void *Context) 1980b94ba42SJung-uk Kim { 199f8146b88SJung-uk Kim UINT32 ThisOpBtype; 2000b94ba42SJung-uk Kim 2010b94ba42SJung-uk Kim 2020b94ba42SJung-uk Kim switch (Op->Asl.ParseOpcode) 2030b94ba42SJung-uk Kim { 2040b94ba42SJung-uk Kim case PARSEOP_METHOD: 2050b94ba42SJung-uk Kim 2065f9b24faSJung-uk Kim Op->Asl.CompileFlags |= OP_METHOD_TYPED; 2070b94ba42SJung-uk Kim break; 2080b94ba42SJung-uk Kim 2090b94ba42SJung-uk Kim case PARSEOP_RETURN: 2100b94ba42SJung-uk Kim 2110b94ba42SJung-uk Kim if ((Op->Asl.Child) && 2120b94ba42SJung-uk Kim (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)) 2130b94ba42SJung-uk Kim { 214f8146b88SJung-uk Kim ThisOpBtype = AnGetBtype (Op->Asl.Child); 2150b94ba42SJung-uk Kim 2160b94ba42SJung-uk Kim if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_METHODCALL) && 217f8146b88SJung-uk Kim (ThisOpBtype == (ACPI_UINT32_MAX -1))) 2180b94ba42SJung-uk Kim { 2190b94ba42SJung-uk Kim /* 2200b94ba42SJung-uk Kim * The called method is untyped at this time (typically a 2210b94ba42SJung-uk Kim * forward reference). 2220b94ba42SJung-uk Kim * 223f8146b88SJung-uk Kim * Check for a recursive method call first. Note: the 224f8146b88SJung-uk Kim * Child->Node will be null if the method has not been 225f8146b88SJung-uk Kim * resolved. 2260b94ba42SJung-uk Kim */ 227f8146b88SJung-uk Kim if (Op->Asl.Child->Asl.Node && 228f8146b88SJung-uk Kim (Op->Asl.ParentMethod != Op->Asl.Child->Asl.Node->Op)) 2290b94ba42SJung-uk Kim { 2300b94ba42SJung-uk Kim /* We must type the method here */ 2310b94ba42SJung-uk Kim 2320b94ba42SJung-uk Kim TrWalkParseTree (Op->Asl.Child->Asl.Node->Op, 2330b94ba42SJung-uk Kim ASL_WALK_VISIT_UPWARD, NULL, 2340b94ba42SJung-uk Kim AnMethodTypingWalkEnd, NULL); 2350b94ba42SJung-uk Kim 236f8146b88SJung-uk Kim ThisOpBtype = AnGetBtype (Op->Asl.Child); 2370b94ba42SJung-uk Kim } 2380b94ba42SJung-uk Kim } 2390b94ba42SJung-uk Kim 2400b94ba42SJung-uk Kim /* Returns a value, save the value type */ 2410b94ba42SJung-uk Kim 2420b94ba42SJung-uk Kim if (Op->Asl.ParentMethod) 2430b94ba42SJung-uk Kim { 244f8146b88SJung-uk Kim Op->Asl.ParentMethod->Asl.AcpiBtype |= ThisOpBtype; 2450b94ba42SJung-uk Kim } 2460b94ba42SJung-uk Kim } 2470b94ba42SJung-uk Kim break; 2480b94ba42SJung-uk Kim 2490b94ba42SJung-uk Kim default: 250a9d8d09cSJung-uk Kim 2510b94ba42SJung-uk Kim break; 2520b94ba42SJung-uk Kim } 2530b94ba42SJung-uk Kim 2540b94ba42SJung-uk Kim return (AE_OK); 2550b94ba42SJung-uk Kim } 2560b94ba42SJung-uk Kim 2570b94ba42SJung-uk Kim 2580b94ba42SJung-uk Kim /******************************************************************************* 2590b94ba42SJung-uk Kim * 2600b94ba42SJung-uk Kim * FUNCTION: AnOperandTypecheckWalkEnd 2610b94ba42SJung-uk Kim * 2620b94ba42SJung-uk Kim * PARAMETERS: ASL_WALK_CALLBACK 2630b94ba42SJung-uk Kim * 2640b94ba42SJung-uk Kim * RETURN: Status 2650b94ba42SJung-uk Kim * 2660b94ba42SJung-uk Kim * DESCRIPTION: Ascending callback for analysis walk. Complete method 2670b94ba42SJung-uk Kim * return analysis. 2680b94ba42SJung-uk Kim * 2690b94ba42SJung-uk Kim ******************************************************************************/ 2700b94ba42SJung-uk Kim 2710b94ba42SJung-uk Kim ACPI_STATUS 2720b94ba42SJung-uk Kim AnOperandTypecheckWalkEnd ( 2730b94ba42SJung-uk Kim ACPI_PARSE_OBJECT *Op, 2740b94ba42SJung-uk Kim UINT32 Level, 2750b94ba42SJung-uk Kim void *Context) 2760b94ba42SJung-uk Kim { 2770b94ba42SJung-uk Kim const ACPI_OPCODE_INFO *OpInfo; 2780b94ba42SJung-uk Kim UINT32 RuntimeArgTypes; 2790b94ba42SJung-uk Kim UINT32 RuntimeArgTypes2; 2800b94ba42SJung-uk Kim UINT32 RequiredBtypes; 2810b94ba42SJung-uk Kim UINT32 ThisNodeBtype; 2820b94ba42SJung-uk Kim UINT32 CommonBtypes; 2830b94ba42SJung-uk Kim UINT32 OpcodeClass; 2840b94ba42SJung-uk Kim ACPI_PARSE_OBJECT *ArgOp; 2850b94ba42SJung-uk Kim UINT32 ArgType; 2860b94ba42SJung-uk Kim 2870b94ba42SJung-uk Kim 2880b94ba42SJung-uk Kim switch (Op->Asl.AmlOpcode) 2890b94ba42SJung-uk Kim { 2900b94ba42SJung-uk Kim case AML_RAW_DATA_BYTE: 2910b94ba42SJung-uk Kim case AML_RAW_DATA_WORD: 2920b94ba42SJung-uk Kim case AML_RAW_DATA_DWORD: 2930b94ba42SJung-uk Kim case AML_RAW_DATA_QWORD: 2940b94ba42SJung-uk Kim case AML_RAW_DATA_BUFFER: 2950b94ba42SJung-uk Kim case AML_RAW_DATA_CHAIN: 2960b94ba42SJung-uk Kim case AML_PACKAGE_LENGTH: 2970b94ba42SJung-uk Kim case AML_UNASSIGNED_OPCODE: 2980b94ba42SJung-uk Kim case AML_DEFAULT_ARG_OP: 2990b94ba42SJung-uk Kim 3000b94ba42SJung-uk Kim /* Ignore the internal (compiler-only) AML opcodes */ 3010b94ba42SJung-uk Kim 3020b94ba42SJung-uk Kim return (AE_OK); 3030b94ba42SJung-uk Kim 3040b94ba42SJung-uk Kim default: 305a9d8d09cSJung-uk Kim 3060b94ba42SJung-uk Kim break; 3070b94ba42SJung-uk Kim } 3080b94ba42SJung-uk Kim 3090b94ba42SJung-uk Kim OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); 3100b94ba42SJung-uk Kim if (!OpInfo) 3110b94ba42SJung-uk Kim { 3120b94ba42SJung-uk Kim return (AE_OK); 3130b94ba42SJung-uk Kim } 3140b94ba42SJung-uk Kim 3150b94ba42SJung-uk Kim ArgOp = Op->Asl.Child; 3160b94ba42SJung-uk Kim OpcodeClass = OpInfo->Class; 317f8146b88SJung-uk Kim RuntimeArgTypes = OpInfo->RuntimeArgs; 3180b94ba42SJung-uk Kim 3190b94ba42SJung-uk Kim #ifdef ASL_ERROR_NAMED_OBJECT_IN_WHILE 3200b94ba42SJung-uk Kim /* 3210b94ba42SJung-uk Kim * Update 11/2008: In practice, we can't perform this check. A simple 3220b94ba42SJung-uk Kim * analysis is not sufficient. Also, it can cause errors when compiling 3230b94ba42SJung-uk Kim * disassembled code because of the way Switch operators are implemented 3240b94ba42SJung-uk Kim * (a While(One) loop with a named temp variable created within.) 3250b94ba42SJung-uk Kim */ 3260b94ba42SJung-uk Kim 3270b94ba42SJung-uk Kim /* 3280b94ba42SJung-uk Kim * If we are creating a named object, check if we are within a while loop 3290b94ba42SJung-uk Kim * by checking if the parent is a WHILE op. This is a simple analysis, but 3300b94ba42SJung-uk Kim * probably sufficient for many cases. 3310b94ba42SJung-uk Kim * 3320b94ba42SJung-uk Kim * Allow Scope(), Buffer(), and Package(). 3330b94ba42SJung-uk Kim */ 3340b94ba42SJung-uk Kim if (((OpcodeClass == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_SCOPE_OP)) || 3350b94ba42SJung-uk Kim ((OpcodeClass == AML_CLASS_CREATE) && (OpInfo->Flags & AML_NSNODE))) 3360b94ba42SJung-uk Kim { 3370b94ba42SJung-uk Kim if (Op->Asl.Parent->Asl.AmlOpcode == AML_WHILE_OP) 3380b94ba42SJung-uk Kim { 3390b94ba42SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NAMED_OBJECT_IN_WHILE, Op, NULL); 3400b94ba42SJung-uk Kim } 3410b94ba42SJung-uk Kim } 3420b94ba42SJung-uk Kim #endif 3430b94ba42SJung-uk Kim 3440b94ba42SJung-uk Kim /* 3450b94ba42SJung-uk Kim * Special case for control opcodes IF/RETURN/WHILE since they 3460b94ba42SJung-uk Kim * have no runtime arg list (at this time) 3470b94ba42SJung-uk Kim */ 3480b94ba42SJung-uk Kim switch (Op->Asl.AmlOpcode) 3490b94ba42SJung-uk Kim { 3500b94ba42SJung-uk Kim case AML_IF_OP: 3510b94ba42SJung-uk Kim case AML_WHILE_OP: 3520b94ba42SJung-uk Kim case AML_RETURN_OP: 3530b94ba42SJung-uk Kim 3540b94ba42SJung-uk Kim if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) 3550b94ba42SJung-uk Kim { 3560b94ba42SJung-uk Kim /* Check for an internal method */ 3570b94ba42SJung-uk Kim 3580b94ba42SJung-uk Kim if (AnIsInternalMethod (ArgOp)) 3590b94ba42SJung-uk Kim { 3600b94ba42SJung-uk Kim return (AE_OK); 3610b94ba42SJung-uk Kim } 3620b94ba42SJung-uk Kim 3630b94ba42SJung-uk Kim /* The lone arg is a method call, check it */ 3640b94ba42SJung-uk Kim 3650b94ba42SJung-uk Kim RequiredBtypes = AnMapArgTypeToBtype (ARGI_INTEGER); 3660b94ba42SJung-uk Kim if (Op->Asl.AmlOpcode == AML_RETURN_OP) 3670b94ba42SJung-uk Kim { 3680b94ba42SJung-uk Kim RequiredBtypes = 0xFFFFFFFF; 3690b94ba42SJung-uk Kim } 3700b94ba42SJung-uk Kim 3710b94ba42SJung-uk Kim ThisNodeBtype = AnGetBtype (ArgOp); 3720b94ba42SJung-uk Kim if (ThisNodeBtype == ACPI_UINT32_MAX) 3730b94ba42SJung-uk Kim { 3740b94ba42SJung-uk Kim return (AE_OK); 3750b94ba42SJung-uk Kim } 376f8146b88SJung-uk Kim 3770b94ba42SJung-uk Kim AnCheckMethodReturnValue (Op, OpInfo, ArgOp, 3780b94ba42SJung-uk Kim RequiredBtypes, ThisNodeBtype); 3790b94ba42SJung-uk Kim } 3800b94ba42SJung-uk Kim return (AE_OK); 3810b94ba42SJung-uk Kim 3827cf3e94aSJung-uk Kim case AML_EXTERNAL_OP: 3837cf3e94aSJung-uk Kim /* 3847cf3e94aSJung-uk Kim * Not really a "runtime" opcode since it used by disassembler only. 3857cf3e94aSJung-uk Kim * The parser will find any issues with the operands. 3867cf3e94aSJung-uk Kim */ 3877cf3e94aSJung-uk Kim return (AE_OK); 3887cf3e94aSJung-uk Kim 3890b94ba42SJung-uk Kim default: 390a9d8d09cSJung-uk Kim 3910b94ba42SJung-uk Kim break; 3920b94ba42SJung-uk Kim } 3930b94ba42SJung-uk Kim 3940b94ba42SJung-uk Kim /* Ignore the non-executable opcodes */ 3950b94ba42SJung-uk Kim 3960b94ba42SJung-uk Kim if (RuntimeArgTypes == ARGI_INVALID_OPCODE) 3970b94ba42SJung-uk Kim { 3980b94ba42SJung-uk Kim return (AE_OK); 3990b94ba42SJung-uk Kim } 4000b94ba42SJung-uk Kim 401f8146b88SJung-uk Kim /* 402f8146b88SJung-uk Kim * Special handling for certain opcodes. 403f8146b88SJung-uk Kim */ 404f8146b88SJung-uk Kim switch (Op->Asl.AmlOpcode) 405f8146b88SJung-uk Kim { 406f8146b88SJung-uk Kim /* BankField has one TermArg */ 407f8146b88SJung-uk Kim 408f8146b88SJung-uk Kim case AML_BANK_FIELD_OP: 409f8146b88SJung-uk Kim 410f8146b88SJung-uk Kim OpcodeClass = AML_CLASS_EXECUTE; 411f8146b88SJung-uk Kim ArgOp = ArgOp->Asl.Next; 412f8146b88SJung-uk Kim ArgOp = ArgOp->Asl.Next; 413f8146b88SJung-uk Kim break; 414f8146b88SJung-uk Kim 415f8146b88SJung-uk Kim /* Operation Region has 2 TermArgs */ 416f8146b88SJung-uk Kim 417f8146b88SJung-uk Kim case AML_REGION_OP: 418f8146b88SJung-uk Kim 419f8146b88SJung-uk Kim OpcodeClass = AML_CLASS_EXECUTE; 420f8146b88SJung-uk Kim ArgOp = ArgOp->Asl.Next; 421f8146b88SJung-uk Kim ArgOp = ArgOp->Asl.Next; 422f8146b88SJung-uk Kim break; 423f8146b88SJung-uk Kim 424f8146b88SJung-uk Kim /* DataTableRegion has 3 TermArgs */ 425f8146b88SJung-uk Kim 426f8146b88SJung-uk Kim case AML_DATA_REGION_OP: 427f8146b88SJung-uk Kim 428f8146b88SJung-uk Kim OpcodeClass = AML_CLASS_EXECUTE; 429f8146b88SJung-uk Kim ArgOp = ArgOp->Asl.Next; 430f8146b88SJung-uk Kim break; 431f8146b88SJung-uk Kim 432f8146b88SJung-uk Kim /* Buffers/Packages have a length that is a TermArg */ 433f8146b88SJung-uk Kim 434f8146b88SJung-uk Kim case AML_BUFFER_OP: 435f8146b88SJung-uk Kim case AML_PACKAGE_OP: 4360d84335fSJung-uk Kim case AML_VARIABLE_PACKAGE_OP: 437f8146b88SJung-uk Kim 438f8146b88SJung-uk Kim /* If length is a constant, we are done */ 439f8146b88SJung-uk Kim 440f8146b88SJung-uk Kim if ((ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) || 441f8146b88SJung-uk Kim (ArgOp->Asl.ParseOpcode == PARSEOP_RAW_DATA)) 442f8146b88SJung-uk Kim { 443f8146b88SJung-uk Kim return (AE_OK); 444f8146b88SJung-uk Kim } 445f8146b88SJung-uk Kim break; 446f8146b88SJung-uk Kim 447f8146b88SJung-uk Kim /* Store can write any object to the Debug object */ 448f8146b88SJung-uk Kim 449f8146b88SJung-uk Kim case AML_STORE_OP: 450f8146b88SJung-uk Kim /* 451f8146b88SJung-uk Kim * If this is a Store() to the Debug object, we don't need 452f8146b88SJung-uk Kim * to perform any further validation -- because a Store of 453f8146b88SJung-uk Kim * any object to Debug is permitted and supported. 454f8146b88SJung-uk Kim */ 455f8146b88SJung-uk Kim if (ArgOp->Asl.Next->Asl.AmlOpcode == AML_DEBUG_OP) 456f8146b88SJung-uk Kim { 457f8146b88SJung-uk Kim return (AE_OK); 458f8146b88SJung-uk Kim } 459f8146b88SJung-uk Kim break; 460f8146b88SJung-uk Kim 461f8146b88SJung-uk Kim default: 462f8146b88SJung-uk Kim break; 463f8146b88SJung-uk Kim } 464f8146b88SJung-uk Kim 4650b94ba42SJung-uk Kim switch (OpcodeClass) 4660b94ba42SJung-uk Kim { 4670b94ba42SJung-uk Kim case AML_CLASS_EXECUTE: 4680b94ba42SJung-uk Kim case AML_CLASS_CREATE: 4690b94ba42SJung-uk Kim case AML_CLASS_CONTROL: 4700b94ba42SJung-uk Kim case AML_CLASS_RETURN_VALUE: 4710b94ba42SJung-uk Kim 4720b94ba42SJung-uk Kim /* Reverse the runtime argument list */ 4730b94ba42SJung-uk Kim 4740b94ba42SJung-uk Kim RuntimeArgTypes2 = 0; 4750b94ba42SJung-uk Kim while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes))) 4760b94ba42SJung-uk Kim { 4770b94ba42SJung-uk Kim RuntimeArgTypes2 <<= ARG_TYPE_WIDTH; 4780b94ba42SJung-uk Kim RuntimeArgTypes2 |= ArgType; 4790b94ba42SJung-uk Kim INCREMENT_ARG_LIST (RuntimeArgTypes); 4800b94ba42SJung-uk Kim } 4810b94ba42SJung-uk Kim 482f8146b88SJung-uk Kim /* Typecheck each argument */ 483f8146b88SJung-uk Kim 4840b94ba42SJung-uk Kim while ((ArgType = GET_CURRENT_ARG_TYPE (RuntimeArgTypes2))) 4850b94ba42SJung-uk Kim { 486f8146b88SJung-uk Kim /* Get the required type(s) for the argument */ 487f8146b88SJung-uk Kim 4880b94ba42SJung-uk Kim RequiredBtypes = AnMapArgTypeToBtype (ArgType); 4890b94ba42SJung-uk Kim 4901c0e1b6dSJung-uk Kim if (!ArgOp) 4911c0e1b6dSJung-uk Kim { 4921c0e1b6dSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, 4931c0e1b6dSJung-uk Kim "Null ArgOp in argument loop"); 4941c0e1b6dSJung-uk Kim AslAbort (); 4951c0e1b6dSJung-uk Kim } 4961c0e1b6dSJung-uk Kim 497f8146b88SJung-uk Kim /* Get the actual type of the argument */ 498f8146b88SJung-uk Kim 4990b94ba42SJung-uk Kim ThisNodeBtype = AnGetBtype (ArgOp); 5000b94ba42SJung-uk Kim if (ThisNodeBtype == ACPI_UINT32_MAX) 5010b94ba42SJung-uk Kim { 5020b94ba42SJung-uk Kim goto NextArgument; 5030b94ba42SJung-uk Kim } 5040b94ba42SJung-uk Kim 5050b94ba42SJung-uk Kim /* Examine the arg based on the required type of the arg */ 5060b94ba42SJung-uk Kim 5070b94ba42SJung-uk Kim switch (ArgType) 5080b94ba42SJung-uk Kim { 5090b94ba42SJung-uk Kim case ARGI_TARGETREF: 5100b94ba42SJung-uk Kim 5110b94ba42SJung-uk Kim if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) 5120b94ba42SJung-uk Kim { 5130b94ba42SJung-uk Kim /* ZERO is the placeholder for "don't store result" */ 5140b94ba42SJung-uk Kim 5150b94ba42SJung-uk Kim ThisNodeBtype = RequiredBtypes; 5160b94ba42SJung-uk Kim break; 5170b94ba42SJung-uk Kim } 5180b94ba42SJung-uk Kim 519385fb5d9SJung-uk Kim ACPI_FALLTHROUGH; 520f8146b88SJung-uk Kim 521f8146b88SJung-uk Kim case ARGI_STORE_TARGET: 522f8146b88SJung-uk Kim 5230b94ba42SJung-uk Kim if (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER) 5240b94ba42SJung-uk Kim { 5250b94ba42SJung-uk Kim /* 5260b94ba42SJung-uk Kim * This is the case where an original reference to a resource 5270b94ba42SJung-uk Kim * descriptor field has been replaced by an (Integer) offset. 5280b94ba42SJung-uk Kim * These named fields are supported at compile-time only; 5290b94ba42SJung-uk Kim * the names are not passed to the interpreter (via the AML). 5300b94ba42SJung-uk Kim */ 5310b94ba42SJung-uk Kim if ((ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE_FIELD) || 5320b94ba42SJung-uk Kim (ArgOp->Asl.Node->Type == ACPI_TYPE_LOCAL_RESOURCE)) 5330b94ba42SJung-uk Kim { 534f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESOURCE_FIELD, 535f8146b88SJung-uk Kim ArgOp, NULL); 5360b94ba42SJung-uk Kim } 5370b94ba42SJung-uk Kim else 5380b94ba42SJung-uk Kim { 539f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, 540f8146b88SJung-uk Kim ArgOp, NULL); 541f8146b88SJung-uk Kim } 5420b94ba42SJung-uk Kim } 5430b94ba42SJung-uk Kim break; 5440b94ba42SJung-uk Kim 5450b94ba42SJung-uk Kim 546f8146b88SJung-uk Kim #ifdef __FUTURE_IMPLEMENTATION 547f8146b88SJung-uk Kim /* 548f8146b88SJung-uk Kim * Possible future typechecking support 549f8146b88SJung-uk Kim */ 5500b94ba42SJung-uk Kim case ARGI_REFERENCE: /* References */ 5510b94ba42SJung-uk Kim case ARGI_INTEGER_REF: 5520b94ba42SJung-uk Kim case ARGI_OBJECT_REF: 5530b94ba42SJung-uk Kim case ARGI_DEVICE_REF: 5540b94ba42SJung-uk Kim 5550b94ba42SJung-uk Kim switch (ArgOp->Asl.ParseOpcode) 5560b94ba42SJung-uk Kim { 5570b94ba42SJung-uk Kim case PARSEOP_LOCAL0: 5580b94ba42SJung-uk Kim case PARSEOP_LOCAL1: 5590b94ba42SJung-uk Kim case PARSEOP_LOCAL2: 5600b94ba42SJung-uk Kim case PARSEOP_LOCAL3: 5610b94ba42SJung-uk Kim case PARSEOP_LOCAL4: 5620b94ba42SJung-uk Kim case PARSEOP_LOCAL5: 5630b94ba42SJung-uk Kim case PARSEOP_LOCAL6: 5640b94ba42SJung-uk Kim case PARSEOP_LOCAL7: 5650b94ba42SJung-uk Kim 5660b94ba42SJung-uk Kim /* TBD: implement analysis of current value (type) of the local */ 5670b94ba42SJung-uk Kim /* For now, just treat any local as a typematch */ 5680b94ba42SJung-uk Kim 5690b94ba42SJung-uk Kim /*ThisNodeBtype = RequiredBtypes;*/ 5700b94ba42SJung-uk Kim break; 5710b94ba42SJung-uk Kim 5720b94ba42SJung-uk Kim case PARSEOP_ARG0: 5730b94ba42SJung-uk Kim case PARSEOP_ARG1: 5740b94ba42SJung-uk Kim case PARSEOP_ARG2: 5750b94ba42SJung-uk Kim case PARSEOP_ARG3: 5760b94ba42SJung-uk Kim case PARSEOP_ARG4: 5770b94ba42SJung-uk Kim case PARSEOP_ARG5: 5780b94ba42SJung-uk Kim case PARSEOP_ARG6: 5790b94ba42SJung-uk Kim 580f8146b88SJung-uk Kim /* Hard to analyze argument types, so we won't */ 581f8146b88SJung-uk Kim /* for now. Just treat any arg as a typematch */ 5820b94ba42SJung-uk Kim 5830b94ba42SJung-uk Kim /* ThisNodeBtype = RequiredBtypes; */ 5840b94ba42SJung-uk Kim break; 5850b94ba42SJung-uk Kim 5860b94ba42SJung-uk Kim case PARSEOP_DEBUG: 5870b94ba42SJung-uk Kim case PARSEOP_REFOF: 5880b94ba42SJung-uk Kim case PARSEOP_INDEX: 5890b94ba42SJung-uk Kim default: 590a9d8d09cSJung-uk Kim 5910b94ba42SJung-uk Kim break; 5920b94ba42SJung-uk Kim } 5930b94ba42SJung-uk Kim break; 594f8146b88SJung-uk Kim #endif 5950b94ba42SJung-uk Kim case ARGI_INTEGER: 5960b94ba42SJung-uk Kim default: 597a9d8d09cSJung-uk Kim 5980b94ba42SJung-uk Kim break; 5990b94ba42SJung-uk Kim } 6000b94ba42SJung-uk Kim 6010b94ba42SJung-uk Kim 602f8146b88SJung-uk Kim /* Check for a type mismatch (required versus actual) */ 603f8146b88SJung-uk Kim 6040b94ba42SJung-uk Kim CommonBtypes = ThisNodeBtype & RequiredBtypes; 6050b94ba42SJung-uk Kim 6060b94ba42SJung-uk Kim if (ArgOp->Asl.ParseOpcode == PARSEOP_METHODCALL) 6070b94ba42SJung-uk Kim { 6080b94ba42SJung-uk Kim if (AnIsInternalMethod (ArgOp)) 6090b94ba42SJung-uk Kim { 6100b94ba42SJung-uk Kim return (AE_OK); 6110b94ba42SJung-uk Kim } 6120b94ba42SJung-uk Kim 6130b94ba42SJung-uk Kim /* Check a method call for a valid return value */ 6140b94ba42SJung-uk Kim 6150b94ba42SJung-uk Kim AnCheckMethodReturnValue (Op, OpInfo, ArgOp, 6160b94ba42SJung-uk Kim RequiredBtypes, ThisNodeBtype); 6170b94ba42SJung-uk Kim } 6180b94ba42SJung-uk Kim 6190b94ba42SJung-uk Kim /* 6200b94ba42SJung-uk Kim * Now check if the actual type(s) match at least one 6210b94ba42SJung-uk Kim * bit to the required type 6220b94ba42SJung-uk Kim */ 6230b94ba42SJung-uk Kim else if (!CommonBtypes) 6240b94ba42SJung-uk Kim { 6250b94ba42SJung-uk Kim /* No match -- this is a type mismatch error */ 6260b94ba42SJung-uk Kim 6276f1f1a63SJung-uk Kim AnFormatBtype (AslGbl_StringBuffer, ThisNodeBtype); 6286f1f1a63SJung-uk Kim AnFormatBtype (AslGbl_StringBuffer2, RequiredBtypes); 6290b94ba42SJung-uk Kim 6306f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "[%s] found, %s operator requires [%s]", 6316f1f1a63SJung-uk Kim AslGbl_StringBuffer, OpInfo->Name, AslGbl_StringBuffer2); 6320b94ba42SJung-uk Kim 633f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, 6346f1f1a63SJung-uk Kim ArgOp, AslGbl_MsgBuffer); 6350b94ba42SJung-uk Kim } 6360b94ba42SJung-uk Kim 6370b94ba42SJung-uk Kim NextArgument: 6380b94ba42SJung-uk Kim ArgOp = ArgOp->Asl.Next; 6390b94ba42SJung-uk Kim INCREMENT_ARG_LIST (RuntimeArgTypes2); 6400b94ba42SJung-uk Kim } 6410b94ba42SJung-uk Kim break; 6420b94ba42SJung-uk Kim 6430b94ba42SJung-uk Kim default: 644a9d8d09cSJung-uk Kim 6450b94ba42SJung-uk Kim break; 6460b94ba42SJung-uk Kim } 6470b94ba42SJung-uk Kim 6480b94ba42SJung-uk Kim return (AE_OK); 6490b94ba42SJung-uk Kim } 6500b94ba42SJung-uk Kim 6510b94ba42SJung-uk Kim 6520b94ba42SJung-uk Kim /******************************************************************************* 6530b94ba42SJung-uk Kim * 6540b94ba42SJung-uk Kim * FUNCTION: AnOtherSemanticAnalysisWalkBegin 6550b94ba42SJung-uk Kim * 6560b94ba42SJung-uk Kim * PARAMETERS: ASL_WALK_CALLBACK 6570b94ba42SJung-uk Kim * 6580b94ba42SJung-uk Kim * RETURN: Status 6590b94ba42SJung-uk Kim * 6600b94ba42SJung-uk Kim * DESCRIPTION: Descending callback for the analysis walk. Checks for 6610b94ba42SJung-uk Kim * miscellaneous issues in the code. 6620b94ba42SJung-uk Kim * 6630b94ba42SJung-uk Kim ******************************************************************************/ 6640b94ba42SJung-uk Kim 6650b94ba42SJung-uk Kim ACPI_STATUS 6660b94ba42SJung-uk Kim AnOtherSemanticAnalysisWalkBegin ( 6670b94ba42SJung-uk Kim ACPI_PARSE_OBJECT *Op, 6680b94ba42SJung-uk Kim UINT32 Level, 6690b94ba42SJung-uk Kim void *Context) 6700b94ba42SJung-uk Kim { 671f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *ArgOp; 672f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *PrevArgOp = NULL; 6730b94ba42SJung-uk Kim const ACPI_OPCODE_INFO *OpInfo; 6743f0275a0SJung-uk Kim ACPI_NAMESPACE_NODE *Node; 6750b94ba42SJung-uk Kim 6760b94ba42SJung-uk Kim 6770b94ba42SJung-uk Kim OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); 6780b94ba42SJung-uk Kim 679f8146b88SJung-uk Kim 6809ad8b64eSJung-uk Kim if (OpInfo->Flags & AML_CREATE) 6819ad8b64eSJung-uk Kim { 6829ad8b64eSJung-uk Kim /* This group contains all of the Create Buffer Field operators */ 6839ad8b64eSJung-uk Kim 6849ad8b64eSJung-uk Kim AnValidateCreateBufferField (Op); 6859ad8b64eSJung-uk Kim return (AE_OK); 6869ad8b64eSJung-uk Kim } 6879ad8b64eSJung-uk Kim 6880b94ba42SJung-uk Kim /* 6890b94ba42SJung-uk Kim * Determine if an execution class operator actually does something by 6900b94ba42SJung-uk Kim * checking if it has a target and/or the function return value is used. 6910b94ba42SJung-uk Kim * (Target is optional, so a standalone statement can actually do nothing.) 6920b94ba42SJung-uk Kim */ 6930b94ba42SJung-uk Kim if ((OpInfo->Class == AML_CLASS_EXECUTE) && 6940b94ba42SJung-uk Kim (OpInfo->Flags & AML_HAS_RETVAL) && 6950b94ba42SJung-uk Kim (!AnIsResultUsed (Op))) 6960b94ba42SJung-uk Kim { 6970b94ba42SJung-uk Kim if (OpInfo->Flags & AML_HAS_TARGET) 6980b94ba42SJung-uk Kim { 6990b94ba42SJung-uk Kim /* 700f8146b88SJung-uk Kim * Find the target node, it is always the last child. If the target 7010b94ba42SJung-uk Kim * is not specified in the ASL, a default node of type Zero was 7020b94ba42SJung-uk Kim * created by the parser. 7030b94ba42SJung-uk Kim */ 704f8146b88SJung-uk Kim ArgOp = Op->Asl.Child; 705f8146b88SJung-uk Kim while (ArgOp->Asl.Next) 7060b94ba42SJung-uk Kim { 707f8146b88SJung-uk Kim PrevArgOp = ArgOp; 708f8146b88SJung-uk Kim ArgOp = ArgOp->Asl.Next; 7090b94ba42SJung-uk Kim } 7100b94ba42SJung-uk Kim 7110b94ba42SJung-uk Kim /* Divide() is the only weird case, it has two targets */ 7120b94ba42SJung-uk Kim 7130b94ba42SJung-uk Kim if (Op->Asl.AmlOpcode == AML_DIVIDE_OP) 7140b94ba42SJung-uk Kim { 715f8146b88SJung-uk Kim if ((ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) && 716f8146b88SJung-uk Kim (PrevArgOp) && 717f8146b88SJung-uk Kim (PrevArgOp->Asl.ParseOpcode == PARSEOP_ZERO)) 7180b94ba42SJung-uk Kim { 7199c7c683cSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, 7200b94ba42SJung-uk Kim Op, Op->Asl.ExternalName); 7210b94ba42SJung-uk Kim } 7220b94ba42SJung-uk Kim } 723f8146b88SJung-uk Kim 724f8146b88SJung-uk Kim else if (ArgOp->Asl.ParseOpcode == PARSEOP_ZERO) 7250b94ba42SJung-uk Kim { 7269c7c683cSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, 7270b94ba42SJung-uk Kim Op, Op->Asl.ExternalName); 7280b94ba42SJung-uk Kim } 7290b94ba42SJung-uk Kim } 7300b94ba42SJung-uk Kim else 7310b94ba42SJung-uk Kim { 7320b94ba42SJung-uk Kim /* 7330b94ba42SJung-uk Kim * Has no target and the result is not used. Only a couple opcodes 7340b94ba42SJung-uk Kim * can have this combination. 7350b94ba42SJung-uk Kim */ 7360b94ba42SJung-uk Kim switch (Op->Asl.ParseOpcode) 7370b94ba42SJung-uk Kim { 7380b94ba42SJung-uk Kim case PARSEOP_ACQUIRE: 7390b94ba42SJung-uk Kim case PARSEOP_WAIT: 7400b94ba42SJung-uk Kim case PARSEOP_LOADTABLE: 741a9d8d09cSJung-uk Kim 7420b94ba42SJung-uk Kim break; 7430b94ba42SJung-uk Kim 7440b94ba42SJung-uk Kim default: 745a9d8d09cSJung-uk Kim 7469c7c683cSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESULT_NOT_USED, 7470b94ba42SJung-uk Kim Op, Op->Asl.ExternalName); 7480b94ba42SJung-uk Kim break; 7490b94ba42SJung-uk Kim } 7500b94ba42SJung-uk Kim } 7510b94ba42SJung-uk Kim } 7520b94ba42SJung-uk Kim 7530b94ba42SJung-uk Kim /* 7540b94ba42SJung-uk Kim * Semantic checks for individual ASL operators 7550b94ba42SJung-uk Kim */ 7569ad8b64eSJung-uk Kim 7570b94ba42SJung-uk Kim switch (Op->Asl.ParseOpcode) 7580b94ba42SJung-uk Kim { 759f8146b88SJung-uk Kim case PARSEOP_STORE: 760f8146b88SJung-uk Kim 7616f1f1a63SJung-uk Kim if (AslGbl_DoTypechecking) 762f8146b88SJung-uk Kim { 763f8146b88SJung-uk Kim AnAnalyzeStoreOperator (Op); 764f8146b88SJung-uk Kim } 765f8146b88SJung-uk Kim break; 766f8146b88SJung-uk Kim 767f8146b88SJung-uk Kim 7680b94ba42SJung-uk Kim case PARSEOP_ACQUIRE: 7690b94ba42SJung-uk Kim case PARSEOP_WAIT: 7700b94ba42SJung-uk Kim /* 7710b94ba42SJung-uk Kim * Emit a warning if the timeout parameter for these operators is not 7720b94ba42SJung-uk Kim * ACPI_WAIT_FOREVER, and the result value from the operator is not 7730b94ba42SJung-uk Kim * checked, meaning that a timeout could happen, but the code 7740b94ba42SJung-uk Kim * would not know about it. 7750b94ba42SJung-uk Kim */ 7760b94ba42SJung-uk Kim 7770b94ba42SJung-uk Kim /* First child is the namepath, 2nd child is timeout */ 7780b94ba42SJung-uk Kim 779f8146b88SJung-uk Kim ArgOp = Op->Asl.Child; 780f8146b88SJung-uk Kim ArgOp = ArgOp->Asl.Next; 7810b94ba42SJung-uk Kim 7820b94ba42SJung-uk Kim /* 7830b94ba42SJung-uk Kim * Check for the WAIT_FOREVER case - defined by the ACPI spec to be 7840b94ba42SJung-uk Kim * 0xFFFF or greater 7850b94ba42SJung-uk Kim */ 786f8146b88SJung-uk Kim if (((ArgOp->Asl.ParseOpcode == PARSEOP_WORDCONST) || 787f8146b88SJung-uk Kim (ArgOp->Asl.ParseOpcode == PARSEOP_INTEGER)) && 788f8146b88SJung-uk Kim (ArgOp->Asl.Value.Integer >= (UINT64) ACPI_WAIT_FOREVER)) 7890b94ba42SJung-uk Kim { 7900b94ba42SJung-uk Kim break; 7910b94ba42SJung-uk Kim } 7920b94ba42SJung-uk Kim 7930b94ba42SJung-uk Kim /* 7940b94ba42SJung-uk Kim * The operation could timeout. If the return value is not used 7950b94ba42SJung-uk Kim * (indicates timeout occurred), issue a warning 7960b94ba42SJung-uk Kim */ 7970b94ba42SJung-uk Kim if (!AnIsResultUsed (Op)) 7980b94ba42SJung-uk Kim { 799f8146b88SJung-uk Kim AslError (ASL_WARNING, ASL_MSG_TIMEOUT, ArgOp, 8000b94ba42SJung-uk Kim Op->Asl.ExternalName); 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 * 8919ad8b64eSJung-uk Kim * FUNCTION: AnValidateCreateBufferField 8929ad8b64eSJung-uk Kim * 8939ad8b64eSJung-uk Kim * PARAMETERS: Op - A create buffer field operator 8949ad8b64eSJung-uk Kim * 8959ad8b64eSJung-uk Kim * RETURN: None 8969ad8b64eSJung-uk Kim * 8979ad8b64eSJung-uk Kim * DESCRIPTION: Check if a buffer index argument to a create buffer field 8989ad8b64eSJung-uk Kim * operation is beyond the end of the target buffer. 8999ad8b64eSJung-uk Kim * 9009ad8b64eSJung-uk Kim * Validates these AML operators: 9019ad8b64eSJung-uk Kim * 9029ad8b64eSJung-uk Kim * AML_CREATE_FIELD_OP 9039ad8b64eSJung-uk Kim * AML_CREATE_BIT_FIELD_OP 9049ad8b64eSJung-uk Kim * AML_CREATE_BYTE_FIELD_OP 9059ad8b64eSJung-uk Kim * AML_CREATE_WORD_FIELD_OP 9069ad8b64eSJung-uk Kim * AML_CREATE_DWORD_FIELD_OP 9079ad8b64eSJung-uk Kim * AML_CREATE_QWORD_FIELD_OP 9089ad8b64eSJung-uk Kim * 9099ad8b64eSJung-uk Kim * There are two conditions that must be satisfied in order to enable 9109ad8b64eSJung-uk Kim * validation at compile time: 9119ad8b64eSJung-uk Kim * 9129ad8b64eSJung-uk Kim * 1) The length of the target buffer must be an integer constant 9139ad8b64eSJung-uk Kim * 2) The index specified in the create* must be an integer constant 9149ad8b64eSJung-uk Kim * 3) For CreateField, the bit length argument must be non-zero. 9159ad8b64eSJung-uk Kim * 9169ad8b64eSJung-uk Kim ******************************************************************************/ 9179ad8b64eSJung-uk Kim 9189ad8b64eSJung-uk Kim static void 9199ad8b64eSJung-uk Kim AnValidateCreateBufferField ( 9209ad8b64eSJung-uk Kim ACPI_PARSE_OBJECT *CreateBufferFieldOp) 9219ad8b64eSJung-uk Kim { 9229ad8b64eSJung-uk Kim ACPI_PARSE_OBJECT *TargetBufferOp; 9239ad8b64eSJung-uk Kim ACPI_PARSE_OBJECT *ArgOp; 9249ad8b64eSJung-uk Kim UINT32 TargetBufferLength; 9259ad8b64eSJung-uk Kim UINT32 LastFieldByteIndex; 9269ad8b64eSJung-uk Kim 9279ad8b64eSJung-uk Kim 9289ad8b64eSJung-uk Kim /* 9299ad8b64eSJung-uk Kim * 1) Get the length of the target buffer 9309ad8b64eSJung-uk Kim */ 9319ad8b64eSJung-uk Kim ArgOp = CreateBufferFieldOp->Asl.Child; /* Reference to target buffer */ 9329ad8b64eSJung-uk Kim 9339ad8b64eSJung-uk Kim /* 9349ad8b64eSJung-uk Kim * If no attached Node, the target buffer may be something like an 9359ad8b64eSJung-uk Kim * ArgX or LocalX and cannot be evaluated at compile time. 9369ad8b64eSJung-uk Kim */ 9379ad8b64eSJung-uk Kim if (!ArgOp->Asl.Node) 9389ad8b64eSJung-uk Kim { 9399ad8b64eSJung-uk Kim return; 9409ad8b64eSJung-uk Kim } 9419ad8b64eSJung-uk Kim 9429ad8b64eSJung-uk Kim TargetBufferOp = ArgOp->Asl.Node->Op; 9439ad8b64eSJung-uk Kim TargetBufferOp = TargetBufferOp->Asl.Child; /* Target buffer */ 9449ad8b64eSJung-uk Kim TargetBufferOp = TargetBufferOp->Asl.Next; /* "Buffer" keyword */ 9459ad8b64eSJung-uk Kim if (!TargetBufferOp) 9469ad8b64eSJung-uk Kim { 9479ad8b64eSJung-uk Kim /* Not a statement of the form NAME(XXXX, Buffer.... */ 9489ad8b64eSJung-uk Kim 9499ad8b64eSJung-uk Kim return; 9509ad8b64eSJung-uk Kim } 9519ad8b64eSJung-uk Kim 9529ad8b64eSJung-uk Kim /* Get the buffer length argument. It must be an integer constant */ 9539ad8b64eSJung-uk Kim 9549ad8b64eSJung-uk Kim ArgOp = TargetBufferOp->Asl.Child; 9559ad8b64eSJung-uk Kim if (!AnIsValidBufferConstant (ArgOp)) 9569ad8b64eSJung-uk Kim { 9579ad8b64eSJung-uk Kim return; 9589ad8b64eSJung-uk Kim } 9599ad8b64eSJung-uk Kim 9609ad8b64eSJung-uk Kim TargetBufferLength = (UINT32) ArgOp->Asl.Value.Integer; 9619ad8b64eSJung-uk Kim 9629ad8b64eSJung-uk Kim /* 9639ad8b64eSJung-uk Kim * 2) Get the value of the buffer index argument. It must be 9649ad8b64eSJung-uk Kim * an integer constant. 9659ad8b64eSJung-uk Kim */ 9669ad8b64eSJung-uk Kim ArgOp = CreateBufferFieldOp->Asl.Child; /* Reference to target buffer */ 9679ad8b64eSJung-uk Kim ArgOp = ArgOp->Asl.Next; /* Buffer Index argument*/ 9689ad8b64eSJung-uk Kim if (!AnIsValidBufferConstant (ArgOp)) 9699ad8b64eSJung-uk Kim { 9709ad8b64eSJung-uk Kim return; 9719ad8b64eSJung-uk Kim } 9729ad8b64eSJung-uk Kim 9739ad8b64eSJung-uk Kim LastFieldByteIndex = 9749ad8b64eSJung-uk Kim (UINT32) ArgOp->Asl.Value.Integer; /* Index can be in either bytes or bits */ 9759ad8b64eSJung-uk Kim 9769ad8b64eSJung-uk Kim /* 9779ad8b64eSJung-uk Kim * 3) Get the length of the new buffer field, in bytes. Also, 9789ad8b64eSJung-uk Kim * create the final target buffer index for the last byte of the field 9799ad8b64eSJung-uk Kim */ 9809ad8b64eSJung-uk Kim switch (CreateBufferFieldOp->Asl.ParseOpcode) 9819ad8b64eSJung-uk Kim { 9829ad8b64eSJung-uk Kim case PARSEOP_CREATEBITFIELD: /* A one bit field */ 9839ad8b64eSJung-uk Kim 9849ad8b64eSJung-uk Kim LastFieldByteIndex = ACPI_ROUND_BITS_DOWN_TO_BYTES (LastFieldByteIndex); 9859ad8b64eSJung-uk Kim break; 9869ad8b64eSJung-uk Kim 9879ad8b64eSJung-uk Kim case PARSEOP_CREATEBYTEFIELD: 9889ad8b64eSJung-uk Kim break; 9899ad8b64eSJung-uk Kim 9909ad8b64eSJung-uk Kim case PARSEOP_CREATEWORDFIELD: 9919ad8b64eSJung-uk Kim 9929ad8b64eSJung-uk Kim LastFieldByteIndex += (sizeof (UINT16) - 1); 9939ad8b64eSJung-uk Kim break; 9949ad8b64eSJung-uk Kim 9959ad8b64eSJung-uk Kim case PARSEOP_CREATEDWORDFIELD: 9969ad8b64eSJung-uk Kim 9979ad8b64eSJung-uk Kim LastFieldByteIndex += (sizeof (UINT32) - 1); 9989ad8b64eSJung-uk Kim break; 9999ad8b64eSJung-uk Kim 10009ad8b64eSJung-uk Kim case PARSEOP_CREATEQWORDFIELD: 10019ad8b64eSJung-uk Kim 10029ad8b64eSJung-uk Kim LastFieldByteIndex += (sizeof (UINT64) - 1); 10039ad8b64eSJung-uk Kim break; 10049ad8b64eSJung-uk Kim 10059ad8b64eSJung-uk Kim case PARSEOP_CREATEFIELD: /* Multi-bit field */ 10069ad8b64eSJung-uk Kim 10079ad8b64eSJung-uk Kim ArgOp = ArgOp->Asl.Next; /* Length argument, in bits */ 10089ad8b64eSJung-uk Kim if (!AnIsValidBufferConstant (ArgOp)) 10099ad8b64eSJung-uk Kim { 10109ad8b64eSJung-uk Kim return; 10119ad8b64eSJung-uk Kim } 10129ad8b64eSJung-uk Kim 10139ad8b64eSJung-uk Kim /* The buffer field length is not allowed to be zero */ 10149ad8b64eSJung-uk Kim 10159ad8b64eSJung-uk Kim if (ArgOp->Asl.Value.Integer == 0) 10169ad8b64eSJung-uk Kim { 10179ad8b64eSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_BUFFER_FIELD_LENGTH, ArgOp, NULL); 10189ad8b64eSJung-uk Kim return; 10199ad8b64eSJung-uk Kim } 10209ad8b64eSJung-uk Kim 10219ad8b64eSJung-uk Kim LastFieldByteIndex += 10229ad8b64eSJung-uk Kim ((UINT32) ArgOp->Asl.Value.Integer - 1); /* Create final bit index */ 10239ad8b64eSJung-uk Kim 10249ad8b64eSJung-uk Kim /* Convert bit index to a byte index */ 10259ad8b64eSJung-uk Kim 10269ad8b64eSJung-uk Kim LastFieldByteIndex = ACPI_ROUND_BITS_DOWN_TO_BYTES (LastFieldByteIndex); 10279ad8b64eSJung-uk Kim break; 10289ad8b64eSJung-uk Kim 10299ad8b64eSJung-uk Kim default: 10309ad8b64eSJung-uk Kim return; 10319ad8b64eSJung-uk Kim } 10329ad8b64eSJung-uk Kim 10339ad8b64eSJung-uk Kim /* 10349ad8b64eSJung-uk Kim * 4) Check for an access (index) beyond the end of the target buffer, 10359ad8b64eSJung-uk Kim * or a zero length target buffer. 10369ad8b64eSJung-uk Kim */ 10379ad8b64eSJung-uk Kim if (!TargetBufferLength || (LastFieldByteIndex >= TargetBufferLength)) 10389ad8b64eSJung-uk Kim { 10399ad8b64eSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_BUFFER_FIELD_OVERFLOW, ArgOp, NULL); 10409ad8b64eSJung-uk Kim } 10419ad8b64eSJung-uk Kim } 10429ad8b64eSJung-uk Kim 10439ad8b64eSJung-uk Kim 10449ad8b64eSJung-uk Kim /******************************************************************************* 10459ad8b64eSJung-uk Kim * 10469ad8b64eSJung-uk Kim * FUNCTION: AnIsValidBufferConstant 10479ad8b64eSJung-uk Kim * 10489ad8b64eSJung-uk Kim * PARAMETERS: Op - A buffer-related operand 10499ad8b64eSJung-uk Kim * 10509ad8b64eSJung-uk Kim * RETURN: TRUE if operand is valid constant, FALSE otherwise 10519ad8b64eSJung-uk Kim * 10529ad8b64eSJung-uk Kim * DESCRIPTION: Check if the input Op is valid constant that can be used 10539ad8b64eSJung-uk Kim * in compile-time analysis. 10549ad8b64eSJung-uk Kim * 10559ad8b64eSJung-uk Kim ******************************************************************************/ 10569ad8b64eSJung-uk Kim 10579ad8b64eSJung-uk Kim static BOOLEAN 10589ad8b64eSJung-uk Kim AnIsValidBufferConstant ( 10599ad8b64eSJung-uk Kim ACPI_PARSE_OBJECT *Op) 10609ad8b64eSJung-uk Kim { 10619ad8b64eSJung-uk Kim if (!Op) 10629ad8b64eSJung-uk Kim { 10639ad8b64eSJung-uk Kim return (FALSE); 10649ad8b64eSJung-uk Kim } 10659ad8b64eSJung-uk Kim 10669ad8b64eSJung-uk Kim if ((Op->Asl.ParseOpcode == PARSEOP_INTEGER) || 10679ad8b64eSJung-uk Kim (Op->Asl.ParseOpcode == PARSEOP_ZERO) || 10689ad8b64eSJung-uk Kim (Op->Asl.ParseOpcode == PARSEOP_ONE)) 10699ad8b64eSJung-uk Kim { 10709ad8b64eSJung-uk Kim return (TRUE); 10719ad8b64eSJung-uk Kim } 10729ad8b64eSJung-uk Kim 10739ad8b64eSJung-uk Kim return (FALSE); 10749ad8b64eSJung-uk Kim } 10759ad8b64eSJung-uk Kim 10769ad8b64eSJung-uk Kim 10779ad8b64eSJung-uk Kim /******************************************************************************* 10789ad8b64eSJung-uk Kim * 1079f8146b88SJung-uk Kim * FUNCTION: AnAnalyzeStoreOperator 1080f8146b88SJung-uk Kim * 1081f8146b88SJung-uk Kim * PARAMETERS: Op - Store() operator 1082f8146b88SJung-uk Kim * 1083f8146b88SJung-uk Kim * RETURN: None 1084f8146b88SJung-uk Kim * 1085f8146b88SJung-uk Kim * DESCRIPTION: Analyze a store operator. Mostly for stores to/from package 1086f8146b88SJung-uk Kim * objects where there are more restrictions than other data 1087f8146b88SJung-uk Kim * types. 1088f8146b88SJung-uk Kim * 1089f8146b88SJung-uk Kim ******************************************************************************/ 1090f8146b88SJung-uk Kim 1091f8146b88SJung-uk Kim static void 1092f8146b88SJung-uk Kim AnAnalyzeStoreOperator ( 1093f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *Op) 1094f8146b88SJung-uk Kim { 1095f8146b88SJung-uk Kim ACPI_NAMESPACE_NODE *SourceNode; 1096f8146b88SJung-uk Kim ACPI_NAMESPACE_NODE *TargetNode; 1097f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *SourceOperandOp; 1098f8146b88SJung-uk Kim ACPI_PARSE_OBJECT *TargetOperandOp; 1099f8146b88SJung-uk Kim UINT32 SourceOperandBtype; 1100f8146b88SJung-uk Kim UINT32 TargetOperandBtype; 1101f8146b88SJung-uk Kim 1102f8146b88SJung-uk Kim 1103f8146b88SJung-uk Kim /* Extract the two operands for STORE */ 1104f8146b88SJung-uk Kim 1105f8146b88SJung-uk Kim SourceOperandOp = Op->Asl.Child; 1106f8146b88SJung-uk Kim TargetOperandOp = SourceOperandOp->Asl.Next; 1107f8146b88SJung-uk Kim 1108f8146b88SJung-uk Kim /* 1109f8146b88SJung-uk Kim * Ignore these Source operand opcodes, they cannot be typechecked, 1110f8146b88SJung-uk Kim * the actual result is unknown here. 1111f8146b88SJung-uk Kim */ 1112f8146b88SJung-uk Kim switch (SourceOperandOp->Asl.ParseOpcode) 1113f8146b88SJung-uk Kim { 1114f8146b88SJung-uk Kim /* For these, type of the returned value is unknown at compile time */ 1115f8146b88SJung-uk Kim 1116f8146b88SJung-uk Kim case PARSEOP_DEREFOF: 1117f8146b88SJung-uk Kim case PARSEOP_METHODCALL: 1118f8146b88SJung-uk Kim case PARSEOP_STORE: 1119f8146b88SJung-uk Kim case PARSEOP_COPYOBJECT: 1120f8146b88SJung-uk Kim 1121f8146b88SJung-uk Kim return; 1122f8146b88SJung-uk Kim 1123f8146b88SJung-uk Kim case PARSEOP_INDEX: 1124f8146b88SJung-uk Kim case PARSEOP_REFOF: 1125f8146b88SJung-uk Kim 11266f1f1a63SJung-uk Kim if (!AslGbl_EnableReferenceTypechecking) 1127f8146b88SJung-uk Kim { 1128f8146b88SJung-uk Kim return; 1129f8146b88SJung-uk Kim } 1130f8146b88SJung-uk Kim 1131f8146b88SJung-uk Kim /* 1132f8146b88SJung-uk Kim * These opcodes always return an object reference, and thus 1133f8146b88SJung-uk Kim * the result can only be stored to a Local, Arg, or Debug. 1134f8146b88SJung-uk Kim */ 1135f8146b88SJung-uk Kim if (TargetOperandOp->Asl.AmlOpcode == AML_DEBUG_OP) 1136f8146b88SJung-uk Kim { 1137f8146b88SJung-uk Kim return; 1138f8146b88SJung-uk Kim } 1139f8146b88SJung-uk Kim 1140f8146b88SJung-uk Kim if ((TargetOperandOp->Asl.AmlOpcode < AML_LOCAL0) || 1141f8146b88SJung-uk Kim (TargetOperandOp->Asl.AmlOpcode > AML_ARG6)) 1142f8146b88SJung-uk Kim { 1143f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp, 1144f8146b88SJung-uk Kim "Source [Reference], Target must be [Local/Arg/Debug]"); 1145f8146b88SJung-uk Kim } 1146f8146b88SJung-uk Kim return; 1147f8146b88SJung-uk Kim 1148f8146b88SJung-uk Kim default: 1149f8146b88SJung-uk Kim break; 1150f8146b88SJung-uk Kim } 1151f8146b88SJung-uk Kim 1152f8146b88SJung-uk Kim /* 1153f8146b88SJung-uk Kim * Ignore these Target operand opcodes, they cannot be typechecked 1154f8146b88SJung-uk Kim */ 1155f8146b88SJung-uk Kim switch (TargetOperandOp->Asl.ParseOpcode) 1156f8146b88SJung-uk Kim { 1157f8146b88SJung-uk Kim case PARSEOP_DEBUG: 1158f8146b88SJung-uk Kim case PARSEOP_DEREFOF: 1159f8146b88SJung-uk Kim case PARSEOP_REFOF: 1160f8146b88SJung-uk Kim case PARSEOP_INDEX: 11611cc50d6bSJung-uk Kim case PARSEOP_STORE: 1162f8146b88SJung-uk Kim 1163f8146b88SJung-uk Kim return; 1164f8146b88SJung-uk Kim 1165f8146b88SJung-uk Kim default: 1166f8146b88SJung-uk Kim break; 1167f8146b88SJung-uk Kim } 1168f8146b88SJung-uk Kim 1169f8146b88SJung-uk Kim /* 1170f8146b88SJung-uk Kim * Ignore typecheck for External() operands of type "UnknownObj", 1171f8146b88SJung-uk Kim * we don't know the actual type (source or target). 1172f8146b88SJung-uk Kim */ 1173f8146b88SJung-uk Kim SourceNode = SourceOperandOp->Asl.Node; 1174f8146b88SJung-uk Kim if (SourceNode && 1175f8146b88SJung-uk Kim (SourceNode->Flags & ANOBJ_IS_EXTERNAL) && 1176f8146b88SJung-uk Kim (SourceNode->Type == ACPI_TYPE_ANY)) 1177f8146b88SJung-uk Kim { 1178f8146b88SJung-uk Kim return; 1179f8146b88SJung-uk Kim } 1180f8146b88SJung-uk Kim 1181f8146b88SJung-uk Kim TargetNode = TargetOperandOp->Asl.Node; 1182f8146b88SJung-uk Kim if (TargetNode && 1183f8146b88SJung-uk Kim (TargetNode->Flags & ANOBJ_IS_EXTERNAL) && 1184f8146b88SJung-uk Kim (TargetNode->Type == ACPI_TYPE_ANY)) 1185f8146b88SJung-uk Kim { 1186f8146b88SJung-uk Kim return; 1187f8146b88SJung-uk Kim } 1188f8146b88SJung-uk Kim 1189f8146b88SJung-uk Kim /* 1190f8146b88SJung-uk Kim * A NULL node with a namepath AML opcode indicates non-existent 1191f8146b88SJung-uk Kim * name. Just return, the error message is generated elsewhere. 1192f8146b88SJung-uk Kim */ 1193f8146b88SJung-uk Kim if ((!SourceNode && (SourceOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)) || 1194f8146b88SJung-uk Kim (!TargetNode && (TargetOperandOp->Asl.AmlOpcode == AML_INT_NAMEPATH_OP))) 1195f8146b88SJung-uk Kim { 1196f8146b88SJung-uk Kim return; 1197f8146b88SJung-uk Kim } 1198f8146b88SJung-uk Kim 1199f8146b88SJung-uk Kim /* 1200f8146b88SJung-uk Kim * Simple check for source same as target via NS node. 1201f8146b88SJung-uk Kim * -- Could be expanded to locals and args. 1202f8146b88SJung-uk Kim */ 1203f8146b88SJung-uk Kim if (SourceNode && TargetNode) 1204f8146b88SJung-uk Kim { 1205f8146b88SJung-uk Kim if (SourceNode == TargetNode) 1206f8146b88SJung-uk Kim { 1207f8146b88SJung-uk Kim AslError (ASL_WARNING, ASL_MSG_DUPLICATE_ITEM, 1208f8146b88SJung-uk Kim TargetOperandOp, "Source is the same as Target"); 1209f8146b88SJung-uk Kim return; 1210f8146b88SJung-uk Kim } 1211f8146b88SJung-uk Kim } 1212f8146b88SJung-uk Kim 1213f8146b88SJung-uk Kim /* Ignore typecheck if either source or target is a local or arg */ 1214f8146b88SJung-uk Kim 1215f8146b88SJung-uk Kim if ((SourceOperandOp->Asl.AmlOpcode >= AML_LOCAL0) && 1216f8146b88SJung-uk Kim (SourceOperandOp->Asl.AmlOpcode <= AML_ARG6)) 1217f8146b88SJung-uk Kim { 1218f8146b88SJung-uk Kim return; /* Cannot type a local/arg at compile time */ 1219f8146b88SJung-uk Kim } 1220f8146b88SJung-uk Kim 1221f8146b88SJung-uk Kim if ((TargetOperandOp->Asl.AmlOpcode >= AML_LOCAL0) && 1222f8146b88SJung-uk Kim (TargetOperandOp->Asl.AmlOpcode <= AML_ARG6)) 1223f8146b88SJung-uk Kim { 1224f8146b88SJung-uk Kim return; /* Cannot type a local/arg at compile time */ 1225f8146b88SJung-uk Kim } 1226f8146b88SJung-uk Kim 1227f8146b88SJung-uk Kim /* 1228f8146b88SJung-uk Kim * Package objects are a special case because they cannot by implicitly 1229f8146b88SJung-uk Kim * converted to/from anything. Check for these two illegal cases: 1230f8146b88SJung-uk Kim * 1231f8146b88SJung-uk Kim * Store (non-package, package) 1232f8146b88SJung-uk Kim * Store (package, non-package) 1233f8146b88SJung-uk Kim */ 1234f8146b88SJung-uk Kim SourceOperandBtype = AnGetBtype (SourceOperandOp); 1235f8146b88SJung-uk Kim TargetOperandBtype = AnGetBtype (TargetOperandOp); 1236f8146b88SJung-uk Kim 1237f8146b88SJung-uk Kim /* Check source first for (package, non-package) case */ 1238f8146b88SJung-uk Kim 1239f8146b88SJung-uk Kim if (SourceOperandBtype & ACPI_BTYPE_PACKAGE) 1240f8146b88SJung-uk Kim { 1241f8146b88SJung-uk Kim /* If Source is PACKAGE-->Target must be PACKAGE */ 1242f8146b88SJung-uk Kim 1243f8146b88SJung-uk Kim if (!(TargetOperandBtype & ACPI_BTYPE_PACKAGE)) 1244f8146b88SJung-uk Kim { 1245f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, TargetOperandOp, 1246f8146b88SJung-uk Kim "Source is [Package], Target must be a package also"); 1247f8146b88SJung-uk Kim } 1248f8146b88SJung-uk Kim } 1249f8146b88SJung-uk Kim 1250f8146b88SJung-uk Kim /* Else check target for (non-package, package) case */ 1251f8146b88SJung-uk Kim 1252f8146b88SJung-uk Kim else if (TargetOperandBtype & ACPI_BTYPE_PACKAGE) 1253f8146b88SJung-uk Kim { 1254f8146b88SJung-uk Kim /* If Target is PACKAGE, Source must be PACKAGE */ 1255f8146b88SJung-uk Kim 1256f8146b88SJung-uk Kim if (!(SourceOperandBtype & ACPI_BTYPE_PACKAGE)) 1257f8146b88SJung-uk Kim { 1258f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, SourceOperandOp, 1259f8146b88SJung-uk Kim "Target is [Package], Source must be a package also"); 1260f8146b88SJung-uk Kim } 1261f8146b88SJung-uk Kim } 1262f8146b88SJung-uk Kim } 1263