utglobal.c revision 99679
1/****************************************************************************** 2 * 3 * Module Name: utglobal - Global variables for the ACPI subsystem 4 * $Revision: 162 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117#define __UTGLOBAL_C__ 118#define DEFINE_ACPI_GLOBALS 119 120#include "acpi.h" 121#include "acnamesp.h" 122 123#define _COMPONENT ACPI_UTILITIES 124 ACPI_MODULE_NAME ("utglobal") 125 126 127 128/****************************************************************************** 129 * 130 * FUNCTION: AcpiFormatException 131 * 132 * PARAMETERS: Status - The ACPI_STATUS code to be formatted 133 * 134 * RETURN: A string containing the exception text 135 * 136 * DESCRIPTION: This function translates an ACPI exception into an ASCII string. 137 * 138 ******************************************************************************/ 139 140const char * 141AcpiFormatException ( 142 ACPI_STATUS Status) 143{ 144 const char *Exception = "UNKNOWN_STATUS_CODE"; 145 ACPI_STATUS SubStatus; 146 147 148 ACPI_FUNCTION_NAME ("FormatException"); 149 150 151 SubStatus = (Status & ~AE_CODE_MASK); 152 153 switch (Status & AE_CODE_MASK) 154 { 155 case AE_CODE_ENVIRONMENTAL: 156 157 if (SubStatus <= AE_CODE_ENV_MAX) 158 { 159 Exception = AcpiGbl_ExceptionNames_Env [SubStatus]; 160 break; 161 } 162 goto Unknown; 163 164 case AE_CODE_PROGRAMMER: 165 166 if (SubStatus <= AE_CODE_PGM_MAX) 167 { 168 Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1]; 169 break; 170 } 171 goto Unknown; 172 173 case AE_CODE_ACPI_TABLES: 174 175 if (SubStatus <= AE_CODE_TBL_MAX) 176 { 177 Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1]; 178 break; 179 } 180 goto Unknown; 181 182 case AE_CODE_AML: 183 184 if (SubStatus <= AE_CODE_AML_MAX) 185 { 186 Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1]; 187 break; 188 } 189 goto Unknown; 190 191 case AE_CODE_CONTROL: 192 193 if (SubStatus <= AE_CODE_CTRL_MAX) 194 { 195 Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1]; 196 break; 197 } 198 goto Unknown; 199 200 default: 201 goto Unknown; 202 } 203 204 205 return ((const char *) Exception); 206 207Unknown: 208 209 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", Status)); 210 return ((const char *) Exception); 211} 212 213 214/****************************************************************************** 215 * 216 * Static global variable initialization. 217 * 218 ******************************************************************************/ 219 220/* 221 * We want the debug switches statically initialized so they 222 * are already set when the debugger is entered. 223 */ 224 225/* Debug switch - level and trace mask */ 226 227#ifdef ACPI_DEBUG 228UINT32 AcpiDbgLevel = DEBUG_DEFAULT; 229#else 230UINT32 AcpiDbgLevel = NORMAL_DEFAULT; 231#endif 232 233/* Debug switch - layer (component) mask */ 234 235UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT; 236UINT32 AcpiGbl_NestingLevel = 0; 237 238 239/* Debugger globals */ 240 241BOOLEAN AcpiGbl_DbTerminateThreads = FALSE; 242BOOLEAN AcpiGbl_MethodExecuting = FALSE; 243 244/* System flags */ 245 246UINT32 AcpiGbl_StartupFlags = 0; 247 248/* System starts uninitialized */ 249 250BOOLEAN AcpiGbl_Shutdown = TRUE; 251 252const UINT8 AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128}; 253 254const NATIVE_CHAR *AcpiGbl_DbSleepStates[ACPI_NUM_SLEEP_STATES] = { 255 "\\_S0_","\\_S1_","\\_S2_","\\_S3_", 256 "\\_S4_","\\_S5_","\\_S4B"}; 257 258 259/****************************************************************************** 260 * 261 * Namespace globals 262 * 263 ******************************************************************************/ 264 265 266/* 267 * Names built-in to the interpreter 268 * 269 * Initial values are currently supported only for types String and Number. 270 * To avoid type punning, both are specified as strings in this table. 271 * 272 * NOTES: 273 * 1) _SB_ is defined to be a device to allow _SB_/_INI to be run 274 * during the initialization sequence. 275 */ 276 277const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = 278{ 279 {"_GPE", INTERNAL_TYPE_DEF_ANY, NULL}, 280 {"_PR_", INTERNAL_TYPE_DEF_ANY, NULL}, 281 {"_SB_", ACPI_TYPE_DEVICE, NULL}, 282 {"_SI_", INTERNAL_TYPE_DEF_ANY, NULL}, 283 {"_TZ_", INTERNAL_TYPE_DEF_ANY, NULL}, 284 {"_REV", ACPI_TYPE_INTEGER, "2"}, 285 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 286 {"_GL_", ACPI_TYPE_MUTEX, "0"}, 287 {NULL, ACPI_TYPE_ANY, NULL} /* Table terminator */ 288}; 289 290 291/* 292 * Properties of the ACPI Object Types, both internal and external. 293 * 294 * Elements of AcpiNsProperties are bit significant 295 * and the table is indexed by values of ACPI_OBJECT_TYPE 296 */ 297 298const UINT8 AcpiGbl_NsProperties[] = 299{ 300 ACPI_NS_NORMAL, /* 00 Any */ 301 ACPI_NS_NORMAL, /* 01 Number */ 302 ACPI_NS_NORMAL, /* 02 String */ 303 ACPI_NS_NORMAL, /* 03 Buffer */ 304 ACPI_NS_NORMAL, /* 04 Package */ 305 ACPI_NS_NORMAL, /* 05 FieldUnit */ 306 ACPI_NS_NEWSCOPE, /* 06 Device */ 307 ACPI_NS_NORMAL, /* 07 Event */ 308 ACPI_NS_NEWSCOPE, /* 08 Method */ 309 ACPI_NS_NORMAL, /* 09 Mutex */ 310 ACPI_NS_NORMAL, /* 10 Region */ 311 ACPI_NS_NEWSCOPE, /* 11 Power */ 312 ACPI_NS_NEWSCOPE, /* 12 Processor */ 313 ACPI_NS_NEWSCOPE, /* 13 Thermal */ 314 ACPI_NS_NORMAL, /* 14 BufferField */ 315 ACPI_NS_NORMAL, /* 15 DdbHandle */ 316 ACPI_NS_NORMAL, /* 16 Debug Object */ 317 ACPI_NS_NORMAL, /* 17 DefField */ 318 ACPI_NS_NORMAL, /* 18 BankField */ 319 ACPI_NS_NORMAL, /* 19 IndexField */ 320 ACPI_NS_NORMAL, /* 20 Reference */ 321 ACPI_NS_NORMAL, /* 21 Alias */ 322 ACPI_NS_NORMAL, /* 22 Notify */ 323 ACPI_NS_NORMAL, /* 23 Address Handler */ 324 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 24 Resource Desc */ 325 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Field */ 326 ACPI_NS_NORMAL, /* 26 DefFieldDefn */ 327 ACPI_NS_NORMAL, /* 27 BankFieldDefn */ 328 ACPI_NS_NORMAL, /* 28 IndexFieldDefn */ 329 ACPI_NS_NORMAL, /* 29 If */ 330 ACPI_NS_NORMAL, /* 30 Else */ 331 ACPI_NS_NORMAL, /* 31 While */ 332 ACPI_NS_NEWSCOPE, /* 32 Scope */ 333 ACPI_NS_LOCAL, /* 33 DefAny */ 334 ACPI_NS_NORMAL, /* 34 Extra */ 335 ACPI_NS_NORMAL, /* 35 Data */ 336 ACPI_NS_NORMAL /* 36 Invalid */ 337}; 338 339 340/* Hex to ASCII conversion table */ 341 342static const NATIVE_CHAR AcpiGbl_HexToAscii[] = 343 {'0','1','2','3','4','5','6','7', 344 '8','9','A','B','C','D','E','F'}; 345 346/***************************************************************************** 347 * 348 * FUNCTION: AcpiUtHexToAsciiChar 349 * 350 * PARAMETERS: Integer - Contains the hex digit 351 * Position - bit position of the digit within the 352 * integer 353 * 354 * RETURN: Ascii character 355 * 356 * DESCRIPTION: Convert a hex digit to an ascii character 357 * 358 ****************************************************************************/ 359 360char 361AcpiUtHexToAsciiChar ( 362 ACPI_INTEGER Integer, 363 UINT32 Position) 364{ 365 366 return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); 367} 368 369 370/****************************************************************************** 371 * 372 * Table name globals 373 * 374 * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes. 375 * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables 376 * that are not used by the subsystem are simply ignored. 377 * 378 * Do NOT add any table to this list that is not consumed directly by this 379 * subsystem. 380 * 381 ******************************************************************************/ 382 383 384ACPI_TABLE_DESC AcpiGbl_AcpiTables[NUM_ACPI_TABLES]; 385 386 387ACPI_TABLE_SUPPORT AcpiGbl_AcpiTableData[NUM_ACPI_TABLES] = 388{ 389 /*********** Name, Signature, Global typed pointer Signature size, How many allowed?, Contains valid AML? */ 390 391 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_SINGLE}, 392 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void **) &AcpiGbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE}, 393 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void **) &AcpiGbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_SINGLE}, 394 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void **) &AcpiGbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SINGLE}, 395 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, 396 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, 397 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_SINGLE}, 398}; 399 400 401/****************************************************************************** 402 * 403 * Event and Hardware globals 404 * 405 ******************************************************************************/ 406 407ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = 408{ 409 /* Name Parent Register Register Bit Position Register Bit Mask */ 410 411 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, 412 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, 413 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, 414 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, 415 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, 416 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, 417 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, 418 419 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, 420 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 421 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 422 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 423 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, 424 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, 425 426 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, 427 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, 428 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, 429 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 430 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 431 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, 432 433 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} 434}; 435 436 437ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = 438{ 439 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, 440 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 441 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 442 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 443 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, 0, 0}, 444}; 445 446/***************************************************************************** 447 * 448 * FUNCTION: AcpiUtGetRegionName 449 * 450 * PARAMETERS: None. 451 * 452 * RETURN: Status 453 * 454 * DESCRIPTION: Translate a Space ID into a name string (Debug only) 455 * 456 ****************************************************************************/ 457 458/* Region type decoding */ 459 460static const NATIVE_CHAR *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = 461{ 462 "SystemMemory", 463 "SystemIO", 464 "PCIConfig", 465 "EmbeddedControl", 466 "SMBus", 467 "CMOS", 468 "PCIBarTarget", 469 "DataTable", 470}; 471 472 473NATIVE_CHAR * 474AcpiUtGetRegionName ( 475 UINT8 SpaceId) 476{ 477 478 if (SpaceId >= ACPI_USER_REGION_BEGIN) 479 { 480 return ("UserDefinedRegion"); 481 } 482 483 else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) 484 { 485 return ("InvalidSpaceID"); 486 } 487 488 return ((NATIVE_CHAR *) AcpiGbl_RegionTypes[SpaceId]); 489} 490 491 492/***************************************************************************** 493 * 494 * FUNCTION: AcpiUtGetEventName 495 * 496 * PARAMETERS: None. 497 * 498 * RETURN: Status 499 * 500 * DESCRIPTION: Translate a Event ID into a name string (Debug only) 501 * 502 ****************************************************************************/ 503 504/* Event type decoding */ 505 506static const NATIVE_CHAR *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = 507{ 508 "PM_Timer", 509 "GlobalLock", 510 "PowerButton", 511 "SleepButton", 512 "RealTimeClock", 513}; 514 515 516NATIVE_CHAR * 517AcpiUtGetEventName ( 518 UINT32 EventId) 519{ 520 521 if (EventId > ACPI_EVENT_MAX) 522 { 523 return ("InvalidEventID"); 524 } 525 526 return ((NATIVE_CHAR *) AcpiGbl_EventTypes[EventId]); 527} 528 529 530#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER) 531 532/* 533 * Strings and procedures used for debug only 534 * 535 */ 536 537 538/***************************************************************************** 539 * 540 * FUNCTION: AcpiUtGetMutexName 541 * 542 * PARAMETERS: None. 543 * 544 * RETURN: Status 545 * 546 * DESCRIPTION: Translate a mutex ID into a name string (Debug only) 547 * 548 ****************************************************************************/ 549 550NATIVE_CHAR * 551AcpiUtGetMutexName ( 552 UINT32 MutexId) 553{ 554 555 if (MutexId > MAX_MTX) 556 { 557 return ("Invalid Mutex ID"); 558 } 559 560 return (AcpiGbl_MutexNames[MutexId]); 561} 562 563 564/***************************************************************************** 565 * 566 * FUNCTION: AcpiUtGetTypeName 567 * 568 * PARAMETERS: None. 569 * 570 * RETURN: Status 571 * 572 * DESCRIPTION: Translate a Type ID into a name string (Debug only) 573 * 574 ****************************************************************************/ 575 576/* 577 * Elements of AcpiGbl_NsTypeNames below must match 578 * one-to-one with values of ACPI_OBJECT_TYPE 579 * 580 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when 581 * stored in a table it really means that we have thus far seen no evidence to 582 * indicatewhat type is actually going to be stored for this entry. 583 */ 584 585static const NATIVE_CHAR AcpiGbl_BadType[] = "UNDEFINED"; 586#define TYPE_NAME_LENGTH 12 /* Maximum length of each string */ 587 588static const NATIVE_CHAR *AcpiGbl_NsTypeNames[] = /* printable names of ACPI types */ 589{ 590 /* 00 */ "Untyped", 591 /* 01 */ "Integer", 592 /* 02 */ "String", 593 /* 03 */ "Buffer", 594 /* 04 */ "Package", 595 /* 05 */ "FieldUnit", 596 /* 06 */ "Device", 597 /* 07 */ "Event", 598 /* 08 */ "Method", 599 /* 09 */ "Mutex", 600 /* 10 */ "Region", 601 /* 11 */ "Power", 602 /* 12 */ "Processor", 603 /* 13 */ "Thermal", 604 /* 14 */ "BufferField", 605 /* 15 */ "DdbHandle", 606 /* 16 */ "DebugObject", 607 /* 17 */ "RegionField", 608 /* 18 */ "BankField", 609 /* 19 */ "IndexField", 610 /* 20 */ "Reference", 611 /* 21 */ "Alias", 612 /* 22 */ "Notify", 613 /* 23 */ "AddrHandler", 614 /* 24 */ "ResourceDesc", 615 /* 25 */ "ResourceFld", 616 /* 26 */ "RegionFldDfn", 617 /* 27 */ "BankFldDfn", 618 /* 28 */ "IndexFldDfn", 619 /* 29 */ "If", 620 /* 30 */ "Else", 621 /* 31 */ "While", 622 /* 32 */ "Scope", 623 /* 33 */ "DefAny", 624 /* 34 */ "Extra", 625 /* 35 */ "Data", 626 /* 36 */ "Invalid" 627}; 628 629 630NATIVE_CHAR * 631AcpiUtGetTypeName ( 632 ACPI_OBJECT_TYPE Type) 633{ 634 635 if (Type > INTERNAL_TYPE_INVALID) 636 { 637 return ((NATIVE_CHAR *) AcpiGbl_BadType); 638 } 639 640 return ((NATIVE_CHAR *) AcpiGbl_NsTypeNames[Type]); 641} 642 643 644NATIVE_CHAR * 645AcpiUtGetObjectTypeName ( 646 ACPI_OPERAND_OBJECT *ObjDesc) 647{ 648 649 if (!ObjDesc) 650 { 651 return ("[NULL Object Descriptor]"); 652 } 653 654 return (AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc))); 655} 656 657 658/* Various strings for future use */ 659 660#if 0 661#include "amlcode.h" 662 663/* Data used in keeping track of fields */ 664 665static const NATIVE_CHAR *AcpiGbl_FENames[NUM_FIELD_NAMES] = 666{ 667 "skip", 668 "?access?" 669}; /* FE = Field Element */ 670 671 672static const NATIVE_CHAR *AcpiGbl_MatchOps[NUM_MATCH_OPS] = 673{ 674 "Error", 675 "MTR", 676 "MEQ", 677 "MLE", 678 "MLT", 679 "MGE", 680 "MGT" 681}; 682 683 684/* Access type decoding */ 685 686static const NATIVE_CHAR *AcpiGbl_AccessTypes[NUM_ACCESS_TYPES] = 687{ 688 "AnyAcc", 689 "ByteAcc", 690 "WordAcc", 691 "DWordAcc", 692 "QWordAcc", 693 "BufferAcc", 694}; 695 696 697/* Update rule decoding */ 698 699static const NATIVE_CHAR *AcpiGbl_UpdateRules[NUM_UPDATE_RULES] = 700{ 701 "Preserve", 702 "WriteAsOnes", 703 "WriteAsZeros" 704}; 705#endif /* Future use */ 706 707#endif 708 709 710/***************************************************************************** 711 * 712 * FUNCTION: AcpiUtValidObjectType 713 * 714 * PARAMETERS: None. 715 * 716 * RETURN: TRUE if valid object type 717 * 718 * DESCRIPTION: Validate an object type 719 * 720 ****************************************************************************/ 721 722BOOLEAN 723AcpiUtValidObjectType ( 724 ACPI_OBJECT_TYPE Type) 725{ 726 727 if (Type > ACPI_TYPE_MAX) 728 { 729 if ((Type < INTERNAL_TYPE_BEGIN) || 730 (Type > INTERNAL_TYPE_MAX)) 731 { 732 return (FALSE); 733 } 734 } 735 736 return (TRUE); 737} 738 739 740/**************************************************************************** 741 * 742 * FUNCTION: AcpiUtAllocateOwnerId 743 * 744 * PARAMETERS: IdType - Type of ID (method or table) 745 * 746 * DESCRIPTION: Allocate a table or method owner id 747 * 748 ***************************************************************************/ 749 750ACPI_OWNER_ID 751AcpiUtAllocateOwnerId ( 752 UINT32 IdType) 753{ 754 ACPI_OWNER_ID OwnerId = 0xFFFF; 755 756 757 ACPI_FUNCTION_TRACE ("UtAllocateOwnerId"); 758 759 760 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES))) 761 { 762 return (0); 763 } 764 765 switch (IdType) 766 { 767 case ACPI_OWNER_TYPE_TABLE: 768 769 OwnerId = AcpiGbl_NextTableOwnerId; 770 AcpiGbl_NextTableOwnerId++; 771 772 if (AcpiGbl_NextTableOwnerId == ACPI_FIRST_METHOD_ID) 773 { 774 AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID; 775 } 776 break; 777 778 779 case ACPI_OWNER_TYPE_METHOD: 780 781 OwnerId = AcpiGbl_NextMethodOwnerId; 782 AcpiGbl_NextMethodOwnerId++; 783 784 if (AcpiGbl_NextMethodOwnerId == ACPI_FIRST_TABLE_ID) 785 { 786 AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID; 787 } 788 break; 789 790 default: 791 break; 792 } 793 794 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); 795 return_VALUE (OwnerId); 796} 797 798 799/**************************************************************************** 800 * 801 * FUNCTION: AcpiUtInitGlobals 802 * 803 * PARAMETERS: none 804 * 805 * DESCRIPTION: Init library globals. All globals that require specific 806 * initialization should be initialized here! 807 * 808 ***************************************************************************/ 809 810void 811AcpiUtInitGlobals ( 812 void) 813{ 814 UINT32 i; 815 816 817 ACPI_FUNCTION_TRACE ("UtInitGlobals"); 818 819 /* Memory allocation and cache lists */ 820 821 ACPI_MEMSET (AcpiGbl_MemoryLists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS); 822 823 AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_GENERIC_STATE *) NULL)->Common.Next), NULL); 824 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL); 825 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL); 826 AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_OPERAND_OBJECT *) NULL)->Cache.Next), NULL); 827 AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_WALK_STATE *) NULL)->Next), NULL); 828 829 AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ObjectSize = sizeof (ACPI_NAMESPACE_NODE); 830 AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ObjectSize = sizeof (ACPI_GENERIC_STATE); 831 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ObjectSize = sizeof (ACPI_PARSE_OBJ_COMMON); 832 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ObjectSize = sizeof (ACPI_PARSE_OBJ_NAMED); 833 AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ObjectSize = sizeof (ACPI_OPERAND_OBJECT); 834 AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ObjectSize = sizeof (ACPI_WALK_STATE); 835 836 AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].MaxCacheDepth = MAX_STATE_CACHE_DEPTH; 837 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].MaxCacheDepth = MAX_PARSE_CACHE_DEPTH; 838 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].MaxCacheDepth = MAX_EXTPARSE_CACHE_DEPTH; 839 AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].MaxCacheDepth = MAX_OBJECT_CACHE_DEPTH; 840 AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].MaxCacheDepth = MAX_WALK_CACHE_DEPTH; 841 842 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].ListName = "Global Memory Allocation"); 843 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ListName = "Namespace Nodes"); 844 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ListName = "State Object Cache"); 845 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ListName = "Parse Node Cache"); 846 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ListName = "Extended Parse Node Cache"); 847 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ListName = "Operand Object Cache"); 848 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ListName = "Tree Walk Node Cache"); 849 850 /* ACPI table structure */ 851 852 for (i = 0; i < NUM_ACPI_TABLES; i++) 853 { 854 AcpiGbl_AcpiTables[i].Prev = &AcpiGbl_AcpiTables[i]; 855 AcpiGbl_AcpiTables[i].Next = &AcpiGbl_AcpiTables[i]; 856 AcpiGbl_AcpiTables[i].Pointer = NULL; 857 AcpiGbl_AcpiTables[i].Length = 0; 858 AcpiGbl_AcpiTables[i].Allocation = ACPI_MEM_NOT_ALLOCATED; 859 AcpiGbl_AcpiTables[i].Count = 0; 860 } 861 862 /* Mutex locked flags */ 863 864 for (i = 0; i < NUM_MTX; i++) 865 { 866 AcpiGbl_AcpiMutexInfo[i].Mutex = NULL; 867 AcpiGbl_AcpiMutexInfo[i].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; 868 AcpiGbl_AcpiMutexInfo[i].UseCount = 0; 869 } 870 871 /* Global notify handlers */ 872 873 AcpiGbl_SysNotify.Handler = NULL; 874 AcpiGbl_DrvNotify.Handler = NULL; 875 AcpiGbl_InitHandler = NULL; 876 877 /* Global "typed" ACPI table pointers */ 878 879 AcpiGbl_RSDP = NULL; 880 AcpiGbl_XSDT = NULL; 881 AcpiGbl_FACS = NULL; 882 AcpiGbl_FADT = NULL; 883 AcpiGbl_DSDT = NULL; 884 885 /* Global Lock support */ 886 887 AcpiGbl_GlobalLockAcquired = FALSE; 888 AcpiGbl_GlobalLockThreadCount = 0; 889 AcpiGbl_GlobalLockHandle = 0; 890 891 /* Miscellaneous variables */ 892 893 AcpiGbl_TableFlags = ACPI_PHYSICAL_POINTER; 894 AcpiGbl_RsdpOriginalLocation = 0; 895 AcpiGbl_CmSingleStep = FALSE; 896 AcpiGbl_DbTerminateThreads = FALSE; 897 AcpiGbl_Shutdown = FALSE; 898 AcpiGbl_NsLookupCount = 0; 899 AcpiGbl_PsFindCount = 0; 900 AcpiGbl_AcpiHardwarePresent = TRUE; 901 AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID; 902 AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID; 903 AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; 904 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; 905 906 /* Hardware oriented */ 907 908 AcpiGbl_GpeRegisterInfo = NULL; 909 AcpiGbl_GpeNumberInfo = NULL; 910 911 /* Namespace */ 912 913 AcpiGbl_RootNode = NULL; 914 915 AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; 916 AcpiGbl_RootNodeStruct.Descriptor = ACPI_DESC_TYPE_NAMED; 917 AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_ANY; 918 AcpiGbl_RootNodeStruct.Child = NULL; 919 AcpiGbl_RootNodeStruct.Peer = NULL; 920 AcpiGbl_RootNodeStruct.Object = NULL; 921 AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; 922 923 924#ifdef ACPI_DEBUG 925 AcpiGbl_LowestStackPointer = ACPI_SIZE_MAX; 926#endif 927 928 return_VOID; 929} 930 931 932