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