aslpredef.c revision 204766
1204766Sjkim/****************************************************************************** 2204766Sjkim * 3204766Sjkim * Module Name: aslpredef - support for ACPI predefined names 4204766Sjkim * 5204766Sjkim *****************************************************************************/ 6204766Sjkim 7204766Sjkim/****************************************************************************** 8204766Sjkim * 9204766Sjkim * 1. Copyright Notice 10204766Sjkim * 11204766Sjkim * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. 12204766Sjkim * All rights reserved. 13204766Sjkim * 14204766Sjkim * 2. License 15204766Sjkim * 16204766Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property 17204766Sjkim * rights. You may have additional license terms from the party that provided 18204766Sjkim * you this software, covering your right to use that party's intellectual 19204766Sjkim * property rights. 20204766Sjkim * 21204766Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22204766Sjkim * copy of the source code appearing in this file ("Covered Code") an 23204766Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24204766Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy, 25204766Sjkim * make derivatives, distribute, use and display any portion of the Covered 26204766Sjkim * Code in any form, with the right to sublicense such rights; and 27204766Sjkim * 28204766Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29204766Sjkim * license (with the right to sublicense), under only those claims of Intel 30204766Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell, 31204766Sjkim * offer to sell, and import the Covered Code and derivative works thereof 32204766Sjkim * solely to the minimum extent necessary to exercise the above copyright 33204766Sjkim * license, and in no event shall the patent license extend to any additions 34204766Sjkim * to or modifications of the Original Intel Code. No other license or right 35204766Sjkim * is granted directly or by implication, estoppel or otherwise; 36204766Sjkim * 37204766Sjkim * The above copyright and patent license is granted only if the following 38204766Sjkim * conditions are met: 39204766Sjkim * 40204766Sjkim * 3. Conditions 41204766Sjkim * 42204766Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43204766Sjkim * Redistribution of source code of any substantial portion of the Covered 44204766Sjkim * Code or modification with rights to further distribute source must include 45204766Sjkim * the above Copyright Notice, the above License, this list of Conditions, 46204766Sjkim * and the following Disclaimer and Export Compliance provision. In addition, 47204766Sjkim * Licensee must cause all Covered Code to which Licensee contributes to 48204766Sjkim * contain a file documenting the changes Licensee made to create that Covered 49204766Sjkim * Code and the date of any change. Licensee must include in that file the 50204766Sjkim * documentation of any changes made by any predecessor Licensee. Licensee 51204766Sjkim * must include a prominent statement that the modification is derived, 52204766Sjkim * directly or indirectly, from Original Intel Code. 53204766Sjkim * 54204766Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55204766Sjkim * Redistribution of source code of any substantial portion of the Covered 56204766Sjkim * Code or modification without rights to further distribute source must 57204766Sjkim * include the following Disclaimer and Export Compliance provision in the 58204766Sjkim * documentation and/or other materials provided with distribution. In 59204766Sjkim * addition, Licensee may not authorize further sublicense of source of any 60204766Sjkim * portion of the Covered Code, and must include terms to the effect that the 61204766Sjkim * license from Licensee to its licensee is limited to the intellectual 62204766Sjkim * property embodied in the software Licensee provides to its licensee, and 63204766Sjkim * not to intellectual property embodied in modifications its licensee may 64204766Sjkim * make. 65204766Sjkim * 66204766Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67204766Sjkim * substantial portion of the Covered Code or modification must reproduce the 68204766Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance 69204766Sjkim * provision in the documentation and/or other materials provided with the 70204766Sjkim * distribution. 71204766Sjkim * 72204766Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original 73204766Sjkim * Intel Code. 74204766Sjkim * 75204766Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76204766Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or 77204766Sjkim * other dealings in products derived from or relating to the Covered Code 78204766Sjkim * without prior written authorization from Intel. 79204766Sjkim * 80204766Sjkim * 4. Disclaimer and Export Compliance 81204766Sjkim * 82204766Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83204766Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84204766Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85204766Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86204766Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87204766Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88204766Sjkim * PARTICULAR PURPOSE. 89204766Sjkim * 90204766Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91204766Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92204766Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93204766Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94204766Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95204766Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96204766Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97204766Sjkim * LIMITED REMEDY. 98204766Sjkim * 99204766Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100204766Sjkim * software or system incorporating such software without first obtaining any 101204766Sjkim * required license or other approval from the U. S. Department of Commerce or 102204766Sjkim * any other agency or department of the United States Government. In the 103204766Sjkim * event Licensee exports any such software from the United States or 104204766Sjkim * re-exports any such software from a foreign destination, Licensee shall 105204766Sjkim * ensure that the distribution and export/re-export of the software is in 106204766Sjkim * compliance with all laws, regulations, orders, or other restrictions of the 107204766Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108204766Sjkim * any of its subsidiaries will export/re-export any technical data, process, 109204766Sjkim * software, or service, directly or indirectly, to any country for which the 110204766Sjkim * United States government or any agency thereof requires an export license, 111204766Sjkim * other governmental approval, or letter of assurance, without first obtaining 112204766Sjkim * such license, approval or letter. 113204766Sjkim * 114204766Sjkim *****************************************************************************/ 115204766Sjkim 116204766Sjkim#define ACPI_CREATE_PREDEFINED_TABLE 117204766Sjkim 118204766Sjkim#include "aslcompiler.h" 119204766Sjkim#include "aslcompiler.y.h" 120204766Sjkim#include "amlcode.h" 121204766Sjkim#include "acparser.h" 122204766Sjkim#include "acpredef.h" 123204766Sjkim 124204766Sjkim 125204766Sjkim#define _COMPONENT ACPI_COMPILER 126204766Sjkim ACPI_MODULE_NAME ("aslpredef") 127204766Sjkim 128204766Sjkim 129204766Sjkim/* Local prototypes */ 130204766Sjkim 131204766Sjkimstatic UINT32 132204766SjkimApCheckForSpecialName ( 133204766Sjkim ACPI_PARSE_OBJECT *Op, 134204766Sjkim char *Name); 135204766Sjkim 136204766Sjkimstatic void 137204766SjkimApCheckObjectType ( 138204766Sjkim ACPI_PARSE_OBJECT *Op, 139204766Sjkim UINT32 ExpectedBtypes); 140204766Sjkim 141204766Sjkimstatic void 142204766SjkimApGetExpectedTypes ( 143204766Sjkim char *Buffer, 144204766Sjkim UINT32 ExpectedBtypes); 145204766Sjkim 146204766Sjkim 147204766Sjkim/* 148204766Sjkim * Names for the types that can be returned by the predefined objects. 149204766Sjkim * Used for warning messages. Must be in the same order as the ACPI_RTYPEs 150204766Sjkim */ 151204766Sjkimstatic const char *AcpiRtypeNames[] = 152204766Sjkim{ 153204766Sjkim "/Integer", 154204766Sjkim "/String", 155204766Sjkim "/Buffer", 156204766Sjkim "/Package", 157204766Sjkim "/Reference", 158204766Sjkim}; 159204766Sjkim 160204766Sjkim/* 161204766Sjkim * Predefined names for use in Resource Descriptors. These names do not 162204766Sjkim * appear in the global Predefined Name table (since these names never 163204766Sjkim * appear in actual AML byte code, only in the original ASL) 164204766Sjkim */ 165204766Sjkimstatic const ACPI_PREDEFINED_INFO ResourceNames[] = { 166204766Sjkim {{"_ALN", 0, 0}}, 167204766Sjkim {{"_ASI", 0, 0}}, 168204766Sjkim {{"_ASZ", 0, 0}}, 169204766Sjkim {{"_ATT", 0, 0}}, 170204766Sjkim {{"_BAS", 0, 0}}, 171204766Sjkim {{"_BM_", 0, 0}}, 172204766Sjkim {{"_DEC", 0, 0}}, 173204766Sjkim {{"_GRA", 0, 0}}, 174204766Sjkim {{"_HE_", 0, 0}}, 175204766Sjkim {{"_INT", 0, 0}}, 176204766Sjkim {{"_LEN", 0, 0}}, 177204766Sjkim {{"_LL_", 0, 0}}, 178204766Sjkim {{"_MAF", 0, 0}}, 179204766Sjkim {{"_MAX", 0, 0}}, 180204766Sjkim {{"_MEM", 0, 0}}, 181204766Sjkim {{"_MIF", 0, 0}}, 182204766Sjkim {{"_MIN", 0, 0}}, 183204766Sjkim {{"_MTP", 0, 0}}, 184204766Sjkim {{"_RBO", 0, 0}}, 185204766Sjkim {{"_RBW", 0, 0}}, 186204766Sjkim {{"_RNG", 0, 0}}, 187204766Sjkim {{"_RT_", 0, 0}}, /* Acpi 3.0 */ 188204766Sjkim {{"_RW_", 0, 0}}, 189204766Sjkim {{"_SHR", 0, 0}}, 190204766Sjkim {{"_SIZ", 0, 0}}, 191204766Sjkim {{"_TRA", 0, 0}}, 192204766Sjkim {{"_TRS", 0, 0}}, 193204766Sjkim {{"_TSF", 0, 0}}, /* Acpi 3.0 */ 194204766Sjkim {{"_TTP", 0, 0}}, 195204766Sjkim {{"_TYP", 0, 0}}, 196204766Sjkim {{{0,0,0,0}, 0, 0}} /* Table terminator */ 197204766Sjkim}; 198204766Sjkim 199204766Sjkimstatic const ACPI_PREDEFINED_INFO ScopeNames[] = { 200204766Sjkim {{"_SB_", 0, 0}}, 201204766Sjkim {{"_SI_", 0, 0}}, 202204766Sjkim {{"_TZ_", 0, 0}}, 203204766Sjkim {{{0,0,0,0}, 0, 0}} /* Table terminator */ 204204766Sjkim}; 205204766Sjkim 206204766Sjkim 207204766Sjkim/******************************************************************************* 208204766Sjkim * 209204766Sjkim * FUNCTION: ApCheckForPredefinedMethod 210204766Sjkim * 211204766Sjkim * PARAMETERS: Op - A parse node of type "METHOD". 212204766Sjkim * MethodInfo - Saved info about this method 213204766Sjkim * 214204766Sjkim * RETURN: None 215204766Sjkim * 216204766Sjkim * DESCRIPTION: If method is a predefined name, check that the number of 217204766Sjkim * arguments and the return type (returns a value or not) 218204766Sjkim * is correct. 219204766Sjkim * 220204766Sjkim ******************************************************************************/ 221204766Sjkim 222204766Sjkimvoid 223204766SjkimApCheckForPredefinedMethod ( 224204766Sjkim ACPI_PARSE_OBJECT *Op, 225204766Sjkim ASL_METHOD_INFO *MethodInfo) 226204766Sjkim{ 227204766Sjkim UINT32 Index; 228204766Sjkim UINT32 RequiredArgsCurrent; 229204766Sjkim UINT32 RequiredArgsOld; 230204766Sjkim 231204766Sjkim 232204766Sjkim /* Check for a match against the predefined name list */ 233204766Sjkim 234204766Sjkim Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); 235204766Sjkim 236204766Sjkim switch (Index) 237204766Sjkim { 238204766Sjkim case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ 239204766Sjkim case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ 240204766Sjkim case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ 241204766Sjkim 242204766Sjkim /* Just return, nothing to do */ 243204766Sjkim break; 244204766Sjkim 245204766Sjkim 246204766Sjkim case ACPI_EVENT_RESERVED_NAME: /* _Lxx, _Exx, and _Qxx methods */ 247204766Sjkim 248204766Sjkim Gbl_ReservedMethods++; 249204766Sjkim 250204766Sjkim /* NumArguments must be zero for all _Lxx, _Exx, and _Qxx methods */ 251204766Sjkim 252204766Sjkim if (MethodInfo->NumArguments != 0) 253204766Sjkim { 254204766Sjkim sprintf (MsgBuffer, "%s requires %d", Op->Asl.ExternalName, 0); 255204766Sjkim 256204766Sjkim AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, 257204766Sjkim MsgBuffer); 258204766Sjkim } 259204766Sjkim break; 260204766Sjkim 261204766Sjkim 262204766Sjkim default: 263204766Sjkim /* 264204766Sjkim * Matched a predefined method name 265204766Sjkim * 266204766Sjkim * Validate the ASL-defined argument count. Allow two different legal 267204766Sjkim * arg counts. 268204766Sjkim */ 269204766Sjkim Gbl_ReservedMethods++; 270204766Sjkim 271204766Sjkim RequiredArgsCurrent = PredefinedNames[Index].Info.ParamCount & 0x0F; 272204766Sjkim RequiredArgsOld = PredefinedNames[Index].Info.ParamCount >> 4; 273204766Sjkim 274204766Sjkim if ((MethodInfo->NumArguments != RequiredArgsCurrent) && 275204766Sjkim (MethodInfo->NumArguments != RequiredArgsOld)) 276204766Sjkim { 277204766Sjkim sprintf (MsgBuffer, "%4.4s requires %d", 278204766Sjkim PredefinedNames[Index].Info.Name, RequiredArgsCurrent); 279204766Sjkim 280204766Sjkim if (MethodInfo->NumArguments > RequiredArgsCurrent) 281204766Sjkim { 282204766Sjkim AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, 283204766Sjkim MsgBuffer); 284204766Sjkim } 285204766Sjkim else 286204766Sjkim { 287204766Sjkim AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, 288204766Sjkim MsgBuffer); 289204766Sjkim } 290204766Sjkim } 291204766Sjkim 292204766Sjkim /* 293204766Sjkim * Check if method returns no value, but the predefined name is 294204766Sjkim * required to return a value 295204766Sjkim */ 296204766Sjkim if (MethodInfo->NumReturnNoValue && 297204766Sjkim PredefinedNames[Index].Info.ExpectedBtypes) 298204766Sjkim { 299204766Sjkim sprintf (MsgBuffer, "%4.4s", PredefinedNames[Index].Info.Name); 300204766Sjkim 301204766Sjkim AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, 302204766Sjkim MsgBuffer); 303204766Sjkim } 304204766Sjkim break; 305204766Sjkim } 306204766Sjkim} 307204766Sjkim 308204766Sjkim 309204766Sjkim/******************************************************************************* 310204766Sjkim * 311204766Sjkim * FUNCTION: ApCheckForPredefinedObject 312204766Sjkim * 313204766Sjkim * PARAMETERS: Op - A parse node 314204766Sjkim * Name - The ACPI name to be checked 315204766Sjkim * 316204766Sjkim * RETURN: None 317204766Sjkim * 318204766Sjkim * DESCRIPTION: Check for a predefined name for a static object (created via 319204766Sjkim * the ASL Name operator). If it is a predefined ACPI name, ensure 320204766Sjkim * that the name does not require any arguments (which would 321204766Sjkim * require a control method implemenation of the name), and that 322204766Sjkim * the type of the object is one of the expected types for the 323204766Sjkim * predefined name. 324204766Sjkim * 325204766Sjkim ******************************************************************************/ 326204766Sjkim 327204766Sjkimvoid 328204766SjkimApCheckForPredefinedObject ( 329204766Sjkim ACPI_PARSE_OBJECT *Op, 330204766Sjkim char *Name) 331204766Sjkim{ 332204766Sjkim UINT32 Index; 333204766Sjkim 334204766Sjkim 335204766Sjkim /* 336204766Sjkim * Check for a real predefined name -- not a resource descriptor name 337204766Sjkim * or a predefined scope name 338204766Sjkim */ 339204766Sjkim Index = ApCheckForPredefinedName (Op, Name); 340204766Sjkim if (Index > ACPI_VALID_RESERVED_NAME_MAX) 341204766Sjkim { 342204766Sjkim return; 343204766Sjkim } 344204766Sjkim 345204766Sjkim /* 346204766Sjkim * We found a matching predefind name. 347204766Sjkim * Check if this predefined name requires input arguments 348204766Sjkim */ 349204766Sjkim if (PredefinedNames[Index].Info.ParamCount > 0) 350204766Sjkim { 351204766Sjkim /* 352204766Sjkim * This predefined name must always be defined as a control 353204766Sjkim * method because it is required to have input arguments. 354204766Sjkim */ 355204766Sjkim AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, 356204766Sjkim "with arguments"); 357204766Sjkim } 358204766Sjkim 359204766Sjkim /* Typecheck the actual object, it is the next argument */ 360204766Sjkim 361204766Sjkim ApCheckObjectType (Op->Asl.Child->Asl.Next, 362204766Sjkim PredefinedNames[Index].Info.ExpectedBtypes); 363204766Sjkim} 364204766Sjkim 365204766Sjkim 366204766Sjkim/******************************************************************************* 367204766Sjkim * 368204766Sjkim * FUNCTION: ApCheckForPredefinedName 369204766Sjkim * 370204766Sjkim * PARAMETERS: Op - A parse node 371204766Sjkim * Name - NameSeg to check 372204766Sjkim * 373204766Sjkim * RETURN: None 374204766Sjkim * 375204766Sjkim * DESCRIPTION: Check a NameSeg against the reserved list. 376204766Sjkim * 377204766Sjkim ******************************************************************************/ 378204766Sjkim 379204766SjkimUINT32 380204766SjkimApCheckForPredefinedName ( 381204766Sjkim ACPI_PARSE_OBJECT *Op, 382204766Sjkim char *Name) 383204766Sjkim{ 384204766Sjkim UINT32 i; 385204766Sjkim 386204766Sjkim 387204766Sjkim if (Name[0] == 0) 388204766Sjkim { 389204766Sjkim AcpiOsPrintf ("Found a null name, external = %s\n", 390204766Sjkim Op->Asl.ExternalName); 391204766Sjkim } 392204766Sjkim 393204766Sjkim /* All reserved names are prefixed with a single underscore */ 394204766Sjkim 395204766Sjkim if (Name[0] != '_') 396204766Sjkim { 397204766Sjkim return (ACPI_NOT_RESERVED_NAME); 398204766Sjkim } 399204766Sjkim 400204766Sjkim /* Check for a standard predefined method name */ 401204766Sjkim 402204766Sjkim for (i = 0; PredefinedNames[i].Info.Name[0]; i++) 403204766Sjkim { 404204766Sjkim if (ACPI_COMPARE_NAME (Name, PredefinedNames[i].Info.Name)) 405204766Sjkim { 406204766Sjkim /* Return index into predefined array */ 407204766Sjkim return (i); 408204766Sjkim } 409204766Sjkim } 410204766Sjkim 411204766Sjkim /* Check for resource names and predefined scope names */ 412204766Sjkim 413204766Sjkim for (i = 0; ResourceNames[i].Info.Name[0]; i++) 414204766Sjkim { 415204766Sjkim if (ACPI_COMPARE_NAME (Name, ResourceNames[i].Info.Name)) 416204766Sjkim { 417204766Sjkim return (ACPI_PREDEFINED_NAME); 418204766Sjkim } 419204766Sjkim } 420204766Sjkim 421204766Sjkim for (i = 0; ScopeNames[i].Info.Name[0]; i++) 422204766Sjkim { 423204766Sjkim if (ACPI_COMPARE_NAME (Name, ScopeNames[i].Info.Name)) 424204766Sjkim { 425204766Sjkim return (ACPI_PREDEFINED_NAME); 426204766Sjkim } 427204766Sjkim } 428204766Sjkim 429204766Sjkim /* Check for _Lxx, _Exx, _Qxx, _T_x. Warning if unknown predefined name */ 430204766Sjkim 431204766Sjkim return (ApCheckForSpecialName (Op, Name)); 432204766Sjkim} 433204766Sjkim 434204766Sjkim 435204766Sjkim/******************************************************************************* 436204766Sjkim * 437204766Sjkim * FUNCTION: ApCheckForSpecialName 438204766Sjkim * 439204766Sjkim * PARAMETERS: Op - A parse node 440204766Sjkim * Name - NameSeg to check 441204766Sjkim * 442204766Sjkim * RETURN: None 443204766Sjkim * 444204766Sjkim * DESCRIPTION: Check for the "special" predefined names - 445204766Sjkim * _Lxx, _Exx, _Qxx, and _T_x 446204766Sjkim * 447204766Sjkim ******************************************************************************/ 448204766Sjkim 449204766Sjkimstatic UINT32 450204766SjkimApCheckForSpecialName ( 451204766Sjkim ACPI_PARSE_OBJECT *Op, 452204766Sjkim char *Name) 453204766Sjkim{ 454204766Sjkim 455204766Sjkim /* 456204766Sjkim * Check for the "special" predefined names. We know the first char is an 457204766Sjkim * underscore already. 458204766Sjkim * GPE: _Lxx 459204766Sjkim * GPE: _Exx 460204766Sjkim * EC: _Qxx 461204766Sjkim */ 462204766Sjkim if ((Name[1] == 'L') || 463204766Sjkim (Name[1] == 'E') || 464204766Sjkim (Name[1] == 'Q')) 465204766Sjkim { 466204766Sjkim /* The next two characters must be hex digits */ 467204766Sjkim 468204766Sjkim if ((isxdigit ((int) Name[2])) && 469204766Sjkim (isxdigit ((int) Name[3]))) 470204766Sjkim { 471204766Sjkim return (ACPI_EVENT_RESERVED_NAME); 472204766Sjkim } 473204766Sjkim } 474204766Sjkim 475204766Sjkim /* Check for the names reserved for the compiler itself: _T_x */ 476204766Sjkim 477204766Sjkim else if ((Op->Asl.ExternalName[1] == 'T') && 478204766Sjkim (Op->Asl.ExternalName[2] == '_')) 479204766Sjkim { 480204766Sjkim /* Ignore if actually emitted by the compiler */ 481204766Sjkim 482204766Sjkim if (Op->Asl.CompileFlags & NODE_COMPILER_EMITTED) 483204766Sjkim { 484204766Sjkim return (ACPI_NOT_RESERVED_NAME); 485204766Sjkim } 486204766Sjkim 487204766Sjkim /* 488204766Sjkim * Was not actually emitted by the compiler. This is a special case, 489204766Sjkim * however. If the ASL code being compiled was the result of a 490204766Sjkim * dissasembly, it may possibly contain valid compiler-emitted names 491204766Sjkim * of the form "_T_x". We don't want to issue an error or even a 492204766Sjkim * warning and force the user to manually change the names. So, we 493204766Sjkim * will issue a remark instead. 494204766Sjkim */ 495204766Sjkim AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, Op, Op->Asl.ExternalName); 496204766Sjkim return (ACPI_COMPILER_RESERVED_NAME); 497204766Sjkim } 498204766Sjkim 499204766Sjkim /* 500204766Sjkim * The name didn't match any of the known predefined names. Flag it as a 501204766Sjkim * warning, since the entire namespace starting with an underscore is 502204766Sjkim * reserved by the ACPI spec. 503204766Sjkim */ 504204766Sjkim AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op, 505204766Sjkim Op->Asl.ExternalName); 506204766Sjkim 507204766Sjkim return (ACPI_NOT_RESERVED_NAME); 508204766Sjkim} 509204766Sjkim 510204766Sjkim 511204766Sjkim/******************************************************************************* 512204766Sjkim * 513204766Sjkim * FUNCTION: ApCheckObjectType 514204766Sjkim * 515204766Sjkim * PARAMETERS: Op - A parse node 516204766Sjkim * ExpectedBtypes - Bitmap of expected return type(s) 517204766Sjkim * 518204766Sjkim * RETURN: None 519204766Sjkim * 520204766Sjkim * DESCRIPTION: Check if the object type is one of the types that is expected 521204766Sjkim * by the predefined name. Only a limited number of object types 522204766Sjkim * can be returned by the predefined names. 523204766Sjkim * 524204766Sjkim ******************************************************************************/ 525204766Sjkim 526204766Sjkimstatic void 527204766SjkimApCheckObjectType ( 528204766Sjkim ACPI_PARSE_OBJECT *Op, 529204766Sjkim UINT32 ExpectedBtypes) 530204766Sjkim{ 531204766Sjkim UINT32 ReturnBtype; 532204766Sjkim char TypeBuffer[48]; /* Room for 5 types */ 533204766Sjkim 534204766Sjkim 535204766Sjkim switch (Op->Asl.ParseOpcode) 536204766Sjkim { 537204766Sjkim case PARSEOP_INTEGER: 538204766Sjkim ReturnBtype = ACPI_RTYPE_INTEGER; 539204766Sjkim break; 540204766Sjkim 541204766Sjkim case PARSEOP_BUFFER: 542204766Sjkim ReturnBtype = ACPI_RTYPE_BUFFER; 543204766Sjkim break; 544204766Sjkim 545204766Sjkim case PARSEOP_STRING_LITERAL: 546204766Sjkim ReturnBtype = ACPI_RTYPE_STRING; 547204766Sjkim break; 548204766Sjkim 549204766Sjkim case PARSEOP_PACKAGE: 550204766Sjkim ReturnBtype = ACPI_RTYPE_PACKAGE; 551204766Sjkim break; 552204766Sjkim 553204766Sjkim default: 554204766Sjkim /* Not one of the supported object types */ 555204766Sjkim 556204766Sjkim goto TypeErrorExit; 557204766Sjkim } 558204766Sjkim 559204766Sjkim /* Is the object one of the expected types? */ 560204766Sjkim 561204766Sjkim if (ReturnBtype & ExpectedBtypes) 562204766Sjkim { 563204766Sjkim return; 564204766Sjkim } 565204766Sjkim 566204766Sjkim 567204766SjkimTypeErrorExit: 568204766Sjkim 569204766Sjkim /* Format the expected types and emit an error message */ 570204766Sjkim 571204766Sjkim ApGetExpectedTypes (TypeBuffer, ExpectedBtypes); 572204766Sjkim 573204766Sjkim AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, 574204766Sjkim TypeBuffer); 575204766Sjkim} 576204766Sjkim 577204766Sjkim 578204766Sjkim/******************************************************************************* 579204766Sjkim * 580204766Sjkim * FUNCTION: ApDisplayReservedNames 581204766Sjkim * 582204766Sjkim * PARAMETERS: None 583204766Sjkim * 584204766Sjkim * RETURN: None 585204766Sjkim * 586204766Sjkim * DESCRIPTION: Dump information about the ACPI predefined names and predefined 587204766Sjkim * resource descriptor names. 588204766Sjkim * 589204766Sjkim ******************************************************************************/ 590204766Sjkim 591204766Sjkimvoid 592204766SjkimApDisplayReservedNames ( 593204766Sjkim void) 594204766Sjkim{ 595204766Sjkim const ACPI_PREDEFINED_INFO *ThisName; 596204766Sjkim char TypeBuffer[48]; /* Room for 5 types */ 597204766Sjkim UINT32 Count; 598204766Sjkim 599204766Sjkim 600204766Sjkim /* 601204766Sjkim * Predefined names/methods 602204766Sjkim */ 603204766Sjkim printf ("\nPredefined Name Information\n\n"); 604204766Sjkim 605204766Sjkim Count = 0; 606204766Sjkim ThisName = PredefinedNames; 607204766Sjkim while (ThisName->Info.Name[0]) 608204766Sjkim { 609204766Sjkim printf ("%4.4s Requires %d arguments, ", 610204766Sjkim ThisName->Info.Name, ThisName->Info.ParamCount & 0x0F); 611204766Sjkim 612204766Sjkim if (ThisName->Info.ExpectedBtypes) 613204766Sjkim { 614204766Sjkim ApGetExpectedTypes (TypeBuffer, ThisName->Info.ExpectedBtypes); 615204766Sjkim printf ("Must return: %s\n", TypeBuffer); 616204766Sjkim } 617204766Sjkim else 618204766Sjkim { 619204766Sjkim printf ("No return value\n"); 620204766Sjkim } 621204766Sjkim 622204766Sjkim /* 623204766Sjkim * Skip next entry in the table if this name returns a Package 624204766Sjkim * (next entry contains the package info) 625204766Sjkim */ 626204766Sjkim if (ThisName->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE) 627204766Sjkim { 628204766Sjkim ThisName++; 629204766Sjkim } 630204766Sjkim 631204766Sjkim Count++; 632204766Sjkim ThisName++; 633204766Sjkim } 634204766Sjkim 635204766Sjkim printf ("%u Predefined Names are recognized\n", Count); 636204766Sjkim 637204766Sjkim /* 638204766Sjkim * Resource Descriptor names 639204766Sjkim */ 640204766Sjkim printf ("\nResource Descriptor Predefined Names\n\n"); 641204766Sjkim 642204766Sjkim Count = 0; 643204766Sjkim ThisName = ResourceNames; 644204766Sjkim while (ThisName->Info.Name[0]) 645204766Sjkim { 646204766Sjkim printf ("%4.4s Resource Descriptor\n", ThisName->Info.Name); 647204766Sjkim Count++; 648204766Sjkim ThisName++; 649204766Sjkim } 650204766Sjkim 651204766Sjkim printf ("%u Resource Descriptor Names are recognized\n", Count); 652204766Sjkim 653204766Sjkim /* 654204766Sjkim * Predefined scope names 655204766Sjkim */ 656204766Sjkim printf ("\nPredefined Scope Names\n\n"); 657204766Sjkim 658204766Sjkim ThisName = ScopeNames; 659204766Sjkim while (ThisName->Info.Name[0]) 660204766Sjkim { 661204766Sjkim printf ("%4.4s Scope\n", ThisName->Info.Name); 662204766Sjkim ThisName++; 663204766Sjkim } 664204766Sjkim} 665204766Sjkim 666204766Sjkim 667204766Sjkim/******************************************************************************* 668204766Sjkim * 669204766Sjkim * FUNCTION: ApGetExpectedTypes 670204766Sjkim * 671204766Sjkim * PARAMETERS: Buffer - Where the formatted string is returned 672204766Sjkim * ExpectedBTypes - Bitfield of expected data types 673204766Sjkim * 674204766Sjkim * RETURN: None, formatted string 675204766Sjkim * 676204766Sjkim * DESCRIPTION: Format the expected object types into a printable string. 677204766Sjkim * 678204766Sjkim ******************************************************************************/ 679204766Sjkim 680204766Sjkimstatic void 681204766SjkimApGetExpectedTypes ( 682204766Sjkim char *Buffer, 683204766Sjkim UINT32 ExpectedBtypes) 684204766Sjkim{ 685204766Sjkim UINT32 ThisRtype; 686204766Sjkim UINT32 i; 687204766Sjkim UINT32 j; 688204766Sjkim 689204766Sjkim 690204766Sjkim j = 1; 691204766Sjkim Buffer[0] = 0; 692204766Sjkim ThisRtype = ACPI_RTYPE_INTEGER; 693204766Sjkim 694204766Sjkim for (i = 0; i < ACPI_NUM_RTYPES; i++) 695204766Sjkim { 696204766Sjkim /* If one of the expected types, concatenate the name of this type */ 697204766Sjkim 698204766Sjkim if (ExpectedBtypes & ThisRtype) 699204766Sjkim { 700204766Sjkim ACPI_STRCAT (Buffer, &AcpiRtypeNames[i][j]); 701204766Sjkim j = 0; /* Use name separator from now on */ 702204766Sjkim } 703204766Sjkim ThisRtype <<= 1; /* Next Rtype */ 704204766Sjkim } 705204766Sjkim} 706204766Sjkim 707