]> err.no Git - linux-2.6/blob - drivers/acpi/utilities/utglobal.c
ACPI: ACPICA 20060310
[linux-2.6] / drivers / acpi / utilities / utglobal.c
1 /******************************************************************************
2  *
3  * Module Name: utglobal - Global variables for the ACPI subsystem
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2006, R. Byron Moore
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43
44 #define DEFINE_ACPI_GLOBALS
45
46 #include <acpi/acpi.h>
47 #include <acpi/acnamesp.h>
48
49 #define _COMPONENT          ACPI_UTILITIES
50 ACPI_MODULE_NAME("utglobal")
51
52 /*******************************************************************************
53  *
54  * FUNCTION:    acpi_format_exception
55  *
56  * PARAMETERS:  Status       - The acpi_status code to be formatted
57  *
58  * RETURN:      A string containing the exception text. A valid pointer is
59  *              always returned.
60  *
61  * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
62  *
63  ******************************************************************************/
64 const char *acpi_format_exception(acpi_status status)
65 {
66         acpi_status sub_status;
67         const char *exception = NULL;
68
69         ACPI_FUNCTION_ENTRY();
70
71         /*
72          * Status is composed of two parts, a "type" and an actual code
73          */
74         sub_status = (status & ~AE_CODE_MASK);
75
76         switch (status & AE_CODE_MASK) {
77         case AE_CODE_ENVIRONMENTAL:
78
79                 if (sub_status <= AE_CODE_ENV_MAX) {
80                         exception = acpi_gbl_exception_names_env[sub_status];
81                 }
82                 break;
83
84         case AE_CODE_PROGRAMMER:
85
86                 if (sub_status <= AE_CODE_PGM_MAX) {
87                         exception =
88                             acpi_gbl_exception_names_pgm[sub_status - 1];
89                 }
90                 break;
91
92         case AE_CODE_ACPI_TABLES:
93
94                 if (sub_status <= AE_CODE_TBL_MAX) {
95                         exception =
96                             acpi_gbl_exception_names_tbl[sub_status - 1];
97                 }
98                 break;
99
100         case AE_CODE_AML:
101
102                 if (sub_status <= AE_CODE_AML_MAX) {
103                         exception =
104                             acpi_gbl_exception_names_aml[sub_status - 1];
105                 }
106                 break;
107
108         case AE_CODE_CONTROL:
109
110                 if (sub_status <= AE_CODE_CTRL_MAX) {
111                         exception =
112                             acpi_gbl_exception_names_ctrl[sub_status - 1];
113                 }
114                 break;
115
116         default:
117                 break;
118         }
119
120         if (!exception) {
121
122                 /* Exception code was not recognized */
123
124                 ACPI_ERROR((AE_INFO,
125                             "Unknown exception code: 0x%8.8X", status));
126
127                 exception = "UNKNOWN_STATUS_CODE";
128         }
129
130         return (ACPI_CAST_PTR(const char, exception));
131 }
132
133 /*******************************************************************************
134  *
135  * Static global variable initialization.
136  *
137  ******************************************************************************/
138
139 /*
140  * We want the debug switches statically initialized so they
141  * are already set when the debugger is entered.
142  */
143
144 /* Debug switch - level and trace mask */
145 u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
146
147 /* Debug switch - layer (component) mask */
148
149 u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
150 u32 acpi_gbl_nesting_level = 0;
151
152 /* Debugger globals */
153
154 u8 acpi_gbl_db_terminate_threads = FALSE;
155 u8 acpi_gbl_abort_method = FALSE;
156 u8 acpi_gbl_method_executing = FALSE;
157
158 /* System flags */
159
160 u32 acpi_gbl_startup_flags = 0;
161
162 /* System starts uninitialized */
163
164 u8 acpi_gbl_shutdown = TRUE;
165
166 const u8 acpi_gbl_decode_to8bit[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
167
168 const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
169         "\\_S0_",
170         "\\_S1_",
171         "\\_S2_",
172         "\\_S3_",
173         "\\_S4_",
174         "\\_S5_"
175 };
176
177 const char *acpi_gbl_highest_dstate_names[4] = {
178         "_S1D",
179         "_S2D",
180         "_S3D",
181         "_S4D"
182 };
183
184 /*
185  * Strings supported by the _OSI predefined (internal) method.
186  * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS.
187  */
188 const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = {
189         /* Operating System Vendor Strings */
190
191         "Linux",
192         "Windows 2000",
193         "Windows 2001",
194         "Windows 2001.1",
195         "Windows 2001 SP0",
196         "Windows 2001 SP1",
197         "Windows 2001 SP2",
198         "Windows 2001 SP3",
199         "Windows 2001 SP4",
200
201         /* Feature Group Strings */
202
203         "Extended Address Space Descriptor"
204 };
205
206 /*******************************************************************************
207  *
208  * Namespace globals
209  *
210  ******************************************************************************/
211
212 /*
213  * Predefined ACPI Names (Built-in to the Interpreter)
214  *
215  * NOTES:
216  * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
217  *    during the initialization sequence.
218  * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
219  *    perform a Notify() operation on it.
220  */
221 const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
222         {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
223         {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
224         {"_SB_", ACPI_TYPE_DEVICE, NULL},
225         {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
226         {"_TZ_", ACPI_TYPE_THERMAL, NULL},
227         {"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
228         {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
229         {"_GL_", ACPI_TYPE_MUTEX, (char *)1},
230
231 #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
232         {"_OSI", ACPI_TYPE_METHOD, (char *)1},
233 #endif
234
235         /* Table terminator */
236
237         {NULL, ACPI_TYPE_ANY, NULL}
238 };
239
240 /*
241  * Properties of the ACPI Object Types, both internal and external.
242  * The table is indexed by values of acpi_object_type
243  */
244 const u8 acpi_gbl_ns_properties[] = {
245         ACPI_NS_NORMAL,         /* 00 Any              */
246         ACPI_NS_NORMAL,         /* 01 Number           */
247         ACPI_NS_NORMAL,         /* 02 String           */
248         ACPI_NS_NORMAL,         /* 03 Buffer           */
249         ACPI_NS_NORMAL,         /* 04 Package          */
250         ACPI_NS_NORMAL,         /* 05 field_unit       */
251         ACPI_NS_NEWSCOPE,       /* 06 Device           */
252         ACPI_NS_NORMAL,         /* 07 Event            */
253         ACPI_NS_NEWSCOPE,       /* 08 Method           */
254         ACPI_NS_NORMAL,         /* 09 Mutex            */
255         ACPI_NS_NORMAL,         /* 10 Region           */
256         ACPI_NS_NEWSCOPE,       /* 11 Power            */
257         ACPI_NS_NEWSCOPE,       /* 12 Processor        */
258         ACPI_NS_NEWSCOPE,       /* 13 Thermal          */
259         ACPI_NS_NORMAL,         /* 14 buffer_field     */
260         ACPI_NS_NORMAL,         /* 15 ddb_handle       */
261         ACPI_NS_NORMAL,         /* 16 Debug Object     */
262         ACPI_NS_NORMAL,         /* 17 def_field        */
263         ACPI_NS_NORMAL,         /* 18 bank_field       */
264         ACPI_NS_NORMAL,         /* 19 index_field      */
265         ACPI_NS_NORMAL,         /* 20 Reference        */
266         ACPI_NS_NORMAL,         /* 21 Alias            */
267         ACPI_NS_NORMAL,         /* 22 method_alias     */
268         ACPI_NS_NORMAL,         /* 23 Notify           */
269         ACPI_NS_NORMAL,         /* 24 Address Handler  */
270         ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,       /* 25 Resource Desc    */
271         ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,       /* 26 Resource Field   */
272         ACPI_NS_NEWSCOPE,       /* 27 Scope            */
273         ACPI_NS_NORMAL,         /* 28 Extra            */
274         ACPI_NS_NORMAL,         /* 29 Data             */
275         ACPI_NS_NORMAL          /* 30 Invalid          */
276 };
277
278 /* Hex to ASCII conversion table */
279
280 static const char acpi_gbl_hex_to_ascii[] = {
281         '0', '1', '2', '3', '4', '5', '6', '7',
282         '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
283 };
284
285 /*******************************************************************************
286  *
287  * FUNCTION:    acpi_ut_hex_to_ascii_char
288  *
289  * PARAMETERS:  Integer             - Contains the hex digit
290  *              Position            - bit position of the digit within the
291  *                                    integer (multiple of 4)
292  *
293  * RETURN:      The converted Ascii character
294  *
295  * DESCRIPTION: Convert a hex digit to an Ascii character
296  *
297  ******************************************************************************/
298
299 char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position)
300 {
301
302         return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
303 }
304
305 /*******************************************************************************
306  *
307  * Table name globals
308  *
309  * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
310  * it is NOT an exhaustive list of all possible ACPI tables.  All ACPI tables
311  * that are not used by the subsystem are simply ignored.
312  *
313  * Do NOT add any table to this list that is not consumed directly by this
314  * subsystem (No MADT, ECDT, SBST, etc.)
315  *
316  ******************************************************************************/
317
318 struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
319
320 struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = {
321         /***********    Name,   Signature, Global typed pointer     Signature size,      Type                  How many allowed?,    Contains valid AML? */
322
323         /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof(RSDP_SIG) - 1,
324                       ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
325         ,
326         /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *)&acpi_gbl_DSDT,
327                       sizeof(DSDT_SIG) - 1,
328                       ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE |
329                       ACPI_TABLE_EXECUTABLE}
330         ,
331         /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *)&acpi_gbl_FADT,
332                       sizeof(FADT_SIG) - 1,
333                       ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}
334         ,
335         /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *)&acpi_gbl_FACS,
336                       sizeof(FACS_SIG) - 1,
337                       ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE}
338         ,
339         /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof(PSDT_SIG) - 1,
340                       ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
341                       ACPI_TABLE_EXECUTABLE}
342         ,
343         /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof(SSDT_SIG) - 1,
344                       ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
345                       ACPI_TABLE_EXECUTABLE}
346         ,
347         /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof(RSDT_SIG) - 1,
348                       ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
349         ,
350 };
351
352 /******************************************************************************
353  *
354  * Event and Hardware globals
355  *
356  ******************************************************************************/
357
358 struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
359         /* Name                                     Parent Register             Register Bit Position                   Register Bit Mask       */
360
361         /* ACPI_BITREG_TIMER_STATUS         */ {ACPI_REGISTER_PM1_STATUS,
362                                                 ACPI_BITPOSITION_TIMER_STATUS,
363                                                 ACPI_BITMASK_TIMER_STATUS},
364         /* ACPI_BITREG_BUS_MASTER_STATUS    */ {ACPI_REGISTER_PM1_STATUS,
365                                                 ACPI_BITPOSITION_BUS_MASTER_STATUS,
366                                                 ACPI_BITMASK_BUS_MASTER_STATUS},
367         /* ACPI_BITREG_GLOBAL_LOCK_STATUS   */ {ACPI_REGISTER_PM1_STATUS,
368                                                 ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,
369                                                 ACPI_BITMASK_GLOBAL_LOCK_STATUS},
370         /* ACPI_BITREG_POWER_BUTTON_STATUS  */ {ACPI_REGISTER_PM1_STATUS,
371                                                 ACPI_BITPOSITION_POWER_BUTTON_STATUS,
372                                                 ACPI_BITMASK_POWER_BUTTON_STATUS},
373         /* ACPI_BITREG_SLEEP_BUTTON_STATUS  */ {ACPI_REGISTER_PM1_STATUS,
374                                                 ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,
375                                                 ACPI_BITMASK_SLEEP_BUTTON_STATUS},
376         /* ACPI_BITREG_RT_CLOCK_STATUS      */ {ACPI_REGISTER_PM1_STATUS,
377                                                 ACPI_BITPOSITION_RT_CLOCK_STATUS,
378                                                 ACPI_BITMASK_RT_CLOCK_STATUS},
379         /* ACPI_BITREG_WAKE_STATUS          */ {ACPI_REGISTER_PM1_STATUS,
380                                                 ACPI_BITPOSITION_WAKE_STATUS,
381                                                 ACPI_BITMASK_WAKE_STATUS},
382         /* ACPI_BITREG_PCIEXP_WAKE_STATUS   */ {ACPI_REGISTER_PM1_STATUS,
383                                                 ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,
384                                                 ACPI_BITMASK_PCIEXP_WAKE_STATUS},
385
386         /* ACPI_BITREG_TIMER_ENABLE         */ {ACPI_REGISTER_PM1_ENABLE,
387                                                 ACPI_BITPOSITION_TIMER_ENABLE,
388                                                 ACPI_BITMASK_TIMER_ENABLE},
389         /* ACPI_BITREG_GLOBAL_LOCK_ENABLE   */ {ACPI_REGISTER_PM1_ENABLE,
390                                                 ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,
391                                                 ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
392         /* ACPI_BITREG_POWER_BUTTON_ENABLE  */ {ACPI_REGISTER_PM1_ENABLE,
393                                                 ACPI_BITPOSITION_POWER_BUTTON_ENABLE,
394                                                 ACPI_BITMASK_POWER_BUTTON_ENABLE},
395         /* ACPI_BITREG_SLEEP_BUTTON_ENABLE  */ {ACPI_REGISTER_PM1_ENABLE,
396                                                 ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,
397                                                 ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
398         /* ACPI_BITREG_RT_CLOCK_ENABLE      */ {ACPI_REGISTER_PM1_ENABLE,
399                                                 ACPI_BITPOSITION_RT_CLOCK_ENABLE,
400                                                 ACPI_BITMASK_RT_CLOCK_ENABLE},
401         /* ACPI_BITREG_WAKE_ENABLE          */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
402         /* ACPI_BITREG_PCIEXP_WAKE_DISABLE  */ {ACPI_REGISTER_PM1_ENABLE,
403                                                 ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
404                                                 ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
405
406         /* ACPI_BITREG_SCI_ENABLE           */ {ACPI_REGISTER_PM1_CONTROL,
407                                                 ACPI_BITPOSITION_SCI_ENABLE,
408                                                 ACPI_BITMASK_SCI_ENABLE},
409         /* ACPI_BITREG_BUS_MASTER_RLD       */ {ACPI_REGISTER_PM1_CONTROL,
410                                                 ACPI_BITPOSITION_BUS_MASTER_RLD,
411                                                 ACPI_BITMASK_BUS_MASTER_RLD},
412         /* ACPI_BITREG_GLOBAL_LOCK_RELEASE  */ {ACPI_REGISTER_PM1_CONTROL,
413                                                 ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
414                                                 ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
415         /* ACPI_BITREG_SLEEP_TYPE_A         */ {ACPI_REGISTER_PM1_CONTROL,
416                                                 ACPI_BITPOSITION_SLEEP_TYPE_X,
417                                                 ACPI_BITMASK_SLEEP_TYPE_X},
418         /* ACPI_BITREG_SLEEP_TYPE_B         */ {ACPI_REGISTER_PM1_CONTROL,
419                                                 ACPI_BITPOSITION_SLEEP_TYPE_X,
420                                                 ACPI_BITMASK_SLEEP_TYPE_X},
421         /* ACPI_BITREG_SLEEP_ENABLE         */ {ACPI_REGISTER_PM1_CONTROL,
422                                                 ACPI_BITPOSITION_SLEEP_ENABLE,
423                                                 ACPI_BITMASK_SLEEP_ENABLE},
424
425         /* ACPI_BITREG_ARB_DIS              */ {ACPI_REGISTER_PM2_CONTROL,
426                                                 ACPI_BITPOSITION_ARB_DISABLE,
427                                                 ACPI_BITMASK_ARB_DISABLE}
428 };
429
430 struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = {
431         /* ACPI_EVENT_PMTIMER       */ {ACPI_BITREG_TIMER_STATUS,
432                                         ACPI_BITREG_TIMER_ENABLE,
433                                         ACPI_BITMASK_TIMER_STATUS,
434                                         ACPI_BITMASK_TIMER_ENABLE},
435         /* ACPI_EVENT_GLOBAL        */ {ACPI_BITREG_GLOBAL_LOCK_STATUS,
436                                         ACPI_BITREG_GLOBAL_LOCK_ENABLE,
437                                         ACPI_BITMASK_GLOBAL_LOCK_STATUS,
438                                         ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
439         /* ACPI_EVENT_POWER_BUTTON  */ {ACPI_BITREG_POWER_BUTTON_STATUS,
440                                         ACPI_BITREG_POWER_BUTTON_ENABLE,
441                                         ACPI_BITMASK_POWER_BUTTON_STATUS,
442                                         ACPI_BITMASK_POWER_BUTTON_ENABLE},
443         /* ACPI_EVENT_SLEEP_BUTTON  */ {ACPI_BITREG_SLEEP_BUTTON_STATUS,
444                                         ACPI_BITREG_SLEEP_BUTTON_ENABLE,
445                                         ACPI_BITMASK_SLEEP_BUTTON_STATUS,
446                                         ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
447         /* ACPI_EVENT_RTC           */ {ACPI_BITREG_RT_CLOCK_STATUS,
448                                         ACPI_BITREG_RT_CLOCK_ENABLE,
449                                         ACPI_BITMASK_RT_CLOCK_STATUS,
450                                         ACPI_BITMASK_RT_CLOCK_ENABLE},
451 };
452
453 /*******************************************************************************
454  *
455  * FUNCTION:    acpi_ut_get_region_name
456  *
457  * PARAMETERS:  None.
458  *
459  * RETURN:      Status
460  *
461  * DESCRIPTION: Translate a Space ID into a name string (Debug only)
462  *
463  ******************************************************************************/
464
465 /* Region type decoding */
466
467 const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
468 /*! [Begin] no source code translation (keep these ASL Keywords as-is) */
469         "SystemMemory",
470         "SystemIO",
471         "PCI_Config",
472         "EmbeddedControl",
473         "SMBus",
474         "CMOS",
475         "PCIBARTarget",
476         "DataTable"
477 /*! [End] no source code translation !*/
478 };
479
480 char *acpi_ut_get_region_name(u8 space_id)
481 {
482
483         if (space_id >= ACPI_USER_REGION_BEGIN) {
484                 return ("user_defined_region");
485         } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
486                 return ("invalid_space_id");
487         }
488
489         return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
490 }
491
492 /*******************************************************************************
493  *
494  * FUNCTION:    acpi_ut_get_event_name
495  *
496  * PARAMETERS:  None.
497  *
498  * RETURN:      Status
499  *
500  * DESCRIPTION: Translate a Event ID into a name string (Debug only)
501  *
502  ******************************************************************************/
503
504 /* Event type decoding */
505
506 static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
507 /*! [Begin] no source code translation (keep these strings as-is) */
508         "PM_Timer",
509         "GlobalLock",
510         "PowerButton",
511         "SleepButton",
512         "RealTimeClock",
513 /*! [End] no source code translation !*/
514 };
515
516 char *acpi_ut_get_event_name(u32 event_id)
517 {
518
519         if (event_id > ACPI_EVENT_MAX) {
520                 return ("invalid_event_iD");
521         }
522
523         return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
524 }
525
526 /*******************************************************************************
527  *
528  * FUNCTION:    acpi_ut_get_type_name
529  *
530  * PARAMETERS:  None.
531  *
532  * RETURN:      Status
533  *
534  * DESCRIPTION: Translate a Type ID into a name string (Debug only)
535  *
536  ******************************************************************************/
537
538 /*
539  * Elements of acpi_gbl_ns_type_names below must match
540  * one-to-one with values of acpi_object_type
541  *
542  * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
543  * when stored in a table it really means that we have thus far seen no
544  * evidence to indicate what type is actually going to be stored for this entry.
545  */
546 static const char acpi_gbl_bad_type[] = "UNDEFINED";
547
548 /* Printable names of the ACPI object types */
549
550 static const char *acpi_gbl_ns_type_names[] = {
551 /*! [Begin] no source code translation (keep these strings as-is) */
552         /* 00 */ "Untyped",
553         /* 01 */ "Integer",
554         /* 02 */ "String",
555         /* 03 */ "Buffer",
556         /* 04 */ "Package",
557         /* 05 */ "FieldUnit",
558         /* 06 */ "Device",
559         /* 07 */ "Event",
560         /* 08 */ "Method",
561         /* 09 */ "Mutex",
562         /* 10 */ "Region",
563         /* 11 */ "Power",
564         /* 12 */ "Processor",
565         /* 13 */ "Thermal",
566         /* 14 */ "BufferField",
567         /* 15 */ "DdbHandle",
568         /* 16 */ "DebugObject",
569         /* 17 */ "RegionField",
570         /* 18 */ "BankField",
571         /* 19 */ "IndexField",
572         /* 20 */ "Reference",
573         /* 21 */ "Alias",
574         /* 22 */ "MethodAlias",
575         /* 23 */ "Notify",
576         /* 24 */ "AddrHandler",
577         /* 25 */ "ResourceDesc",
578         /* 26 */ "ResourceFld",
579         /* 27 */ "Scope",
580         /* 28 */ "Extra",
581         /* 29 */ "Data",
582         /* 30 */ "Invalid"
583 /*! [End] no source code translation !*/
584 };
585
586 char *acpi_ut_get_type_name(acpi_object_type type)
587 {
588
589         if (type > ACPI_TYPE_INVALID) {
590                 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
591         }
592
593         return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
594 }
595
596 char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
597 {
598
599         if (!obj_desc) {
600                 return ("[NULL Object Descriptor]");
601         }
602
603         return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)));
604 }
605
606 /*******************************************************************************
607  *
608  * FUNCTION:    acpi_ut_get_node_name
609  *
610  * PARAMETERS:  Object               - A namespace node
611  *
612  * RETURN:      Pointer to a string
613  *
614  * DESCRIPTION: Validate the node and return the node's ACPI name.
615  *
616  ******************************************************************************/
617
618 char *acpi_ut_get_node_name(void *object)
619 {
620         struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
621
622         /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
623
624         if (!object) {
625                 return ("NULL");
626         }
627
628         /* Check for Root node */
629
630         if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
631                 return ("\"\\\" ");
632         }
633
634         /* Descriptor must be a namespace node */
635
636         if (node->descriptor != ACPI_DESC_TYPE_NAMED) {
637                 return ("####");
638         }
639
640         /* Name must be a valid ACPI name */
641
642         if (!acpi_ut_valid_acpi_name(node->name.integer)) {
643                 return ("????");
644         }
645
646         /* Return the name */
647
648         return (node->name.ascii);
649 }
650
651 /*******************************************************************************
652  *
653  * FUNCTION:    acpi_ut_get_descriptor_name
654  *
655  * PARAMETERS:  Object               - An ACPI object
656  *
657  * RETURN:      Pointer to a string
658  *
659  * DESCRIPTION: Validate object and return the descriptor type
660  *
661  ******************************************************************************/
662
663 /* Printable names of object descriptor types */
664
665 static const char *acpi_gbl_desc_type_names[] = {
666 /*! [Begin] no source code translation (keep these ASL Keywords as-is) */
667         /* 00 */ "Invalid",
668         /* 01 */ "Cached",
669         /* 02 */ "State-Generic",
670         /* 03 */ "State-Update",
671         /* 04 */ "State-Package",
672         /* 05 */ "State-Control",
673         /* 06 */ "State-RootParseScope",
674         /* 07 */ "State-ParseScope",
675         /* 08 */ "State-WalkScope",
676         /* 09 */ "State-Result",
677         /* 10 */ "State-Notify",
678         /* 11 */ "State-Thread",
679         /* 12 */ "Walk",
680         /* 13 */ "Parser",
681         /* 14 */ "Operand",
682         /* 15 */ "Node"
683 /*! [End] no source code translation !*/
684 };
685
686 char *acpi_ut_get_descriptor_name(void *object)
687 {
688
689         if (!object) {
690                 return ("NULL OBJECT");
691         }
692
693         if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
694                 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
695         }
696
697         return (ACPI_CAST_PTR(char,
698                               acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
699                                                        (object)]));
700
701 }
702
703 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
704 /*
705  * Strings and procedures used for debug only
706  */
707
708 /*******************************************************************************
709  *
710  * FUNCTION:    acpi_ut_get_mutex_name
711  *
712  * PARAMETERS:  mutex_id        - The predefined ID for this mutex.
713  *
714  * RETURN:      String containing the name of the mutex. Always returns a valid
715  *              pointer.
716  *
717  * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
718  *
719  ******************************************************************************/
720
721 char *acpi_ut_get_mutex_name(u32 mutex_id)
722 {
723
724         if (mutex_id > MAX_MUTEX) {
725                 return ("Invalid Mutex ID");
726         }
727
728         return (acpi_gbl_mutex_names[mutex_id]);
729 }
730 #endif
731
732 /*******************************************************************************
733  *
734  * FUNCTION:    acpi_ut_valid_object_type
735  *
736  * PARAMETERS:  Type            - Object type to be validated
737  *
738  * RETURN:      TRUE if valid object type, FALSE otherwise
739  *
740  * DESCRIPTION: Validate an object type
741  *
742  ******************************************************************************/
743
744 u8 acpi_ut_valid_object_type(acpi_object_type type)
745 {
746
747         if (type > ACPI_TYPE_LOCAL_MAX) {
748
749                 /* Note: Assumes all TYPEs are contiguous (external/local) */
750
751                 return (FALSE);
752         }
753
754         return (TRUE);
755 }
756
757 /*******************************************************************************
758  *
759  * FUNCTION:    acpi_ut_init_globals
760  *
761  * PARAMETERS:  None
762  *
763  * RETURN:      None
764  *
765  * DESCRIPTION: Init library globals.  All globals that require specific
766  *              initialization should be initialized here!
767  *
768  ******************************************************************************/
769
770 void acpi_ut_init_globals(void)
771 {
772         acpi_status status;
773         u32 i;
774
775         ACPI_FUNCTION_TRACE("ut_init_globals");
776
777         /* Create all memory caches */
778
779         status = acpi_ut_create_caches();
780         if (ACPI_FAILURE(status)) {
781                 return;
782         }
783
784         /* ACPI table structure */
785
786         for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) {
787                 acpi_gbl_table_lists[i].next = NULL;
788                 acpi_gbl_table_lists[i].count = 0;
789         }
790
791         /* Mutex locked flags */
792
793         for (i = 0; i < NUM_MUTEX; i++) {
794                 acpi_gbl_mutex_info[i].mutex = NULL;
795                 acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
796                 acpi_gbl_mutex_info[i].use_count = 0;
797         }
798
799         for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
800                 acpi_gbl_owner_id_mask[i] = 0;
801         }
802         acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;        /* Last ID is never valid */
803
804         /* GPE support */
805
806         acpi_gbl_gpe_xrupt_list_head = NULL;
807         acpi_gbl_gpe_fadt_blocks[0] = NULL;
808         acpi_gbl_gpe_fadt_blocks[1] = NULL;
809
810         /* Global notify handlers */
811
812         acpi_gbl_system_notify.handler = NULL;
813         acpi_gbl_device_notify.handler = NULL;
814         acpi_gbl_exception_handler = NULL;
815         acpi_gbl_init_handler = NULL;
816
817         /* Global "typed" ACPI table pointers */
818
819         acpi_gbl_RSDP = NULL;
820         acpi_gbl_XSDT = NULL;
821         acpi_gbl_FACS = NULL;
822         acpi_gbl_FADT = NULL;
823         acpi_gbl_DSDT = NULL;
824
825         /* Global Lock support */
826
827         acpi_gbl_global_lock_acquired = FALSE;
828         acpi_gbl_global_lock_thread_count = 0;
829         acpi_gbl_global_lock_handle = 0;
830
831         /* Miscellaneous variables */
832
833         acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER;
834         acpi_gbl_rsdp_original_location = 0;
835         acpi_gbl_cm_single_step = FALSE;
836         acpi_gbl_db_terminate_threads = FALSE;
837         acpi_gbl_shutdown = FALSE;
838         acpi_gbl_ns_lookup_count = 0;
839         acpi_gbl_ps_find_count = 0;
840         acpi_gbl_acpi_hardware_present = TRUE;
841         acpi_gbl_last_owner_id_index = 0;
842         acpi_gbl_next_owner_id_offset = 0;
843         acpi_gbl_trace_method_name = 0;
844         acpi_gbl_trace_dbg_level = 0;
845         acpi_gbl_trace_dbg_layer = 0;
846         acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
847         acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
848
849         /* Hardware oriented */
850
851         acpi_gbl_events_initialized = FALSE;
852         acpi_gbl_system_awake_and_running = TRUE;
853
854         /* Namespace */
855
856         acpi_gbl_root_node = NULL;
857         acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
858         acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
859         acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
860         acpi_gbl_root_node_struct.child = NULL;
861         acpi_gbl_root_node_struct.peer = NULL;
862         acpi_gbl_root_node_struct.object = NULL;
863         acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
864
865 #ifdef ACPI_DEBUG_OUTPUT
866         acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;
867 #endif
868
869         return_VOID;
870 }
871
872 ACPI_EXPORT_SYMBOL(acpi_dbg_level)
873 ACPI_EXPORT_SYMBOL(acpi_dbg_layer)