utglobal.c revision 104470
1/****************************************************************************** 2 * 3 * Module Name: utglobal - Global variables for the ACPI subsystem 4 * $Revision: 171 $ 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 * FUNCTION: AcpiFormatException 130 * 131 * PARAMETERS: Status - The ACPI_STATUS code to be formatted 132 * 133 * RETURN: A string containing the exception text 134 * 135 * DESCRIPTION: This function translates an ACPI exception into an ASCII string. 136 * 137 ******************************************************************************/ 138 139const char * 140AcpiFormatException ( 141 ACPI_STATUS Status) 142{ 143 const char *Exception = "UNKNOWN_STATUS_CODE"; 144 ACPI_STATUS SubStatus; 145 146 147 ACPI_FUNCTION_NAME ("FormatException"); 148 149 150 SubStatus = (Status & ~AE_CODE_MASK); 151 152 switch (Status & AE_CODE_MASK) 153 { 154 case AE_CODE_ENVIRONMENTAL: 155 156 if (SubStatus <= AE_CODE_ENV_MAX) 157 { 158 Exception = AcpiGbl_ExceptionNames_Env [SubStatus]; 159 break; 160 } 161 goto Unknown; 162 163 case AE_CODE_PROGRAMMER: 164 165 if (SubStatus <= AE_CODE_PGM_MAX) 166 { 167 Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1]; 168 break; 169 } 170 goto Unknown; 171 172 case AE_CODE_ACPI_TABLES: 173 174 if (SubStatus <= AE_CODE_TBL_MAX) 175 { 176 Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1]; 177 break; 178 } 179 goto Unknown; 180 181 case AE_CODE_AML: 182 183 if (SubStatus <= AE_CODE_AML_MAX) 184 { 185 Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1]; 186 break; 187 } 188 goto Unknown; 189 190 case AE_CODE_CONTROL: 191 192 if (SubStatus <= AE_CODE_CTRL_MAX) 193 { 194 Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1]; 195 break; 196 } 197 goto Unknown; 198 199 default: 200 goto Unknown; 201 } 202 203 204 return ((const char *) Exception); 205 206Unknown: 207 208 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", Status)); 209 return ((const char *) Exception); 210} 211 212 213/****************************************************************************** 214 * 215 * Static global variable initialization. 216 * 217 ******************************************************************************/ 218 219/* 220 * We want the debug switches statically initialized so they 221 * are already set when the debugger is entered. 222 */ 223 224/* Debug switch - level and trace mask */ 225 226#ifdef ACPI_DEBUG_OUTPUT 227UINT32 AcpiDbgLevel = DEBUG_DEFAULT; 228#else 229UINT32 AcpiDbgLevel = NORMAL_DEFAULT; 230#endif 231 232/* Debug switch - layer (component) mask */ 233 234UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT; 235UINT32 AcpiGbl_NestingLevel = 0; 236 237 238/* Debugger globals */ 239 240BOOLEAN AcpiGbl_DbTerminateThreads = FALSE; 241BOOLEAN AcpiGbl_MethodExecuting = FALSE; 242 243/* System flags */ 244 245UINT32 AcpiGbl_StartupFlags = 0; 246 247/* System starts uninitialized */ 248 249BOOLEAN AcpiGbl_Shutdown = TRUE; 250 251const UINT8 AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128}; 252 253const NATIVE_CHAR *AcpiGbl_DbSleepStates[ACPI_NUM_SLEEP_STATES] = { 254 "\\_S0_","\\_S1_","\\_S2_","\\_S3_", 255 "\\_S4_","\\_S5_","\\_S4B"}; 256 257 258/****************************************************************************** 259 * 260 * Namespace globals 261 * 262 ******************************************************************************/ 263 264 265/* 266 * Predefined ACPI Names (Built-in to the Interpreter) 267 * 268 * Initial values are currently supported only for types String and Number. 269 * Both are specified as strings in this table. 270 * 271 * NOTES: 272 * 1) _SB_ is defined to be a device to allow _SB_/_INI to be run 273 * during the initialization sequence. 274 */ 275 276const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = 277{ 278 {"_GPE", INTERNAL_TYPE_SCOPE, NULL}, 279 {"_PR_", INTERNAL_TYPE_SCOPE, NULL}, 280 {"_SB_", ACPI_TYPE_DEVICE, NULL}, 281 {"_SI_", INTERNAL_TYPE_SCOPE, NULL}, 282 {"_TZ_", INTERNAL_TYPE_SCOPE, NULL}, 283 {"_REV", ACPI_TYPE_INTEGER, "2"}, 284 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 285 {"_GL_", ACPI_TYPE_MUTEX, "0"}, 286 287#if defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 288 {"_OSI", ACPI_TYPE_METHOD, "1"}, 289#endif 290 {NULL, ACPI_TYPE_ANY, NULL} /* Table terminator */ 291}; 292 293 294/* 295 * Properties of the ACPI Object Types, both internal and external. 296 * The table is indexed by values of ACPI_OBJECT_TYPE 297 */ 298 299const UINT8 AcpiGbl_NsProperties[] = 300{ 301 ACPI_NS_NORMAL, /* 00 Any */ 302 ACPI_NS_NORMAL, /* 01 Number */ 303 ACPI_NS_NORMAL, /* 02 String */ 304 ACPI_NS_NORMAL, /* 03 Buffer */ 305 ACPI_NS_NORMAL, /* 04 Package */ 306 ACPI_NS_NORMAL, /* 05 FieldUnit */ 307 ACPI_NS_NEWSCOPE, /* 06 Device */ 308 ACPI_NS_NORMAL, /* 07 Event */ 309 ACPI_NS_NEWSCOPE, /* 08 Method */ 310 ACPI_NS_NORMAL, /* 09 Mutex */ 311 ACPI_NS_NORMAL, /* 10 Region */ 312 ACPI_NS_NEWSCOPE, /* 11 Power */ 313 ACPI_NS_NEWSCOPE, /* 12 Processor */ 314 ACPI_NS_NEWSCOPE, /* 13 Thermal */ 315 ACPI_NS_NORMAL, /* 14 BufferField */ 316 ACPI_NS_NORMAL, /* 15 DdbHandle */ 317 ACPI_NS_NORMAL, /* 16 Debug Object */ 318 ACPI_NS_NORMAL, /* 17 DefField */ 319 ACPI_NS_NORMAL, /* 18 BankField */ 320 ACPI_NS_NORMAL, /* 19 IndexField */ 321 ACPI_NS_NORMAL, /* 20 Reference */ 322 ACPI_NS_NORMAL, /* 21 Alias */ 323 ACPI_NS_NORMAL, /* 22 Notify */ 324 ACPI_NS_NORMAL, /* 23 Address Handler */ 325 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 24 Resource Desc */ 326 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Field */ 327 ACPI_NS_NORMAL, /* 26 DefFieldDefn */ 328 ACPI_NS_NORMAL, /* 27 BankFieldDefn */ 329 ACPI_NS_NORMAL, /* 28 IndexFieldDefn */ 330 ACPI_NS_NORMAL, /* 29 If */ 331 ACPI_NS_NORMAL, /* 30 Else */ 332 ACPI_NS_NORMAL, /* 31 While */ 333 ACPI_NS_NEWSCOPE, /* 32 Scope */ 334 ACPI_NS_LOCAL, /* 33 DefAny */ 335 ACPI_NS_NORMAL, /* 34 Extra */ 336 ACPI_NS_NORMAL, /* 35 Data */ 337 ACPI_NS_NORMAL /* 36 Invalid */ 338}; 339 340 341/* Hex to ASCII conversion table */ 342 343static const NATIVE_CHAR AcpiGbl_HexToAscii[] = 344 {'0','1','2','3','4','5','6','7', 345 '8','9','A','B','C','D','E','F'}; 346 347/***************************************************************************** 348 * 349 * FUNCTION: AcpiUtHexToAsciiChar 350 * 351 * PARAMETERS: Integer - Contains the hex digit 352 * Position - bit position of the digit within the 353 * integer 354 * 355 * RETURN: Ascii character 356 * 357 * DESCRIPTION: Convert a hex digit to an ascii character 358 * 359 ****************************************************************************/ 360 361char 362AcpiUtHexToAsciiChar ( 363 ACPI_INTEGER Integer, 364 UINT32 Position) 365{ 366 367 return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); 368} 369 370 371/****************************************************************************** 372 * 373 * Table name globals 374 * 375 * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes. 376 * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables 377 * that are not used by the subsystem are simply ignored. 378 * 379 * Do NOT add any table to this list that is not consumed directly by this 380 * subsystem. 381 * 382 ******************************************************************************/ 383 384 385ACPI_TABLE_DESC AcpiGbl_AcpiTables[NUM_ACPI_TABLES]; 386 387 388ACPI_TABLE_SUPPORT AcpiGbl_AcpiTableData[NUM_ACPI_TABLES] = 389{ 390 /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */ 391 392 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, 393 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void **) &AcpiGbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE}, 394 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void **) &AcpiGbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}, 395 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void **) &AcpiGbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE}, 396 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, 397 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, 398 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, 399}; 400 401 402/****************************************************************************** 403 * 404 * Event and Hardware globals 405 * 406 ******************************************************************************/ 407 408ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = 409{ 410 /* Name Parent Register Register Bit Position Register Bit Mask */ 411 412 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, 413 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, 414 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, 415 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, 416 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, 417 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, 418 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, 419 420 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, 421 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 422 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 423 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 424 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, 425 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, 426 427 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, 428 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, 429 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, 430 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 431 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 432 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, 433 434 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} 435}; 436 437 438ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = 439{ 440 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, 441 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 442 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 443 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 444 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, 0, 0}, 445}; 446 447/***************************************************************************** 448 * 449 * FUNCTION: AcpiUtGetRegionName 450 * 451 * PARAMETERS: None. 452 * 453 * RETURN: Status 454 * 455 * DESCRIPTION: Translate a Space ID into a name string (Debug only) 456 * 457 ****************************************************************************/ 458 459/* Region type decoding */ 460 461const NATIVE_CHAR *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = 462{ 463 "SystemMemory", 464 "SystemIO", 465 "PCI_Config", 466 "EmbeddedControl", 467 "SMBus", 468 "CMOS", 469 "PCIBARTarget", 470 "DataTable", 471}; 472 473 474NATIVE_CHAR * 475AcpiUtGetRegionName ( 476 UINT8 SpaceId) 477{ 478 479 if (SpaceId >= ACPI_USER_REGION_BEGIN) 480 { 481 return ("UserDefinedRegion"); 482 } 483 484 else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) 485 { 486 return ("InvalidSpaceID"); 487 } 488 489 return ((NATIVE_CHAR *) AcpiGbl_RegionTypes[SpaceId]); 490} 491 492 493/***************************************************************************** 494 * 495 * FUNCTION: AcpiUtGetEventName 496 * 497 * PARAMETERS: None. 498 * 499 * RETURN: Status 500 * 501 * DESCRIPTION: Translate a Event ID into a name string (Debug only) 502 * 503 ****************************************************************************/ 504 505/* Event type decoding */ 506 507static const NATIVE_CHAR *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = 508{ 509 "PM_Timer", 510 "GlobalLock", 511 "PowerButton", 512 "SleepButton", 513 "RealTimeClock", 514}; 515 516 517NATIVE_CHAR * 518AcpiUtGetEventName ( 519 UINT32 EventId) 520{ 521 522 if (EventId > ACPI_EVENT_MAX) 523 { 524 return ("InvalidEventID"); 525 } 526 527 return ((NATIVE_CHAR *) AcpiGbl_EventTypes[EventId]); 528} 529 530 531/***************************************************************************** 532 * 533 * FUNCTION: AcpiUtGetTypeName 534 * 535 * PARAMETERS: None. 536 * 537 * RETURN: Status 538 * 539 * DESCRIPTION: Translate a Type ID into a name string (Debug only) 540 * 541 ****************************************************************************/ 542 543/* 544 * Elements of AcpiGbl_NsTypeNames below must match 545 * one-to-one with values of ACPI_OBJECT_TYPE 546 * 547 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when 548 * stored in a table it really means that we have thus far seen no evidence to 549 * indicatewhat type is actually going to be stored for this entry. 550 */ 551 552static const NATIVE_CHAR AcpiGbl_BadType[] = "UNDEFINED"; 553#define TYPE_NAME_LENGTH 12 /* Maximum length of each string */ 554 555static const NATIVE_CHAR *AcpiGbl_NsTypeNames[] = /* printable names of ACPI types */ 556{ 557 /* 00 */ "Untyped", 558 /* 01 */ "Integer", 559 /* 02 */ "String", 560 /* 03 */ "Buffer", 561 /* 04 */ "Package", 562 /* 05 */ "FieldUnit", 563 /* 06 */ "Device", 564 /* 07 */ "Event", 565 /* 08 */ "Method", 566 /* 09 */ "Mutex", 567 /* 10 */ "Region", 568 /* 11 */ "Power", 569 /* 12 */ "Processor", 570 /* 13 */ "Thermal", 571 /* 14 */ "BufferField", 572 /* 15 */ "DdbHandle", 573 /* 16 */ "DebugObject", 574 /* 17 */ "RegionField", 575 /* 18 */ "BankField", 576 /* 19 */ "IndexField", 577 /* 20 */ "Reference", 578 /* 21 */ "Alias", 579 /* 22 */ "Notify", 580 /* 23 */ "AddrHandler", 581 /* 24 */ "ResourceDesc", 582 /* 25 */ "ResourceFld", 583 /* 26 */ "RegionFldDfn", 584 /* 27 */ "BankFldDfn", 585 /* 28 */ "IndexFldDfn", 586 /* 29 */ "If", 587 /* 30 */ "Else", 588 /* 31 */ "While", 589 /* 32 */ "Scope", 590 /* 33 */ "DefAny", 591 /* 34 */ "Extra", 592 /* 35 */ "Data", 593 /* 36 */ "Invalid" 594}; 595 596 597NATIVE_CHAR * 598AcpiUtGetTypeName ( 599 ACPI_OBJECT_TYPE Type) 600{ 601 602 if (Type > INTERNAL_TYPE_INVALID) 603 { 604 return ((NATIVE_CHAR *) AcpiGbl_BadType); 605 } 606 607 return ((NATIVE_CHAR *) AcpiGbl_NsTypeNames[Type]); 608} 609 610 611NATIVE_CHAR * 612AcpiUtGetObjectTypeName ( 613 ACPI_OPERAND_OBJECT *ObjDesc) 614{ 615 616 if (!ObjDesc) 617 { 618 return ("[NULL Object Descriptor]"); 619 } 620 621 return (AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc))); 622} 623 624 625#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 626 627/* 628 * Strings and procedures used for debug only 629 */ 630 631 632/***************************************************************************** 633 * 634 * FUNCTION: AcpiUtGetMutexName 635 * 636 * PARAMETERS: None. 637 * 638 * RETURN: Status 639 * 640 * DESCRIPTION: Translate a mutex ID into a name string (Debug only) 641 * 642 ****************************************************************************/ 643 644NATIVE_CHAR * 645AcpiUtGetMutexName ( 646 UINT32 MutexId) 647{ 648 649 if (MutexId > MAX_MTX) 650 { 651 return ("Invalid Mutex ID"); 652 } 653 654 return (AcpiGbl_MutexNames[MutexId]); 655} 656 657 658#endif 659 660 661/***************************************************************************** 662 * 663 * FUNCTION: AcpiUtValidObjectType 664 * 665 * PARAMETERS: None. 666 * 667 * RETURN: TRUE if valid object type 668 * 669 * DESCRIPTION: Validate an object type 670 * 671 ****************************************************************************/ 672 673BOOLEAN 674AcpiUtValidObjectType ( 675 ACPI_OBJECT_TYPE Type) 676{ 677 678 if (Type > ACPI_TYPE_MAX) 679 { 680 if ((Type < INTERNAL_TYPE_BEGIN) || 681 (Type > INTERNAL_TYPE_MAX)) 682 { 683 return (FALSE); 684 } 685 } 686 687 return (TRUE); 688} 689 690 691/**************************************************************************** 692 * 693 * FUNCTION: AcpiUtAllocateOwnerId 694 * 695 * PARAMETERS: IdType - Type of ID (method or table) 696 * 697 * DESCRIPTION: Allocate a table or method owner id 698 * 699 ***************************************************************************/ 700 701ACPI_OWNER_ID 702AcpiUtAllocateOwnerId ( 703 UINT32 IdType) 704{ 705 ACPI_OWNER_ID OwnerId = 0xFFFF; 706 707 708 ACPI_FUNCTION_TRACE ("UtAllocateOwnerId"); 709 710 711 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES))) 712 { 713 return (0); 714 } 715 716 switch (IdType) 717 { 718 case ACPI_OWNER_TYPE_TABLE: 719 720 OwnerId = AcpiGbl_NextTableOwnerId; 721 AcpiGbl_NextTableOwnerId++; 722 723 if (AcpiGbl_NextTableOwnerId == ACPI_FIRST_METHOD_ID) 724 { 725 AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID; 726 } 727 break; 728 729 730 case ACPI_OWNER_TYPE_METHOD: 731 732 OwnerId = AcpiGbl_NextMethodOwnerId; 733 AcpiGbl_NextMethodOwnerId++; 734 735 if (AcpiGbl_NextMethodOwnerId == ACPI_FIRST_TABLE_ID) 736 { 737 AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID; 738 } 739 break; 740 741 default: 742 break; 743 } 744 745 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); 746 return_VALUE (OwnerId); 747} 748 749 750/**************************************************************************** 751 * 752 * FUNCTION: AcpiUtInitGlobals 753 * 754 * PARAMETERS: none 755 * 756 * DESCRIPTION: Init library globals. All globals that require specific 757 * initialization should be initialized here! 758 * 759 ***************************************************************************/ 760 761void 762AcpiUtInitGlobals ( 763 void) 764{ 765 UINT32 i; 766 767 768 ACPI_FUNCTION_TRACE ("UtInitGlobals"); 769 770 /* Memory allocation and cache lists */ 771 772 ACPI_MEMSET (AcpiGbl_MemoryLists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS); 773 774 AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_GENERIC_STATE *) NULL)->Common.Next), NULL); 775 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL); 776 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL); 777 AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_OPERAND_OBJECT *) NULL)->Cache.Next), NULL); 778 AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_WALK_STATE *) NULL)->Next), NULL); 779 780 AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ObjectSize = sizeof (ACPI_NAMESPACE_NODE); 781 AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ObjectSize = sizeof (ACPI_GENERIC_STATE); 782 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ObjectSize = sizeof (ACPI_PARSE_OBJ_COMMON); 783 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ObjectSize = sizeof (ACPI_PARSE_OBJ_NAMED); 784 AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ObjectSize = sizeof (ACPI_OPERAND_OBJECT); 785 AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ObjectSize = sizeof (ACPI_WALK_STATE); 786 787 AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].MaxCacheDepth = MAX_STATE_CACHE_DEPTH; 788 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].MaxCacheDepth = MAX_PARSE_CACHE_DEPTH; 789 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].MaxCacheDepth = MAX_EXTPARSE_CACHE_DEPTH; 790 AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].MaxCacheDepth = MAX_OBJECT_CACHE_DEPTH; 791 AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].MaxCacheDepth = MAX_WALK_CACHE_DEPTH; 792 793 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].ListName = "Global Memory Allocation"); 794 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ListName = "Namespace Nodes"); 795 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ListName = "State Object Cache"); 796 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ListName = "Parse Node Cache"); 797 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ListName = "Extended Parse Node Cache"); 798 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ListName = "Operand Object Cache"); 799 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ListName = "Tree Walk Node Cache"); 800 801 /* ACPI table structure */ 802 803 for (i = 0; i < NUM_ACPI_TABLES; i++) 804 { 805 AcpiGbl_AcpiTables[i].Prev = &AcpiGbl_AcpiTables[i]; 806 AcpiGbl_AcpiTables[i].Next = &AcpiGbl_AcpiTables[i]; 807 AcpiGbl_AcpiTables[i].Pointer = NULL; 808 AcpiGbl_AcpiTables[i].Length = 0; 809 AcpiGbl_AcpiTables[i].Allocation = ACPI_MEM_NOT_ALLOCATED; 810 AcpiGbl_AcpiTables[i].Count = 0; 811 } 812 813 /* Mutex locked flags */ 814 815 for (i = 0; i < NUM_MTX; i++) 816 { 817 AcpiGbl_AcpiMutexInfo[i].Mutex = NULL; 818 AcpiGbl_AcpiMutexInfo[i].OwnerId = ACPI_MUTEX_NOT_ACQUIRED; 819 AcpiGbl_AcpiMutexInfo[i].UseCount = 0; 820 } 821 822 /* Global notify handlers */ 823 824 AcpiGbl_SysNotify.Handler = NULL; 825 AcpiGbl_DrvNotify.Handler = NULL; 826 AcpiGbl_InitHandler = NULL; 827 828 /* Global "typed" ACPI table pointers */ 829 830 AcpiGbl_RSDP = NULL; 831 AcpiGbl_XSDT = NULL; 832 AcpiGbl_FACS = NULL; 833 AcpiGbl_FADT = NULL; 834 AcpiGbl_DSDT = NULL; 835 836 /* Global Lock support */ 837 838 AcpiGbl_GlobalLockAcquired = FALSE; 839 AcpiGbl_GlobalLockThreadCount = 0; 840 AcpiGbl_GlobalLockHandle = 0; 841 842 /* Miscellaneous variables */ 843 844 AcpiGbl_TableFlags = ACPI_PHYSICAL_POINTER; 845 AcpiGbl_RsdpOriginalLocation = 0; 846 AcpiGbl_CmSingleStep = FALSE; 847 AcpiGbl_DbTerminateThreads = FALSE; 848 AcpiGbl_Shutdown = FALSE; 849 AcpiGbl_NsLookupCount = 0; 850 AcpiGbl_PsFindCount = 0; 851 AcpiGbl_AcpiHardwarePresent = TRUE; 852 AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID; 853 AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID; 854 AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; 855 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; 856 857 /* Hardware oriented */ 858 859 AcpiGbl_GpeRegisterInfo = NULL; 860 AcpiGbl_GpeNumberInfo = NULL; 861 AcpiGbl_EventsInitialized = FALSE; 862 863 /* Namespace */ 864 865 AcpiGbl_RootNode = NULL; 866 867 AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; 868 AcpiGbl_RootNodeStruct.Descriptor = ACPI_DESC_TYPE_NAMED; 869 AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_ANY; 870 AcpiGbl_RootNodeStruct.Child = NULL; 871 AcpiGbl_RootNodeStruct.Peer = NULL; 872 AcpiGbl_RootNodeStruct.Object = NULL; 873 AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; 874 875 876#ifdef ACPI_DEBUG_OUTPUT 877 AcpiGbl_LowestStackPointer = ACPI_SIZE_MAX; 878#endif 879 880 return_VOID; 881} 882 883 884