xref: /titanic_41/usr/src/uts/intel/io/acpica/utilities/utglobal.c (revision 40e5e17b3361b3eea56a9723071c406894a20b78)
1 /******************************************************************************
2  *
3  * Module Name: utglobal - Global variables for the ACPI subsystem
4  *              $Revision: 1.242 $
5  *
6  *****************************************************************************/
7 
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
17  * 2.1. This is your license from Intel Corp. under its intellectual property
18  * rights.  You may have additional license terms from the party that provided
19  * you this software, covering your right to use that party's intellectual
20  * property rights.
21  *
22  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23  * copy of the source code appearing in this file ("Covered Code") an
24  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25  * base code distributed originally by Intel ("Original Intel Code") to copy,
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116 
117 #define __UTGLOBAL_C__
118 #define DEFINE_ACPI_GLOBALS
119 
120 #include "acpi.h"
121 #include "acnamesp.h"
122 
123 #define _COMPONENT          ACPI_UTILITIES
124         ACPI_MODULE_NAME    ("utglobal")
125 
126 
127 /*******************************************************************************
128  *
129  * FUNCTION:    AcpiFormatException
130  *
131  * PARAMETERS:  Status       - The ACPI_STATUS code to be formatted
132  *
133  * RETURN:      A string containing the exception text. A valid pointer is
134  *              always returned.
135  *
136  * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
137  *
138  ******************************************************************************/
139 
140 const char *
141 AcpiFormatException (
142     ACPI_STATUS             Status)
143 {
144     ACPI_STATUS             SubStatus;
145     const char              *Exception = NULL;
146 
147 
148     ACPI_FUNCTION_ENTRY ();
149 
150 
151     /*
152      * Status is composed of two parts, a "type" and an actual code
153      */
154     SubStatus = (Status & ~AE_CODE_MASK);
155 
156     switch (Status & AE_CODE_MASK)
157     {
158     case AE_CODE_ENVIRONMENTAL:
159 
160         if (SubStatus <= AE_CODE_ENV_MAX)
161         {
162             Exception = AcpiGbl_ExceptionNames_Env [SubStatus];
163         }
164         break;
165 
166     case AE_CODE_PROGRAMMER:
167 
168         if (SubStatus <= AE_CODE_PGM_MAX)
169         {
170             Exception = AcpiGbl_ExceptionNames_Pgm [SubStatus -1];
171         }
172         break;
173 
174     case AE_CODE_ACPI_TABLES:
175 
176         if (SubStatus <= AE_CODE_TBL_MAX)
177         {
178             Exception = AcpiGbl_ExceptionNames_Tbl [SubStatus -1];
179         }
180         break;
181 
182     case AE_CODE_AML:
183 
184         if (SubStatus <= AE_CODE_AML_MAX)
185         {
186             Exception = AcpiGbl_ExceptionNames_Aml [SubStatus -1];
187         }
188         break;
189 
190     case AE_CODE_CONTROL:
191 
192         if (SubStatus <= AE_CODE_CTRL_MAX)
193         {
194             Exception = AcpiGbl_ExceptionNames_Ctrl [SubStatus -1];
195         }
196         break;
197 
198     default:
199         break;
200     }
201 
202     if (!Exception)
203     {
204         /* Exception code was not recognized */
205 
206         ACPI_ERROR ((AE_INFO,
207             "Unknown exception code: 0x%8.8X", Status));
208 
209         Exception = "UNKNOWN_STATUS_CODE";
210     }
211 
212     return (ACPI_CAST_PTR (const char, Exception));
213 }
214 
215 
216 /*******************************************************************************
217  *
218  * Static global variable initialization.
219  *
220  ******************************************************************************/
221 
222 /*
223  * We want the debug switches statically initialized so they
224  * are already set when the debugger is entered.
225  */
226 
227 /* Debug switch - level and trace mask */
228 
229 #ifdef ACPI_DEBUG_OUTPUT
230 UINT32                      AcpiDbgLevel = ACPI_DEBUG_DEFAULT;
231 #else
232 UINT32                      AcpiDbgLevel = ACPI_NORMAL_DEFAULT;
233 #endif
234 
235 /* Debug switch - layer (component) mask */
236 
237 UINT32                      AcpiDbgLayer = ACPI_COMPONENT_DEFAULT;
238 UINT32                      AcpiGbl_NestingLevel = 0;
239 
240 /* Debugger globals */
241 
242 BOOLEAN                     AcpiGbl_DbTerminateThreads = FALSE;
243 BOOLEAN                     AcpiGbl_AbortMethod = FALSE;
244 BOOLEAN                     AcpiGbl_MethodExecuting = FALSE;
245 
246 /* System flags */
247 
248 UINT32                      AcpiGbl_StartupFlags = 0;
249 
250 /* System starts uninitialized */
251 
252 BOOLEAN                     AcpiGbl_Shutdown = TRUE;
253 
254 const UINT8                 AcpiGbl_DecodeTo8bit [8] = {1,2,4,8,16,32,64,128};
255 
256 const char                  *AcpiGbl_SleepStateNames[ACPI_S_STATE_COUNT] =
257 {
258     "\\_S0_",
259     "\\_S1_",
260     "\\_S2_",
261     "\\_S3_",
262     "\\_S4_",
263     "\\_S5_"
264 };
265 
266 const char                  *AcpiGbl_HighestDstateNames[4] =
267 {
268     "_S1D",
269     "_S2D",
270     "_S3D",
271     "_S4D"
272 };
273 
274 
275 /*******************************************************************************
276  *
277  * Namespace globals
278  *
279  ******************************************************************************/
280 
281 /*
282  * Predefined ACPI Names (Built-in to the Interpreter)
283  *
284  * NOTES:
285  * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
286  *    during the initialization sequence.
287  * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
288  *    perform a Notify() operation on it.
289  */
290 const ACPI_PREDEFINED_NAMES     AcpiGbl_PreDefinedNames[] =
291 {
292     {"_GPE",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
293     {"_PR_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
294     {"_SB_",    ACPI_TYPE_DEVICE,           NULL},
295     {"_SI_",    ACPI_TYPE_LOCAL_SCOPE,      NULL},
296     {"_TZ_",    ACPI_TYPE_THERMAL,          NULL},
297     {"_REV",    ACPI_TYPE_INTEGER,          (char *) ACPI_CA_SUPPORT_LEVEL},
298     {"_OS_",    ACPI_TYPE_STRING,           ACPI_OS_NAME},
299     {"_GL_",    ACPI_TYPE_MUTEX,            (char *) 1},
300 
301 #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
302     {"_OSI",    ACPI_TYPE_METHOD,           (char *) 1},
303 #endif
304 
305     /* Table terminator */
306 
307     {NULL,      ACPI_TYPE_ANY,              NULL}
308 };
309 
310 /*
311  * Properties of the ACPI Object Types, both internal and external.
312  * The table is indexed by values of ACPI_OBJECT_TYPE
313  */
314 const UINT8                     AcpiGbl_NsProperties[] =
315 {
316     ACPI_NS_NORMAL,                     /* 00 Any              */
317     ACPI_NS_NORMAL,                     /* 01 Number           */
318     ACPI_NS_NORMAL,                     /* 02 String           */
319     ACPI_NS_NORMAL,                     /* 03 Buffer           */
320     ACPI_NS_NORMAL,                     /* 04 Package          */
321     ACPI_NS_NORMAL,                     /* 05 FieldUnit        */
322     ACPI_NS_NEWSCOPE,                   /* 06 Device           */
323     ACPI_NS_NORMAL,                     /* 07 Event            */
324     ACPI_NS_NEWSCOPE,                   /* 08 Method           */
325     ACPI_NS_NORMAL,                     /* 09 Mutex            */
326     ACPI_NS_NORMAL,                     /* 10 Region           */
327     ACPI_NS_NEWSCOPE,                   /* 11 Power            */
328     ACPI_NS_NEWSCOPE,                   /* 12 Processor        */
329     ACPI_NS_NEWSCOPE,                   /* 13 Thermal          */
330     ACPI_NS_NORMAL,                     /* 14 BufferField      */
331     ACPI_NS_NORMAL,                     /* 15 DdbHandle        */
332     ACPI_NS_NORMAL,                     /* 16 Debug Object     */
333     ACPI_NS_NORMAL,                     /* 17 DefField         */
334     ACPI_NS_NORMAL,                     /* 18 BankField        */
335     ACPI_NS_NORMAL,                     /* 19 IndexField       */
336     ACPI_NS_NORMAL,                     /* 20 Reference        */
337     ACPI_NS_NORMAL,                     /* 21 Alias            */
338     ACPI_NS_NORMAL,                     /* 22 MethodAlias      */
339     ACPI_NS_NORMAL,                     /* 23 Notify           */
340     ACPI_NS_NORMAL,                     /* 24 Address Handler  */
341     ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 25 Resource Desc    */
342     ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,   /* 26 Resource Field   */
343     ACPI_NS_NEWSCOPE,                   /* 27 Scope            */
344     ACPI_NS_NORMAL,                     /* 28 Extra            */
345     ACPI_NS_NORMAL,                     /* 29 Data             */
346     ACPI_NS_NORMAL                      /* 30 Invalid          */
347 };
348 
349 
350 /* Hex to ASCII conversion table */
351 
352 static const char           AcpiGbl_HexToAscii[] =
353 {
354     '0','1','2','3','4','5','6','7',
355     '8','9','A','B','C','D','E','F'
356 };
357 
358 
359 /*******************************************************************************
360  *
361  * FUNCTION:    AcpiUtHexToAsciiChar
362  *
363  * PARAMETERS:  Integer             - Contains the hex digit
364  *              Position            - bit position of the digit within the
365  *                                    integer (multiple of 4)
366  *
367  * RETURN:      The converted Ascii character
368  *
369  * DESCRIPTION: Convert a hex digit to an Ascii character
370  *
371  ******************************************************************************/
372 
373 char
374 AcpiUtHexToAsciiChar (
375     ACPI_INTEGER            Integer,
376     UINT32                  Position)
377 {
378 
379     return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
380 }
381 
382 
383 /*******************************************************************************
384  *
385  * Table name globals
386  *
387  * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
388  * it is NOT an exhaustive list of all possible ACPI tables.  All ACPI tables
389  * that are not used by the subsystem are simply ignored.
390  *
391  * Do NOT add any table to this list that is not consumed directly by this
392  * subsystem (No MADT, ECDT, SBST, etc.)
393  *
394  ******************************************************************************/
395 
396 ACPI_TABLE_LIST             AcpiGbl_TableLists[ACPI_TABLE_ID_MAX+1];
397 
398 ACPI_TABLE_SUPPORT          AcpiGbl_TableData[ACPI_TABLE_ID_MAX+1] =
399 {
400     /***********    Name,   Signature, Global typed pointer     Signature size,      Type                  How many allowed?,    Contains valid AML? */
401 
402     /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL,                    sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT     | ACPI_TABLE_SINGLE},
403     /* DSDT 1 */ {DSDT_SIG,  DSDT_SIG, (void *) &AcpiGbl_DSDT,  sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE   | ACPI_TABLE_EXECUTABLE},
404     /* FADT 2 */ {FADT_SIG,  FADT_SIG, (void *) &AcpiGbl_FADT,  sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY  | ACPI_TABLE_SINGLE},
405     /* FACS 3 */ {FACS_SIG,  FACS_SIG, (void *) &AcpiGbl_FACS,  sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE},
406     /* PSDT 4 */ {PSDT_SIG,  PSDT_SIG, NULL,                    sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY  | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
407     /* SSDT 5 */ {SSDT_SIG,  SSDT_SIG, NULL,                    sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY  | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
408     /* XSDT 6 */ {XSDT_SIG,  XSDT_SIG, NULL,                    sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT     | ACPI_TABLE_SINGLE},
409 };
410 
411 
412 /******************************************************************************
413  *
414  * Event and Hardware globals
415  *
416  ******************************************************************************/
417 
418 ACPI_BIT_REGISTER_INFO      AcpiGbl_BitRegisterInfo[ACPI_NUM_BITREG] =
419 {
420     /* Name                                     Parent Register             Register Bit Position                   Register Bit Mask       */
421 
422     /* ACPI_BITREG_TIMER_STATUS         */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_TIMER_STATUS,          ACPI_BITMASK_TIMER_STATUS},
423     /* ACPI_BITREG_BUS_MASTER_STATUS    */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_BUS_MASTER_STATUS,     ACPI_BITMASK_BUS_MASTER_STATUS},
424     /* ACPI_BITREG_GLOBAL_LOCK_STATUS   */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,    ACPI_BITMASK_GLOBAL_LOCK_STATUS},
425     /* ACPI_BITREG_POWER_BUTTON_STATUS  */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_POWER_BUTTON_STATUS,   ACPI_BITMASK_POWER_BUTTON_STATUS},
426     /* ACPI_BITREG_SLEEP_BUTTON_STATUS  */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,   ACPI_BITMASK_SLEEP_BUTTON_STATUS},
427     /* ACPI_BITREG_RT_CLOCK_STATUS      */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_RT_CLOCK_STATUS,       ACPI_BITMASK_RT_CLOCK_STATUS},
428     /* ACPI_BITREG_WAKE_STATUS          */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_WAKE_STATUS,           ACPI_BITMASK_WAKE_STATUS},
429     /* ACPI_BITREG_PCIEXP_WAKE_STATUS   */   {ACPI_REGISTER_PM1_STATUS,   ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,    ACPI_BITMASK_PCIEXP_WAKE_STATUS},
430 
431     /* ACPI_BITREG_TIMER_ENABLE         */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_TIMER_ENABLE,          ACPI_BITMASK_TIMER_ENABLE},
432     /* ACPI_BITREG_GLOBAL_LOCK_ENABLE   */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,    ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
433     /* ACPI_BITREG_POWER_BUTTON_ENABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_POWER_BUTTON_ENABLE,   ACPI_BITMASK_POWER_BUTTON_ENABLE},
434     /* ACPI_BITREG_SLEEP_BUTTON_ENABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,   ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
435     /* ACPI_BITREG_RT_CLOCK_ENABLE      */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_RT_CLOCK_ENABLE,       ACPI_BITMASK_RT_CLOCK_ENABLE},
436     /* ACPI_BITREG_WAKE_ENABLE          */   {ACPI_REGISTER_PM1_ENABLE,   0,                                      0},
437     /* ACPI_BITREG_PCIEXP_WAKE_DISABLE  */   {ACPI_REGISTER_PM1_ENABLE,   ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,   ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
438 
439     /* ACPI_BITREG_SCI_ENABLE           */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SCI_ENABLE,            ACPI_BITMASK_SCI_ENABLE},
440     /* ACPI_BITREG_BUS_MASTER_RLD       */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_BUS_MASTER_RLD,        ACPI_BITMASK_BUS_MASTER_RLD},
441     /* ACPI_BITREG_GLOBAL_LOCK_RELEASE  */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,   ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
442     /* ACPI_BITREG_SLEEP_TYPE_A         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_TYPE_X,          ACPI_BITMASK_SLEEP_TYPE_X},
443     /* ACPI_BITREG_SLEEP_TYPE_B         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_TYPE_X,          ACPI_BITMASK_SLEEP_TYPE_X},
444     /* ACPI_BITREG_SLEEP_ENABLE         */   {ACPI_REGISTER_PM1_CONTROL,  ACPI_BITPOSITION_SLEEP_ENABLE,          ACPI_BITMASK_SLEEP_ENABLE},
445 
446     /* ACPI_BITREG_ARB_DIS              */   {ACPI_REGISTER_PM2_CONTROL,  ACPI_BITPOSITION_ARB_DISABLE,           ACPI_BITMASK_ARB_DISABLE}
447 };
448 
449 
450 ACPI_FIXED_EVENT_INFO       AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS] =
451 {
452     /* ACPI_EVENT_PMTIMER       */  {ACPI_BITREG_TIMER_STATUS,          ACPI_BITREG_TIMER_ENABLE,        ACPI_BITMASK_TIMER_STATUS,          ACPI_BITMASK_TIMER_ENABLE},
453     /* ACPI_EVENT_GLOBAL        */  {ACPI_BITREG_GLOBAL_LOCK_STATUS,    ACPI_BITREG_GLOBAL_LOCK_ENABLE,  ACPI_BITMASK_GLOBAL_LOCK_STATUS,    ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
454     /* ACPI_EVENT_POWER_BUTTON  */  {ACPI_BITREG_POWER_BUTTON_STATUS,   ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS,   ACPI_BITMASK_POWER_BUTTON_ENABLE},
455     /* ACPI_EVENT_SLEEP_BUTTON  */  {ACPI_BITREG_SLEEP_BUTTON_STATUS,   ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS,   ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
456     /* ACPI_EVENT_RTC           */  {ACPI_BITREG_RT_CLOCK_STATUS,       ACPI_BITREG_RT_CLOCK_ENABLE,     ACPI_BITMASK_RT_CLOCK_STATUS,       ACPI_BITMASK_RT_CLOCK_ENABLE},
457 };
458 
459 /*******************************************************************************
460  *
461  * FUNCTION:    AcpiUtGetRegionName
462  *
463  * PARAMETERS:  None.
464  *
465  * RETURN:      Status
466  *
467  * DESCRIPTION: Translate a Space ID into a name string (Debug only)
468  *
469  ******************************************************************************/
470 
471 /* Region type decoding */
472 
473 const char        *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
474 {
475     "SystemMemory",
476     "SystemIO",
477     "PCI_Config",
478     "EmbeddedControl",
479     "SMBus",
480     "CMOS",
481     "PCIBARTarget",
482     "DataTable"
483 };
484 
485 
486 char *
487 AcpiUtGetRegionName (
488     UINT8                   SpaceId)
489 {
490 
491     if (SpaceId >= ACPI_USER_REGION_BEGIN)
492     {
493         return ("UserDefinedRegion");
494     }
495     else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
496     {
497         return ("InvalidSpaceId");
498     }
499 
500     return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
501 }
502 
503 
504 /*******************************************************************************
505  *
506  * FUNCTION:    AcpiUtGetEventName
507  *
508  * PARAMETERS:  None.
509  *
510  * RETURN:      Status
511  *
512  * DESCRIPTION: Translate a Event ID into a name string (Debug only)
513  *
514  ******************************************************************************/
515 
516 /* Event type decoding */
517 
518 static const char        *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
519 {
520     "PM_Timer",
521     "GlobalLock",
522     "PowerButton",
523     "SleepButton",
524     "RealTimeClock",
525 };
526 
527 
528 char *
529 AcpiUtGetEventName (
530     UINT32                  EventId)
531 {
532 
533     if (EventId > ACPI_EVENT_MAX)
534     {
535         return ("InvalidEventID");
536     }
537 
538     return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
539 }
540 
541 
542 /*******************************************************************************
543  *
544  * FUNCTION:    AcpiUtGetTypeName
545  *
546  * PARAMETERS:  None.
547  *
548  * RETURN:      Status
549  *
550  * DESCRIPTION: Translate a Type ID into a name string (Debug only)
551  *
552  ******************************************************************************/
553 
554 /*
555  * Elements of AcpiGbl_NsTypeNames below must match
556  * one-to-one with values of ACPI_OBJECT_TYPE
557  *
558  * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
559  * when stored in a table it really means that we have thus far seen no
560  * evidence to indicate what type is actually going to be stored for this entry.
561  */
562 static const char           AcpiGbl_BadType[] = "UNDEFINED";
563 
564 /* Printable names of the ACPI object types */
565 
566 static const char           *AcpiGbl_NsTypeNames[] =
567 {
568     /* 00 */ "Untyped",
569     /* 01 */ "Integer",
570     /* 02 */ "String",
571     /* 03 */ "Buffer",
572     /* 04 */ "Package",
573     /* 05 */ "FieldUnit",
574     /* 06 */ "Device",
575     /* 07 */ "Event",
576     /* 08 */ "Method",
577     /* 09 */ "Mutex",
578     /* 10 */ "Region",
579     /* 11 */ "Power",
580     /* 12 */ "Processor",
581     /* 13 */ "Thermal",
582     /* 14 */ "BufferField",
583     /* 15 */ "DdbHandle",
584     /* 16 */ "DebugObject",
585     /* 17 */ "RegionField",
586     /* 18 */ "BankField",
587     /* 19 */ "IndexField",
588     /* 20 */ "Reference",
589     /* 21 */ "Alias",
590     /* 22 */ "MethodAlias",
591     /* 23 */ "Notify",
592     /* 24 */ "AddrHandler",
593     /* 25 */ "ResourceDesc",
594     /* 26 */ "ResourceFld",
595     /* 27 */ "Scope",
596     /* 28 */ "Extra",
597     /* 29 */ "Data",
598     /* 30 */ "Invalid"
599 };
600 
601 
602 char *
603 AcpiUtGetTypeName (
604     ACPI_OBJECT_TYPE        Type)
605 {
606 
607     if (Type > ACPI_TYPE_INVALID)
608     {
609         return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
610     }
611 
612     return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
613 }
614 
615 
616 char *
617 AcpiUtGetObjectTypeName (
618     ACPI_OPERAND_OBJECT     *ObjDesc)
619 {
620 
621     if (!ObjDesc)
622     {
623         return ("[NULL Object Descriptor]");
624     }
625 
626     return (AcpiUtGetTypeName (ACPI_GET_OBJECT_TYPE (ObjDesc)));
627 }
628 
629 
630 /*******************************************************************************
631  *
632  * FUNCTION:    AcpiUtGetNodeName
633  *
634  * PARAMETERS:  Object               - A namespace node
635  *
636  * RETURN:      Pointer to a string
637  *
638  * DESCRIPTION: Validate the node and return the node's ACPI name.
639  *
640  ******************************************************************************/
641 
642 char *
643 AcpiUtGetNodeName (
644     void                    *Object)
645 {
646     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) Object;
647 
648 
649     /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
650 
651     if (!Object)
652     {
653         return ("NULL");
654     }
655 
656     /* Check for Root node */
657 
658     if ((Object == ACPI_ROOT_OBJECT) ||
659         (Object == AcpiGbl_RootNode))
660     {
661         return ("\"\\\" ");
662     }
663 
664     /* Descriptor must be a namespace node */
665 
666     if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
667     {
668         return ("####");
669     }
670 
671     /* Name must be a valid ACPI name */
672 
673     if (!AcpiUtValidAcpiName (Node->Name.Integer))
674     {
675         Node->Name.Integer = AcpiUtRepairName (Node->Name.Integer);
676     }
677 
678     /* Return the name */
679 
680     return (Node->Name.Ascii);
681 }
682 
683 
684 /*******************************************************************************
685  *
686  * FUNCTION:    AcpiUtGetDescriptorName
687  *
688  * PARAMETERS:  Object               - An ACPI object
689  *
690  * RETURN:      Pointer to a string
691  *
692  * DESCRIPTION: Validate object and return the descriptor type
693  *
694  ******************************************************************************/
695 
696 /* Printable names of object descriptor types */
697 
698 static const char           *AcpiGbl_DescTypeNames[] =
699 {
700     /* 00 */ "Invalid",
701     /* 01 */ "Cached",
702     /* 02 */ "State-Generic",
703     /* 03 */ "State-Update",
704     /* 04 */ "State-Package",
705     /* 05 */ "State-Control",
706     /* 06 */ "State-RootParseScope",
707     /* 07 */ "State-ParseScope",
708     /* 08 */ "State-WalkScope",
709     /* 09 */ "State-Result",
710     /* 10 */ "State-Notify",
711     /* 11 */ "State-Thread",
712     /* 12 */ "Walk",
713     /* 13 */ "Parser",
714     /* 14 */ "Operand",
715     /* 15 */ "Node"
716 };
717 
718 
719 char *
720 AcpiUtGetDescriptorName (
721     void                    *Object)
722 {
723 
724     if (!Object)
725     {
726         return ("NULL OBJECT");
727     }
728 
729     if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
730     {
731         return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
732     }
733 
734     return (ACPI_CAST_PTR (char,
735         AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
736 
737 }
738 
739 
740 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
741 /*
742  * Strings and procedures used for debug only
743  */
744 
745 /*******************************************************************************
746  *
747  * FUNCTION:    AcpiUtGetMutexName
748  *
749  * PARAMETERS:  MutexId         - The predefined ID for this mutex.
750  *
751  * RETURN:      String containing the name of the mutex. Always returns a valid
752  *              pointer.
753  *
754  * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
755  *
756  ******************************************************************************/
757 
758 char *
759 AcpiUtGetMutexName (
760     UINT32                  MutexId)
761 {
762 
763     if (MutexId > ACPI_MAX_MUTEX)
764     {
765         return ("Invalid Mutex ID");
766     }
767 
768     return (AcpiGbl_MutexNames[MutexId]);
769 }
770 #endif
771 
772 
773 /*******************************************************************************
774  *
775  * FUNCTION:    AcpiUtValidObjectType
776  *
777  * PARAMETERS:  Type            - Object type to be validated
778  *
779  * RETURN:      TRUE if valid object type, FALSE otherwise
780  *
781  * DESCRIPTION: Validate an object type
782  *
783  ******************************************************************************/
784 
785 BOOLEAN
786 AcpiUtValidObjectType (
787     ACPI_OBJECT_TYPE        Type)
788 {
789 
790     if (Type > ACPI_TYPE_LOCAL_MAX)
791     {
792         /* Note: Assumes all TYPEs are contiguous (external/local) */
793 
794         return (FALSE);
795     }
796 
797     return (TRUE);
798 }
799 
800 
801 /*******************************************************************************
802  *
803  * FUNCTION:    AcpiUtInitGlobals
804  *
805  * PARAMETERS:  None
806  *
807  * RETURN:      None
808  *
809  * DESCRIPTION: Init library globals.  All globals that require specific
810  *              initialization should be initialized here!
811  *
812  ******************************************************************************/
813 
814 void
815 AcpiUtInitGlobals (
816     void)
817 {
818     ACPI_STATUS             Status;
819     UINT32                  i;
820 
821 
822     ACPI_FUNCTION_TRACE (UtInitGlobals);
823 
824 
825     /* Create all memory caches */
826 
827     Status = AcpiUtCreateCaches ();
828     if (ACPI_FAILURE (Status))
829     {
830         return;
831     }
832 
833     /* ACPI table structure */
834 
835     for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++)
836     {
837         AcpiGbl_TableLists[i].Next          = NULL;
838         AcpiGbl_TableLists[i].Count         = 0;
839     }
840 
841     /* Mutex locked flags */
842 
843     for (i = 0; i < ACPI_NUM_MUTEX; i++)
844     {
845         AcpiGbl_MutexInfo[i].Mutex          = NULL;
846         AcpiGbl_MutexInfo[i].ThreadId       = ACPI_MUTEX_NOT_ACQUIRED;
847         AcpiGbl_MutexInfo[i].UseCount       = 0;
848     }
849 
850     for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++)
851     {
852         AcpiGbl_OwnerIdMask[i]              = 0;
853     }
854     AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */
855 
856     /* GPE support */
857 
858     AcpiGbl_GpeXruptListHead            = NULL;
859     AcpiGbl_GpeFadtBlocks[0]            = NULL;
860     AcpiGbl_GpeFadtBlocks[1]            = NULL;
861 
862     /* Global notify handlers */
863 
864     AcpiGbl_SystemNotify.Handler        = NULL;
865     AcpiGbl_DeviceNotify.Handler        = NULL;
866     AcpiGbl_ExceptionHandler            = NULL;
867     AcpiGbl_InitHandler                 = NULL;
868 
869     /* Global "typed" ACPI table pointers */
870 
871     AcpiGbl_RSDP                        = NULL;
872     AcpiGbl_XSDT                        = NULL;
873     AcpiGbl_FACS                        = NULL;
874     AcpiGbl_FADT                        = NULL;
875     AcpiGbl_DSDT                        = NULL;
876 
877     /* Global Lock support */
878 
879     AcpiGbl_GlobalLockSemaphore         = NULL;
880     AcpiGbl_GlobalLockMutex             = NULL;
881     AcpiGbl_GlobalLockAcquired          = FALSE;
882     AcpiGbl_GlobalLockHandle            = 0;
883 
884     /* Miscellaneous variables */
885 
886     AcpiGbl_TableFlags                  = ACPI_PHYSICAL_POINTER;
887     AcpiGbl_RsdpOriginalLocation        = 0;
888     AcpiGbl_CmSingleStep                = FALSE;
889     AcpiGbl_DbTerminateThreads          = FALSE;
890     AcpiGbl_Shutdown                    = FALSE;
891     AcpiGbl_NsLookupCount               = 0;
892     AcpiGbl_PsFindCount                 = 0;
893     AcpiGbl_AcpiHardwarePresent         = TRUE;
894     AcpiGbl_LastOwnerIdIndex            = 0;
895     AcpiGbl_NextOwnerIdOffset           = 0;
896     AcpiGbl_TraceMethodName             = 0;
897     AcpiGbl_TraceDbgLevel               = 0;
898     AcpiGbl_TraceDbgLayer               = 0;
899     AcpiGbl_DebuggerConfiguration       = DEBUGGER_THREADING;
900     AcpiGbl_DbOutputFlags               = ACPI_DB_CONSOLE_OUTPUT;
901 
902     /* Hardware oriented */
903 
904     AcpiGbl_EventsInitialized           = FALSE;
905     AcpiGbl_SystemAwakeAndRunning       = TRUE;
906 
907     /* Namespace */
908 
909     AcpiGbl_RootNode                    = NULL;
910     AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
911     AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
912     AcpiGbl_RootNodeStruct.Type         = ACPI_TYPE_DEVICE;
913     AcpiGbl_RootNodeStruct.Child        = NULL;
914     AcpiGbl_RootNodeStruct.Peer         = NULL;
915     AcpiGbl_RootNodeStruct.Object       = NULL;
916     AcpiGbl_RootNodeStruct.Flags        = ANOBJ_END_OF_PEER_LIST;
917 
918 
919 #ifdef ACPI_DEBUG_OUTPUT
920     AcpiGbl_LowestStackPointer          = ACPI_SIZE_MAX;
921 #endif
922 
923     return_VOID;
924 }
925 
926 /* Public globals */
927 
928 ACPI_EXPORT_SYMBOL (AcpiDbgLevel)
929 ACPI_EXPORT_SYMBOL (AcpiDbgLayer)
930 
931 
932