1ca3cf4faSJung-uk Kim /****************************************************************************** 2ca3cf4faSJung-uk Kim * 3ca3cf4faSJung-uk Kim * Module Name: aslpredef - support for ACPI predefined names 4ca3cf4faSJung-uk Kim * 5ca3cf4faSJung-uk Kim *****************************************************************************/ 6ca3cf4faSJung-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. 12ca3cf4faSJung-uk Kim * All rights reserved. 13ca3cf4faSJung-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 * 119d244b227SJung-uk Kim * Redistribution and use in source and binary forms, with or without 120d244b227SJung-uk Kim * modification, are permitted provided that the following conditions 121d244b227SJung-uk Kim * are met: 122d244b227SJung-uk Kim * 1. Redistributions of source code must retain the above copyright 123d244b227SJung-uk Kim * notice, this list of conditions, and the following disclaimer, 124d244b227SJung-uk Kim * without modification. 125d244b227SJung-uk Kim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126d244b227SJung-uk Kim * substantially similar to the "NO WARRANTY" disclaimer below 127d244b227SJung-uk Kim * ("Disclaimer") and any redistribution must be conditioned upon 128d244b227SJung-uk Kim * including a substantially similar Disclaimer requirement for further 129d244b227SJung-uk Kim * binary redistribution. 130d244b227SJung-uk Kim * 3. Neither the names of the above-listed copyright holders nor the names 131d244b227SJung-uk Kim * of any contributors may be used to endorse or promote products derived 132d244b227SJung-uk Kim * from this software without specific prior written permission. 133ca3cf4faSJung-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 147d244b227SJung-uk Kim * GNU General Public License ("GPL") version 2 as published by the Free 148d244b227SJung-uk Kim * Software Foundation. 149ca3cf4faSJung-uk Kim * 1500d84335fSJung-uk Kim *****************************************************************************/ 151ca3cf4faSJung-uk Kim 152ca3cf4faSJung-uk Kim #define ACPI_CREATE_PREDEFINED_TABLE 1539c7c683cSJung-uk Kim #define ACPI_CREATE_RESOURCE_TABLE 154ca3cf4faSJung-uk Kim 155ca3cf4faSJung-uk Kim #include <contrib/dev/acpica/compiler/aslcompiler.h> 156ca3cf4faSJung-uk Kim #include "aslcompiler.y.h" 157ca3cf4faSJung-uk Kim #include <contrib/dev/acpica/include/acpredef.h> 1589c48c75eSJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h> 159ca3cf4faSJung-uk Kim 160ca3cf4faSJung-uk Kim 161ca3cf4faSJung-uk Kim #define _COMPONENT ACPI_COMPILER 162ca3cf4faSJung-uk Kim ACPI_MODULE_NAME ("aslpredef") 163ca3cf4faSJung-uk Kim 164ca3cf4faSJung-uk Kim 165ca3cf4faSJung-uk Kim /* Local prototypes */ 166ca3cf4faSJung-uk Kim 1670b94ba42SJung-uk Kim static void 1680b94ba42SJung-uk Kim ApCheckForUnexpectedReturnValue ( 1690b94ba42SJung-uk Kim ACPI_PARSE_OBJECT *Op, 1700b94ba42SJung-uk Kim ASL_METHOD_INFO *MethodInfo); 1710b94ba42SJung-uk Kim 172ca3cf4faSJung-uk Kim static UINT32 173ca3cf4faSJung-uk Kim ApCheckForSpecialName ( 174ca3cf4faSJung-uk Kim ACPI_PARSE_OBJECT *Op, 175ca3cf4faSJung-uk Kim char *Name); 176ca3cf4faSJung-uk Kim 177ca3cf4faSJung-uk Kim 178ca3cf4faSJung-uk Kim /******************************************************************************* 179ca3cf4faSJung-uk Kim * 180ca3cf4faSJung-uk Kim * FUNCTION: ApCheckForPredefinedMethod 181ca3cf4faSJung-uk Kim * 182ca3cf4faSJung-uk Kim * PARAMETERS: Op - A parse node of type "METHOD". 183ca3cf4faSJung-uk Kim * MethodInfo - Saved info about this method 184ca3cf4faSJung-uk Kim * 185ca3cf4faSJung-uk Kim * RETURN: None 186ca3cf4faSJung-uk Kim * 187ca3cf4faSJung-uk Kim * DESCRIPTION: If method is a predefined name, check that the number of 188ca3cf4faSJung-uk Kim * arguments and the return type (returns a value or not) 189ca3cf4faSJung-uk Kim * is correct. 190ca3cf4faSJung-uk Kim * 191ca3cf4faSJung-uk Kim ******************************************************************************/ 192ca3cf4faSJung-uk Kim 193d052a1ccSJung-uk Kim BOOLEAN 194ca3cf4faSJung-uk Kim ApCheckForPredefinedMethod ( 195ca3cf4faSJung-uk Kim ACPI_PARSE_OBJECT *Op, 196ca3cf4faSJung-uk Kim ASL_METHOD_INFO *MethodInfo) 197ca3cf4faSJung-uk Kim { 198ca3cf4faSJung-uk Kim UINT32 Index; 1999c7c683cSJung-uk Kim UINT32 RequiredArgCount; 2009c7c683cSJung-uk Kim const ACPI_PREDEFINED_INFO *ThisName; 201ca3cf4faSJung-uk Kim 202ca3cf4faSJung-uk Kim 203ca3cf4faSJung-uk Kim /* Check for a match against the predefined name list */ 204ca3cf4faSJung-uk Kim 205ca3cf4faSJung-uk Kim Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); 206ca3cf4faSJung-uk Kim 207ca3cf4faSJung-uk Kim switch (Index) 208ca3cf4faSJung-uk Kim { 209ca3cf4faSJung-uk Kim case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ 210ca3cf4faSJung-uk Kim case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ 211ca3cf4faSJung-uk Kim case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ 212ca3cf4faSJung-uk Kim 213ca3cf4faSJung-uk Kim /* Just return, nothing to do */ 214d052a1ccSJung-uk Kim return (FALSE); 215ca3cf4faSJung-uk Kim 216ca3cf4faSJung-uk Kim 2173f5e024cSJung-uk Kim case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ 218ca3cf4faSJung-uk Kim 2196f1f1a63SJung-uk Kim AslGbl_ReservedMethods++; 220ca3cf4faSJung-uk Kim 2213f5e024cSJung-uk Kim /* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */ 222ca3cf4faSJung-uk Kim 223ca3cf4faSJung-uk Kim if (MethodInfo->NumArguments != 0) 224ca3cf4faSJung-uk Kim { 2254a38ee6dSJung-uk Kim sprintf (AslGbl_MsgBuffer, "%s requires %d", Op->Asl.ExternalName, 0); 226ca3cf4faSJung-uk Kim 227ca3cf4faSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, 2286f1f1a63SJung-uk Kim AslGbl_MsgBuffer); 229ca3cf4faSJung-uk Kim } 230ca3cf4faSJung-uk Kim break; 231ca3cf4faSJung-uk Kim 232ca3cf4faSJung-uk Kim 233ca3cf4faSJung-uk Kim default: 234ca3cf4faSJung-uk Kim /* 235895f26a9SJung-uk Kim * Matched a predefined method name - validate the ASL-defined 236895f26a9SJung-uk Kim * argument count against the ACPI specification. 237ca3cf4faSJung-uk Kim * 238895f26a9SJung-uk Kim * Some methods are allowed to have a "minimum" number of args 239895f26a9SJung-uk Kim * (_SCP) because their definition in ACPI has changed over time. 240ca3cf4faSJung-uk Kim */ 2416f1f1a63SJung-uk Kim AslGbl_ReservedMethods++; 2429c7c683cSJung-uk Kim ThisName = &AcpiGbl_PredefinedMethods[Index]; 243895f26a9SJung-uk Kim RequiredArgCount = METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList); 244ca3cf4faSJung-uk Kim 2459c7c683cSJung-uk Kim if (MethodInfo->NumArguments != RequiredArgCount) 246ca3cf4faSJung-uk Kim { 2476f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "%4.4s requires %u", 2489c7c683cSJung-uk Kim ThisName->Info.Name, RequiredArgCount); 249ca3cf4faSJung-uk Kim 250895f26a9SJung-uk Kim if (MethodInfo->NumArguments < RequiredArgCount) 251895f26a9SJung-uk Kim { 252895f26a9SJung-uk Kim AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, 2536f1f1a63SJung-uk Kim AslGbl_MsgBuffer); 254895f26a9SJung-uk Kim } 255895f26a9SJung-uk Kim else if ((MethodInfo->NumArguments > RequiredArgCount) && 2569c7c683cSJung-uk Kim !(ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM)) 257ca3cf4faSJung-uk Kim { 258ca3cf4faSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, 2596f1f1a63SJung-uk Kim AslGbl_MsgBuffer); 260ca3cf4faSJung-uk Kim } 261ca3cf4faSJung-uk Kim } 262ca3cf4faSJung-uk Kim 263ca3cf4faSJung-uk Kim /* 264ca3cf4faSJung-uk Kim * Check if method returns no value, but the predefined name is 265ca3cf4faSJung-uk Kim * required to return a value 266ca3cf4faSJung-uk Kim */ 267ca3cf4faSJung-uk Kim if (MethodInfo->NumReturnNoValue && 2689c7c683cSJung-uk Kim ThisName->Info.ExpectedBtypes) 269ca3cf4faSJung-uk Kim { 2706f1f1a63SJung-uk Kim AcpiUtGetExpectedReturnTypes (AslGbl_StringBuffer, 2719c7c683cSJung-uk Kim ThisName->Info.ExpectedBtypes); 2728c8be05fSJung-uk Kim 2736f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "%s required for %4.4s", 2746f1f1a63SJung-uk Kim AslGbl_StringBuffer, ThisName->Info.Name); 275ca3cf4faSJung-uk Kim 276ca3cf4faSJung-uk Kim AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, 2776f1f1a63SJung-uk Kim AslGbl_MsgBuffer); 278ca3cf4faSJung-uk Kim } 279ca3cf4faSJung-uk Kim break; 280ca3cf4faSJung-uk Kim } 281d052a1ccSJung-uk Kim 282d052a1ccSJung-uk Kim return (TRUE); 283ca3cf4faSJung-uk Kim } 284ca3cf4faSJung-uk Kim 285ca3cf4faSJung-uk Kim 286ca3cf4faSJung-uk Kim /******************************************************************************* 287ca3cf4faSJung-uk Kim * 2880b94ba42SJung-uk Kim * FUNCTION: ApCheckForUnexpectedReturnValue 2890b94ba42SJung-uk Kim * 2900b94ba42SJung-uk Kim * PARAMETERS: Op - A parse node of type "RETURN". 2910b94ba42SJung-uk Kim * MethodInfo - Saved info about this method 2920b94ba42SJung-uk Kim * 2930b94ba42SJung-uk Kim * RETURN: None 2940b94ba42SJung-uk Kim * 2950b94ba42SJung-uk Kim * DESCRIPTION: Check for an unexpected return value from a predefined method. 2960b94ba42SJung-uk Kim * Invoked for predefined methods that are defined to not return 2970b94ba42SJung-uk Kim * any value. If there is a return value, issue a remark, since 2980b94ba42SJung-uk Kim * the ASL writer may be confused as to the method definition 2990b94ba42SJung-uk Kim * and/or functionality. 3000b94ba42SJung-uk Kim * 3010b94ba42SJung-uk Kim * Note: We ignore all return values of "Zero", since this is what a standalone 3020b94ba42SJung-uk Kim * Return() statement will always generate -- so we ignore it here -- 3030b94ba42SJung-uk Kim * i.e., there is no difference between Return() and Return(Zero). 3040b94ba42SJung-uk Kim * Also, a null Return() will be disassembled to return(Zero) -- so, we 3050b94ba42SJung-uk Kim * don't want to generate extraneous remarks/warnings for a disassembled 3060b94ba42SJung-uk Kim * ASL file. 3070b94ba42SJung-uk Kim * 3080b94ba42SJung-uk Kim ******************************************************************************/ 3090b94ba42SJung-uk Kim 3100b94ba42SJung-uk Kim static void 3110b94ba42SJung-uk Kim ApCheckForUnexpectedReturnValue ( 3120b94ba42SJung-uk Kim ACPI_PARSE_OBJECT *Op, 3130b94ba42SJung-uk Kim ASL_METHOD_INFO *MethodInfo) 3140b94ba42SJung-uk Kim { 3150b94ba42SJung-uk Kim ACPI_PARSE_OBJECT *ReturnValueOp; 3160b94ba42SJung-uk Kim 3170b94ba42SJung-uk Kim 3180b94ba42SJung-uk Kim /* Ignore Return() and Return(Zero) (they are the same) */ 3190b94ba42SJung-uk Kim 3200b94ba42SJung-uk Kim ReturnValueOp = Op->Asl.Child; 3210b94ba42SJung-uk Kim if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_ZERO) 3220b94ba42SJung-uk Kim { 3230b94ba42SJung-uk Kim return; 3240b94ba42SJung-uk Kim } 3250b94ba42SJung-uk Kim 3260b94ba42SJung-uk Kim /* We have a valid return value, but the reserved name did not expect it */ 3270b94ba42SJung-uk Kim 3280b94ba42SJung-uk Kim AslError (ASL_WARNING, ASL_MSG_RESERVED_NO_RETURN_VAL, 3290b94ba42SJung-uk Kim Op, MethodInfo->Op->Asl.ExternalName); 3300b94ba42SJung-uk Kim } 3310b94ba42SJung-uk Kim 3320b94ba42SJung-uk Kim 3330b94ba42SJung-uk Kim /******************************************************************************* 3340b94ba42SJung-uk Kim * 3358c8be05fSJung-uk Kim * FUNCTION: ApCheckPredefinedReturnValue 3368c8be05fSJung-uk Kim * 3378c8be05fSJung-uk Kim * PARAMETERS: Op - A parse node of type "RETURN". 3388c8be05fSJung-uk Kim * MethodInfo - Saved info about this method 3398c8be05fSJung-uk Kim * 3408c8be05fSJung-uk Kim * RETURN: None 3418c8be05fSJung-uk Kim * 3428c8be05fSJung-uk Kim * DESCRIPTION: If method is a predefined name, attempt to validate the return 3438c8be05fSJung-uk Kim * value. Only "static" types can be validated - a simple return 3448c8be05fSJung-uk Kim * of an integer/string/buffer/package or a named reference to 3458c8be05fSJung-uk Kim * a static object. Values such as a Localx or Argx or a control 3460b94ba42SJung-uk Kim * method invocation are not checked. Issue a warning if there is 3470b94ba42SJung-uk Kim * a valid return value, but the reserved method defines no 3480b94ba42SJung-uk Kim * return value. 3498c8be05fSJung-uk Kim * 3508c8be05fSJung-uk Kim ******************************************************************************/ 3518c8be05fSJung-uk Kim 3528c8be05fSJung-uk Kim void 3538c8be05fSJung-uk Kim ApCheckPredefinedReturnValue ( 3548c8be05fSJung-uk Kim ACPI_PARSE_OBJECT *Op, 3558c8be05fSJung-uk Kim ASL_METHOD_INFO *MethodInfo) 3568c8be05fSJung-uk Kim { 3578c8be05fSJung-uk Kim UINT32 Index; 3588c8be05fSJung-uk Kim ACPI_PARSE_OBJECT *ReturnValueOp; 3599c7c683cSJung-uk Kim const ACPI_PREDEFINED_INFO *ThisName; 3608c8be05fSJung-uk Kim 3618c8be05fSJung-uk Kim 362313a0c13SJung-uk Kim /* 363313a0c13SJung-uk Kim * Check parent method for a match against the predefined name list. 364313a0c13SJung-uk Kim * 365313a0c13SJung-uk Kim * Note: Disable compiler errors/warnings because any errors will be 366313a0c13SJung-uk Kim * caught when analyzing the parent method. Eliminates duplicate errors. 367313a0c13SJung-uk Kim */ 3686f1f1a63SJung-uk Kim AslGbl_AllExceptionsDisabled = TRUE; 3698c8be05fSJung-uk Kim Index = ApCheckForPredefinedName (MethodInfo->Op, 3708c8be05fSJung-uk Kim MethodInfo->Op->Asl.NameSeg); 3716f1f1a63SJung-uk Kim AslGbl_AllExceptionsDisabled = FALSE; 3728c8be05fSJung-uk Kim 3738c8be05fSJung-uk Kim switch (Index) 3748c8be05fSJung-uk Kim { 3750b94ba42SJung-uk Kim case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ 3760b94ba42SJung-uk Kim 3770b94ba42SJung-uk Kim /* No return value expected, warn if there is one */ 3780b94ba42SJung-uk Kim 3790b94ba42SJung-uk Kim ApCheckForUnexpectedReturnValue (Op, MethodInfo); 3800b94ba42SJung-uk Kim return; 3810b94ba42SJung-uk Kim 3828c8be05fSJung-uk Kim case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ 3838c8be05fSJung-uk Kim case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ 3848c8be05fSJung-uk Kim case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ 3858c8be05fSJung-uk Kim 3868c8be05fSJung-uk Kim /* Just return, nothing to do */ 3878c8be05fSJung-uk Kim return; 3888c8be05fSJung-uk Kim 3893f5e024cSJung-uk Kim default: /* A standard predefined ACPI name */ 3908c8be05fSJung-uk Kim 3919c7c683cSJung-uk Kim ThisName = &AcpiGbl_PredefinedMethods[Index]; 3929c7c683cSJung-uk Kim if (!ThisName->Info.ExpectedBtypes) 3938c8be05fSJung-uk Kim { 3940b94ba42SJung-uk Kim /* No return value expected, warn if there is one */ 3950b94ba42SJung-uk Kim 3960b94ba42SJung-uk Kim ApCheckForUnexpectedReturnValue (Op, MethodInfo); 3978c8be05fSJung-uk Kim return; 3988c8be05fSJung-uk Kim } 3998c8be05fSJung-uk Kim 4008c8be05fSJung-uk Kim /* Get the object returned, it is the next argument */ 4018c8be05fSJung-uk Kim 4028c8be05fSJung-uk Kim ReturnValueOp = Op->Asl.Child; 4038c8be05fSJung-uk Kim switch (ReturnValueOp->Asl.ParseOpcode) 4048c8be05fSJung-uk Kim { 4058c8be05fSJung-uk Kim case PARSEOP_ZERO: 4068c8be05fSJung-uk Kim case PARSEOP_ONE: 4078c8be05fSJung-uk Kim case PARSEOP_ONES: 4088c8be05fSJung-uk Kim case PARSEOP_INTEGER: 4098c8be05fSJung-uk Kim case PARSEOP_STRING_LITERAL: 4108c8be05fSJung-uk Kim case PARSEOP_BUFFER: 4118c8be05fSJung-uk Kim case PARSEOP_PACKAGE: 4128c8be05fSJung-uk Kim 4138c8be05fSJung-uk Kim /* Static data return object - check against expected type */ 4148c8be05fSJung-uk Kim 4159c7c683cSJung-uk Kim ApCheckObjectType (ThisName->Info.Name, ReturnValueOp, 4169c7c683cSJung-uk Kim ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); 4179c48c75eSJung-uk Kim 4189c48c75eSJung-uk Kim /* For packages, check the individual package elements */ 4199c48c75eSJung-uk Kim 4209c48c75eSJung-uk Kim if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_PACKAGE) 4219c48c75eSJung-uk Kim { 4229c7c683cSJung-uk Kim ApCheckPackage (ReturnValueOp, ThisName); 4239c48c75eSJung-uk Kim } 4248c8be05fSJung-uk Kim break; 4258c8be05fSJung-uk Kim 4268c8be05fSJung-uk Kim default: 4278c8be05fSJung-uk Kim /* 4288c8be05fSJung-uk Kim * All other ops are very difficult or impossible to typecheck at 4298c8be05fSJung-uk Kim * compile time. These include all Localx, Argx, and method 4308c8be05fSJung-uk Kim * invocations. Also, NAMESEG and NAMESTRING because the type of 4318c8be05fSJung-uk Kim * any named object can be changed at runtime (for example, 4328c8be05fSJung-uk Kim * CopyObject will change the type of the target object.) 4338c8be05fSJung-uk Kim */ 4348c8be05fSJung-uk Kim break; 4358c8be05fSJung-uk Kim } 4368c8be05fSJung-uk Kim } 4378c8be05fSJung-uk Kim } 4388c8be05fSJung-uk Kim 4398c8be05fSJung-uk Kim 4408c8be05fSJung-uk Kim /******************************************************************************* 4418c8be05fSJung-uk Kim * 442ca3cf4faSJung-uk Kim * FUNCTION: ApCheckForPredefinedObject 443ca3cf4faSJung-uk Kim * 444ca3cf4faSJung-uk Kim * PARAMETERS: Op - A parse node 445ca3cf4faSJung-uk Kim * Name - The ACPI name to be checked 446ca3cf4faSJung-uk Kim * 447ca3cf4faSJung-uk Kim * RETURN: None 448ca3cf4faSJung-uk Kim * 449ca3cf4faSJung-uk Kim * DESCRIPTION: Check for a predefined name for a static object (created via 450ca3cf4faSJung-uk Kim * the ASL Name operator). If it is a predefined ACPI name, ensure 451ca3cf4faSJung-uk Kim * that the name does not require any arguments (which would 452cd6518c7SJung-uk Kim * require a control method implementation of the name), and that 453ca3cf4faSJung-uk Kim * the type of the object is one of the expected types for the 454ca3cf4faSJung-uk Kim * predefined name. 455ca3cf4faSJung-uk Kim * 456ca3cf4faSJung-uk Kim ******************************************************************************/ 457ca3cf4faSJung-uk Kim 458ca3cf4faSJung-uk Kim void 459ca3cf4faSJung-uk Kim ApCheckForPredefinedObject ( 460ca3cf4faSJung-uk Kim ACPI_PARSE_OBJECT *Op, 461ca3cf4faSJung-uk Kim char *Name) 462ca3cf4faSJung-uk Kim { 463ca3cf4faSJung-uk Kim UINT32 Index; 4649c48c75eSJung-uk Kim ACPI_PARSE_OBJECT *ObjectOp; 4659c7c683cSJung-uk Kim const ACPI_PREDEFINED_INFO *ThisName; 466ca3cf4faSJung-uk Kim 467ca3cf4faSJung-uk Kim 468ca3cf4faSJung-uk Kim /* 469ca3cf4faSJung-uk Kim * Check for a real predefined name -- not a resource descriptor name 470ca3cf4faSJung-uk Kim * or a predefined scope name 471ca3cf4faSJung-uk Kim */ 472ca3cf4faSJung-uk Kim Index = ApCheckForPredefinedName (Op, Name); 4733f5e024cSJung-uk Kim 4743f5e024cSJung-uk Kim switch (Index) 475ca3cf4faSJung-uk Kim { 4763f5e024cSJung-uk Kim case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ 4773f5e024cSJung-uk Kim case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ 4783f5e024cSJung-uk Kim case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ 4793f5e024cSJung-uk Kim 4803f5e024cSJung-uk Kim /* Nothing to do */ 4813f5e024cSJung-uk Kim return; 4823f5e024cSJung-uk Kim 4833f5e024cSJung-uk Kim case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ 4843f5e024cSJung-uk Kim 4853f5e024cSJung-uk Kim /* 4863f5e024cSJung-uk Kim * These names must be control methods, by definition in ACPI spec. 4873f5e024cSJung-uk Kim * Also because they are defined to return no value. None of them 4883f5e024cSJung-uk Kim * require any arguments. 4893f5e024cSJung-uk Kim */ 4903f5e024cSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, 4913f5e024cSJung-uk Kim "with zero arguments"); 4923f5e024cSJung-uk Kim return; 4933f5e024cSJung-uk Kim 4949c48c75eSJung-uk Kim default: 495a9d8d09cSJung-uk Kim 4969c48c75eSJung-uk Kim break; 4979c48c75eSJung-uk Kim } 4989c48c75eSJung-uk Kim 4999c48c75eSJung-uk Kim /* A standard predefined ACPI name */ 5003f5e024cSJung-uk Kim 5013f5e024cSJung-uk Kim /* 5023f5e024cSJung-uk Kim * If this predefined name requires input arguments, then 5033f5e024cSJung-uk Kim * it must be implemented as a control method 5043f5e024cSJung-uk Kim */ 5059c7c683cSJung-uk Kim ThisName = &AcpiGbl_PredefinedMethods[Index]; 506895f26a9SJung-uk Kim if (METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList) > 0) 5073f5e024cSJung-uk Kim { 5083f5e024cSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, 5093f5e024cSJung-uk Kim "with arguments"); 510ca3cf4faSJung-uk Kim return; 511ca3cf4faSJung-uk Kim } 512ca3cf4faSJung-uk Kim 513ca3cf4faSJung-uk Kim /* 5143f5e024cSJung-uk Kim * If no return value is expected from this predefined name, then 5153f5e024cSJung-uk Kim * it follows that it must be implemented as a control method 5163f5e024cSJung-uk Kim * (with zero args, because the args > 0 case was handled above) 5173f5e024cSJung-uk Kim * Examples are: _DIS, _INI, _IRC, _OFF, _ON, _PSx 518ca3cf4faSJung-uk Kim */ 5199c7c683cSJung-uk Kim if (!ThisName->Info.ExpectedBtypes) 520ca3cf4faSJung-uk Kim { 521ca3cf4faSJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, 5223f5e024cSJung-uk Kim "with zero arguments"); 5233f5e024cSJung-uk Kim return; 524ca3cf4faSJung-uk Kim } 525ca3cf4faSJung-uk Kim 526ca3cf4faSJung-uk Kim /* Typecheck the actual object, it is the next argument */ 527ca3cf4faSJung-uk Kim 5289c48c75eSJung-uk Kim ObjectOp = Op->Asl.Child->Asl.Next; 5299c7c683cSJung-uk Kim ApCheckObjectType (ThisName->Info.Name, Op->Asl.Child->Asl.Next, 5309c7c683cSJung-uk Kim ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); 5319c48c75eSJung-uk Kim 5329c48c75eSJung-uk Kim /* For packages, check the individual package elements */ 5339c48c75eSJung-uk Kim 5349c48c75eSJung-uk Kim if (ObjectOp->Asl.ParseOpcode == PARSEOP_PACKAGE) 5359c48c75eSJung-uk Kim { 5369c7c683cSJung-uk Kim ApCheckPackage (ObjectOp, ThisName); 5373f5e024cSJung-uk Kim } 538ca3cf4faSJung-uk Kim } 539ca3cf4faSJung-uk Kim 540ca3cf4faSJung-uk Kim 541ca3cf4faSJung-uk Kim /******************************************************************************* 542ca3cf4faSJung-uk Kim * 543ca3cf4faSJung-uk Kim * FUNCTION: ApCheckForPredefinedName 544ca3cf4faSJung-uk Kim * 545ca3cf4faSJung-uk Kim * PARAMETERS: Op - A parse node 546ca3cf4faSJung-uk Kim * Name - NameSeg to check 547ca3cf4faSJung-uk Kim * 548ca3cf4faSJung-uk Kim * RETURN: None 549ca3cf4faSJung-uk Kim * 550ca3cf4faSJung-uk Kim * DESCRIPTION: Check a NameSeg against the reserved list. 551ca3cf4faSJung-uk Kim * 552ca3cf4faSJung-uk Kim ******************************************************************************/ 553ca3cf4faSJung-uk Kim 554ca3cf4faSJung-uk Kim UINT32 555ca3cf4faSJung-uk Kim ApCheckForPredefinedName ( 556ca3cf4faSJung-uk Kim ACPI_PARSE_OBJECT *Op, 557ca3cf4faSJung-uk Kim char *Name) 558ca3cf4faSJung-uk Kim { 559ca3cf4faSJung-uk Kim UINT32 i; 5609c7c683cSJung-uk Kim const ACPI_PREDEFINED_INFO *ThisName; 561ca3cf4faSJung-uk Kim 562ca3cf4faSJung-uk Kim 563ca3cf4faSJung-uk Kim if (Name[0] == 0) 564ca3cf4faSJung-uk Kim { 565f8146b88SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, 566f8146b88SJung-uk Kim "zero length name found"); 567ca3cf4faSJung-uk Kim } 568ca3cf4faSJung-uk Kim 569ca3cf4faSJung-uk Kim /* All reserved names are prefixed with a single underscore */ 570ca3cf4faSJung-uk Kim 571ca3cf4faSJung-uk Kim if (Name[0] != '_') 572ca3cf4faSJung-uk Kim { 573ca3cf4faSJung-uk Kim return (ACPI_NOT_RESERVED_NAME); 574ca3cf4faSJung-uk Kim } 575ca3cf4faSJung-uk Kim 576ca3cf4faSJung-uk Kim /* Check for a standard predefined method name */ 577ca3cf4faSJung-uk Kim 5789c7c683cSJung-uk Kim ThisName = AcpiGbl_PredefinedMethods; 5799c7c683cSJung-uk Kim for (i = 0; ThisName->Info.Name[0]; i++) 580ca3cf4faSJung-uk Kim { 581278f0de6SJung-uk Kim if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name)) 582ca3cf4faSJung-uk Kim { 583ca3cf4faSJung-uk Kim /* Return index into predefined array */ 584ca3cf4faSJung-uk Kim return (i); 585ca3cf4faSJung-uk Kim } 5869c7c683cSJung-uk Kim 5879c7c683cSJung-uk Kim ThisName++; /* Does not account for extra package data, but is OK */ 588ca3cf4faSJung-uk Kim } 589ca3cf4faSJung-uk Kim 590ca3cf4faSJung-uk Kim /* Check for resource names and predefined scope names */ 591ca3cf4faSJung-uk Kim 5929c7c683cSJung-uk Kim ThisName = AcpiGbl_ResourceNames; 5939c7c683cSJung-uk Kim while (ThisName->Info.Name[0]) 594ca3cf4faSJung-uk Kim { 595278f0de6SJung-uk Kim if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name)) 596ca3cf4faSJung-uk Kim { 597ca3cf4faSJung-uk Kim return (ACPI_PREDEFINED_NAME); 598ca3cf4faSJung-uk Kim } 599ca3cf4faSJung-uk Kim 6009c7c683cSJung-uk Kim ThisName++; 6019c7c683cSJung-uk Kim } 6029c7c683cSJung-uk Kim 6039c7c683cSJung-uk Kim ThisName = AcpiGbl_ScopeNames; 6049c7c683cSJung-uk Kim while (ThisName->Info.Name[0]) 605ca3cf4faSJung-uk Kim { 606278f0de6SJung-uk Kim if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name)) 607ca3cf4faSJung-uk Kim { 608ca3cf4faSJung-uk Kim return (ACPI_PREDEFINED_NAME); 609ca3cf4faSJung-uk Kim } 6109c7c683cSJung-uk Kim 6119c7c683cSJung-uk Kim ThisName++; 612ca3cf4faSJung-uk Kim } 613ca3cf4faSJung-uk Kim 6143f5e024cSJung-uk Kim /* Check for _Lxx/_Exx/_Wxx/_Qxx/_T_x. Warning if unknown predefined name */ 615ca3cf4faSJung-uk Kim 616ca3cf4faSJung-uk Kim return (ApCheckForSpecialName (Op, Name)); 617ca3cf4faSJung-uk Kim } 618ca3cf4faSJung-uk Kim 619ca3cf4faSJung-uk Kim 620ca3cf4faSJung-uk Kim /******************************************************************************* 621ca3cf4faSJung-uk Kim * 622ca3cf4faSJung-uk Kim * FUNCTION: ApCheckForSpecialName 623ca3cf4faSJung-uk Kim * 624ca3cf4faSJung-uk Kim * PARAMETERS: Op - A parse node 625ca3cf4faSJung-uk Kim * Name - NameSeg to check 626ca3cf4faSJung-uk Kim * 627ca3cf4faSJung-uk Kim * RETURN: None 628ca3cf4faSJung-uk Kim * 629ca3cf4faSJung-uk Kim * DESCRIPTION: Check for the "special" predefined names - 6303f5e024cSJung-uk Kim * _Lxx, _Exx, _Qxx, _Wxx, and _T_x 631ca3cf4faSJung-uk Kim * 632ca3cf4faSJung-uk Kim ******************************************************************************/ 633ca3cf4faSJung-uk Kim 634ca3cf4faSJung-uk Kim static UINT32 635ca3cf4faSJung-uk Kim ApCheckForSpecialName ( 636ca3cf4faSJung-uk Kim ACPI_PARSE_OBJECT *Op, 637ca3cf4faSJung-uk Kim char *Name) 638ca3cf4faSJung-uk Kim { 639ca3cf4faSJung-uk Kim 640ca3cf4faSJung-uk Kim /* 6413f5e024cSJung-uk Kim * Check for the "special" predefined names. We already know that the 6423f5e024cSJung-uk Kim * first character is an underscore. 643ca3cf4faSJung-uk Kim * GPE: _Lxx 644ca3cf4faSJung-uk Kim * GPE: _Exx 6453f5e024cSJung-uk Kim * GPE: _Wxx 646ca3cf4faSJung-uk Kim * EC: _Qxx 647ca3cf4faSJung-uk Kim */ 648ca3cf4faSJung-uk Kim if ((Name[1] == 'L') || 649ca3cf4faSJung-uk Kim (Name[1] == 'E') || 6503f5e024cSJung-uk Kim (Name[1] == 'W') || 651ca3cf4faSJung-uk Kim (Name[1] == 'Q')) 652ca3cf4faSJung-uk Kim { 653ca3cf4faSJung-uk Kim /* The next two characters must be hex digits */ 654ca3cf4faSJung-uk Kim 655ca3cf4faSJung-uk Kim if ((isxdigit ((int) Name[2])) && 656ca3cf4faSJung-uk Kim (isxdigit ((int) Name[3]))) 657ca3cf4faSJung-uk Kim { 658ca3cf4faSJung-uk Kim return (ACPI_EVENT_RESERVED_NAME); 659ca3cf4faSJung-uk Kim } 660ca3cf4faSJung-uk Kim } 661ca3cf4faSJung-uk Kim 662ca3cf4faSJung-uk Kim /* Check for the names reserved for the compiler itself: _T_x */ 663ca3cf4faSJung-uk Kim 664ca3cf4faSJung-uk Kim else if ((Op->Asl.ExternalName[1] == 'T') && 665ca3cf4faSJung-uk Kim (Op->Asl.ExternalName[2] == '_')) 666ca3cf4faSJung-uk Kim { 667ca3cf4faSJung-uk Kim /* Ignore if actually emitted by the compiler */ 668ca3cf4faSJung-uk Kim 6695f9b24faSJung-uk Kim if (Op->Asl.CompileFlags & OP_COMPILER_EMITTED) 670ca3cf4faSJung-uk Kim { 671ca3cf4faSJung-uk Kim return (ACPI_NOT_RESERVED_NAME); 672ca3cf4faSJung-uk Kim } 673ca3cf4faSJung-uk Kim 674ca3cf4faSJung-uk Kim /* 675ca3cf4faSJung-uk Kim * Was not actually emitted by the compiler. This is a special case, 676ca3cf4faSJung-uk Kim * however. If the ASL code being compiled was the result of a 67708ddfe86SJung-uk Kim * disassembly, it may possibly contain valid compiler-emitted names 678ca3cf4faSJung-uk Kim * of the form "_T_x". We don't want to issue an error or even a 679ca3cf4faSJung-uk Kim * warning and force the user to manually change the names. So, we 680ca3cf4faSJung-uk Kim * will issue a remark instead. 681ca3cf4faSJung-uk Kim */ 682f8146b88SJung-uk Kim AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, 683f8146b88SJung-uk Kim Op, Op->Asl.ExternalName); 684ca3cf4faSJung-uk Kim return (ACPI_COMPILER_RESERVED_NAME); 685ca3cf4faSJung-uk Kim } 686ca3cf4faSJung-uk Kim 687ca3cf4faSJung-uk Kim /* 688ca3cf4faSJung-uk Kim * The name didn't match any of the known predefined names. Flag it as a 689ca3cf4faSJung-uk Kim * warning, since the entire namespace starting with an underscore is 690ca3cf4faSJung-uk Kim * reserved by the ACPI spec. 691ca3cf4faSJung-uk Kim */ 692f8146b88SJung-uk Kim AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, 693f8146b88SJung-uk Kim Op, Op->Asl.ExternalName); 694ca3cf4faSJung-uk Kim 695ca3cf4faSJung-uk Kim return (ACPI_NOT_RESERVED_NAME); 696ca3cf4faSJung-uk Kim } 697ca3cf4faSJung-uk Kim 698ca3cf4faSJung-uk Kim 699ca3cf4faSJung-uk Kim /******************************************************************************* 700ca3cf4faSJung-uk Kim * 701ca3cf4faSJung-uk Kim * FUNCTION: ApCheckObjectType 702ca3cf4faSJung-uk Kim * 703efcc2a30SJung-uk Kim * PARAMETERS: PredefinedName - Name of the predefined object we are checking 704efcc2a30SJung-uk Kim * Op - Current parse node 705ca3cf4faSJung-uk Kim * ExpectedBtypes - Bitmap of expected return type(s) 7069c48c75eSJung-uk Kim * PackageIndex - Index of object within parent package (if 7079c48c75eSJung-uk Kim * applicable - ACPI_NOT_PACKAGE_ELEMENT 7089c48c75eSJung-uk Kim * otherwise) 709ca3cf4faSJung-uk Kim * 710ca3cf4faSJung-uk Kim * RETURN: None 711ca3cf4faSJung-uk Kim * 712ca3cf4faSJung-uk Kim * DESCRIPTION: Check if the object type is one of the types that is expected 713ca3cf4faSJung-uk Kim * by the predefined name. Only a limited number of object types 714ca3cf4faSJung-uk Kim * can be returned by the predefined names. 715ca3cf4faSJung-uk Kim * 716ca3cf4faSJung-uk Kim ******************************************************************************/ 717ca3cf4faSJung-uk Kim 7189c48c75eSJung-uk Kim ACPI_STATUS 719ca3cf4faSJung-uk Kim ApCheckObjectType ( 720efcc2a30SJung-uk Kim const char *PredefinedName, 721ca3cf4faSJung-uk Kim ACPI_PARSE_OBJECT *Op, 7229c48c75eSJung-uk Kim UINT32 ExpectedBtypes, 7239c48c75eSJung-uk Kim UINT32 PackageIndex) 724ca3cf4faSJung-uk Kim { 725ca3cf4faSJung-uk Kim UINT32 ReturnBtype; 7269c48c75eSJung-uk Kim char *TypeName; 727ca3cf4faSJung-uk Kim 728ca3cf4faSJung-uk Kim 7299c48c75eSJung-uk Kim if (!Op) 7309c48c75eSJung-uk Kim { 7319c48c75eSJung-uk Kim return (AE_TYPE); 7329c48c75eSJung-uk Kim } 7339c48c75eSJung-uk Kim 7349c48c75eSJung-uk Kim /* Map the parse opcode to a bitmapped return type (RTYPE) */ 7359c48c75eSJung-uk Kim 736ca3cf4faSJung-uk Kim switch (Op->Asl.ParseOpcode) 737ca3cf4faSJung-uk Kim { 7388c8be05fSJung-uk Kim case PARSEOP_ZERO: 7398c8be05fSJung-uk Kim case PARSEOP_ONE: 7408c8be05fSJung-uk Kim case PARSEOP_ONES: 741ca3cf4faSJung-uk Kim case PARSEOP_INTEGER: 742a9d8d09cSJung-uk Kim 743ca3cf4faSJung-uk Kim ReturnBtype = ACPI_RTYPE_INTEGER; 7449c48c75eSJung-uk Kim TypeName = "Integer"; 745ca3cf4faSJung-uk Kim break; 746ca3cf4faSJung-uk Kim 747ca3cf4faSJung-uk Kim case PARSEOP_STRING_LITERAL: 748a9d8d09cSJung-uk Kim 749ca3cf4faSJung-uk Kim ReturnBtype = ACPI_RTYPE_STRING; 7509c48c75eSJung-uk Kim TypeName = "String"; 7519c48c75eSJung-uk Kim break; 7529c48c75eSJung-uk Kim 7539c48c75eSJung-uk Kim case PARSEOP_BUFFER: 754a9d8d09cSJung-uk Kim 7559c48c75eSJung-uk Kim ReturnBtype = ACPI_RTYPE_BUFFER; 7569c48c75eSJung-uk Kim TypeName = "Buffer"; 757ca3cf4faSJung-uk Kim break; 758ca3cf4faSJung-uk Kim 759ca3cf4faSJung-uk Kim case PARSEOP_PACKAGE: 7603f0275a0SJung-uk Kim case PARSEOP_VAR_PACKAGE: 761a9d8d09cSJung-uk Kim 762ca3cf4faSJung-uk Kim ReturnBtype = ACPI_RTYPE_PACKAGE; 7639c48c75eSJung-uk Kim TypeName = "Package"; 7649c48c75eSJung-uk Kim break; 7659c48c75eSJung-uk Kim 7669c48c75eSJung-uk Kim case PARSEOP_NAMESEG: 7679c48c75eSJung-uk Kim case PARSEOP_NAMESTRING: 768a9d8d09cSJung-uk Kim /* 769a9d8d09cSJung-uk Kim * Ignore any named references within a package object. 770a9d8d09cSJung-uk Kim * 771a9d8d09cSJung-uk Kim * For Package objects, references are allowed instead of any of the 772a9d8d09cSJung-uk Kim * standard data types (Integer/String/Buffer/Package). These 773a9d8d09cSJung-uk Kim * references are resolved at runtime. NAMESEG and NAMESTRING are 774a9d8d09cSJung-uk Kim * impossible to typecheck at compile time because the type of 775a9d8d09cSJung-uk Kim * any named object can be changed at runtime (for example, 776a9d8d09cSJung-uk Kim * CopyObject will change the type of the target object). 777a9d8d09cSJung-uk Kim */ 778a9d8d09cSJung-uk Kim if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) 779a9d8d09cSJung-uk Kim { 780a9d8d09cSJung-uk Kim return (AE_OK); 781a9d8d09cSJung-uk Kim } 782a9d8d09cSJung-uk Kim 7839c48c75eSJung-uk Kim ReturnBtype = ACPI_RTYPE_REFERENCE; 7849c48c75eSJung-uk Kim TypeName = "Reference"; 785ca3cf4faSJung-uk Kim break; 786ca3cf4faSJung-uk Kim 787ca3cf4faSJung-uk Kim default: 788a9d8d09cSJung-uk Kim 789ca3cf4faSJung-uk Kim /* Not one of the supported object types */ 790ca3cf4faSJung-uk Kim 7919c48c75eSJung-uk Kim TypeName = UtGetOpName (Op->Asl.ParseOpcode); 792ca3cf4faSJung-uk Kim goto TypeErrorExit; 793ca3cf4faSJung-uk Kim } 794ca3cf4faSJung-uk Kim 7958c8be05fSJung-uk Kim /* Exit if the object is one of the expected types */ 796ca3cf4faSJung-uk Kim 797ca3cf4faSJung-uk Kim if (ReturnBtype & ExpectedBtypes) 798ca3cf4faSJung-uk Kim { 7999c48c75eSJung-uk Kim return (AE_OK); 800ca3cf4faSJung-uk Kim } 801ca3cf4faSJung-uk Kim 802ca3cf4faSJung-uk Kim 803ca3cf4faSJung-uk Kim TypeErrorExit: 804ca3cf4faSJung-uk Kim 805ca3cf4faSJung-uk Kim /* Format the expected types and emit an error message */ 806ca3cf4faSJung-uk Kim 8076f1f1a63SJung-uk Kim AcpiUtGetExpectedReturnTypes (AslGbl_StringBuffer, ExpectedBtypes); 8088c8be05fSJung-uk Kim 8099c48c75eSJung-uk Kim if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) 8109c48c75eSJung-uk Kim { 8116f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "%4.4s: found %s, %s required", 8126f1f1a63SJung-uk Kim PredefinedName, TypeName, AslGbl_StringBuffer); 8139c48c75eSJung-uk Kim } 8149c48c75eSJung-uk Kim else 8159c48c75eSJung-uk Kim { 8166f1f1a63SJung-uk Kim sprintf (AslGbl_MsgBuffer, "%4.4s: found %s at index %u, %s required", 8176f1f1a63SJung-uk Kim PredefinedName, TypeName, PackageIndex, AslGbl_StringBuffer); 8189c48c75eSJung-uk Kim } 819ca3cf4faSJung-uk Kim 8206f1f1a63SJung-uk Kim AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, AslGbl_MsgBuffer); 8219c48c75eSJung-uk Kim return (AE_TYPE); 822ca3cf4faSJung-uk Kim } 823ca3cf4faSJung-uk Kim 824ca3cf4faSJung-uk Kim 825ca3cf4faSJung-uk Kim /******************************************************************************* 826ca3cf4faSJung-uk Kim * 827ca3cf4faSJung-uk Kim * FUNCTION: ApDisplayReservedNames 828ca3cf4faSJung-uk Kim * 829ca3cf4faSJung-uk Kim * PARAMETERS: None 830ca3cf4faSJung-uk Kim * 831ca3cf4faSJung-uk Kim * RETURN: None 832ca3cf4faSJung-uk Kim * 833ca3cf4faSJung-uk Kim * DESCRIPTION: Dump information about the ACPI predefined names and predefined 834ca3cf4faSJung-uk Kim * resource descriptor names. 835ca3cf4faSJung-uk Kim * 836ca3cf4faSJung-uk Kim ******************************************************************************/ 837ca3cf4faSJung-uk Kim 838ca3cf4faSJung-uk Kim void 839ca3cf4faSJung-uk Kim ApDisplayReservedNames ( 840ca3cf4faSJung-uk Kim void) 841ca3cf4faSJung-uk Kim { 842ca3cf4faSJung-uk Kim const ACPI_PREDEFINED_INFO *ThisName; 843ca3cf4faSJung-uk Kim UINT32 Count; 8449c7c683cSJung-uk Kim UINT32 NumTypes; 845ca3cf4faSJung-uk Kim 846ca3cf4faSJung-uk Kim 847ca3cf4faSJung-uk Kim /* 848ca3cf4faSJung-uk Kim * Predefined names/methods 849ca3cf4faSJung-uk Kim */ 850ca3cf4faSJung-uk Kim printf ("\nPredefined Name Information\n\n"); 851ca3cf4faSJung-uk Kim 852ca3cf4faSJung-uk Kim Count = 0; 8539c7c683cSJung-uk Kim ThisName = AcpiGbl_PredefinedMethods; 854ca3cf4faSJung-uk Kim while (ThisName->Info.Name[0]) 855ca3cf4faSJung-uk Kim { 8566f1f1a63SJung-uk Kim AcpiUtDisplayPredefinedMethod (AslGbl_MsgBuffer, ThisName, FALSE); 857ca3cf4faSJung-uk Kim Count++; 8589c7c683cSJung-uk Kim ThisName = AcpiUtGetNextPredefinedMethod (ThisName); 859ca3cf4faSJung-uk Kim } 860ca3cf4faSJung-uk Kim 861ca3cf4faSJung-uk Kim printf ("%u Predefined Names are recognized\n", Count); 862ca3cf4faSJung-uk Kim 863ca3cf4faSJung-uk Kim /* 864ca3cf4faSJung-uk Kim * Resource Descriptor names 865ca3cf4faSJung-uk Kim */ 8669c7c683cSJung-uk Kim printf ("\nPredefined Names for Resource Descriptor Fields\n\n"); 867ca3cf4faSJung-uk Kim 868ca3cf4faSJung-uk Kim Count = 0; 8699c7c683cSJung-uk Kim ThisName = AcpiGbl_ResourceNames; 870ca3cf4faSJung-uk Kim while (ThisName->Info.Name[0]) 871ca3cf4faSJung-uk Kim { 8726f1f1a63SJung-uk Kim NumTypes = AcpiUtGetResourceBitWidth (AslGbl_MsgBuffer, 8739c7c683cSJung-uk Kim ThisName->Info.ArgumentList); 8749c7c683cSJung-uk Kim 8759c7c683cSJung-uk Kim printf ("%4.4s Field is %s bits wide%s\n", 8766f1f1a63SJung-uk Kim ThisName->Info.Name, AslGbl_MsgBuffer, 8779c7c683cSJung-uk Kim (NumTypes > 1) ? " (depending on descriptor type)" : ""); 8789c7c683cSJung-uk Kim 879ca3cf4faSJung-uk Kim Count++; 880ca3cf4faSJung-uk Kim ThisName++; 881ca3cf4faSJung-uk Kim } 882ca3cf4faSJung-uk Kim 8839c7c683cSJung-uk Kim printf ("%u Resource Descriptor Field Names are recognized\n", Count); 884ca3cf4faSJung-uk Kim 885ca3cf4faSJung-uk Kim /* 886ca3cf4faSJung-uk Kim * Predefined scope names 887ca3cf4faSJung-uk Kim */ 8889c7c683cSJung-uk Kim printf ("\nPredefined Scope/Device Names (automatically created at root)\n\n"); 889ca3cf4faSJung-uk Kim 8909c7c683cSJung-uk Kim ThisName = AcpiGbl_ScopeNames; 891ca3cf4faSJung-uk Kim while (ThisName->Info.Name[0]) 892ca3cf4faSJung-uk Kim { 8939c7c683cSJung-uk Kim printf ("%4.4s Scope/Device\n", ThisName->Info.Name); 894ca3cf4faSJung-uk Kim ThisName++; 895ca3cf4faSJung-uk Kim } 896ca3cf4faSJung-uk Kim } 897