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