1efcc2a30SJung-uk Kim /****************************************************************************** 2efcc2a30SJung-uk Kim * 3efcc2a30SJung-uk Kim * Module Name: aslmethod.c - Control method analysis walk 4efcc2a30SJung-uk Kim * 5efcc2a30SJung-uk Kim *****************************************************************************/ 6efcc2a30SJung-uk Kim 70d84335fSJung-uk Kim /****************************************************************************** 80d84335fSJung-uk Kim * 90d84335fSJung-uk Kim * 1. Copyright Notice 100d84335fSJung-uk Kim * 1129f37e9bSJung-uk Kim * Some or all of this work - Copyright (c) 1999 - 2021, Intel Corp. 12efcc2a30SJung-uk Kim * All rights reserved. 13efcc2a30SJung-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 * 119efcc2a30SJung-uk Kim * Redistribution and use in source and binary forms, with or without 120efcc2a30SJung-uk Kim * modification, are permitted provided that the following conditions 121efcc2a30SJung-uk Kim * are met: 122efcc2a30SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 123efcc2a30SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 124efcc2a30SJung-uk Kim * without modification. 125efcc2a30SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126efcc2a30SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 127efcc2a30SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 128efcc2a30SJung-uk Kim * including a substantially similar Disclaimer requirement for further 129efcc2a30SJung-uk Kim * binary redistribution. 130efcc2a30SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 131efcc2a30SJung-uk Kim * of any contributors may be used to endorse or promote products derived 132efcc2a30SJung-uk Kim * from this software without specific prior written permission. 133efcc2a30SJung-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 147efcc2a30SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 148efcc2a30SJung-uk Kim * Software Foundation. 149efcc2a30SJung-uk Kim * 1500d84335fSJung-uk Kim *****************************************************************************/ 151efcc2a30SJung-uk Kim 152efcc2a30SJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 153efcc2a30SJung-uk Kim #include "aslcompiler.y.h" 154ec0234b4SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h> 155a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/include/acparser.h> 156a9d8d09cSJung-uk Kim #include <contrib/dev/acpica/include/amlcode.h> 157efcc2a30SJung-uk Kim 158efcc2a30SJung-uk Kim 159efcc2a30SJung-uk Kim #define _COMPONENT ACPI_COMPILER 160efcc2a30SJung-uk Kim ACPI_MODULE_NAME ("aslmethod") 161efcc2a30SJung-uk Kim 162efcc2a30SJung-uk Kim 163a9d8d09cSJung-uk Kim /* Local prototypes */ 164a9d8d09cSJung-uk Kim 165f8146b88SJung-uk Kim static void 166a9d8d09cSJung-uk Kim MtCheckNamedObjectInMethod ( 167a9d8d09cSJung-uk Kim ACPI_PARSE_OBJECT *Op, 168a9d8d09cSJung-uk Kim ASL_METHOD_INFO *MethodInfo); 169a9d8d09cSJung-uk Kim 170ec0234b4SJung-uk Kim static void 171ec0234b4SJung-uk Kim MtCheckStaticOperationRegionInMethod ( 172ec0234b4SJung-uk Kim ACPI_PARSE_OBJECT *Op); 173ec0234b4SJung-uk Kim 174a9d8d09cSJung-uk Kim 175efcc2a30SJung-uk Kim /******************************************************************************* 176efcc2a30SJung-uk Kim * 177efcc2a30SJung-uk Kim * FUNCTION: MtMethodAnalysisWalkBegin 178efcc2a30SJung-uk Kim * 179efcc2a30SJung-uk Kim * PARAMETERS: ASL_WALK_CALLBACK 180efcc2a30SJung-uk Kim * 181efcc2a30SJung-uk Kim * RETURN: Status 182efcc2a30SJung-uk Kim * 183efcc2a30SJung-uk Kim * DESCRIPTION: Descending callback for the analysis walk. Check methods for: 184efcc2a30SJung-uk Kim * 1) Initialized local variables 185efcc2a30SJung-uk Kim * 2) Valid arguments 186efcc2a30SJung-uk Kim * 3) Return types 187efcc2a30SJung-uk Kim * 188efcc2a30SJung-uk Kim ******************************************************************************/ 189efcc2a30SJung-uk Kim 190efcc2a30SJung-uk Kim ACPI_STATUS 191efcc2a30SJung-uk Kim MtMethodAnalysisWalkBegin ( 192efcc2a30SJung-uk Kim ACPI_PARSE_OBJECT *Op, 193efcc2a30SJung-uk Kim UINT32 Level, 194efcc2a30SJung-uk Kim void *Context) 195efcc2a30SJung-uk Kim { 196efcc2a30SJung-uk Kim ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; 197efcc2a30SJung-uk Kim ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack; 198efcc2a30SJung-uk Kim ACPI_PARSE_OBJECT *Next; 199efcc2a30SJung-uk Kim UINT32 RegisterNumber; 200efcc2a30SJung-uk Kim UINT32 i; 201efcc2a30SJung-uk Kim char LocalName[] = "Local0"; 202efcc2a30SJung-uk Kim char ArgName[] = "Arg0"; 203efcc2a30SJung-uk Kim ACPI_PARSE_OBJECT *ArgNode; 204efcc2a30SJung-uk Kim ACPI_PARSE_OBJECT *NextType; 205efcc2a30SJung-uk Kim UINT8 ActualArgs = 0; 206a009b7dcSJung-uk Kim BOOLEAN HidExists; 207a009b7dcSJung-uk Kim BOOLEAN AdrExists; 20897c0b5abSJung-uk Kim BOOLEAN PrsExists; 20997c0b5abSJung-uk Kim BOOLEAN CrsExists; 21097c0b5abSJung-uk Kim BOOLEAN SrsExists; 21197c0b5abSJung-uk Kim BOOLEAN DisExists; 212efcc2a30SJung-uk Kim 213efcc2a30SJung-uk Kim 214f8146b88SJung-uk Kim /* Build cross-reference output file if requested */ 215f8146b88SJung-uk Kim 2166f1f1a63SJung-uk Kim if (AslGbl_CrossReferenceOutput) 217f8146b88SJung-uk Kim { 218f8146b88SJung-uk Kim OtXrefWalkPart1 (Op, Level, MethodInfo); 219f8146b88SJung-uk Kim } 220f8146b88SJung-uk Kim 221efcc2a30SJung-uk Kim switch (Op->Asl.ParseOpcode) 222efcc2a30SJung-uk Kim { 223efcc2a30SJung-uk Kim case PARSEOP_METHOD: 224efcc2a30SJung-uk Kim 2256f1f1a63SJung-uk Kim AslGbl_TotalMethods++; 226efcc2a30SJung-uk Kim 227efcc2a30SJung-uk Kim /* Create and init method info */ 228efcc2a30SJung-uk Kim 229efcc2a30SJung-uk Kim MethodInfo = UtLocalCalloc (sizeof (ASL_METHOD_INFO)); 230efcc2a30SJung-uk Kim MethodInfo->Next = WalkInfo->MethodStack; 231efcc2a30SJung-uk Kim MethodInfo->Op = Op; 232efcc2a30SJung-uk Kim 233efcc2a30SJung-uk Kim WalkInfo->MethodStack = MethodInfo; 234efcc2a30SJung-uk Kim 235313a0c13SJung-uk Kim /* 236313a0c13SJung-uk Kim * Special handling for _PSx methods. Dependency rules (same scope): 237313a0c13SJung-uk Kim * 238313a0c13SJung-uk Kim * 1) _PS0 - One of these must exist: _PS1, _PS2, _PS3 239313a0c13SJung-uk Kim * 2) _PS1/_PS2/_PS3: A _PS0 must exist 240313a0c13SJung-uk Kim */ 241278f0de6SJung-uk Kim if (ACPI_COMPARE_NAMESEG (METHOD_NAME__PS0, Op->Asl.NameSeg)) 242313a0c13SJung-uk Kim { 243313a0c13SJung-uk Kim /* For _PS0, one of _PS1/_PS2/_PS3 must exist */ 244313a0c13SJung-uk Kim 245313a0c13SJung-uk Kim if ((!ApFindNameInScope (METHOD_NAME__PS1, Op)) && 246313a0c13SJung-uk Kim (!ApFindNameInScope (METHOD_NAME__PS2, Op)) && 247313a0c13SJung-uk Kim (!ApFindNameInScope (METHOD_NAME__PS3, Op))) 248313a0c13SJung-uk Kim { 249313a0c13SJung-uk Kim AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, 250313a0c13SJung-uk Kim "_PS0 requires one of _PS1/_PS2/_PS3 in same scope"); 251313a0c13SJung-uk Kim } 252313a0c13SJung-uk Kim } 253313a0c13SJung-uk Kim else if ( 254278f0de6SJung-uk Kim ACPI_COMPARE_NAMESEG (METHOD_NAME__PS1, Op->Asl.NameSeg) || 255278f0de6SJung-uk Kim ACPI_COMPARE_NAMESEG (METHOD_NAME__PS2, Op->Asl.NameSeg) || 256278f0de6SJung-uk Kim ACPI_COMPARE_NAMESEG (METHOD_NAME__PS3, Op->Asl.NameSeg)) 257313a0c13SJung-uk Kim { 258313a0c13SJung-uk Kim /* For _PS1/_PS2/_PS3, a _PS0 must exist */ 259313a0c13SJung-uk Kim 260313a0c13SJung-uk Kim if (!ApFindNameInScope (METHOD_NAME__PS0, Op)) 261313a0c13SJung-uk Kim { 2626f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, 263313a0c13SJung-uk Kim "%4.4s requires _PS0 in same scope", Op->Asl.NameSeg); 264313a0c13SJung-uk Kim 265313a0c13SJung-uk Kim AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, 2666f1f1a63SJung-uk Kim AslGbl_MsgBuffer); 267313a0c13SJung-uk Kim } 268313a0c13SJung-uk Kim } 269313a0c13SJung-uk Kim 270313a0c13SJung-uk Kim /* Get the name node */ 271efcc2a30SJung-uk Kim 272efcc2a30SJung-uk Kim Next = Op->Asl.Child; 273efcc2a30SJung-uk Kim 274efcc2a30SJung-uk Kim /* Get the NumArguments node */ 275efcc2a30SJung-uk Kim 276efcc2a30SJung-uk Kim Next = Next->Asl.Next; 277efcc2a30SJung-uk Kim MethodInfo->NumArguments = (UINT8) 278efcc2a30SJung-uk Kim (((UINT8) Next->Asl.Value.Integer) & 0x07); 279efcc2a30SJung-uk Kim 280efcc2a30SJung-uk Kim /* Get the SerializeRule and SyncLevel nodes, ignored here */ 281efcc2a30SJung-uk Kim 282efcc2a30SJung-uk Kim Next = Next->Asl.Next; 283a9d8d09cSJung-uk Kim MethodInfo->ShouldBeSerialized = (UINT8) Next->Asl.Value.Integer; 284a9d8d09cSJung-uk Kim 285efcc2a30SJung-uk Kim Next = Next->Asl.Next; 286efcc2a30SJung-uk Kim ArgNode = Next; 287efcc2a30SJung-uk Kim 288efcc2a30SJung-uk Kim /* Get the ReturnType node */ 289efcc2a30SJung-uk Kim 290efcc2a30SJung-uk Kim Next = Next->Asl.Next; 291efcc2a30SJung-uk Kim 292efcc2a30SJung-uk Kim NextType = Next->Asl.Child; 293efcc2a30SJung-uk Kim 294ec0234b4SJung-uk Kim MethodInfo->ValidReturnTypes = MtProcessTypeOp (NextType); 295385fb5d9SJung-uk Kim Op->Asl.AcpiBtype |= MethodInfo->ValidReturnTypes; 296efcc2a30SJung-uk Kim 297efcc2a30SJung-uk Kim /* Get the ParameterType node */ 298efcc2a30SJung-uk Kim 299efcc2a30SJung-uk Kim Next = Next->Asl.Next; 300efcc2a30SJung-uk Kim 301efcc2a30SJung-uk Kim NextType = Next->Asl.Child; 302ec0234b4SJung-uk Kim if (!NextType) 303efcc2a30SJung-uk Kim { 304ec0234b4SJung-uk Kim /* 305ec0234b4SJung-uk Kim * The optional parameter types list was omitted at the source 306ec0234b4SJung-uk Kim * level. Use the Argument count parameter instead. 307ec0234b4SJung-uk Kim */ 308ec0234b4SJung-uk Kim ActualArgs = MethodInfo->NumArguments; 309efcc2a30SJung-uk Kim } 310efcc2a30SJung-uk Kim else 311efcc2a30SJung-uk Kim { 312ec0234b4SJung-uk Kim ActualArgs = MtProcessParameterTypeList (NextType, 313ec0234b4SJung-uk Kim MethodInfo->ValidArgTypes); 31461b18036SJung-uk Kim MethodInfo->NumArguments = ActualArgs; 31561b18036SJung-uk Kim ArgNode->Asl.Value.Integer |= ActualArgs; 316efcc2a30SJung-uk Kim } 317efcc2a30SJung-uk Kim 318efcc2a30SJung-uk Kim if ((MethodInfo->NumArguments) && 319efcc2a30SJung-uk Kim (MethodInfo->NumArguments != ActualArgs)) 320efcc2a30SJung-uk Kim { 321ec0234b4SJung-uk Kim sprintf (AslGbl_MsgBuffer, 322ec0234b4SJung-uk Kim "Length = %u", ActualArgs); 323ec0234b4SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_ARG_COUNT_MISMATCH, 324ec0234b4SJung-uk Kim Op->Asl.Child->Asl.Next, AslGbl_MsgBuffer); 325efcc2a30SJung-uk Kim } 326efcc2a30SJung-uk Kim 327efcc2a30SJung-uk Kim /* Allow numarguments == 0 for Function() */ 328efcc2a30SJung-uk Kim 329efcc2a30SJung-uk Kim if ((!MethodInfo->NumArguments) && (ActualArgs)) 330efcc2a30SJung-uk Kim { 331efcc2a30SJung-uk Kim MethodInfo->NumArguments = ActualArgs; 332efcc2a30SJung-uk Kim ArgNode->Asl.Value.Integer |= ActualArgs; 333efcc2a30SJung-uk Kim } 334efcc2a30SJung-uk Kim 335efcc2a30SJung-uk Kim /* 336efcc2a30SJung-uk Kim * Actual arguments are initialized at method entry. 337efcc2a30SJung-uk Kim * All other ArgX "registers" can be used as locals, so we 338efcc2a30SJung-uk Kim * track their initialization. 339efcc2a30SJung-uk Kim */ 340efcc2a30SJung-uk Kim for (i = 0; i < MethodInfo->NumArguments; i++) 341efcc2a30SJung-uk Kim { 342efcc2a30SJung-uk Kim MethodInfo->ArgInitialized[i] = TRUE; 343efcc2a30SJung-uk Kim } 344efcc2a30SJung-uk Kim break; 345efcc2a30SJung-uk Kim 346efcc2a30SJung-uk Kim case PARSEOP_METHODCALL: 347efcc2a30SJung-uk Kim 34867d9aa44SJung-uk Kim /* Check for a recursive method call */ 34967d9aa44SJung-uk Kim 350efcc2a30SJung-uk Kim if (MethodInfo && 351efcc2a30SJung-uk Kim (Op->Asl.Node == MethodInfo->Op->Asl.Node)) 352efcc2a30SJung-uk Kim { 35367d9aa44SJung-uk Kim if (MethodInfo->CreatesNamedObjects) 35467d9aa44SJung-uk Kim { 35567d9aa44SJung-uk Kim /* 35667d9aa44SJung-uk Kim * This is an error, as it will fail at runtime on all ACPI 35767d9aa44SJung-uk Kim * implementations. Any named object declarations will be 35867d9aa44SJung-uk Kim * executed twice, causing failure the second time. Note, 35967d9aa44SJung-uk Kim * this is independent of whether the method is declared 36067d9aa44SJung-uk Kim * Serialized, because the same thread is attempting to 36167d9aa44SJung-uk Kim * reenter the method, and this will always succeed. 36267d9aa44SJung-uk Kim */ 36367d9aa44SJung-uk Kim AslDualParseOpError (ASL_ERROR, ASL_MSG_ILLEGAL_RECURSION, Op, 36467d9aa44SJung-uk Kim Op->Asl.Value.String, ASL_MSG_FOUND_HERE, MethodInfo->Op, 36567d9aa44SJung-uk Kim MethodInfo->Op->Asl.ExternalName); 36667d9aa44SJung-uk Kim } 36767d9aa44SJung-uk Kim else 36867d9aa44SJung-uk Kim { 36967d9aa44SJung-uk Kim /* Method does not create objects, issue a remark */ 37067d9aa44SJung-uk Kim 371efcc2a30SJung-uk Kim AslError (ASL_REMARK, ASL_MSG_RECURSION, Op, Op->Asl.ExternalName); 372efcc2a30SJung-uk Kim } 37367d9aa44SJung-uk Kim } 374efcc2a30SJung-uk Kim break; 375efcc2a30SJung-uk Kim 376efcc2a30SJung-uk Kim case PARSEOP_LOCAL0: 377efcc2a30SJung-uk Kim case PARSEOP_LOCAL1: 378efcc2a30SJung-uk Kim case PARSEOP_LOCAL2: 379efcc2a30SJung-uk Kim case PARSEOP_LOCAL3: 380efcc2a30SJung-uk Kim case PARSEOP_LOCAL4: 381efcc2a30SJung-uk Kim case PARSEOP_LOCAL5: 382efcc2a30SJung-uk Kim case PARSEOP_LOCAL6: 383efcc2a30SJung-uk Kim case PARSEOP_LOCAL7: 384efcc2a30SJung-uk Kim 385efcc2a30SJung-uk Kim if (!MethodInfo) 386efcc2a30SJung-uk Kim { 387efcc2a30SJung-uk Kim /* 388efcc2a30SJung-uk Kim * Local was used outside a control method, or there was an error 389efcc2a30SJung-uk Kim * in the method declaration. 390efcc2a30SJung-uk Kim */ 391f8146b88SJung-uk Kim AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, 392f8146b88SJung-uk Kim Op, Op->Asl.ExternalName); 393efcc2a30SJung-uk Kim return (AE_ERROR); 394efcc2a30SJung-uk Kim } 395efcc2a30SJung-uk Kim 396fe0f0bbbSJung-uk Kim RegisterNumber = (Op->Asl.AmlOpcode & 0x0007); 397efcc2a30SJung-uk Kim 398efcc2a30SJung-uk Kim /* 399efcc2a30SJung-uk Kim * If the local is being used as a target, mark the local 400efcc2a30SJung-uk Kim * initialized 401efcc2a30SJung-uk Kim */ 4025f9b24faSJung-uk Kim if (Op->Asl.CompileFlags & OP_IS_TARGET) 403efcc2a30SJung-uk Kim { 404efcc2a30SJung-uk Kim MethodInfo->LocalInitialized[RegisterNumber] = TRUE; 405efcc2a30SJung-uk Kim } 406efcc2a30SJung-uk Kim 407efcc2a30SJung-uk Kim /* 408efcc2a30SJung-uk Kim * Otherwise, this is a reference, check if the local 409efcc2a30SJung-uk Kim * has been previously initialized. 410efcc2a30SJung-uk Kim * 411efcc2a30SJung-uk Kim * The only operator that accepts an uninitialized value is ObjectType() 412efcc2a30SJung-uk Kim */ 413efcc2a30SJung-uk Kim else if ((!MethodInfo->LocalInitialized[RegisterNumber]) && 414efcc2a30SJung-uk Kim (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) 415efcc2a30SJung-uk Kim { 416efcc2a30SJung-uk Kim LocalName[strlen (LocalName) -1] = (char) (RegisterNumber + 0x30); 417efcc2a30SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_LOCAL_INIT, Op, LocalName); 418efcc2a30SJung-uk Kim } 419efcc2a30SJung-uk Kim break; 420efcc2a30SJung-uk Kim 421efcc2a30SJung-uk Kim case PARSEOP_ARG0: 422efcc2a30SJung-uk Kim case PARSEOP_ARG1: 423efcc2a30SJung-uk Kim case PARSEOP_ARG2: 424efcc2a30SJung-uk Kim case PARSEOP_ARG3: 425efcc2a30SJung-uk Kim case PARSEOP_ARG4: 426efcc2a30SJung-uk Kim case PARSEOP_ARG5: 427efcc2a30SJung-uk Kim case PARSEOP_ARG6: 428efcc2a30SJung-uk Kim 429efcc2a30SJung-uk Kim if (!MethodInfo) 430efcc2a30SJung-uk Kim { 431efcc2a30SJung-uk Kim /* 432efcc2a30SJung-uk Kim * Arg was used outside a control method, or there was an error 433efcc2a30SJung-uk Kim * in the method declaration. 434efcc2a30SJung-uk Kim */ 435f8146b88SJung-uk Kim AslError (ASL_REMARK, ASL_MSG_LOCAL_OUTSIDE_METHOD, 436f8146b88SJung-uk Kim Op, Op->Asl.ExternalName); 437efcc2a30SJung-uk Kim return (AE_ERROR); 438efcc2a30SJung-uk Kim } 439efcc2a30SJung-uk Kim 440efcc2a30SJung-uk Kim RegisterNumber = (Op->Asl.AmlOpcode & 0x000F) - 8; 441efcc2a30SJung-uk Kim ArgName[strlen (ArgName) -1] = (char) (RegisterNumber + 0x30); 442efcc2a30SJung-uk Kim 443efcc2a30SJung-uk Kim /* 444efcc2a30SJung-uk Kim * If the Arg is being used as a target, mark the local 445efcc2a30SJung-uk Kim * initialized 446efcc2a30SJung-uk Kim */ 4475f9b24faSJung-uk Kim if (Op->Asl.CompileFlags & OP_IS_TARGET) 448efcc2a30SJung-uk Kim { 449efcc2a30SJung-uk Kim MethodInfo->ArgInitialized[RegisterNumber] = TRUE; 450efcc2a30SJung-uk Kim } 451efcc2a30SJung-uk Kim 452efcc2a30SJung-uk Kim /* 453efcc2a30SJung-uk Kim * Otherwise, this is a reference, check if the Arg 454efcc2a30SJung-uk Kim * has been previously initialized. 455efcc2a30SJung-uk Kim * 456efcc2a30SJung-uk Kim * The only operator that accepts an uninitialized value is ObjectType() 457efcc2a30SJung-uk Kim */ 458efcc2a30SJung-uk Kim else if ((!MethodInfo->ArgInitialized[RegisterNumber]) && 459efcc2a30SJung-uk Kim (Op->Asl.Parent->Asl.ParseOpcode != PARSEOP_OBJECTTYPE)) 460efcc2a30SJung-uk Kim { 461efcc2a30SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_ARG_INIT, Op, ArgName); 462efcc2a30SJung-uk Kim } 463efcc2a30SJung-uk Kim 464efcc2a30SJung-uk Kim /* Flag this arg if it is not a "real" argument to the method */ 465efcc2a30SJung-uk Kim 466efcc2a30SJung-uk Kim if (RegisterNumber >= MethodInfo->NumArguments) 467efcc2a30SJung-uk Kim { 468efcc2a30SJung-uk Kim AslError (ASL_REMARK, ASL_MSG_NOT_PARAMETER, Op, ArgName); 469efcc2a30SJung-uk Kim } 470efcc2a30SJung-uk Kim break; 471efcc2a30SJung-uk Kim 472efcc2a30SJung-uk Kim case PARSEOP_RETURN: 473efcc2a30SJung-uk Kim 474efcc2a30SJung-uk Kim if (!MethodInfo) 475efcc2a30SJung-uk Kim { 476efcc2a30SJung-uk Kim /* 477efcc2a30SJung-uk Kim * Probably was an error in the method declaration, 478efcc2a30SJung-uk Kim * no additional error here 479efcc2a30SJung-uk Kim */ 480efcc2a30SJung-uk Kim ACPI_WARNING ((AE_INFO, "%p, No parent method", Op)); 481efcc2a30SJung-uk Kim return (AE_ERROR); 482efcc2a30SJung-uk Kim } 483efcc2a30SJung-uk Kim 484efcc2a30SJung-uk Kim /* 485efcc2a30SJung-uk Kim * A child indicates a possible return value. A simple Return or 4865f9b24faSJung-uk Kim * Return() is marked with OP_IS_NULL_RETURN by the parser so 487efcc2a30SJung-uk Kim * that it is not counted as a "real" return-with-value, although 488efcc2a30SJung-uk Kim * the AML code that is actually emitted is Return(0). The AML 489efcc2a30SJung-uk Kim * definition of Return has a required parameter, so we are 490efcc2a30SJung-uk Kim * forced to convert a null return to Return(0). 491efcc2a30SJung-uk Kim */ 492efcc2a30SJung-uk Kim if ((Op->Asl.Child) && 493efcc2a30SJung-uk Kim (Op->Asl.Child->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) && 4945f9b24faSJung-uk Kim (!(Op->Asl.Child->Asl.CompileFlags & OP_IS_NULL_RETURN))) 495efcc2a30SJung-uk Kim { 496efcc2a30SJung-uk Kim MethodInfo->NumReturnWithValue++; 497efcc2a30SJung-uk Kim } 498efcc2a30SJung-uk Kim else 499efcc2a30SJung-uk Kim { 500efcc2a30SJung-uk Kim MethodInfo->NumReturnNoValue++; 501efcc2a30SJung-uk Kim } 502efcc2a30SJung-uk Kim break; 503efcc2a30SJung-uk Kim 504efcc2a30SJung-uk Kim case PARSEOP_BREAK: 505efcc2a30SJung-uk Kim case PARSEOP_CONTINUE: 506efcc2a30SJung-uk Kim 507efcc2a30SJung-uk Kim Next = Op->Asl.Parent; 508efcc2a30SJung-uk Kim while (Next) 509efcc2a30SJung-uk Kim { 510efcc2a30SJung-uk Kim if (Next->Asl.ParseOpcode == PARSEOP_WHILE) 511efcc2a30SJung-uk Kim { 512efcc2a30SJung-uk Kim break; 513efcc2a30SJung-uk Kim } 514efcc2a30SJung-uk Kim Next = Next->Asl.Parent; 515efcc2a30SJung-uk Kim } 516efcc2a30SJung-uk Kim 517efcc2a30SJung-uk Kim if (!Next) 518efcc2a30SJung-uk Kim { 519efcc2a30SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_NO_WHILE, Op, NULL); 520efcc2a30SJung-uk Kim } 521efcc2a30SJung-uk Kim break; 522efcc2a30SJung-uk Kim 523efcc2a30SJung-uk Kim case PARSEOP_STALL: 524efcc2a30SJung-uk Kim 525efcc2a30SJung-uk Kim /* We can range check if the argument is an integer */ 526efcc2a30SJung-uk Kim 527efcc2a30SJung-uk Kim if ((Op->Asl.Child->Asl.ParseOpcode == PARSEOP_INTEGER) && 528efcc2a30SJung-uk Kim (Op->Asl.Child->Asl.Value.Integer > ACPI_UINT8_MAX)) 529efcc2a30SJung-uk Kim { 530efcc2a30SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_INVALID_TIME, Op, NULL); 531efcc2a30SJung-uk Kim } 532efcc2a30SJung-uk Kim break; 533efcc2a30SJung-uk Kim 534efcc2a30SJung-uk Kim case PARSEOP_DEVICE: 535313a0c13SJung-uk Kim 536a009b7dcSJung-uk Kim /* Check usage of _HID and _ADR objects */ 537a009b7dcSJung-uk Kim 538a009b7dcSJung-uk Kim HidExists = ApFindNameInDeviceTree (METHOD_NAME__HID, Op); 539a009b7dcSJung-uk Kim AdrExists = ApFindNameInDeviceTree (METHOD_NAME__ADR, Op); 540a009b7dcSJung-uk Kim 541a009b7dcSJung-uk Kim if (!HidExists && !AdrExists) 542313a0c13SJung-uk Kim { 54397c0b5abSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_MISSING_DEPENDENCY, Op, 54497c0b5abSJung-uk Kim "Device object requires a _HID or _ADR"); 545313a0c13SJung-uk Kim } 546a009b7dcSJung-uk Kim else if (HidExists && AdrExists) 547a009b7dcSJung-uk Kim { 548a009b7dcSJung-uk Kim /* 549a009b7dcSJung-uk Kim * According to the ACPI spec, "A device object must contain 550a009b7dcSJung-uk Kim * either an _HID object or an _ADR object, but should not contain 551a009b7dcSJung-uk Kim * both". 552a009b7dcSJung-uk Kim */ 553a009b7dcSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_MULTIPLE_TYPES, Op, 554a009b7dcSJung-uk Kim "Device object requires either a _HID or _ADR, but not both"); 555a009b7dcSJung-uk Kim } 55697c0b5abSJung-uk Kim 55797c0b5abSJung-uk Kim /* 55897c0b5abSJung-uk Kim * Check usage of _CRS, _DIS, _PRS, and _SRS objects (July 2021). 55997c0b5abSJung-uk Kim * 56097c0b5abSJung-uk Kim * Under the Device Object: 56197c0b5abSJung-uk Kim * 56297c0b5abSJung-uk Kim * 1) If _DIS is present, must have a _CRS, _PRS, and _SRS 56397c0b5abSJung-uk Kim * 2) If _PRS is present, must have a _CRS and _SRS 56497c0b5abSJung-uk Kim * 3) If _SRS is present, must have a _CRS and _PRS 56597c0b5abSJung-uk Kim */ 56697c0b5abSJung-uk Kim CrsExists = ApFindNameInDeviceTree (METHOD_NAME__CRS, Op); 56797c0b5abSJung-uk Kim DisExists = ApFindNameInDeviceTree (METHOD_NAME__DIS, Op); 56897c0b5abSJung-uk Kim PrsExists = ApFindNameInDeviceTree (METHOD_NAME__PRS, Op); 56997c0b5abSJung-uk Kim SrsExists = ApFindNameInDeviceTree (METHOD_NAME__SRS, Op); 57097c0b5abSJung-uk Kim 57197c0b5abSJung-uk Kim /* 1) If _DIS is present, must have a _CRS, _PRS, and _SRS */ 57297c0b5abSJung-uk Kim 57397c0b5abSJung-uk Kim if (DisExists) 57497c0b5abSJung-uk Kim { 57597c0b5abSJung-uk Kim if (!CrsExists) 57697c0b5abSJung-uk Kim { 57797c0b5abSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, 57897c0b5abSJung-uk Kim "_DIS is missing a _CRS, requires a _CRS, _PRS, and a _SRS"); 57997c0b5abSJung-uk Kim } 58097c0b5abSJung-uk Kim 58197c0b5abSJung-uk Kim if (!PrsExists) 58297c0b5abSJung-uk Kim { 58397c0b5abSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, 58497c0b5abSJung-uk Kim "_DIS is missing a _PRS, requires a _CRS, _PRS, and a _SRS"); 58597c0b5abSJung-uk Kim } 58697c0b5abSJung-uk Kim 58797c0b5abSJung-uk Kim if (!SrsExists) 58897c0b5abSJung-uk Kim { 58997c0b5abSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, 59097c0b5abSJung-uk Kim "_DIS is missing a _SRS, requires a _CRS, _PRS, and a _SRS"); 59197c0b5abSJung-uk Kim } 59297c0b5abSJung-uk Kim } 59397c0b5abSJung-uk Kim 59497c0b5abSJung-uk Kim /* 2) If _PRS is present, must have a _CRS and _SRS */ 59597c0b5abSJung-uk Kim 59697c0b5abSJung-uk Kim if (PrsExists) 59797c0b5abSJung-uk Kim { 59897c0b5abSJung-uk Kim if (!CrsExists) 59997c0b5abSJung-uk Kim { 60097c0b5abSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, 60197c0b5abSJung-uk Kim "_PRS is missing a _CRS, requires a _CRS and a _SRS"); 60297c0b5abSJung-uk Kim } 60397c0b5abSJung-uk Kim 60497c0b5abSJung-uk Kim if (!SrsExists) 60597c0b5abSJung-uk Kim { 60697c0b5abSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, 60797c0b5abSJung-uk Kim "_PRS is missing a _SRS, requires a _CRS and a _SRS"); 60897c0b5abSJung-uk Kim } 60997c0b5abSJung-uk Kim } 61097c0b5abSJung-uk Kim 61197c0b5abSJung-uk Kim /* 3) If _SRS is present, must have a _CRS and _PRS */ 61297c0b5abSJung-uk Kim 61397c0b5abSJung-uk Kim if (SrsExists) 61497c0b5abSJung-uk Kim { 61597c0b5abSJung-uk Kim if (!CrsExists) 61697c0b5abSJung-uk Kim { 61797c0b5abSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, 61897c0b5abSJung-uk Kim "_SRS is missing a _CRS, requires a _CRS and a _PRS"); 61997c0b5abSJung-uk Kim } 62097c0b5abSJung-uk Kim if (!PrsExists) 62197c0b5abSJung-uk Kim { 62297c0b5abSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_MISSING_DEPENDENCY, Op, 62397c0b5abSJung-uk Kim "_SRS is missing a _PRS, requires a _CRS and a _PRS"); 62497c0b5abSJung-uk Kim } 62597c0b5abSJung-uk Kim if (!DisExists) 62697c0b5abSJung-uk Kim { 62797c0b5abSJung-uk Kim AslError (ASL_REMARK, ASL_MSG_MISSING_DEPENDENCY, Op, 62897c0b5abSJung-uk Kim "_SRS is missing a _DIS"); 62997c0b5abSJung-uk Kim } 63097c0b5abSJung-uk Kim } 631313a0c13SJung-uk Kim break; 632313a0c13SJung-uk Kim 633efcc2a30SJung-uk Kim case PARSEOP_EVENT: 634efcc2a30SJung-uk Kim case PARSEOP_MUTEX: 635efcc2a30SJung-uk Kim case PARSEOP_OPERATIONREGION: 636efcc2a30SJung-uk Kim case PARSEOP_POWERRESOURCE: 637efcc2a30SJung-uk Kim case PARSEOP_PROCESSOR: 638efcc2a30SJung-uk Kim case PARSEOP_THERMALZONE: 639efcc2a30SJung-uk Kim 640efcc2a30SJung-uk Kim /* 641efcc2a30SJung-uk Kim * The first operand is a name to be created in the namespace. 642efcc2a30SJung-uk Kim * Check against the reserved list. 643efcc2a30SJung-uk Kim */ 644efcc2a30SJung-uk Kim i = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); 645efcc2a30SJung-uk Kim if (i < ACPI_VALID_RESERVED_NAME_MAX) 646efcc2a30SJung-uk Kim { 647f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESERVED_USE, 648f8146b88SJung-uk Kim Op, Op->Asl.ExternalName); 649efcc2a30SJung-uk Kim } 650ec0234b4SJung-uk Kim 651ec0234b4SJung-uk Kim MtCheckStaticOperationRegionInMethod (Op); 652efcc2a30SJung-uk Kim break; 653efcc2a30SJung-uk Kim 654efcc2a30SJung-uk Kim case PARSEOP_NAME: 655efcc2a30SJung-uk Kim 656efcc2a30SJung-uk Kim /* Typecheck any predefined names statically defined with Name() */ 657efcc2a30SJung-uk Kim 658efcc2a30SJung-uk Kim ApCheckForPredefinedObject (Op, Op->Asl.NameSeg); 659efcc2a30SJung-uk Kim 660efcc2a30SJung-uk Kim /* Special typechecking for _HID */ 661efcc2a30SJung-uk Kim 662f9a6772eSJung-uk Kim if (ACPI_COMPARE_NAMESEG (METHOD_NAME__HID, Op->Asl.NameSeg)) 663efcc2a30SJung-uk Kim { 664efcc2a30SJung-uk Kim Next = Op->Asl.Child->Asl.Next; 665efcc2a30SJung-uk Kim AnCheckId (Next, ASL_TYPE_HID); 666efcc2a30SJung-uk Kim } 667efcc2a30SJung-uk Kim 668efcc2a30SJung-uk Kim /* Special typechecking for _CID */ 669efcc2a30SJung-uk Kim 670f9a6772eSJung-uk Kim else if (ACPI_COMPARE_NAMESEG (METHOD_NAME__CID, Op->Asl.NameSeg)) 671efcc2a30SJung-uk Kim { 672efcc2a30SJung-uk Kim Next = Op->Asl.Child->Asl.Next; 673efcc2a30SJung-uk Kim 674efcc2a30SJung-uk Kim if ((Next->Asl.ParseOpcode == PARSEOP_PACKAGE) || 675efcc2a30SJung-uk Kim (Next->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)) 676efcc2a30SJung-uk Kim { 677efcc2a30SJung-uk Kim Next = Next->Asl.Child; 678efcc2a30SJung-uk Kim while (Next) 679efcc2a30SJung-uk Kim { 680efcc2a30SJung-uk Kim AnCheckId (Next, ASL_TYPE_CID); 681efcc2a30SJung-uk Kim Next = Next->Asl.Next; 682efcc2a30SJung-uk Kim } 683efcc2a30SJung-uk Kim } 684efcc2a30SJung-uk Kim else 685efcc2a30SJung-uk Kim { 686efcc2a30SJung-uk Kim AnCheckId (Next, ASL_TYPE_CID); 687efcc2a30SJung-uk Kim } 688efcc2a30SJung-uk Kim } 689313a0c13SJung-uk Kim 690efcc2a30SJung-uk Kim break; 691efcc2a30SJung-uk Kim 692efcc2a30SJung-uk Kim default: 693a9d8d09cSJung-uk Kim 694efcc2a30SJung-uk Kim break; 695efcc2a30SJung-uk Kim } 696efcc2a30SJung-uk Kim 697a9d8d09cSJung-uk Kim /* Check for named object creation within a non-serialized method */ 698a9d8d09cSJung-uk Kim 699a9d8d09cSJung-uk Kim MtCheckNamedObjectInMethod (Op, MethodInfo); 700efcc2a30SJung-uk Kim return (AE_OK); 701efcc2a30SJung-uk Kim } 702efcc2a30SJung-uk Kim 703efcc2a30SJung-uk Kim 704efcc2a30SJung-uk Kim /******************************************************************************* 705efcc2a30SJung-uk Kim * 706ec0234b4SJung-uk Kim * FUNCTION: MtProcessTypeOp 707ec0234b4SJung-uk Kim * 708ec0234b4SJung-uk Kim * PARAMETERS: Op - Op representing a btype 709ec0234b4SJung-uk Kim * 710ec0234b4SJung-uk Kim * RETURN: Btype represented by Op 711ec0234b4SJung-uk Kim * 712ec0234b4SJung-uk Kim * DESCRIPTION: Process a parse object that represents single parameter type or 713ec0234b4SJung-uk Kim * a return type in method, function, and external declarations. 714ec0234b4SJung-uk Kim * 715ec0234b4SJung-uk Kim ******************************************************************************/ 716ec0234b4SJung-uk Kim 717ec0234b4SJung-uk Kim UINT32 718ec0234b4SJung-uk Kim MtProcessTypeOp ( 719ec0234b4SJung-uk Kim ACPI_PARSE_OBJECT *TypeOp) 720ec0234b4SJung-uk Kim { 721ec0234b4SJung-uk Kim UINT32 Btype = ACPI_BTYPE_ANY; 722ec0234b4SJung-uk Kim 723ec0234b4SJung-uk Kim 724ec0234b4SJung-uk Kim while (TypeOp) 725ec0234b4SJung-uk Kim { 726ec0234b4SJung-uk Kim Btype |= AnMapObjTypeToBtype (TypeOp); 727ec0234b4SJung-uk Kim TypeOp->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG; 728ec0234b4SJung-uk Kim TypeOp = TypeOp->Asl.Next; 729ec0234b4SJung-uk Kim } 730ec0234b4SJung-uk Kim 731ec0234b4SJung-uk Kim return (Btype); 732ec0234b4SJung-uk Kim } 733ec0234b4SJung-uk Kim 734ec0234b4SJung-uk Kim 735ec0234b4SJung-uk Kim /******************************************************************************* 736ec0234b4SJung-uk Kim * 737ec0234b4SJung-uk Kim * FUNCTION: MtProcessParameterTypeList 738ec0234b4SJung-uk Kim * 739ec0234b4SJung-uk Kim * PARAMETERS: Op - Op representing a btype 740ec0234b4SJung-uk Kim * 741ec0234b4SJung-uk Kim * RETURN: Btype represented by Op 742ec0234b4SJung-uk Kim * 743ec0234b4SJung-uk Kim * DESCRIPTION: Process a parse object that represents a parameter type list in 744ec0234b4SJung-uk Kim * method, function, and external declarations. 745ec0234b4SJung-uk Kim * 746ec0234b4SJung-uk Kim ******************************************************************************/ 747ec0234b4SJung-uk Kim 748ec0234b4SJung-uk Kim UINT8 749ec0234b4SJung-uk Kim MtProcessParameterTypeList ( 750ec0234b4SJung-uk Kim ACPI_PARSE_OBJECT *ParamTypeOp, 751ec0234b4SJung-uk Kim UINT32 *TypeList) 752ec0234b4SJung-uk Kim { 753ec0234b4SJung-uk Kim UINT8 ParameterCount = 0; 754ec0234b4SJung-uk Kim 755ec0234b4SJung-uk Kim 75661b18036SJung-uk Kim if (ParamTypeOp && ParamTypeOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) 75761b18036SJung-uk Kim { 75861b18036SJung-uk Kim /* Special case for a single parameter without braces */ 75961b18036SJung-uk Kim 76061b18036SJung-uk Kim TypeList[ParameterCount] = 76161b18036SJung-uk Kim MtProcessTypeOp (ParamTypeOp); 76261b18036SJung-uk Kim 76361b18036SJung-uk Kim return (1); 76461b18036SJung-uk Kim } 76561b18036SJung-uk Kim 766ec0234b4SJung-uk Kim while (ParamTypeOp) 767ec0234b4SJung-uk Kim { 768ec0234b4SJung-uk Kim TypeList[ParameterCount] = 769ec0234b4SJung-uk Kim MtProcessTypeOp (ParamTypeOp->Asl.Child); 770ec0234b4SJung-uk Kim 771ec0234b4SJung-uk Kim ParameterCount++; 772ec0234b4SJung-uk Kim ParamTypeOp = ParamTypeOp->Asl.Next; 773ec0234b4SJung-uk Kim } 774ec0234b4SJung-uk Kim 775ec0234b4SJung-uk Kim return (ParameterCount); 776ec0234b4SJung-uk Kim } 777ec0234b4SJung-uk Kim 778ec0234b4SJung-uk Kim 779ec0234b4SJung-uk Kim /******************************************************************************* 780ec0234b4SJung-uk Kim * 781a9d8d09cSJung-uk Kim * FUNCTION: MtCheckNamedObjectInMethod 782a9d8d09cSJung-uk Kim * 783a9d8d09cSJung-uk Kim * PARAMETERS: Op - Current parser op 784a9d8d09cSJung-uk Kim * MethodInfo - Info for method being parsed 785a9d8d09cSJung-uk Kim * 786a9d8d09cSJung-uk Kim * RETURN: None 787a9d8d09cSJung-uk Kim * 788a9d8d09cSJung-uk Kim * DESCRIPTION: Detect if a non-serialized method is creating a named object, 789a9d8d09cSJung-uk Kim * which could possibly cause problems if two threads execute 790a9d8d09cSJung-uk Kim * the method concurrently. Emit a remark in this case. 791a9d8d09cSJung-uk Kim * 792a9d8d09cSJung-uk Kim ******************************************************************************/ 793a9d8d09cSJung-uk Kim 794f8146b88SJung-uk Kim static void 795a9d8d09cSJung-uk Kim MtCheckNamedObjectInMethod ( 796a9d8d09cSJung-uk Kim ACPI_PARSE_OBJECT *Op, 797a9d8d09cSJung-uk Kim ASL_METHOD_INFO *MethodInfo) 798a9d8d09cSJung-uk Kim { 799a9d8d09cSJung-uk Kim const ACPI_OPCODE_INFO *OpInfo; 800ec0234b4SJung-uk Kim char *ExternalPath; 801a9d8d09cSJung-uk Kim 802a9d8d09cSJung-uk Kim 803f8146b88SJung-uk Kim /* We don't care about actual method declarations or scopes */ 804a9d8d09cSJung-uk Kim 805f8146b88SJung-uk Kim if ((Op->Asl.AmlOpcode == AML_METHOD_OP) || 806f8146b88SJung-uk Kim (Op->Asl.AmlOpcode == AML_SCOPE_OP)) 807a9d8d09cSJung-uk Kim { 808a9d8d09cSJung-uk Kim return; 809a9d8d09cSJung-uk Kim } 810a9d8d09cSJung-uk Kim 81167d9aa44SJung-uk Kim /* Determine if we are creating a named object within a method */ 81267d9aa44SJung-uk Kim 81367d9aa44SJung-uk Kim if (!MethodInfo) 81467d9aa44SJung-uk Kim { 81567d9aa44SJung-uk Kim return; 81667d9aa44SJung-uk Kim } 817a9d8d09cSJung-uk Kim 818a9d8d09cSJung-uk Kim OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode); 8190b229c80SJung-uk Kim if ((OpInfo->Class == AML_CLASS_NAMED_OBJECT) && (Op->Asl.AmlOpcode != AML_FIELD_OP)) 820a9d8d09cSJung-uk Kim { 821a9d8d09cSJung-uk Kim /* 82267d9aa44SJung-uk Kim * 1) Mark the method as a method that creates named objects. 82367d9aa44SJung-uk Kim * 824ec0234b4SJung-uk Kim * 2) Issue a remark indicating the inefficiency of creating named 825ec0234b4SJung-uk Kim * objects within a method (Except for compiler-emitted temporary 826ec0234b4SJung-uk Kim * variables). 827ec0234b4SJung-uk Kim * 828ec0234b4SJung-uk Kim * 3) If the method is non-serialized, emit a remark that the method 82967d9aa44SJung-uk Kim * should be serialized. 830a9d8d09cSJung-uk Kim * 831a9d8d09cSJung-uk Kim * Reason: If a thread blocks within the method for any reason, and 83267d9aa44SJung-uk Kim * another thread enters the method, the method will fail because 83367d9aa44SJung-uk Kim * an attempt will be made to create the same object twice. 8340b229c80SJung-uk Kim * 8350b229c80SJung-uk Kim * Note: The Field opcode is disallowed here because Field() does not 8360b229c80SJung-uk Kim * create a new named object. 837a9d8d09cSJung-uk Kim */ 838ec0234b4SJung-uk Kim ExternalPath = AcpiNsGetNormalizedPathname (MethodInfo->Op->Asl.Node, TRUE); 839ec0234b4SJung-uk Kim 840ec0234b4SJung-uk Kim /* No error for compiler temp variables (name starts with "_T_") */ 841ec0234b4SJung-uk Kim 842ec0234b4SJung-uk Kim if ((Op->Asl.NameSeg[0] != '_') && 843ec0234b4SJung-uk Kim (Op->Asl.NameSeg[1] != 'T') && 844ec0234b4SJung-uk Kim (Op->Asl.NameSeg[2] != '_')) 845ec0234b4SJung-uk Kim { 846ec0234b4SJung-uk Kim AslError (ASL_REMARK, ASL_MSG_NAMED_OBJECT_CREATION, Op, 847ec0234b4SJung-uk Kim ExternalPath); 848ec0234b4SJung-uk Kim } 849ec0234b4SJung-uk Kim 85067d9aa44SJung-uk Kim MethodInfo->CreatesNamedObjects = TRUE; 85167d9aa44SJung-uk Kim if (!MethodInfo->ShouldBeSerialized) 852a9d8d09cSJung-uk Kim { 853a9d8d09cSJung-uk Kim AslError (ASL_REMARK, ASL_MSG_SERIALIZED_REQUIRED, MethodInfo->Op, 854ec0234b4SJung-uk Kim ExternalPath); 855a9d8d09cSJung-uk Kim 856a9d8d09cSJung-uk Kim /* Emit message only ONCE per method */ 857a9d8d09cSJung-uk Kim 858a9d8d09cSJung-uk Kim MethodInfo->ShouldBeSerialized = TRUE; 859a9d8d09cSJung-uk Kim } 860ec0234b4SJung-uk Kim 861ec0234b4SJung-uk Kim if (ExternalPath) 862ec0234b4SJung-uk Kim { 863ec0234b4SJung-uk Kim ACPI_FREE (ExternalPath); 864a9d8d09cSJung-uk Kim } 865a9d8d09cSJung-uk Kim } 866ec0234b4SJung-uk Kim } 867ec0234b4SJung-uk Kim 868ec0234b4SJung-uk Kim 869ec0234b4SJung-uk Kim /******************************************************************************* 870ec0234b4SJung-uk Kim * 871ec0234b4SJung-uk Kim * FUNCTION: MtCheckStaticOperationRegionInMethod 872ec0234b4SJung-uk Kim * 873ec0234b4SJung-uk Kim * PARAMETERS: Op - Current parser op 874ec0234b4SJung-uk Kim * 875ec0234b4SJung-uk Kim * RETURN: None 876ec0234b4SJung-uk Kim * 877ec0234b4SJung-uk Kim * DESCRIPTION: Warns if an Operation Region with static address or length 878ec0234b4SJung-uk Kim * is declared inside a control method 879ec0234b4SJung-uk Kim * 880ec0234b4SJung-uk Kim ******************************************************************************/ 881ec0234b4SJung-uk Kim 882ec0234b4SJung-uk Kim static void 883ec0234b4SJung-uk Kim MtCheckStaticOperationRegionInMethod( 884ec0234b4SJung-uk Kim ACPI_PARSE_OBJECT* Op) 885ec0234b4SJung-uk Kim { 886ec0234b4SJung-uk Kim ACPI_PARSE_OBJECT* AddressOp; 887ec0234b4SJung-uk Kim ACPI_PARSE_OBJECT* LengthOp; 888ec0234b4SJung-uk Kim 889ec0234b4SJung-uk Kim 890ec0234b4SJung-uk Kim if (Op->Asl.ParseOpcode != PARSEOP_OPERATIONREGION) 891ec0234b4SJung-uk Kim { 892ec0234b4SJung-uk Kim return; 893ec0234b4SJung-uk Kim } 894ec0234b4SJung-uk Kim 895ec0234b4SJung-uk Kim /* 896ec0234b4SJung-uk Kim * OperationRegion should have 4 arguments defined. At this point, we 897ec0234b4SJung-uk Kim * assume that the parse tree is well-formed. 898ec0234b4SJung-uk Kim */ 899ec0234b4SJung-uk Kim AddressOp = Op->Asl.Child->Asl.Next->Asl.Next; 900ec0234b4SJung-uk Kim LengthOp = Op->Asl.Child->Asl.Next->Asl.Next->Asl.Next; 901ec0234b4SJung-uk Kim 902ec0234b4SJung-uk Kim if (UtGetParentMethodOp (Op) && 903ec0234b4SJung-uk Kim AddressOp->Asl.ParseOpcode == PARSEOP_INTEGER && 904ec0234b4SJung-uk Kim LengthOp->Asl.ParseOpcode == PARSEOP_INTEGER) 905ec0234b4SJung-uk Kim { 906ec0234b4SJung-uk Kim /* 907ec0234b4SJung-uk Kim * At this point, a static operation region declared inside of a 908ec0234b4SJung-uk Kim * control method has been found. Throw a warning because this is 909ec0234b4SJung-uk Kim * highly inefficient. 910ec0234b4SJung-uk Kim */ 911ec0234b4SJung-uk Kim AslError(ASL_WARNING, ASL_MSG_STATIC_OPREGION_IN_METHOD, Op, NULL); 912ec0234b4SJung-uk Kim } 913ec0234b4SJung-uk Kim 914ec0234b4SJung-uk Kim return; 915ec0234b4SJung-uk Kim } 916a9d8d09cSJung-uk Kim 917a9d8d09cSJung-uk Kim 918a9d8d09cSJung-uk Kim /******************************************************************************* 919a9d8d09cSJung-uk Kim * 920efcc2a30SJung-uk Kim * FUNCTION: MtMethodAnalysisWalkEnd 921efcc2a30SJung-uk Kim * 922efcc2a30SJung-uk Kim * PARAMETERS: ASL_WALK_CALLBACK 923efcc2a30SJung-uk Kim * 924efcc2a30SJung-uk Kim * RETURN: Status 925efcc2a30SJung-uk Kim * 926efcc2a30SJung-uk Kim * DESCRIPTION: Ascending callback for analysis walk. Complete method 927efcc2a30SJung-uk Kim * return analysis. 928efcc2a30SJung-uk Kim * 929efcc2a30SJung-uk Kim ******************************************************************************/ 930efcc2a30SJung-uk Kim 931efcc2a30SJung-uk Kim ACPI_STATUS 932efcc2a30SJung-uk Kim MtMethodAnalysisWalkEnd ( 933efcc2a30SJung-uk Kim ACPI_PARSE_OBJECT *Op, 934efcc2a30SJung-uk Kim UINT32 Level, 935efcc2a30SJung-uk Kim void *Context) 936efcc2a30SJung-uk Kim { 937efcc2a30SJung-uk Kim ASL_ANALYSIS_WALK_INFO *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context; 938efcc2a30SJung-uk Kim ASL_METHOD_INFO *MethodInfo = WalkInfo->MethodStack; 939ec0234b4SJung-uk Kim char *ExternalPath; 940efcc2a30SJung-uk Kim 941efcc2a30SJung-uk Kim 942efcc2a30SJung-uk Kim switch (Op->Asl.ParseOpcode) 943efcc2a30SJung-uk Kim { 944efcc2a30SJung-uk Kim case PARSEOP_METHOD: 945efcc2a30SJung-uk Kim case PARSEOP_RETURN: 946a9d8d09cSJung-uk Kim 947efcc2a30SJung-uk Kim if (!MethodInfo) 948efcc2a30SJung-uk Kim { 949efcc2a30SJung-uk Kim printf ("No method info for method! [%s]\n", Op->Asl.Namepath); 950efcc2a30SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, 951efcc2a30SJung-uk Kim "No method info for this method"); 952efcc2a30SJung-uk Kim 953efcc2a30SJung-uk Kim CmCleanupAndExit (); 954efcc2a30SJung-uk Kim return (AE_AML_INTERNAL); 955efcc2a30SJung-uk Kim } 956efcc2a30SJung-uk Kim break; 957efcc2a30SJung-uk Kim 958efcc2a30SJung-uk Kim default: 959a9d8d09cSJung-uk Kim 960efcc2a30SJung-uk Kim break; 961efcc2a30SJung-uk Kim } 962efcc2a30SJung-uk Kim 963efcc2a30SJung-uk Kim switch (Op->Asl.ParseOpcode) 964efcc2a30SJung-uk Kim { 965efcc2a30SJung-uk Kim case PARSEOP_METHOD: 966efcc2a30SJung-uk Kim 967efcc2a30SJung-uk Kim WalkInfo->MethodStack = MethodInfo->Next; 968efcc2a30SJung-uk Kim 969efcc2a30SJung-uk Kim /* 970efcc2a30SJung-uk Kim * Check if there is no return statement at the end of the 971efcc2a30SJung-uk Kim * method AND we can actually get there -- i.e., the execution 972efcc2a30SJung-uk Kim * of the method can possibly terminate without a return statement. 973efcc2a30SJung-uk Kim */ 974efcc2a30SJung-uk Kim if ((!AnLastStatementIsReturn (Op)) && 9755f9b24faSJung-uk Kim (!(Op->Asl.CompileFlags & OP_HAS_NO_EXIT))) 976efcc2a30SJung-uk Kim { 977efcc2a30SJung-uk Kim /* 978efcc2a30SJung-uk Kim * No return statement, and execution can possibly exit 979efcc2a30SJung-uk Kim * via this path. This is equivalent to Return () 980efcc2a30SJung-uk Kim */ 981efcc2a30SJung-uk Kim MethodInfo->NumReturnNoValue++; 982efcc2a30SJung-uk Kim } 983efcc2a30SJung-uk Kim 984efcc2a30SJung-uk Kim /* 985efcc2a30SJung-uk Kim * Check for case where some return statements have a return value 986efcc2a30SJung-uk Kim * and some do not. Exit without a return statement is a return with 987efcc2a30SJung-uk Kim * no value 988efcc2a30SJung-uk Kim */ 989efcc2a30SJung-uk Kim if (MethodInfo->NumReturnNoValue && 990efcc2a30SJung-uk Kim MethodInfo->NumReturnWithValue) 991efcc2a30SJung-uk Kim { 992ec0234b4SJung-uk Kim ExternalPath = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE); 993ec0234b4SJung-uk Kim 994efcc2a30SJung-uk Kim AslError (ASL_WARNING, ASL_MSG_RETURN_TYPES, Op, 995ec0234b4SJung-uk Kim ExternalPath); 996ec0234b4SJung-uk Kim 997ec0234b4SJung-uk Kim if (ExternalPath) 998ec0234b4SJung-uk Kim { 999ec0234b4SJung-uk Kim ACPI_FREE (ExternalPath); 1000ec0234b4SJung-uk Kim } 1001efcc2a30SJung-uk Kim } 1002efcc2a30SJung-uk Kim 1003efcc2a30SJung-uk Kim /* 1004efcc2a30SJung-uk Kim * If there are any RETURN() statements with no value, or there is a 1005efcc2a30SJung-uk Kim * control path that allows the method to exit without a return value, 1006efcc2a30SJung-uk Kim * we mark the method as a method that does not return a value. This 1007efcc2a30SJung-uk Kim * knowledge can be used to check method invocations that expect a 1008efcc2a30SJung-uk Kim * returned value. 1009efcc2a30SJung-uk Kim */ 1010efcc2a30SJung-uk Kim if (MethodInfo->NumReturnNoValue) 1011efcc2a30SJung-uk Kim { 1012efcc2a30SJung-uk Kim if (MethodInfo->NumReturnWithValue) 1013efcc2a30SJung-uk Kim { 10145f9b24faSJung-uk Kim Op->Asl.CompileFlags |= OP_METHOD_SOME_NO_RETVAL; 1015efcc2a30SJung-uk Kim } 1016efcc2a30SJung-uk Kim else 1017efcc2a30SJung-uk Kim { 10185f9b24faSJung-uk Kim Op->Asl.CompileFlags |= OP_METHOD_NO_RETVAL; 1019efcc2a30SJung-uk Kim } 1020efcc2a30SJung-uk Kim } 1021efcc2a30SJung-uk Kim 1022efcc2a30SJung-uk Kim /* 1023efcc2a30SJung-uk Kim * Check predefined method names for correct return behavior 1024efcc2a30SJung-uk Kim * and correct number of arguments. Also, some special checks 1025efcc2a30SJung-uk Kim * For GPE and _REG methods. 1026efcc2a30SJung-uk Kim */ 1027efcc2a30SJung-uk Kim if (ApCheckForPredefinedMethod (Op, MethodInfo)) 1028efcc2a30SJung-uk Kim { 1029efcc2a30SJung-uk Kim /* Special check for two names like _L01 and _E01 in same scope */ 1030efcc2a30SJung-uk Kim 1031efcc2a30SJung-uk Kim ApCheckForGpeNameConflict (Op); 1032efcc2a30SJung-uk Kim 1033efcc2a30SJung-uk Kim /* 1034efcc2a30SJung-uk Kim * Special check for _REG: Must have an operation region definition 1035efcc2a30SJung-uk Kim * within the same scope! 1036efcc2a30SJung-uk Kim */ 1037efcc2a30SJung-uk Kim ApCheckRegMethod (Op); 1038efcc2a30SJung-uk Kim } 1039efcc2a30SJung-uk Kim 1040efcc2a30SJung-uk Kim ACPI_FREE (MethodInfo); 1041efcc2a30SJung-uk Kim break; 1042efcc2a30SJung-uk Kim 1043efcc2a30SJung-uk Kim case PARSEOP_NAME: 1044efcc2a30SJung-uk Kim 1045efcc2a30SJung-uk Kim /* Special check for two names like _L01 and _E01 in same scope */ 1046efcc2a30SJung-uk Kim 1047efcc2a30SJung-uk Kim ApCheckForGpeNameConflict (Op); 1048efcc2a30SJung-uk Kim break; 1049efcc2a30SJung-uk Kim 1050efcc2a30SJung-uk Kim case PARSEOP_RETURN: 1051efcc2a30SJung-uk Kim 1052efcc2a30SJung-uk Kim /* 1053efcc2a30SJung-uk Kim * If the parent is a predefined method name, attempt to typecheck 1054efcc2a30SJung-uk Kim * the return value. Only static types can be validated. 1055efcc2a30SJung-uk Kim */ 1056efcc2a30SJung-uk Kim ApCheckPredefinedReturnValue (Op, MethodInfo); 1057efcc2a30SJung-uk Kim 1058efcc2a30SJung-uk Kim /* 1059efcc2a30SJung-uk Kim * The parent block does not "exit" and continue execution -- the 1060efcc2a30SJung-uk Kim * method is terminated here with the Return() statement. 1061efcc2a30SJung-uk Kim */ 10625f9b24faSJung-uk Kim Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT; 1063efcc2a30SJung-uk Kim 1064efcc2a30SJung-uk Kim /* Used in the "typing" pass later */ 1065efcc2a30SJung-uk Kim 1066efcc2a30SJung-uk Kim Op->Asl.ParentMethod = MethodInfo->Op; 1067efcc2a30SJung-uk Kim 1068efcc2a30SJung-uk Kim /* 1069efcc2a30SJung-uk Kim * If there is a peer node after the return statement, then this 1070efcc2a30SJung-uk Kim * node is unreachable code -- i.e., it won't be executed because of 1071efcc2a30SJung-uk Kim * the preceding Return() statement. 1072efcc2a30SJung-uk Kim */ 1073efcc2a30SJung-uk Kim if (Op->Asl.Next) 1074efcc2a30SJung-uk Kim { 1075f8146b88SJung-uk Kim AslError (ASL_WARNING, ASL_MSG_UNREACHABLE_CODE, 1076f8146b88SJung-uk Kim Op->Asl.Next, NULL); 1077efcc2a30SJung-uk Kim } 1078efcc2a30SJung-uk Kim break; 1079efcc2a30SJung-uk Kim 1080efcc2a30SJung-uk Kim case PARSEOP_IF: 1081efcc2a30SJung-uk Kim 10825f9b24faSJung-uk Kim if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) && 1083efcc2a30SJung-uk Kim (Op->Asl.Next) && 1084efcc2a30SJung-uk Kim (Op->Asl.Next->Asl.ParseOpcode == PARSEOP_ELSE)) 1085efcc2a30SJung-uk Kim { 1086efcc2a30SJung-uk Kim /* 1087efcc2a30SJung-uk Kim * This IF has a corresponding ELSE. The IF block has no exit, 1088efcc2a30SJung-uk Kim * (it contains an unconditional Return) 1089efcc2a30SJung-uk Kim * mark the ELSE block to remember this fact. 1090efcc2a30SJung-uk Kim */ 10915f9b24faSJung-uk Kim Op->Asl.Next->Asl.CompileFlags |= OP_IF_HAS_NO_EXIT; 1092efcc2a30SJung-uk Kim } 1093efcc2a30SJung-uk Kim break; 1094efcc2a30SJung-uk Kim 1095efcc2a30SJung-uk Kim case PARSEOP_ELSE: 1096efcc2a30SJung-uk Kim 10975f9b24faSJung-uk Kim if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) && 10985f9b24faSJung-uk Kim (Op->Asl.CompileFlags & OP_IF_HAS_NO_EXIT)) 1099efcc2a30SJung-uk Kim { 1100efcc2a30SJung-uk Kim /* 1101efcc2a30SJung-uk Kim * This ELSE block has no exit and the corresponding IF block 1102efcc2a30SJung-uk Kim * has no exit either. Therefore, the parent node has no exit. 1103efcc2a30SJung-uk Kim */ 11045f9b24faSJung-uk Kim Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT; 1105efcc2a30SJung-uk Kim } 1106efcc2a30SJung-uk Kim break; 1107efcc2a30SJung-uk Kim 1108efcc2a30SJung-uk Kim 1109efcc2a30SJung-uk Kim default: 1110efcc2a30SJung-uk Kim 11115f9b24faSJung-uk Kim if ((Op->Asl.CompileFlags & OP_HAS_NO_EXIT) && 1112efcc2a30SJung-uk Kim (Op->Asl.Parent)) 1113efcc2a30SJung-uk Kim { 1114efcc2a30SJung-uk Kim /* If this node has no exit, then the parent has no exit either */ 1115efcc2a30SJung-uk Kim 11165f9b24faSJung-uk Kim Op->Asl.Parent->Asl.CompileFlags |= OP_HAS_NO_EXIT; 1117efcc2a30SJung-uk Kim } 1118efcc2a30SJung-uk Kim break; 1119efcc2a30SJung-uk Kim } 1120efcc2a30SJung-uk Kim 1121efcc2a30SJung-uk Kim return (AE_OK); 1122efcc2a30SJung-uk Kim } 1123