utglobal.c revision 151937
1/****************************************************************************** 2 * 3 * Module Name: utglobal - Global variables for the ACPI subsystem 4 * $Revision: 1.216 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2005, 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 <contrib/dev/acpica/acpi.h> 121#include <contrib/dev/acpica/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. A valid pointer is 134 * always returned. 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 ACPI_STATUS SubStatus; 145 const char *Exception = NULL; 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 } 161 break; 162 163 case AE_CODE_PROGRAMMER: 164 165 if (SubStatus <= AE_CODE_PGM_MAX) 166 { 167 Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1]; 168 } 169 break; 170 171 case AE_CODE_ACPI_TABLES: 172 173 if (SubStatus <= AE_CODE_TBL_MAX) 174 { 175 Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1]; 176 } 177 break; 178 179 case AE_CODE_AML: 180 181 if (SubStatus <= AE_CODE_AML_MAX) 182 { 183 Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1]; 184 } 185 break; 186 187 case AE_CODE_CONTROL: 188 189 if (SubStatus <= AE_CODE_CTRL_MAX) 190 { 191 Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1]; 192 } 193 break; 194 195 default: 196 break; 197 } 198 199 if (!Exception) 200 { 201 /* Exception code was not recognized */ 202 203 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 204 "Unknown exception code: 0x%8.8X\n", Status)); 205 206 return ((const char *) "UNKNOWN_STATUS_CODE"); 207 } 208 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 = ACPI_DEBUG_DEFAULT; 228#else 229UINT32 AcpiDbgLevel = ACPI_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_AbortMethod = 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 char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] = 255{ 256 "\\_S0_", 257 "\\_S1_", 258 "\\_S2_", 259 "\\_S3_", 260 "\\_S4_", 261 "\\_S5_" 262}; 263 264const char *AcpiGbl_HighestDstateNames[4] = 265{ 266 "_S1D", 267 "_S2D", 268 "_S3D", 269 "_S4D" 270}; 271 272/* 273 * Strings supported by the _OSI predefined (internal) method. 274 * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS. 275 */ 276const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] = 277{ 278 /* Operating System Vendor Strings */ 279 280 "Linux", 281 "Windows 2000", 282 "Windows 2001", 283 "Windows 2001.1", 284 "Windows 2001 SP0", 285 "Windows 2001 SP1", 286 "Windows 2001 SP2", 287 "Windows 2001 SP3", 288 "Windows 2001 SP4", 289 290 /* Feature Group Strings */ 291 292 "Extended Address Space Descriptor" 293}; 294 295 296/******************************************************************************* 297 * 298 * Namespace globals 299 * 300 ******************************************************************************/ 301 302/* 303 * Predefined ACPI Names (Built-in to the Interpreter) 304 * 305 * NOTES: 306 * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run 307 * during the initialization sequence. 308 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to 309 * perform a Notify() operation on it. 310 */ 311const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] = 312{ 313 {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL}, 314 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 315 {"_SB_", ACPI_TYPE_DEVICE, NULL}, 316 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL}, 317 {"_TZ_", ACPI_TYPE_THERMAL, NULL}, 318 {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL}, 319 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME}, 320 {"_GL_", ACPI_TYPE_MUTEX, (char *) 1}, 321 322#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY) 323 {"_OSI", ACPI_TYPE_METHOD, (char *) 1}, 324#endif 325 326 /* Table terminator */ 327 328 {NULL, ACPI_TYPE_ANY, NULL} 329}; 330 331/* 332 * Properties of the ACPI Object Types, both internal and external. 333 * The table is indexed by values of ACPI_OBJECT_TYPE 334 */ 335const UINT8 AcpiGbl_NsProperties[] = 336{ 337 ACPI_NS_NORMAL, /* 00 Any */ 338 ACPI_NS_NORMAL, /* 01 Number */ 339 ACPI_NS_NORMAL, /* 02 String */ 340 ACPI_NS_NORMAL, /* 03 Buffer */ 341 ACPI_NS_NORMAL, /* 04 Package */ 342 ACPI_NS_NORMAL, /* 05 FieldUnit */ 343 ACPI_NS_NEWSCOPE, /* 06 Device */ 344 ACPI_NS_NORMAL, /* 07 Event */ 345 ACPI_NS_NEWSCOPE, /* 08 Method */ 346 ACPI_NS_NORMAL, /* 09 Mutex */ 347 ACPI_NS_NORMAL, /* 10 Region */ 348 ACPI_NS_NEWSCOPE, /* 11 Power */ 349 ACPI_NS_NEWSCOPE, /* 12 Processor */ 350 ACPI_NS_NEWSCOPE, /* 13 Thermal */ 351 ACPI_NS_NORMAL, /* 14 BufferField */ 352 ACPI_NS_NORMAL, /* 15 DdbHandle */ 353 ACPI_NS_NORMAL, /* 16 Debug Object */ 354 ACPI_NS_NORMAL, /* 17 DefField */ 355 ACPI_NS_NORMAL, /* 18 BankField */ 356 ACPI_NS_NORMAL, /* 19 IndexField */ 357 ACPI_NS_NORMAL, /* 20 Reference */ 358 ACPI_NS_NORMAL, /* 21 Alias */ 359 ACPI_NS_NORMAL, /* 22 MethodAlias */ 360 ACPI_NS_NORMAL, /* 23 Notify */ 361 ACPI_NS_NORMAL, /* 24 Address Handler */ 362 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ 363 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ 364 ACPI_NS_NEWSCOPE, /* 27 Scope */ 365 ACPI_NS_NORMAL, /* 28 Extra */ 366 ACPI_NS_NORMAL, /* 29 Data */ 367 ACPI_NS_NORMAL /* 30 Invalid */ 368}; 369 370 371/* Hex to ASCII conversion table */ 372 373static const char AcpiGbl_HexToAscii[] = 374{ 375 '0','1','2','3','4','5','6','7', 376 '8','9','A','B','C','D','E','F' 377}; 378 379 380/******************************************************************************* 381 * 382 * FUNCTION: AcpiUtHexToAsciiChar 383 * 384 * PARAMETERS: Integer - Contains the hex digit 385 * Position - bit position of the digit within the 386 * integer (multiple of 4) 387 * 388 * RETURN: The converted Ascii character 389 * 390 * DESCRIPTION: Convert a hex digit to an Ascii character 391 * 392 ******************************************************************************/ 393 394char 395AcpiUtHexToAsciiChar ( 396 ACPI_INTEGER Integer, 397 UINT32 Position) 398{ 399 400 return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); 401} 402 403 404/******************************************************************************* 405 * 406 * Table name globals 407 * 408 * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes. 409 * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables 410 * that are not used by the subsystem are simply ignored. 411 * 412 * Do NOT add any table to this list that is not consumed directly by this 413 * subsystem (No MADT, ECDT, SBST, etc.) 414 * 415 ******************************************************************************/ 416 417ACPI_TABLE_LIST AcpiGbl_TableLists[NUM_ACPI_TABLE_TYPES]; 418 419ACPI_TABLE_SUPPORT AcpiGbl_TableData[NUM_ACPI_TABLE_TYPES] = 420{ 421 /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */ 422 423 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, 424 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *) &AcpiGbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE}, 425 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *) &AcpiGbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}, 426 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *) &AcpiGbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE}, 427 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, 428 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE}, 429 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}, 430}; 431 432 433/****************************************************************************** 434 * 435 * Event and Hardware globals 436 * 437 ******************************************************************************/ 438 439ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] = 440{ 441 /* Name Parent Register Register Bit Position Register Bit Mask */ 442 443 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS}, 444 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS}, 445 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS}, 446 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS}, 447 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS}, 448 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS}, 449 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS}, 450 /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS}, 451 452 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE}, 453 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 454 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 455 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 456 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE}, 457 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0}, 458 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE}, 459 460 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE}, 461 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD}, 462 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE}, 463 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 464 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X}, 465 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE}, 466 467 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE} 468}; 469 470 471ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] = 472{ 473 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE}, 474 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE}, 475 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE}, 476 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE}, 477 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE}, 478}; 479 480/******************************************************************************* 481 * 482 * FUNCTION: AcpiUtGetRegionName 483 * 484 * PARAMETERS: None. 485 * 486 * RETURN: Status 487 * 488 * DESCRIPTION: Translate a Space ID into a name string (Debug only) 489 * 490 ******************************************************************************/ 491 492/* Region type decoding */ 493 494const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = 495{ 496/*! [Begin] no source code translation (keep these ASL Keywords as-is) */ 497 "SystemMemory", 498 "SystemIO", 499 "PCI_Config", 500 "EmbeddedControl", 501 "SMBus", 502 "CMOS", 503 "PCIBARTarget", 504 "DataTable" 505/*! [End] no source code translation !*/ 506}; 507 508 509char * 510AcpiUtGetRegionName ( 511 UINT8 SpaceId) 512{ 513 514 if (SpaceId >= ACPI_USER_REGION_BEGIN) 515 { 516 return ("UserDefinedRegion"); 517 } 518 else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) 519 { 520 return ("InvalidSpaceId"); 521 } 522 523 return ((char *) AcpiGbl_RegionTypes[SpaceId]); 524} 525 526 527/******************************************************************************* 528 * 529 * FUNCTION: AcpiUtGetEventName 530 * 531 * PARAMETERS: None. 532 * 533 * RETURN: Status 534 * 535 * DESCRIPTION: Translate a Event ID into a name string (Debug only) 536 * 537 ******************************************************************************/ 538 539/* Event type decoding */ 540 541static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = 542{ 543/*! [Begin] no source code translation (keep these strings as-is) */ 544 "PM_Timer", 545 "GlobalLock", 546 "PowerButton", 547 "SleepButton", 548 "RealTimeClock", 549/*! [End] no source code translation !*/ 550}; 551 552 553char * 554AcpiUtGetEventName ( 555 UINT32 EventId) 556{ 557 558 if (EventId > ACPI_EVENT_MAX) 559 { 560 return ("InvalidEventID"); 561 } 562 563 return ((char *) AcpiGbl_EventTypes[EventId]); 564} 565 566 567/******************************************************************************* 568 * 569 * FUNCTION: AcpiUtGetTypeName 570 * 571 * PARAMETERS: None. 572 * 573 * RETURN: Status 574 * 575 * DESCRIPTION: Translate a Type ID into a name string (Debug only) 576 * 577 ******************************************************************************/ 578 579/* 580 * Elements of AcpiGbl_NsTypeNames below must match 581 * one-to-one with values of ACPI_OBJECT_TYPE 582 * 583 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; 584 * when stored in a table it really means that we have thus far seen no 585 * evidence to indicate what type is actually going to be stored for this entry. 586 */ 587static const char AcpiGbl_BadType[] = "UNDEFINED"; 588 589/* Printable names of the ACPI object types */ 590 591static const char *AcpiGbl_NsTypeNames[] = 592{ 593/*! [Begin] no source code translation (keep these strings as-is) */ 594 /* 00 */ "Untyped", 595 /* 01 */ "Integer", 596 /* 02 */ "String", 597 /* 03 */ "Buffer", 598 /* 04 */ "Package", 599 /* 05 */ "FieldUnit", 600 /* 06 */ "Device", 601 /* 07 */ "Event", 602 /* 08 */ "Method", 603 /* 09 */ "Mutex", 604 /* 10 */ "Region", 605 /* 11 */ "Power", 606 /* 12 */ "Processor", 607 /* 13 */ "Thermal", 608 /* 14 */ "BufferField", 609 /* 15 */ "DdbHandle", 610 /* 16 */ "DebugObject", 611 /* 17 */ "RegionField", 612 /* 18 */ "BankField", 613 /* 19 */ "IndexField", 614 /* 20 */ "Reference", 615 /* 21 */ "Alias", 616 /* 22 */ "MethodAlias", 617 /* 23 */ "Notify", 618 /* 24 */ "AddrHandler", 619 /* 25 */ "ResourceDesc", 620 /* 26 */ "ResourceFld", 621 /* 27 */ "Scope", 622 /* 28 */ "Extra", 623 /* 29 */ "Data", 624 /* 30 */ "Invalid" 625/*! [End] no source code translation !*/ 626}; 627 628 629char * 630AcpiUtGetTypeName ( 631 ACPI_OBJECT_TYPE Type) 632{ 633 634 if (Type > ACPI_TYPE_INVALID) 635 { 636 return ((char *) AcpiGbl_BadType); 637 } 638 639 return ((char *) AcpiGbl_NsTypeNames[Type]); 640} 641 642 643char * 644AcpiUtGetObjectTypeName ( 645 ACPI_OPERAND_OBJECT *ObjDesc) 646{ 647 648 if (!ObjDesc) 649 { 650 return ("[NULL Object Descriptor]"); 651 } 652 653 return (AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc))); 654} 655 656 657/******************************************************************************* 658 * 659 * FUNCTION: AcpiUtGetNodeName 660 * 661 * PARAMETERS: Object - A namespace node 662 * 663 * RETURN: Pointer to a string 664 * 665 * DESCRIPTION: Validate the node and return the node's ACPI name. 666 * 667 ******************************************************************************/ 668 669char * 670AcpiUtGetNodeName ( 671 void *Object) 672{ 673 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object; 674 675 676 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ 677 678 if (!Object) 679 { 680 return ("NULL"); 681 } 682 683 /* Check for Root node */ 684 685 if ((Object == ACPI_ROOT_OBJECT) || 686 (Object == AcpiGbl_RootNode)) 687 { 688 return ("\"\\\" "); 689 } 690 691 /* Descriptor must be a namespace node */ 692 693 if (Node->Descriptor != ACPI_DESC_TYPE_NAMED) 694 { 695 return ("####"); 696 } 697 698 /* Name must be a valid ACPI name */ 699 700 if (!AcpiUtValidAcpiName (* (UINT32 *) Node->Name.Ascii)) 701 { 702 return ("????"); 703 } 704 705 /* Return the name */ 706 707 return (Node->Name.Ascii); 708} 709 710 711/******************************************************************************* 712 * 713 * FUNCTION: AcpiUtGetDescriptorName 714 * 715 * PARAMETERS: Object - An ACPI object 716 * 717 * RETURN: Pointer to a string 718 * 719 * DESCRIPTION: Validate object and return the descriptor type 720 * 721 ******************************************************************************/ 722 723/* Printable names of object descriptor types */ 724 725static const char *AcpiGbl_DescTypeNames[] = 726{ 727/*! [Begin] no source code translation (keep these ASL Keywords as-is) */ 728 /* 00 */ "Invalid", 729 /* 01 */ "Cached", 730 /* 02 */ "State-Generic", 731 /* 03 */ "State-Update", 732 /* 04 */ "State-Package", 733 /* 05 */ "State-Control", 734 /* 06 */ "State-RootParseScope", 735 /* 07 */ "State-ParseScope", 736 /* 08 */ "State-WalkScope", 737 /* 09 */ "State-Result", 738 /* 10 */ "State-Notify", 739 /* 11 */ "State-Thread", 740 /* 12 */ "Walk", 741 /* 13 */ "Parser", 742 /* 14 */ "Operand", 743 /* 15 */ "Node" 744/*! [End] no source code translation !*/ 745}; 746 747 748char * 749AcpiUtGetDescriptorName ( 750 void *Object) 751{ 752 753 if (!Object) 754 { 755 return ("NULL OBJECT"); 756 } 757 758 if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX) 759 { 760 return ((char *) AcpiGbl_BadType); 761 } 762 763 return ((char *) AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]); 764 765} 766 767 768#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 769/* 770 * Strings and procedures used for debug only 771 */ 772 773/******************************************************************************* 774 * 775 * FUNCTION: AcpiUtGetMutexName 776 * 777 * PARAMETERS: MutexId - The predefined ID for this mutex. 778 * 779 * RETURN: String containing the name of the mutex. Always returns a valid 780 * pointer. 781 * 782 * DESCRIPTION: Translate a mutex ID into a name string (Debug only) 783 * 784 ******************************************************************************/ 785 786char * 787AcpiUtGetMutexName ( 788 UINT32 MutexId) 789{ 790 791 if (MutexId > MAX_MUTEX) 792 { 793 return ("Invalid Mutex ID"); 794 } 795 796 return (AcpiGbl_MutexNames[MutexId]); 797} 798#endif 799 800 801/******************************************************************************* 802 * 803 * FUNCTION: AcpiUtValidObjectType 804 * 805 * PARAMETERS: Type - Object type to be validated 806 * 807 * RETURN: TRUE if valid object type, FALSE otherwise 808 * 809 * DESCRIPTION: Validate an object type 810 * 811 ******************************************************************************/ 812 813BOOLEAN 814AcpiUtValidObjectType ( 815 ACPI_OBJECT_TYPE Type) 816{ 817 818 if (Type > ACPI_TYPE_LOCAL_MAX) 819 { 820 /* Note: Assumes all TYPEs are contiguous (external/local) */ 821 822 return (FALSE); 823 } 824 825 return (TRUE); 826} 827 828 829/******************************************************************************* 830 * 831 * FUNCTION: AcpiUtInitGlobals 832 * 833 * PARAMETERS: None 834 * 835 * RETURN: None 836 * 837 * DESCRIPTION: Init library globals. All globals that require specific 838 * initialization should be initialized here! 839 * 840 ******************************************************************************/ 841 842void 843AcpiUtInitGlobals ( 844 void) 845{ 846 ACPI_STATUS Status; 847 UINT32 i; 848 849 850 ACPI_FUNCTION_TRACE ("UtInitGlobals"); 851 852 853 /* Create all memory caches */ 854 855 Status = AcpiUtCreateCaches (); 856 if (ACPI_FAILURE (Status)) 857 { 858 return; 859 } 860 861 /* ACPI table structure */ 862 863 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) 864 { 865 AcpiGbl_TableLists[i].Next = NULL; 866 AcpiGbl_TableLists[i].Count = 0; 867 } 868 869 /* Mutex locked flags */ 870 871 for (i = 0; i < NUM_MUTEX; i++) 872 { 873 AcpiGbl_MutexInfo[i].Mutex = NULL; 874 AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED; 875 AcpiGbl_MutexInfo[i].UseCount = 0; 876 } 877 878 /* GPE support */ 879 880 AcpiGbl_GpeXruptListHead = NULL; 881 AcpiGbl_GpeFadtBlocks[0] = NULL; 882 AcpiGbl_GpeFadtBlocks[1] = NULL; 883 884 /* Global notify handlers */ 885 886 AcpiGbl_SystemNotify.Handler = NULL; 887 AcpiGbl_DeviceNotify.Handler = NULL; 888 AcpiGbl_ExceptionHandler = NULL; 889 AcpiGbl_InitHandler = NULL; 890 891 /* Global "typed" ACPI table pointers */ 892 893 AcpiGbl_RSDP = NULL; 894 AcpiGbl_XSDT = NULL; 895 AcpiGbl_FACS = NULL; 896 AcpiGbl_FADT = NULL; 897 AcpiGbl_DSDT = NULL; 898 899 /* Global Lock support */ 900 901 AcpiGbl_GlobalLockAcquired = FALSE; 902 AcpiGbl_GlobalLockThreadCount = 0; 903 AcpiGbl_GlobalLockHandle = 0; 904 905 /* Miscellaneous variables */ 906 907 AcpiGbl_TableFlags = ACPI_PHYSICAL_POINTER; 908 AcpiGbl_RsdpOriginalLocation = 0; 909 AcpiGbl_CmSingleStep = FALSE; 910 AcpiGbl_DbTerminateThreads = FALSE; 911 AcpiGbl_Shutdown = FALSE; 912 AcpiGbl_NsLookupCount = 0; 913 AcpiGbl_PsFindCount = 0; 914 AcpiGbl_AcpiHardwarePresent = TRUE; 915 AcpiGbl_OwnerIdMask = 0; 916 AcpiGbl_TraceMethodName = 0; 917 AcpiGbl_TraceDbgLevel = 0; 918 AcpiGbl_TraceDbgLayer = 0; 919 AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING; 920 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT; 921 922 /* Hardware oriented */ 923 924 AcpiGbl_EventsInitialized = FALSE; 925 AcpiGbl_SystemAwakeAndRunning = TRUE; 926 927 /* Namespace */ 928 929 AcpiGbl_RootNode = NULL; 930 931 AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME; 932 AcpiGbl_RootNodeStruct.Descriptor = ACPI_DESC_TYPE_NAMED; 933 AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE; 934 AcpiGbl_RootNodeStruct.Child = NULL; 935 AcpiGbl_RootNodeStruct.Peer = NULL; 936 AcpiGbl_RootNodeStruct.Object = NULL; 937 AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST; 938 939 940#ifdef ACPI_DEBUG_OUTPUT 941 AcpiGbl_LowestStackPointer = ACPI_SIZE_MAX; 942#endif 943 944 return_VOID; 945} 946 947 948