Import acpica-20050211 from Intel.
[dragonfly.git] / sys / contrib / dev / acpica-unix-20050211 / utilities / utglobal.c
bloba97bb40b535ad8fd9431f98ecf76800a653edc15
1 /******************************************************************************
3 * Module Name: utglobal - Global variables for the ACPI subsystem
4 * $Revision: 206 $
6 *****************************************************************************/
8 /******************************************************************************
10 * 1. Copyright Notice
12 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13 * All rights reserved.
15 * 2. License
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.
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
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;
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
41 * 3. Conditions
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.
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.
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.
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
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.
81 * 4. Disclaimer and Export Compliance
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.
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.
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.
115 *****************************************************************************/
117 #define __UTGLOBAL_C__
118 #define DEFINE_ACPI_GLOBALS
120 #include "acpi.h"
121 #include "acnamesp.h"
123 #define _COMPONENT ACPI_UTILITIES
124 ACPI_MODULE_NAME ("utglobal")
127 /******************************************************************************
129 * FUNCTION: AcpiFormatException
131 * PARAMETERS: Status - The ACPI_STATUS code to be formatted
133 * RETURN: A string containing the exception text
135 * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
137 ******************************************************************************/
139 const char *
140 AcpiFormatException (
141 ACPI_STATUS Status)
143 const char *Exception = "UNKNOWN_STATUS_CODE";
144 ACPI_STATUS SubStatus;
147 ACPI_FUNCTION_NAME ("FormatException");
150 SubStatus = (Status & ~AE_CODE_MASK);
152 switch (Status & AE_CODE_MASK)
154 case AE_CODE_ENVIRONMENTAL:
156 if (SubStatus <= AE_CODE_ENV_MAX)
158 Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
159 break;
161 goto Unknown;
163 case AE_CODE_PROGRAMMER:
165 if (SubStatus <= AE_CODE_PGM_MAX)
167 Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1];
168 break;
170 goto Unknown;
172 case AE_CODE_ACPI_TABLES:
174 if (SubStatus <= AE_CODE_TBL_MAX)
176 Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1];
177 break;
179 goto Unknown;
181 case AE_CODE_AML:
183 if (SubStatus <= AE_CODE_AML_MAX)
185 Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1];
186 break;
188 goto Unknown;
190 case AE_CODE_CONTROL:
192 if (SubStatus <= AE_CODE_CTRL_MAX)
194 Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1];
195 break;
197 goto Unknown;
199 default:
200 goto Unknown;
204 return ((const char *) Exception);
206 Unknown:
208 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", Status));
209 return ((const char *) Exception);
213 /******************************************************************************
215 * Static global variable initialization.
217 ******************************************************************************/
220 * We want the debug switches statically initialized so they
221 * are already set when the debugger is entered.
224 /* Debug switch - level and trace mask */
226 #ifdef ACPI_DEBUG_OUTPUT
227 UINT32 AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
228 #else
229 UINT32 AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
230 #endif
232 /* Debug switch - layer (component) mask */
234 UINT32 AcpiDbgLayer = ACPI_COMPONENT_DEFAULT;
235 UINT32 AcpiGbl_NestingLevel = 0;
238 /* Debugger globals */
240 BOOLEAN AcpiGbl_DbTerminateThreads = FALSE;
241 BOOLEAN AcpiGbl_AbortMethod = FALSE;
242 BOOLEAN AcpiGbl_MethodExecuting = FALSE;
244 /* System flags */
246 UINT32 AcpiGbl_StartupFlags = 0;
248 /* System starts uninitialized */
250 BOOLEAN AcpiGbl_Shutdown = TRUE;
252 const UINT8 AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128};
254 const char *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] =
256 "\\_S0_",
257 "\\_S1_",
258 "\\_S2_",
259 "\\_S3_",
260 "\\_S4_",
261 "\\_S5_"
264 const char *AcpiGbl_HighestDstateNames[4] =
266 "_S1D",
267 "_S2D",
268 "_S3D",
269 "_S4D"
273 * Strings supported by the _OSI predefined (internal) method.
274 * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS.
276 const char *AcpiGbl_ValidOsiStrings[ACPI_NUM_OSI_STRINGS] =
278 "Linux",
279 "Windows 2000",
280 "Windows 2001",
281 "Windows 2001.1",
282 "Windows 2001 SP0",
283 "Windows 2001 SP1",
284 "Windows 2001 SP2",
285 "Windows 2001 SP3",
286 "Windows 2001 SP4"
290 /******************************************************************************
292 * Namespace globals
294 ******************************************************************************/
298 * Predefined ACPI Names (Built-in to the Interpreter)
300 * NOTES:
301 * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
302 * during the initialization sequence.
303 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
304 * perform a Notify() operation on it.
306 const ACPI_PREDEFINED_NAMES AcpiGbl_PreDefinedNames[] =
308 {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
309 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
310 {"_SB_", ACPI_TYPE_DEVICE, NULL},
311 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
312 {"_TZ_", ACPI_TYPE_THERMAL, NULL},
313 {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL},
314 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
315 {"_GL_", ACPI_TYPE_MUTEX, (char *) 1},
317 #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
318 {"_OSI", ACPI_TYPE_METHOD, (char *) 1},
319 #endif
320 {NULL, ACPI_TYPE_ANY, NULL} /* Table terminator */
325 * Properties of the ACPI Object Types, both internal and external.
326 * The table is indexed by values of ACPI_OBJECT_TYPE
328 const UINT8 AcpiGbl_NsProperties[] =
330 ACPI_NS_NORMAL, /* 00 Any */
331 ACPI_NS_NORMAL, /* 01 Number */
332 ACPI_NS_NORMAL, /* 02 String */
333 ACPI_NS_NORMAL, /* 03 Buffer */
334 ACPI_NS_NORMAL, /* 04 Package */
335 ACPI_NS_NORMAL, /* 05 FieldUnit */
336 ACPI_NS_NEWSCOPE, /* 06 Device */
337 ACPI_NS_NORMAL, /* 07 Event */
338 ACPI_NS_NEWSCOPE, /* 08 Method */
339 ACPI_NS_NORMAL, /* 09 Mutex */
340 ACPI_NS_NORMAL, /* 10 Region */
341 ACPI_NS_NEWSCOPE, /* 11 Power */
342 ACPI_NS_NEWSCOPE, /* 12 Processor */
343 ACPI_NS_NEWSCOPE, /* 13 Thermal */
344 ACPI_NS_NORMAL, /* 14 BufferField */
345 ACPI_NS_NORMAL, /* 15 DdbHandle */
346 ACPI_NS_NORMAL, /* 16 Debug Object */
347 ACPI_NS_NORMAL, /* 17 DefField */
348 ACPI_NS_NORMAL, /* 18 BankField */
349 ACPI_NS_NORMAL, /* 19 IndexField */
350 ACPI_NS_NORMAL, /* 20 Reference */
351 ACPI_NS_NORMAL, /* 21 Alias */
352 ACPI_NS_NORMAL, /* 22 MethodAlias */
353 ACPI_NS_NORMAL, /* 23 Notify */
354 ACPI_NS_NORMAL, /* 24 Address Handler */
355 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
356 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
357 ACPI_NS_NEWSCOPE, /* 27 Scope */
358 ACPI_NS_NORMAL, /* 28 Extra */
359 ACPI_NS_NORMAL, /* 29 Data */
360 ACPI_NS_NORMAL /* 30 Invalid */
364 /* Hex to ASCII conversion table */
366 static const char AcpiGbl_HexToAscii[] =
367 {'0','1','2','3','4','5','6','7',
368 '8','9','A','B','C','D','E','F'};
370 /*****************************************************************************
372 * FUNCTION: AcpiUtHexToAsciiChar
374 * PARAMETERS: Integer - Contains the hex digit
375 * Position - bit position of the digit within the
376 * integer
378 * RETURN: Ascii character
380 * DESCRIPTION: Convert a hex digit to an ascii character
382 ****************************************************************************/
384 char
385 AcpiUtHexToAsciiChar (
386 ACPI_INTEGER Integer,
387 UINT32 Position)
390 return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
394 /******************************************************************************
396 * Table name globals
398 * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
399 * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables
400 * that are not used by the subsystem are simply ignored.
402 * Do NOT add any table to this list that is not consumed directly by this
403 * subsystem.
405 ******************************************************************************/
407 ACPI_TABLE_LIST AcpiGbl_TableLists[NUM_ACPI_TABLE_TYPES];
409 ACPI_TABLE_SUPPORT AcpiGbl_TableData[NUM_ACPI_TABLE_TYPES] =
411 /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */
413 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE},
414 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *) &AcpiGbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE},
415 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *) &AcpiGbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE},
416 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *) &AcpiGbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE},
417 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
418 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
419 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE},
423 /******************************************************************************
425 * Event and Hardware globals
427 ******************************************************************************/
429 ACPI_BIT_REGISTER_INFO AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] =
431 /* Name Parent Register Register Bit Position Register Bit Mask */
433 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS},
434 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS},
435 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS},
436 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS},
437 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS},
438 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS},
439 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS},
441 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE},
442 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
443 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE},
444 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
445 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE},
446 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
448 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE},
449 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD},
450 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
451 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X},
452 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X},
453 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE},
455 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE}
459 ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] =
461 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE},
462 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
463 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE},
464 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
465 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE},
468 /*****************************************************************************
470 * FUNCTION: AcpiUtGetRegionName
472 * PARAMETERS: None.
474 * RETURN: Status
476 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
478 ****************************************************************************/
480 /* Region type decoding */
482 const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
484 /*! [Begin] no source code translation (keep these ASL Keywords as-is) */
485 "SystemMemory",
486 "SystemIO",
487 "PCI_Config",
488 "EmbeddedControl",
489 "SMBus",
490 "CMOS",
491 "PCIBARTarget",
492 "DataTable"
493 /*! [End] no source code translation !*/
497 char *
498 AcpiUtGetRegionName (
499 UINT8 SpaceId)
502 if (SpaceId >= ACPI_USER_REGION_BEGIN)
504 return ("UserDefinedRegion");
507 else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
509 return ("InvalidSpaceId");
512 return ((char *) AcpiGbl_RegionTypes[SpaceId]);
516 /*****************************************************************************
518 * FUNCTION: AcpiUtGetEventName
520 * PARAMETERS: None.
522 * RETURN: Status
524 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
526 ****************************************************************************/
528 /* Event type decoding */
530 static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
532 "PM_Timer",
533 "GlobalLock",
534 "PowerButton",
535 "SleepButton",
536 "RealTimeClock",
540 char *
541 AcpiUtGetEventName (
542 UINT32 EventId)
545 if (EventId > ACPI_EVENT_MAX)
547 return ("InvalidEventID");
550 return ((char *) AcpiGbl_EventTypes[EventId]);
554 /*****************************************************************************
556 * FUNCTION: AcpiUtGetTypeName
558 * PARAMETERS: None.
560 * RETURN: Status
562 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
564 ****************************************************************************/
567 * Elements of AcpiGbl_NsTypeNames below must match
568 * one-to-one with values of ACPI_OBJECT_TYPE
570 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when
571 * stored in a table it really means that we have thus far seen no evidence to
572 * indicate what type is actually going to be stored for this entry.
574 static const char AcpiGbl_BadType[] = "UNDEFINED";
575 #define TYPE_NAME_LENGTH 12 /* Maximum length of each string */
577 static const char *AcpiGbl_NsTypeNames[] = /* printable names of ACPI types */
579 /* 00 */ "Untyped",
580 /* 01 */ "Integer",
581 /* 02 */ "String",
582 /* 03 */ "Buffer",
583 /* 04 */ "Package",
584 /* 05 */ "FieldUnit",
585 /* 06 */ "Device",
586 /* 07 */ "Event",
587 /* 08 */ "Method",
588 /* 09 */ "Mutex",
589 /* 10 */ "Region",
590 /* 11 */ "Power",
591 /* 12 */ "Processor",
592 /* 13 */ "Thermal",
593 /* 14 */ "BufferField",
594 /* 15 */ "DdbHandle",
595 /* 16 */ "DebugObject",
596 /* 17 */ "RegionField",
597 /* 18 */ "BankField",
598 /* 19 */ "IndexField",
599 /* 20 */ "Reference",
600 /* 21 */ "Alias",
601 /* 22 */ "MethodAlias",
602 /* 23 */ "Notify",
603 /* 24 */ "AddrHandler",
604 /* 25 */ "ResourceDesc",
605 /* 26 */ "ResourceFld",
606 /* 27 */ "Scope",
607 /* 28 */ "Extra",
608 /* 29 */ "Data",
609 /* 30 */ "Invalid"
613 char *
614 AcpiUtGetTypeName (
615 ACPI_OBJECT_TYPE Type)
618 if (Type > ACPI_TYPE_INVALID)
620 return ((char *) AcpiGbl_BadType);
623 return ((char *) AcpiGbl_NsTypeNames[Type]);
627 char *
628 AcpiUtGetObjectTypeName (
629 ACPI_OPERAND_OBJECT *ObjDesc)
632 if (!ObjDesc)
634 return ("[NULL Object Descriptor]");
637 return (AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc)));
641 /*****************************************************************************
643 * FUNCTION: AcpiUtGetNodeName
645 * PARAMETERS: Object - A namespace node
647 * RETURN: Pointer to a string
649 * DESCRIPTION: Validate the node and return the node's ACPI name.
651 ****************************************************************************/
653 char *
654 AcpiUtGetNodeName (
655 void *Object)
657 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object;
660 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
662 if (!Object)
664 return ("NULL");
667 /* Check for Root node */
669 if ((Object == ACPI_ROOT_OBJECT) ||
670 (Object == AcpiGbl_RootNode))
672 return ("\"\\\" ");
675 /* Descriptor must be a namespace node */
677 if (Node->Descriptor != ACPI_DESC_TYPE_NAMED)
679 return ("####");
682 /* Name must be a valid ACPI name */
684 if (!AcpiUtValidAcpiName (* (UINT32 *) Node->Name.Ascii))
686 return ("????");
689 /* Return the name */
691 return (Node->Name.Ascii);
695 /*****************************************************************************
697 * FUNCTION: AcpiUtGetDescriptorName
699 * PARAMETERS: Object - An ACPI object
701 * RETURN: Pointer to a string
703 * DESCRIPTION: Validate object and return the descriptor type
705 ****************************************************************************/
707 static const char *AcpiGbl_DescTypeNames[] = /* printable names of descriptor types */
709 /* 00 */ "Invalid",
710 /* 01 */ "Cached",
711 /* 02 */ "State-Generic",
712 /* 03 */ "State-Update",
713 /* 04 */ "State-Package",
714 /* 05 */ "State-Control",
715 /* 06 */ "State-RootParseScope",
716 /* 07 */ "State-ParseScope",
717 /* 08 */ "State-WalkScope",
718 /* 09 */ "State-Result",
719 /* 10 */ "State-Notify",
720 /* 11 */ "State-Thread",
721 /* 12 */ "Walk",
722 /* 13 */ "Parser",
723 /* 14 */ "Operand",
724 /* 15 */ "Node"
728 char *
729 AcpiUtGetDescriptorName (
730 void *Object)
733 if (!Object)
735 return ("NULL OBJECT");
738 if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
740 return ((char *) AcpiGbl_BadType);
743 return ((char *) AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]);
748 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
750 * Strings and procedures used for debug only
753 /*****************************************************************************
755 * FUNCTION: AcpiUtGetMutexName
757 * PARAMETERS: None.
759 * RETURN: Status
761 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
763 ****************************************************************************/
765 char *
766 AcpiUtGetMutexName (
767 UINT32 MutexId)
770 if (MutexId > MAX_MUTEX)
772 return ("Invalid Mutex ID");
775 return (AcpiGbl_MutexNames[MutexId]);
778 #endif
781 /*****************************************************************************
783 * FUNCTION: AcpiUtValidObjectType
785 * PARAMETERS: Type - Object type to be validated
787 * RETURN: TRUE if valid object type
789 * DESCRIPTION: Validate an object type
791 ****************************************************************************/
793 BOOLEAN
794 AcpiUtValidObjectType (
795 ACPI_OBJECT_TYPE Type)
798 if (Type > ACPI_TYPE_LOCAL_MAX)
800 /* Note: Assumes all TYPEs are contiguous (external/local) */
802 return (FALSE);
805 return (TRUE);
809 /****************************************************************************
811 * FUNCTION: AcpiUtAllocateOwnerId
813 * PARAMETERS: IdType - Type of ID (method or table)
815 * DESCRIPTION: Allocate a table or method owner id
817 ***************************************************************************/
819 ACPI_OWNER_ID
820 AcpiUtAllocateOwnerId (
821 UINT32 IdType)
823 ACPI_OWNER_ID OwnerId = 0xFFFF;
826 ACPI_FUNCTION_TRACE ("UtAllocateOwnerId");
829 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
831 return (0);
834 switch (IdType)
836 case ACPI_OWNER_TYPE_TABLE:
838 OwnerId = AcpiGbl_NextTableOwnerId;
839 AcpiGbl_NextTableOwnerId++;
841 /* Check for wraparound */
843 if (AcpiGbl_NextTableOwnerId == ACPI_FIRST_METHOD_ID)
845 AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID;
846 ACPI_REPORT_WARNING (("Table owner ID wraparound\n"));
848 break;
851 case ACPI_OWNER_TYPE_METHOD:
853 OwnerId = AcpiGbl_NextMethodOwnerId;
854 AcpiGbl_NextMethodOwnerId++;
856 if (AcpiGbl_NextMethodOwnerId == ACPI_FIRST_TABLE_ID)
858 /* Check for wraparound */
860 AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID;
862 break;
864 default:
865 break;
868 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
869 return_VALUE (OwnerId);
873 /****************************************************************************
875 * FUNCTION: AcpiUtInitGlobals
877 * PARAMETERS: none
879 * DESCRIPTION: Init library globals. All globals that require specific
880 * initialization should be initialized here!
882 ***************************************************************************/
884 void
885 AcpiUtInitGlobals (
886 void)
888 UINT32 i;
891 ACPI_FUNCTION_TRACE ("UtInitGlobals");
894 /* Memory allocation and cache lists */
896 ACPI_MEMSET (AcpiGbl_MemoryLists, 0, sizeof (ACPI_MEMORY_LIST) * ACPI_NUM_MEM_LISTS);
898 AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_GENERIC_STATE *) NULL)->Common.Next), NULL);
899 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL);
900 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_PARSE_OBJECT *) NULL)->Common.Next), NULL);
901 AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_OPERAND_OBJECT *) NULL)->Cache.Next), NULL);
902 AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].LinkOffset = (UINT16) ACPI_PTR_DIFF (&(((ACPI_WALK_STATE *) NULL)->Next), NULL);
904 AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ObjectSize = sizeof (ACPI_NAMESPACE_NODE);
905 AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ObjectSize = sizeof (ACPI_GENERIC_STATE);
906 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ObjectSize = sizeof (ACPI_PARSE_OBJ_COMMON);
907 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ObjectSize = sizeof (ACPI_PARSE_OBJ_NAMED);
908 AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ObjectSize = sizeof (ACPI_OPERAND_OBJECT);
909 AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ObjectSize = sizeof (ACPI_WALK_STATE);
911 AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].MaxCacheDepth = ACPI_MAX_STATE_CACHE_DEPTH;
912 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].MaxCacheDepth = ACPI_MAX_PARSE_CACHE_DEPTH;
913 AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].MaxCacheDepth = ACPI_MAX_EXTPARSE_CACHE_DEPTH;
914 AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].MaxCacheDepth = ACPI_MAX_OBJECT_CACHE_DEPTH;
915 AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].MaxCacheDepth = ACPI_MAX_WALK_CACHE_DEPTH;
917 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].ListName = "Global Memory Allocation");
918 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_NSNODE].ListName = "Namespace Nodes");
919 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_STATE].ListName = "State Object Cache");
920 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE].ListName = "Parse Node Cache");
921 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_PSNODE_EXT].ListName = "Extended Parse Node Cache");
922 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_OPERAND].ListName = "Operand Object Cache");
923 ACPI_MEM_TRACKING (AcpiGbl_MemoryLists[ACPI_MEM_LIST_WALK].ListName = "Tree Walk Node Cache");
925 /* ACPI table structure */
927 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++)
929 AcpiGbl_TableLists[i].Next = NULL;
930 AcpiGbl_TableLists[i].Count = 0;
933 /* Mutex locked flags */
935 for (i = 0; i < NUM_MUTEX; i++)
937 AcpiGbl_MutexInfo[i].Mutex = NULL;
938 AcpiGbl_MutexInfo[i].OwnerId = ACPI_MUTEX_NOT_ACQUIRED;
939 AcpiGbl_MutexInfo[i].UseCount = 0;
942 /* GPE support */
944 AcpiGbl_GpeXruptListHead = NULL;
945 AcpiGbl_GpeFadtBlocks[0] = NULL;
946 AcpiGbl_GpeFadtBlocks[1] = NULL;
948 /* Global notify handlers */
950 AcpiGbl_SystemNotify.Handler = NULL;
951 AcpiGbl_DeviceNotify.Handler = NULL;
952 AcpiGbl_ExceptionHandler = NULL;
953 AcpiGbl_InitHandler = NULL;
955 /* Global "typed" ACPI table pointers */
957 AcpiGbl_RSDP = NULL;
958 AcpiGbl_XSDT = NULL;
959 AcpiGbl_FACS = NULL;
960 AcpiGbl_FADT = NULL;
961 AcpiGbl_DSDT = NULL;
963 /* Global Lock support */
965 AcpiGbl_GlobalLockAcquired = FALSE;
966 AcpiGbl_GlobalLockThreadCount = 0;
967 AcpiGbl_GlobalLockHandle = 0;
969 /* Miscellaneous variables */
971 AcpiGbl_TableFlags = ACPI_PHYSICAL_POINTER;
972 AcpiGbl_RsdpOriginalLocation = 0;
973 AcpiGbl_CmSingleStep = FALSE;
974 AcpiGbl_DbTerminateThreads = FALSE;
975 AcpiGbl_Shutdown = FALSE;
976 AcpiGbl_NsLookupCount = 0;
977 AcpiGbl_PsFindCount = 0;
978 AcpiGbl_AcpiHardwarePresent = TRUE;
979 AcpiGbl_NextTableOwnerId = ACPI_FIRST_TABLE_ID;
980 AcpiGbl_NextMethodOwnerId = ACPI_FIRST_METHOD_ID;
981 AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING;
982 AcpiGbl_DbOutputFlags = ACPI_DB_CONSOLE_OUTPUT;
984 /* Hardware oriented */
986 AcpiGbl_EventsInitialized = FALSE;
987 AcpiGbl_SystemAwakeAndRunning = TRUE;
989 /* Namespace */
991 AcpiGbl_RootNode = NULL;
993 AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
994 AcpiGbl_RootNodeStruct.Descriptor = ACPI_DESC_TYPE_NAMED;
995 AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
996 AcpiGbl_RootNodeStruct.Child = NULL;
997 AcpiGbl_RootNodeStruct.Peer = NULL;
998 AcpiGbl_RootNodeStruct.Object = NULL;
999 AcpiGbl_RootNodeStruct.Flags = ANOBJ_END_OF_PEER_LIST;
1002 #ifdef ACPI_DEBUG_OUTPUT
1003 AcpiGbl_LowestStackPointer = ACPI_SIZE_MAX;
1004 #endif
1006 return_VOID;