| 1 |
/****************************************************************************** |
| 2 |
* |
| 3 |
* Module Name: aslpredef - support for ACPI predefined names |
| 4 |
* |
| 5 |
*****************************************************************************/ |
| 6 |
|
| 7 |
/* |
| 8 |
* Copyright (C) 2000 - 2026, Intel Corp. |
| 9 |
* All rights reserved. |
| 10 |
* |
| 11 |
* Redistribution and use in source and binary forms, with or without |
| 12 |
* modification, are permitted provided that the following conditions |
| 13 |
* are met: |
| 14 |
* 1. Redistributions of source code must retain the above copyright |
| 15 |
* notice, this list of conditions, and the following disclaimer, |
| 16 |
* without modification. |
| 17 |
* 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 |
* substantially similar to the "NO WARRANTY" disclaimer below |
| 19 |
* ("Disclaimer") and any redistribution must be conditioned upon |
| 20 |
* including a substantially similar Disclaimer requirement for further |
| 21 |
* binary redistribution. |
| 22 |
* 3. Neither the names of the above-listed copyright holders nor the names |
| 23 |
* of any contributors may be used to endorse or promote products derived |
| 24 |
* from this software without specific prior written permission. |
| 25 |
* |
| 26 |
* Alternatively, this software may be distributed under the terms of the |
| 27 |
* GNU General Public License ("GPL") version 2 as published by the Free |
| 28 |
* Software Foundation. |
| 29 |
* |
| 30 |
* NO WARRANTY |
| 31 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 34 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 |
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 |
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 |
* POSSIBILITY OF SUCH DAMAGES. |
| 42 |
*/ |
| 43 |
|
| 44 |
#define ACPI_CREATE_PREDEFINED_TABLE |
| 45 |
#define ACPI_CREATE_RESOURCE_TABLE |
| 46 |
|
| 47 |
#include "aslcompiler.h" |
| 48 |
#include "aslcompiler.y.h" |
| 49 |
#include "acpredef.h" |
| 50 |
#include "acnamesp.h" |
| 51 |
|
| 52 |
|
| 53 |
#define _COMPONENT ACPI_COMPILER |
| 54 |
ACPI_MODULE_NAME ("aslpredef") |
| 55 |
|
| 56 |
|
| 57 |
/* Local prototypes */ |
| 58 |
|
| 59 |
static void |
| 60 |
ApCheckForUnexpectedReturnValue ( |
| 61 |
ACPI_PARSE_OBJECT *Op, |
| 62 |
ASL_METHOD_INFO *MethodInfo); |
| 63 |
|
| 64 |
static UINT32 |
| 65 |
ApCheckForSpecialName ( |
| 66 |
ACPI_PARSE_OBJECT *Op, |
| 67 |
char *Name); |
| 68 |
|
| 69 |
|
| 70 |
/******************************************************************************* |
| 71 |
* |
| 72 |
* FUNCTION: ApCheckForPredefinedMethod |
| 73 |
* |
| 74 |
* PARAMETERS: Op - A parse node of type "METHOD". |
| 75 |
* MethodInfo - Saved info about this method |
| 76 |
* |
| 77 |
* RETURN: None |
| 78 |
* |
| 79 |
* DESCRIPTION: If method is a predefined name, check that the number of |
| 80 |
* arguments and the return type (returns a value or not) |
| 81 |
* is correct. |
| 82 |
* |
| 83 |
******************************************************************************/ |
| 84 |
|
| 85 |
BOOLEAN |
| 86 |
ApCheckForPredefinedMethod ( |
| 87 |
ACPI_PARSE_OBJECT *Op, |
| 88 |
ASL_METHOD_INFO *MethodInfo) |
| 89 |
{ |
| 90 |
UINT32 Index; |
| 91 |
UINT32 RequiredArgCount; |
| 92 |
const ACPI_PREDEFINED_INFO *ThisName; |
| 93 |
|
| 94 |
|
| 95 |
/* Check for a match against the predefined name list */ |
| 96 |
|
| 97 |
Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg); |
| 98 |
|
| 99 |
switch (Index) |
| 100 |
{ |
| 101 |
case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ |
| 102 |
case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ |
| 103 |
case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ |
| 104 |
|
| 105 |
/* Just return, nothing to do */ |
| 106 |
return (FALSE); |
| 107 |
|
| 108 |
|
| 109 |
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ |
| 110 |
|
| 111 |
AslGbl_ReservedMethods++; |
| 112 |
|
| 113 |
/* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */ |
| 114 |
|
| 115 |
if (MethodInfo->NumArguments != 0) |
| 116 |
{ |
| 117 |
sprintf (AslGbl_MsgBuffer, "%s requires %d", Op->Asl.ExternalName, 0); |
| 118 |
|
| 119 |
AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, |
| 120 |
AslGbl_MsgBuffer); |
| 121 |
} |
| 122 |
break; |
| 123 |
|
| 124 |
|
| 125 |
default: |
| 126 |
/* |
| 127 |
* Matched a predefined method name - validate the ASL-defined |
| 128 |
* argument count against the ACPI specification. |
| 129 |
* |
| 130 |
* Some methods are allowed to have a "minimum" number of args |
| 131 |
* (_SCP) because their definition in ACPI has changed over time. |
| 132 |
*/ |
| 133 |
AslGbl_ReservedMethods++; |
| 134 |
ThisName = &AcpiGbl_PredefinedMethods[Index]; |
| 135 |
RequiredArgCount = METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList); |
| 136 |
|
| 137 |
if (MethodInfo->NumArguments != RequiredArgCount) |
| 138 |
{ |
| 139 |
sprintf (AslGbl_MsgBuffer, "%4.4s requires %u", |
| 140 |
ThisName->Info.Name, RequiredArgCount); |
| 141 |
|
| 142 |
if (MethodInfo->NumArguments < RequiredArgCount) |
| 143 |
{ |
| 144 |
AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op, |
| 145 |
AslGbl_MsgBuffer); |
| 146 |
} |
| 147 |
else if ((MethodInfo->NumArguments > RequiredArgCount) && |
| 148 |
!(ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM)) |
| 149 |
{ |
| 150 |
AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, |
| 151 |
AslGbl_MsgBuffer); |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
/* |
| 156 |
* Check if method returns no value, but the predefined name is |
| 157 |
* required to return a value |
| 158 |
*/ |
| 159 |
if (MethodInfo->NumReturnNoValue && |
| 160 |
ThisName->Info.ExpectedBtypes) |
| 161 |
{ |
| 162 |
int cnt; |
| 163 |
char *strp; |
| 164 |
|
| 165 |
AcpiUtGetExpectedReturnTypes (AslGbl_StringBuffer, |
| 166 |
ThisName->Info.ExpectedBtypes); |
| 167 |
|
| 168 |
cnt = asprintf (&strp, "%s required for %4.4s", |
| 169 |
AslGbl_StringBuffer, ThisName->Info.Name); |
| 170 |
|
| 171 |
AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, |
| 172 |
strp); |
| 173 |
if (cnt > 0) |
| 174 |
free(strp); |
| 175 |
} |
| 176 |
break; |
| 177 |
} |
| 178 |
|
| 179 |
return (TRUE); |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
/******************************************************************************* |
| 184 |
* |
| 185 |
* FUNCTION: ApCheckForUnexpectedReturnValue |
| 186 |
* |
| 187 |
* PARAMETERS: Op - A parse node of type "RETURN". |
| 188 |
* MethodInfo - Saved info about this method |
| 189 |
* |
| 190 |
* RETURN: None |
| 191 |
* |
| 192 |
* DESCRIPTION: Check for an unexpected return value from a predefined method. |
| 193 |
* Invoked for predefined methods that are defined to not return |
| 194 |
* any value. If there is a return value, issue a remark, since |
| 195 |
* the ASL writer may be confused as to the method definition |
| 196 |
* and/or functionality. |
| 197 |
* |
| 198 |
* Note: We ignore all return values of "Zero", since this is what a standalone |
| 199 |
* Return() statement will always generate -- so we ignore it here -- |
| 200 |
* i.e., there is no difference between Return() and Return(Zero). |
| 201 |
* Also, a null Return() will be disassembled to return(Zero) -- so, we |
| 202 |
* don't want to generate extraneous remarks/warnings for a disassembled |
| 203 |
* ASL file. |
| 204 |
* |
| 205 |
******************************************************************************/ |
| 206 |
|
| 207 |
static void |
| 208 |
ApCheckForUnexpectedReturnValue ( |
| 209 |
ACPI_PARSE_OBJECT *Op, |
| 210 |
ASL_METHOD_INFO *MethodInfo) |
| 211 |
{ |
| 212 |
ACPI_PARSE_OBJECT *ReturnValueOp; |
| 213 |
|
| 214 |
|
| 215 |
/* Ignore Return() and Return(Zero) (they are the same) */ |
| 216 |
|
| 217 |
ReturnValueOp = Op->Asl.Child; |
| 218 |
if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_ZERO) |
| 219 |
{ |
| 220 |
return; |
| 221 |
} |
| 222 |
|
| 223 |
/* We have a valid return value, but the reserved name did not expect it */ |
| 224 |
|
| 225 |
AslError (ASL_WARNING, ASL_MSG_RESERVED_NO_RETURN_VAL, |
| 226 |
Op, MethodInfo->Op->Asl.ExternalName); |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
/******************************************************************************* |
| 231 |
* |
| 232 |
* FUNCTION: ApCheckPredefinedReturnValue |
| 233 |
* |
| 234 |
* PARAMETERS: Op - A parse node of type "RETURN". |
| 235 |
* MethodInfo - Saved info about this method |
| 236 |
* |
| 237 |
* RETURN: None |
| 238 |
* |
| 239 |
* DESCRIPTION: If method is a predefined name, attempt to validate the return |
| 240 |
* value. Only "static" types can be validated - a simple return |
| 241 |
* of an integer/string/buffer/package or a named reference to |
| 242 |
* a static object. Values such as a Localx or Argx or a control |
| 243 |
* method invocation are not checked. Issue a warning if there is |
| 244 |
* a valid return value, but the reserved method defines no |
| 245 |
* return value. |
| 246 |
* |
| 247 |
******************************************************************************/ |
| 248 |
|
| 249 |
void |
| 250 |
ApCheckPredefinedReturnValue ( |
| 251 |
ACPI_PARSE_OBJECT *Op, |
| 252 |
ASL_METHOD_INFO *MethodInfo) |
| 253 |
{ |
| 254 |
UINT32 Index; |
| 255 |
ACPI_PARSE_OBJECT *ReturnValueOp; |
| 256 |
const ACPI_PREDEFINED_INFO *ThisName; |
| 257 |
|
| 258 |
|
| 259 |
/* |
| 260 |
* Check parent method for a match against the predefined name list. |
| 261 |
* |
| 262 |
* Note: Disable compiler errors/warnings because any errors will be |
| 263 |
* caught when analyzing the parent method. Eliminates duplicate errors. |
| 264 |
*/ |
| 265 |
AslGbl_AllExceptionsDisabled = TRUE; |
| 266 |
Index = ApCheckForPredefinedName (MethodInfo->Op, |
| 267 |
MethodInfo->Op->Asl.NameSeg); |
| 268 |
AslGbl_AllExceptionsDisabled = FALSE; |
| 269 |
|
| 270 |
switch (Index) |
| 271 |
{ |
| 272 |
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ |
| 273 |
|
| 274 |
/* No return value expected, warn if there is one */ |
| 275 |
|
| 276 |
ApCheckForUnexpectedReturnValue (Op, MethodInfo); |
| 277 |
return; |
| 278 |
|
| 279 |
case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ |
| 280 |
case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ |
| 281 |
case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ |
| 282 |
|
| 283 |
/* Just return, nothing to do */ |
| 284 |
return; |
| 285 |
|
| 286 |
default: /* A standard predefined ACPI name */ |
| 287 |
|
| 288 |
ThisName = &AcpiGbl_PredefinedMethods[Index]; |
| 289 |
if (!ThisName->Info.ExpectedBtypes) |
| 290 |
{ |
| 291 |
/* No return value expected, warn if there is one */ |
| 292 |
|
| 293 |
ApCheckForUnexpectedReturnValue (Op, MethodInfo); |
| 294 |
return; |
| 295 |
} |
| 296 |
|
| 297 |
/* Get the object returned, it is the next argument */ |
| 298 |
|
| 299 |
ReturnValueOp = Op->Asl.Child; |
| 300 |
switch (ReturnValueOp->Asl.ParseOpcode) |
| 301 |
{ |
| 302 |
case PARSEOP_ZERO: |
| 303 |
case PARSEOP_ONE: |
| 304 |
case PARSEOP_ONES: |
| 305 |
case PARSEOP_INTEGER: |
| 306 |
case PARSEOP_STRING_LITERAL: |
| 307 |
case PARSEOP_BUFFER: |
| 308 |
case PARSEOP_PACKAGE: |
| 309 |
|
| 310 |
/* Static data return object - check against expected type */ |
| 311 |
|
| 312 |
ApCheckObjectType (ThisName->Info.Name, ReturnValueOp, |
| 313 |
ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); |
| 314 |
|
| 315 |
/* For packages, check the individual package elements */ |
| 316 |
|
| 317 |
if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_PACKAGE) |
| 318 |
{ |
| 319 |
ApCheckPackage (ReturnValueOp, ThisName); |
| 320 |
} |
| 321 |
break; |
| 322 |
|
| 323 |
default: |
| 324 |
/* |
| 325 |
* All other ops are very difficult or impossible to typecheck at |
| 326 |
* compile time. These include all Localx, Argx, and method |
| 327 |
* invocations. Also, NAMESEG and NAMESTRING because the type of |
| 328 |
* any named object can be changed at runtime (for example, |
| 329 |
* CopyObject will change the type of the target object.) |
| 330 |
*/ |
| 331 |
break; |
| 332 |
} |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
/******************************************************************************* |
| 338 |
* |
| 339 |
* FUNCTION: ApCheckForPredefinedObject |
| 340 |
* |
| 341 |
* PARAMETERS: Op - A parse node |
| 342 |
* Name - The ACPI name to be checked |
| 343 |
* |
| 344 |
* RETURN: None |
| 345 |
* |
| 346 |
* DESCRIPTION: Check for a predefined name for a static object (created via |
| 347 |
* the ASL Name operator). If it is a predefined ACPI name, ensure |
| 348 |
* that the name does not require any arguments (which would |
| 349 |
* require a control method implementation of the name), and that |
| 350 |
* the type of the object is one of the expected types for the |
| 351 |
* predefined name. |
| 352 |
* |
| 353 |
******************************************************************************/ |
| 354 |
|
| 355 |
void |
| 356 |
ApCheckForPredefinedObject ( |
| 357 |
ACPI_PARSE_OBJECT *Op, |
| 358 |
char *Name) |
| 359 |
{ |
| 360 |
UINT32 Index; |
| 361 |
ACPI_PARSE_OBJECT *ObjectOp; |
| 362 |
const ACPI_PREDEFINED_INFO *ThisName; |
| 363 |
|
| 364 |
|
| 365 |
/* |
| 366 |
* Check for a real predefined name -- not a resource descriptor name |
| 367 |
* or a predefined scope name |
| 368 |
*/ |
| 369 |
Index = ApCheckForPredefinedName (Op, Name); |
| 370 |
|
| 371 |
switch (Index) |
| 372 |
{ |
| 373 |
case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */ |
| 374 |
case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */ |
| 375 |
case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */ |
| 376 |
|
| 377 |
/* Nothing to do */ |
| 378 |
return; |
| 379 |
|
| 380 |
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */ |
| 381 |
|
| 382 |
/* |
| 383 |
* These names must be control methods, by definition in ACPI spec. |
| 384 |
* Also because they are defined to return no value. None of them |
| 385 |
* require any arguments. |
| 386 |
*/ |
| 387 |
AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, |
| 388 |
"with zero arguments"); |
| 389 |
return; |
| 390 |
|
| 391 |
default: |
| 392 |
|
| 393 |
break; |
| 394 |
} |
| 395 |
|
| 396 |
/* A standard predefined ACPI name */ |
| 397 |
|
| 398 |
/* |
| 399 |
* If this predefined name requires input arguments, then |
| 400 |
* it must be implemented as a control method |
| 401 |
*/ |
| 402 |
ThisName = &AcpiGbl_PredefinedMethods[Index]; |
| 403 |
if (METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList) > 0) |
| 404 |
{ |
| 405 |
AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, |
| 406 |
"with arguments"); |
| 407 |
return; |
| 408 |
} |
| 409 |
|
| 410 |
/* |
| 411 |
* If no return value is expected from this predefined name, then |
| 412 |
* it follows that it must be implemented as a control method |
| 413 |
* (with zero args, because the args > 0 case was handled above) |
| 414 |
* Examples are: _DIS, _INI, _IRC, _OFF, _ON, _PSx |
| 415 |
*/ |
| 416 |
if (!ThisName->Info.ExpectedBtypes) |
| 417 |
{ |
| 418 |
AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op, |
| 419 |
"with zero arguments"); |
| 420 |
return; |
| 421 |
} |
| 422 |
|
| 423 |
/* Typecheck the actual object, it is the next argument */ |
| 424 |
|
| 425 |
ObjectOp = Op->Asl.Child->Asl.Next; |
| 426 |
ApCheckObjectType (ThisName->Info.Name, Op->Asl.Child->Asl.Next, |
| 427 |
ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT); |
| 428 |
|
| 429 |
/* For packages, check the individual package elements */ |
| 430 |
|
| 431 |
if (ObjectOp->Asl.ParseOpcode == PARSEOP_PACKAGE) |
| 432 |
{ |
| 433 |
ApCheckPackage (ObjectOp, ThisName); |
| 434 |
} |
| 435 |
} |
| 436 |
|
| 437 |
|
| 438 |
/******************************************************************************* |
| 439 |
* |
| 440 |
* FUNCTION: ApCheckForPredefinedName |
| 441 |
* |
| 442 |
* PARAMETERS: Op - A parse node |
| 443 |
* Name - NameSeg to check |
| 444 |
* |
| 445 |
* RETURN: None |
| 446 |
* |
| 447 |
* DESCRIPTION: Check a NameSeg against the reserved list. |
| 448 |
* |
| 449 |
******************************************************************************/ |
| 450 |
|
| 451 |
UINT32 |
| 452 |
ApCheckForPredefinedName ( |
| 453 |
ACPI_PARSE_OBJECT *Op, |
| 454 |
char *Name) |
| 455 |
{ |
| 456 |
UINT32 i; |
| 457 |
const ACPI_PREDEFINED_INFO *ThisName; |
| 458 |
|
| 459 |
|
| 460 |
if (Name[0] == 0) |
| 461 |
{ |
| 462 |
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op, |
| 463 |
"Zero length name found"); |
| 464 |
} |
| 465 |
|
| 466 |
/* All reserved names are prefixed with a single underscore */ |
| 467 |
|
| 468 |
if (Name[0] != '_') |
| 469 |
{ |
| 470 |
return (ACPI_NOT_RESERVED_NAME); |
| 471 |
} |
| 472 |
|
| 473 |
/* Check for a standard predefined method name */ |
| 474 |
|
| 475 |
ThisName = AcpiGbl_PredefinedMethods; |
| 476 |
for (i = 0; ThisName->Info.Name[0]; i++) |
| 477 |
{ |
| 478 |
if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name)) |
| 479 |
{ |
| 480 |
/* Return index into predefined array */ |
| 481 |
return (i); |
| 482 |
} |
| 483 |
|
| 484 |
ThisName++; /* Does not account for extra package data, but is OK */ |
| 485 |
} |
| 486 |
|
| 487 |
/* Check for resource names and predefined scope names */ |
| 488 |
|
| 489 |
ThisName = AcpiGbl_ResourceNames; |
| 490 |
while (ThisName->Info.Name[0]) |
| 491 |
{ |
| 492 |
if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name)) |
| 493 |
{ |
| 494 |
return (ACPI_PREDEFINED_NAME); |
| 495 |
} |
| 496 |
|
| 497 |
ThisName++; |
| 498 |
} |
| 499 |
|
| 500 |
ThisName = AcpiGbl_ScopeNames; |
| 501 |
while (ThisName->Info.Name[0]) |
| 502 |
{ |
| 503 |
if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name)) |
| 504 |
{ |
| 505 |
return (ACPI_PREDEFINED_NAME); |
| 506 |
} |
| 507 |
|
| 508 |
ThisName++; |
| 509 |
} |
| 510 |
|
| 511 |
/* Check for _Lxx/_Exx/_Wxx/_Qxx/_T_x. Warning if unknown predefined name */ |
| 512 |
|
| 513 |
return (ApCheckForSpecialName (Op, Name)); |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
/******************************************************************************* |
| 518 |
* |
| 519 |
* FUNCTION: ApCheckForSpecialName |
| 520 |
* |
| 521 |
* PARAMETERS: Op - A parse node |
| 522 |
* Name - NameSeg to check |
| 523 |
* |
| 524 |
* RETURN: None |
| 525 |
* |
| 526 |
* DESCRIPTION: Check for the "special" predefined names - |
| 527 |
* _Lxx, _Exx, _Qxx, _Wxx, and _T_x |
| 528 |
* |
| 529 |
******************************************************************************/ |
| 530 |
|
| 531 |
static UINT32 |
| 532 |
ApCheckForSpecialName ( |
| 533 |
ACPI_PARSE_OBJECT *Op, |
| 534 |
char *Name) |
| 535 |
{ |
| 536 |
|
| 537 |
/* |
| 538 |
* Check for the "special" predefined names. We already know that the |
| 539 |
* first character is an underscore. |
| 540 |
* GPE: _Lxx |
| 541 |
* GPE: _Exx |
| 542 |
* GPE: _Wxx |
| 543 |
* EC: _Qxx |
| 544 |
*/ |
| 545 |
if ((Name[1] == 'L') || |
| 546 |
(Name[1] == 'E') || |
| 547 |
(Name[1] == 'W') || |
| 548 |
(Name[1] == 'Q')) |
| 549 |
{ |
| 550 |
/* The next two characters must be hex digits */ |
| 551 |
|
| 552 |
if ((isxdigit ((int) Name[2])) && |
| 553 |
(isxdigit ((int) Name[3]))) |
| 554 |
{ |
| 555 |
return (ACPI_EVENT_RESERVED_NAME); |
| 556 |
} |
| 557 |
} |
| 558 |
|
| 559 |
/* Check for the names reserved for the compiler itself: _T_x */ |
| 560 |
|
| 561 |
else if ((Op->Asl.ExternalName[1] == 'T') && |
| 562 |
(Op->Asl.ExternalName[2] == '_')) |
| 563 |
{ |
| 564 |
/* Ignore if actually emitted by the compiler */ |
| 565 |
|
| 566 |
if (Op->Asl.CompileFlags & OP_COMPILER_EMITTED) |
| 567 |
{ |
| 568 |
return (ACPI_NOT_RESERVED_NAME); |
| 569 |
} |
| 570 |
|
| 571 |
/* |
| 572 |
* Was not actually emitted by the compiler. This is a special case, |
| 573 |
* however. If the ASL code being compiled was the result of a |
| 574 |
* disassembly, it may possibly contain valid compiler-emitted names |
| 575 |
* of the form "_T_x". We don't want to issue an error or even a |
| 576 |
* warning and force the user to manually change the names. So, we |
| 577 |
* will issue a remark instead. |
| 578 |
*/ |
| 579 |
AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED, |
| 580 |
Op, Op->Asl.ExternalName); |
| 581 |
return (ACPI_COMPILER_RESERVED_NAME); |
| 582 |
} |
| 583 |
|
| 584 |
/* |
| 585 |
* The name didn't match any of the known predefined names. Flag it as a |
| 586 |
* warning, since the entire namespace starting with an underscore is |
| 587 |
* reserved by the ACPI spec. |
| 588 |
*/ |
| 589 |
AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, |
| 590 |
Op, Op->Asl.ExternalName); |
| 591 |
|
| 592 |
return (ACPI_NOT_RESERVED_NAME); |
| 593 |
} |
| 594 |
|
| 595 |
|
| 596 |
/******************************************************************************* |
| 597 |
* |
| 598 |
* FUNCTION: ApCheckObjectType |
| 599 |
* |
| 600 |
* PARAMETERS: PredefinedName - Name of the predefined object we are checking |
| 601 |
* Op - Current parse node |
| 602 |
* ExpectedBtypes - Bitmap of expected return type(s) |
| 603 |
* PackageIndex - Index of object within parent package (if |
| 604 |
* applicable - ACPI_NOT_PACKAGE_ELEMENT |
| 605 |
* otherwise) |
| 606 |
* |
| 607 |
* RETURN: None |
| 608 |
* |
| 609 |
* DESCRIPTION: Check if the object type is one of the types that is expected |
| 610 |
* by the predefined name. Only a limited number of object types |
| 611 |
* can be returned by the predefined names. |
| 612 |
* |
| 613 |
******************************************************************************/ |
| 614 |
|
| 615 |
ACPI_STATUS |
| 616 |
ApCheckObjectType ( |
| 617 |
const char *PredefinedName, |
| 618 |
ACPI_PARSE_OBJECT *Op, |
| 619 |
UINT32 ExpectedBtypes, |
| 620 |
UINT32 PackageIndex) |
| 621 |
{ |
| 622 |
UINT32 ReturnBtype; |
| 623 |
char *TypeName; |
| 624 |
|
| 625 |
|
| 626 |
if (!Op) |
| 627 |
{ |
| 628 |
return (AE_TYPE); |
| 629 |
} |
| 630 |
|
| 631 |
/* Map the parse opcode to a bitmapped return type (RTYPE) */ |
| 632 |
|
| 633 |
switch (Op->Asl.ParseOpcode) |
| 634 |
{ |
| 635 |
case PARSEOP_ZERO: |
| 636 |
case PARSEOP_ONE: |
| 637 |
case PARSEOP_ONES: |
| 638 |
case PARSEOP_INTEGER: |
| 639 |
|
| 640 |
ReturnBtype = ACPI_RTYPE_INTEGER; |
| 641 |
TypeName = "Integer"; |
| 642 |
break; |
| 643 |
|
| 644 |
case PARSEOP_STRING_LITERAL: |
| 645 |
|
| 646 |
ReturnBtype = ACPI_RTYPE_STRING; |
| 647 |
TypeName = "String"; |
| 648 |
break; |
| 649 |
|
| 650 |
case PARSEOP_BUFFER: |
| 651 |
|
| 652 |
ReturnBtype = ACPI_RTYPE_BUFFER; |
| 653 |
TypeName = "Buffer"; |
| 654 |
break; |
| 655 |
|
| 656 |
case PARSEOP_PACKAGE: |
| 657 |
case PARSEOP_VAR_PACKAGE: |
| 658 |
|
| 659 |
ReturnBtype = ACPI_RTYPE_PACKAGE; |
| 660 |
TypeName = "Package"; |
| 661 |
break; |
| 662 |
|
| 663 |
case PARSEOP_NAMESEG: |
| 664 |
case PARSEOP_NAMESTRING: |
| 665 |
/* |
| 666 |
* Ignore any named references within a package object. |
| 667 |
* |
| 668 |
* For Package objects, references are allowed instead of any of the |
| 669 |
* standard data types (Integer/String/Buffer/Package). These |
| 670 |
* references are resolved at runtime. NAMESEG and NAMESTRING are |
| 671 |
* impossible to typecheck at compile time because the type of |
| 672 |
* any named object can be changed at runtime (for example, |
| 673 |
* CopyObject will change the type of the target object). |
| 674 |
*/ |
| 675 |
if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT) |
| 676 |
{ |
| 677 |
return (AE_OK); |
| 678 |
} |
| 679 |
|
| 680 |
ReturnBtype = ACPI_RTYPE_REFERENCE; |
| 681 |
TypeName = "Reference"; |
| 682 |
break; |
| 683 |
|
| 684 |
default: |
| 685 |
|
| 686 |
/* Not one of the supported object types */ |
| 687 |
|
| 688 |
TypeName = UtGetOpName (Op->Asl.ParseOpcode); |
| 689 |
goto TypeErrorExit; |
| 690 |
} |
| 691 |
|
| 692 |
/* Exit if the object is one of the expected types */ |
| 693 |
|
| 694 |
if (ReturnBtype & ExpectedBtypes) |
| 695 |
{ |
| 696 |
return (AE_OK); |
| 697 |
} |
| 698 |
|
| 699 |
|
| 700 |
TypeErrorExit: |
| 701 |
|
| 702 |
/* Format the expected types and emit an error message */ |
| 703 |
|
| 704 |
AcpiUtGetExpectedReturnTypes (AslGbl_StringBuffer, ExpectedBtypes); |
| 705 |
|
| 706 |
{ |
| 707 |
int cnt; |
| 708 |
char *strp; |
| 709 |
|
| 710 |
if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) |
| 711 |
{ |
| 712 |
cnt = asprintf (&strp, "%4.4s: found %s, %s required", |
| 713 |
PredefinedName, TypeName, AslGbl_StringBuffer); |
| 714 |
} |
| 715 |
else |
| 716 |
{ |
| 717 |
cnt = asprintf (&strp, "%4.4s: found %s at index %u, %s required", |
| 718 |
PredefinedName, TypeName, PackageIndex, AslGbl_StringBuffer); |
| 719 |
} |
| 720 |
|
| 721 |
AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, strp); |
| 722 |
if (cnt > 0) |
| 723 |
free(strp); |
| 724 |
} |
| 725 |
|
| 726 |
return (AE_TYPE); |
| 727 |
} |
| 728 |
|
| 729 |
|
| 730 |
/******************************************************************************* |
| 731 |
* |
| 732 |
* FUNCTION: ApDisplayReservedNames |
| 733 |
* |
| 734 |
* PARAMETERS: None |
| 735 |
* |
| 736 |
* RETURN: None |
| 737 |
* |
| 738 |
* DESCRIPTION: Dump information about the ACPI predefined names and predefined |
| 739 |
* resource descriptor names. |
| 740 |
* |
| 741 |
******************************************************************************/ |
| 742 |
|
| 743 |
void |
| 744 |
ApDisplayReservedNames ( |
| 745 |
void) |
| 746 |
{ |
| 747 |
const ACPI_PREDEFINED_INFO *ThisName; |
| 748 |
UINT32 Count; |
| 749 |
UINT32 NumTypes; |
| 750 |
|
| 751 |
|
| 752 |
/* |
| 753 |
* Predefined names/methods |
| 754 |
*/ |
| 755 |
printf ("\nPredefined Name Information\n\n"); |
| 756 |
|
| 757 |
Count = 0; |
| 758 |
ThisName = AcpiGbl_PredefinedMethods; |
| 759 |
while (ThisName->Info.Name[0]) |
| 760 |
{ |
| 761 |
AcpiUtDisplayPredefinedMethod (AslGbl_MsgBuffer, ThisName, FALSE); |
| 762 |
Count++; |
| 763 |
ThisName = AcpiUtGetNextPredefinedMethod (ThisName); |
| 764 |
} |
| 765 |
|
| 766 |
printf ("%u Predefined Names are recognized\n", Count); |
| 767 |
|
| 768 |
/* |
| 769 |
* Resource Descriptor names |
| 770 |
*/ |
| 771 |
printf ("\nPredefined Names for Resource Descriptor Fields\n\n"); |
| 772 |
|
| 773 |
Count = 0; |
| 774 |
ThisName = AcpiGbl_ResourceNames; |
| 775 |
while (ThisName->Info.Name[0]) |
| 776 |
{ |
| 777 |
NumTypes = AcpiUtGetResourceBitWidth (AslGbl_MsgBuffer, |
| 778 |
ThisName->Info.ArgumentList); |
| 779 |
|
| 780 |
printf ("%4.4s Field is %s bits wide%s\n", |
| 781 |
ThisName->Info.Name, AslGbl_MsgBuffer, |
| 782 |
(NumTypes > 1) ? " (depending on descriptor type)" : ""); |
| 783 |
|
| 784 |
Count++; |
| 785 |
ThisName++; |
| 786 |
} |
| 787 |
|
| 788 |
printf ("%u Resource Descriptor Field Names are recognized\n", Count); |
| 789 |
|
| 790 |
/* |
| 791 |
* Predefined scope names |
| 792 |
*/ |
| 793 |
printf ("\nPredefined Scope/Device Names (automatically created at root)\n\n"); |
| 794 |
|
| 795 |
ThisName = AcpiGbl_ScopeNames; |
| 796 |
while (ThisName->Info.Name[0]) |
| 797 |
{ |
| 798 |
printf ("%4.4s Scope/Device\n", ThisName->Info.Name); |
| 799 |
ThisName++; |
| 800 |
} |
| 801 |
} |