ACPI: ACPICA 20060421
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / 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 *
186 * Namespace globals
187 *
188 ******************************************************************************/
189
190 /*
191 * Predefined ACPI Names (Built-in to the Interpreter)
192 *
193 * NOTES:
194 * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
195 * during the initialization sequence.
196 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
197 * perform a Notify() operation on it.
198 */
199 const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
200 {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
201 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
202 {"_SB_", ACPI_TYPE_DEVICE, NULL},
203 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
204 {"_TZ_", ACPI_TYPE_THERMAL, NULL},
205 {"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
206 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
207 {"_GL_", ACPI_TYPE_MUTEX, (char *)1},
208
209 #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
210 {"_OSI", ACPI_TYPE_METHOD, (char *)1},
211 #endif
212
213 /* Table terminator */
214
215 {NULL, ACPI_TYPE_ANY, NULL}
216 };
217
218 /*
219 * Properties of the ACPI Object Types, both internal and external.
220 * The table is indexed by values of acpi_object_type
221 */
222 const u8 acpi_gbl_ns_properties[] = {
223 ACPI_NS_NORMAL, /* 00 Any */
224 ACPI_NS_NORMAL, /* 01 Number */
225 ACPI_NS_NORMAL, /* 02 String */
226 ACPI_NS_NORMAL, /* 03 Buffer */
227 ACPI_NS_NORMAL, /* 04 Package */
228 ACPI_NS_NORMAL, /* 05 field_unit */
229 ACPI_NS_NEWSCOPE, /* 06 Device */
230 ACPI_NS_NORMAL, /* 07 Event */
231 ACPI_NS_NEWSCOPE, /* 08 Method */
232 ACPI_NS_NORMAL, /* 09 Mutex */
233 ACPI_NS_NORMAL, /* 10 Region */
234 ACPI_NS_NEWSCOPE, /* 11 Power */
235 ACPI_NS_NEWSCOPE, /* 12 Processor */
236 ACPI_NS_NEWSCOPE, /* 13 Thermal */
237 ACPI_NS_NORMAL, /* 14 buffer_field */
238 ACPI_NS_NORMAL, /* 15 ddb_handle */
239 ACPI_NS_NORMAL, /* 16 Debug Object */
240 ACPI_NS_NORMAL, /* 17 def_field */
241 ACPI_NS_NORMAL, /* 18 bank_field */
242 ACPI_NS_NORMAL, /* 19 index_field */
243 ACPI_NS_NORMAL, /* 20 Reference */
244 ACPI_NS_NORMAL, /* 21 Alias */
245 ACPI_NS_NORMAL, /* 22 method_alias */
246 ACPI_NS_NORMAL, /* 23 Notify */
247 ACPI_NS_NORMAL, /* 24 Address Handler */
248 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
249 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
250 ACPI_NS_NEWSCOPE, /* 27 Scope */
251 ACPI_NS_NORMAL, /* 28 Extra */
252 ACPI_NS_NORMAL, /* 29 Data */
253 ACPI_NS_NORMAL /* 30 Invalid */
254 };
255
256 /* Hex to ASCII conversion table */
257
258 static const char acpi_gbl_hex_to_ascii[] = {
259 '0', '1', '2', '3', '4', '5', '6', '7',
260 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
261 };
262
263 /*******************************************************************************
264 *
265 * FUNCTION: acpi_ut_hex_to_ascii_char
266 *
267 * PARAMETERS: Integer - Contains the hex digit
268 * Position - bit position of the digit within the
269 * integer (multiple of 4)
270 *
271 * RETURN: The converted Ascii character
272 *
273 * DESCRIPTION: Convert a hex digit to an Ascii character
274 *
275 ******************************************************************************/
276
277 char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position)
278 {
279
280 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
281 }
282
283 /*******************************************************************************
284 *
285 * Table name globals
286 *
287 * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
288 * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables
289 * that are not used by the subsystem are simply ignored.
290 *
291 * Do NOT add any table to this list that is not consumed directly by this
292 * subsystem (No MADT, ECDT, SBST, etc.)
293 *
294 ******************************************************************************/
295
296 struct acpi_table_list acpi_gbl_table_lists[ACPI_TABLE_ID_MAX + 1];
297
298 struct acpi_table_support acpi_gbl_table_data[ACPI_TABLE_ID_MAX + 1] = {
299 /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */
300
301 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof(RSDP_SIG) - 1,
302 ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
303 ,
304 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *)&acpi_gbl_DSDT,
305 sizeof(DSDT_SIG) - 1,
306 ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE |
307 ACPI_TABLE_EXECUTABLE}
308 ,
309 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *)&acpi_gbl_FADT,
310 sizeof(FADT_SIG) - 1,
311 ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}
312 ,
313 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *)&acpi_gbl_FACS,
314 sizeof(FACS_SIG) - 1,
315 ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE}
316 ,
317 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof(PSDT_SIG) - 1,
318 ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
319 ACPI_TABLE_EXECUTABLE}
320 ,
321 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof(SSDT_SIG) - 1,
322 ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
323 ACPI_TABLE_EXECUTABLE}
324 ,
325 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof(RSDT_SIG) - 1,
326 ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
327 ,
328 };
329
330 /******************************************************************************
331 *
332 * Event and Hardware globals
333 *
334 ******************************************************************************/
335
336 struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
337 /* Name Parent Register Register Bit Position Register Bit Mask */
338
339 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
340 ACPI_BITPOSITION_TIMER_STATUS,
341 ACPI_BITMASK_TIMER_STATUS},
342 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
343 ACPI_BITPOSITION_BUS_MASTER_STATUS,
344 ACPI_BITMASK_BUS_MASTER_STATUS},
345 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
346 ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,
347 ACPI_BITMASK_GLOBAL_LOCK_STATUS},
348 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
349 ACPI_BITPOSITION_POWER_BUTTON_STATUS,
350 ACPI_BITMASK_POWER_BUTTON_STATUS},
351 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
352 ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,
353 ACPI_BITMASK_SLEEP_BUTTON_STATUS},
354 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
355 ACPI_BITPOSITION_RT_CLOCK_STATUS,
356 ACPI_BITMASK_RT_CLOCK_STATUS},
357 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
358 ACPI_BITPOSITION_WAKE_STATUS,
359 ACPI_BITMASK_WAKE_STATUS},
360 /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
361 ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,
362 ACPI_BITMASK_PCIEXP_WAKE_STATUS},
363
364 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
365 ACPI_BITPOSITION_TIMER_ENABLE,
366 ACPI_BITMASK_TIMER_ENABLE},
367 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
368 ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,
369 ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
370 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
371 ACPI_BITPOSITION_POWER_BUTTON_ENABLE,
372 ACPI_BITMASK_POWER_BUTTON_ENABLE},
373 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
374 ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,
375 ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
376 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
377 ACPI_BITPOSITION_RT_CLOCK_ENABLE,
378 ACPI_BITMASK_RT_CLOCK_ENABLE},
379 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
380 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE,
381 ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
382 ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
383
384 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
385 ACPI_BITPOSITION_SCI_ENABLE,
386 ACPI_BITMASK_SCI_ENABLE},
387 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL,
388 ACPI_BITPOSITION_BUS_MASTER_RLD,
389 ACPI_BITMASK_BUS_MASTER_RLD},
390 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL,
391 ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
392 ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
393 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL,
394 ACPI_BITPOSITION_SLEEP_TYPE_X,
395 ACPI_BITMASK_SLEEP_TYPE_X},
396 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL,
397 ACPI_BITPOSITION_SLEEP_TYPE_X,
398 ACPI_BITMASK_SLEEP_TYPE_X},
399 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
400 ACPI_BITPOSITION_SLEEP_ENABLE,
401 ACPI_BITMASK_SLEEP_ENABLE},
402
403 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL,
404 ACPI_BITPOSITION_ARB_DISABLE,
405 ACPI_BITMASK_ARB_DISABLE}
406 };
407
408 struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = {
409 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS,
410 ACPI_BITREG_TIMER_ENABLE,
411 ACPI_BITMASK_TIMER_STATUS,
412 ACPI_BITMASK_TIMER_ENABLE},
413 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS,
414 ACPI_BITREG_GLOBAL_LOCK_ENABLE,
415 ACPI_BITMASK_GLOBAL_LOCK_STATUS,
416 ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
417 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS,
418 ACPI_BITREG_POWER_BUTTON_ENABLE,
419 ACPI_BITMASK_POWER_BUTTON_STATUS,
420 ACPI_BITMASK_POWER_BUTTON_ENABLE},
421 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS,
422 ACPI_BITREG_SLEEP_BUTTON_ENABLE,
423 ACPI_BITMASK_SLEEP_BUTTON_STATUS,
424 ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
425 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS,
426 ACPI_BITREG_RT_CLOCK_ENABLE,
427 ACPI_BITMASK_RT_CLOCK_STATUS,
428 ACPI_BITMASK_RT_CLOCK_ENABLE},
429 };
430
431 /*******************************************************************************
432 *
433 * FUNCTION: acpi_ut_get_region_name
434 *
435 * PARAMETERS: None.
436 *
437 * RETURN: Status
438 *
439 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
440 *
441 ******************************************************************************/
442
443 /* Region type decoding */
444
445 const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
446 /*! [Begin] no source code translation (keep these ASL Keywords as-is) */
447 "SystemMemory",
448 "SystemIO",
449 "PCI_Config",
450 "EmbeddedControl",
451 "SMBus",
452 "CMOS",
453 "PCIBARTarget",
454 "DataTable"
455 /*! [End] no source code translation !*/
456 };
457
458 char *acpi_ut_get_region_name(u8 space_id)
459 {
460
461 if (space_id >= ACPI_USER_REGION_BEGIN) {
462 return ("UserDefinedRegion");
463 } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
464 return ("InvalidSpaceId");
465 }
466
467 return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
468 }
469
470 /*******************************************************************************
471 *
472 * FUNCTION: acpi_ut_get_event_name
473 *
474 * PARAMETERS: None.
475 *
476 * RETURN: Status
477 *
478 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
479 *
480 ******************************************************************************/
481
482 /* Event type decoding */
483
484 static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
485 /*! [Begin] no source code translation (keep these strings as-is) */
486 "PM_Timer",
487 "GlobalLock",
488 "PowerButton",
489 "SleepButton",
490 "RealTimeClock",
491 /*! [End] no source code translation !*/
492 };
493
494 char *acpi_ut_get_event_name(u32 event_id)
495 {
496
497 if (event_id > ACPI_EVENT_MAX) {
498 return ("InvalidEventID");
499 }
500
501 return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
502 }
503
504 /*******************************************************************************
505 *
506 * FUNCTION: acpi_ut_get_type_name
507 *
508 * PARAMETERS: None.
509 *
510 * RETURN: Status
511 *
512 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
513 *
514 ******************************************************************************/
515
516 /*
517 * Elements of acpi_gbl_ns_type_names below must match
518 * one-to-one with values of acpi_object_type
519 *
520 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
521 * when stored in a table it really means that we have thus far seen no
522 * evidence to indicate what type is actually going to be stored for this entry.
523 */
524 static const char acpi_gbl_bad_type[] = "UNDEFINED";
525
526 /* Printable names of the ACPI object types */
527
528 static const char *acpi_gbl_ns_type_names[] = {
529 /*! [Begin] no source code translation (keep these strings as-is) */
530 /* 00 */ "Untyped",
531 /* 01 */ "Integer",
532 /* 02 */ "String",
533 /* 03 */ "Buffer",
534 /* 04 */ "Package",
535 /* 05 */ "FieldUnit",
536 /* 06 */ "Device",
537 /* 07 */ "Event",
538 /* 08 */ "Method",
539 /* 09 */ "Mutex",
540 /* 10 */ "Region",
541 /* 11 */ "Power",
542 /* 12 */ "Processor",
543 /* 13 */ "Thermal",
544 /* 14 */ "BufferField",
545 /* 15 */ "DdbHandle",
546 /* 16 */ "DebugObject",
547 /* 17 */ "RegionField",
548 /* 18 */ "BankField",
549 /* 19 */ "IndexField",
550 /* 20 */ "Reference",
551 /* 21 */ "Alias",
552 /* 22 */ "MethodAlias",
553 /* 23 */ "Notify",
554 /* 24 */ "AddrHandler",
555 /* 25 */ "ResourceDesc",
556 /* 26 */ "ResourceFld",
557 /* 27 */ "Scope",
558 /* 28 */ "Extra",
559 /* 29 */ "Data",
560 /* 30 */ "Invalid"
561 /*! [End] no source code translation !*/
562 };
563
564 char *acpi_ut_get_type_name(acpi_object_type type)
565 {
566
567 if (type > ACPI_TYPE_INVALID) {
568 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
569 }
570
571 return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
572 }
573
574 char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
575 {
576
577 if (!obj_desc) {
578 return ("[NULL Object Descriptor]");
579 }
580
581 return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)));
582 }
583
584 /*******************************************************************************
585 *
586 * FUNCTION: acpi_ut_get_node_name
587 *
588 * PARAMETERS: Object - A namespace node
589 *
590 * RETURN: Pointer to a string
591 *
592 * DESCRIPTION: Validate the node and return the node's ACPI name.
593 *
594 ******************************************************************************/
595
596 char *acpi_ut_get_node_name(void *object)
597 {
598 struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
599
600 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
601
602 if (!object) {
603 return ("NULL");
604 }
605
606 /* Check for Root node */
607
608 if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
609 return ("\"\\\" ");
610 }
611
612 /* Descriptor must be a namespace node */
613
614 if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
615 return ("####");
616 }
617
618 /* Name must be a valid ACPI name */
619
620 if (!acpi_ut_valid_acpi_name(node->name.integer)) {
621 node->name.integer = acpi_ut_repair_name(node->name.integer);
622 }
623
624 /* Return the name */
625
626 return (node->name.ascii);
627 }
628
629 /*******************************************************************************
630 *
631 * FUNCTION: acpi_ut_get_descriptor_name
632 *
633 * PARAMETERS: Object - An ACPI object
634 *
635 * RETURN: Pointer to a string
636 *
637 * DESCRIPTION: Validate object and return the descriptor type
638 *
639 ******************************************************************************/
640
641 /* Printable names of object descriptor types */
642
643 static const char *acpi_gbl_desc_type_names[] = {
644 /*! [Begin] no source code translation (keep these ASL Keywords as-is) */
645 /* 00 */ "Invalid",
646 /* 01 */ "Cached",
647 /* 02 */ "State-Generic",
648 /* 03 */ "State-Update",
649 /* 04 */ "State-Package",
650 /* 05 */ "State-Control",
651 /* 06 */ "State-RootParseScope",
652 /* 07 */ "State-ParseScope",
653 /* 08 */ "State-WalkScope",
654 /* 09 */ "State-Result",
655 /* 10 */ "State-Notify",
656 /* 11 */ "State-Thread",
657 /* 12 */ "Walk",
658 /* 13 */ "Parser",
659 /* 14 */ "Operand",
660 /* 15 */ "Node"
661 /*! [End] no source code translation !*/
662 };
663
664 char *acpi_ut_get_descriptor_name(void *object)
665 {
666
667 if (!object) {
668 return ("NULL OBJECT");
669 }
670
671 if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
672 return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
673 }
674
675 return (ACPI_CAST_PTR(char,
676 acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
677 (object)]));
678
679 }
680
681 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
682 /*
683 * Strings and procedures used for debug only
684 */
685
686 /*******************************************************************************
687 *
688 * FUNCTION: acpi_ut_get_mutex_name
689 *
690 * PARAMETERS: mutex_id - The predefined ID for this mutex.
691 *
692 * RETURN: String containing the name of the mutex. Always returns a valid
693 * pointer.
694 *
695 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
696 *
697 ******************************************************************************/
698
699 char *acpi_ut_get_mutex_name(u32 mutex_id)
700 {
701
702 if (mutex_id > MAX_MUTEX) {
703 return ("Invalid Mutex ID");
704 }
705
706 return (acpi_gbl_mutex_names[mutex_id]);
707 }
708 #endif
709
710 /*******************************************************************************
711 *
712 * FUNCTION: acpi_ut_valid_object_type
713 *
714 * PARAMETERS: Type - Object type to be validated
715 *
716 * RETURN: TRUE if valid object type, FALSE otherwise
717 *
718 * DESCRIPTION: Validate an object type
719 *
720 ******************************************************************************/
721
722 u8 acpi_ut_valid_object_type(acpi_object_type type)
723 {
724
725 if (type > ACPI_TYPE_LOCAL_MAX) {
726
727 /* Note: Assumes all TYPEs are contiguous (external/local) */
728
729 return (FALSE);
730 }
731
732 return (TRUE);
733 }
734
735 /*******************************************************************************
736 *
737 * FUNCTION: acpi_ut_init_globals
738 *
739 * PARAMETERS: None
740 *
741 * RETURN: None
742 *
743 * DESCRIPTION: Init library globals. All globals that require specific
744 * initialization should be initialized here!
745 *
746 ******************************************************************************/
747
748 void acpi_ut_init_globals(void)
749 {
750 acpi_status status;
751 u32 i;
752
753 ACPI_FUNCTION_TRACE(ut_init_globals);
754
755 /* Create all memory caches */
756
757 status = acpi_ut_create_caches();
758 if (ACPI_FAILURE(status)) {
759 return;
760 }
761
762 /* ACPI table structure */
763
764 for (i = 0; i < (ACPI_TABLE_ID_MAX + 1); i++) {
765 acpi_gbl_table_lists[i].next = NULL;
766 acpi_gbl_table_lists[i].count = 0;
767 }
768
769 /* Mutex locked flags */
770
771 for (i = 0; i < NUM_MUTEX; i++) {
772 acpi_gbl_mutex_info[i].mutex = NULL;
773 acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
774 acpi_gbl_mutex_info[i].use_count = 0;
775 }
776
777 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
778 acpi_gbl_owner_id_mask[i] = 0;
779 }
780 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */
781
782 /* GPE support */
783
784 acpi_gbl_gpe_xrupt_list_head = NULL;
785 acpi_gbl_gpe_fadt_blocks[0] = NULL;
786 acpi_gbl_gpe_fadt_blocks[1] = NULL;
787
788 /* Global notify handlers */
789
790 acpi_gbl_system_notify.handler = NULL;
791 acpi_gbl_device_notify.handler = NULL;
792 acpi_gbl_exception_handler = NULL;
793 acpi_gbl_init_handler = NULL;
794
795 /* Global "typed" ACPI table pointers */
796
797 acpi_gbl_RSDP = NULL;
798 acpi_gbl_XSDT = NULL;
799 acpi_gbl_FACS = NULL;
800 acpi_gbl_FADT = NULL;
801 acpi_gbl_DSDT = NULL;
802
803 /* Global Lock support */
804
805 acpi_gbl_global_lock_acquired = FALSE;
806 acpi_gbl_global_lock_thread_count = 0;
807 acpi_gbl_global_lock_handle = 0;
808
809 /* Miscellaneous variables */
810
811 acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER;
812 acpi_gbl_rsdp_original_location = 0;
813 acpi_gbl_cm_single_step = FALSE;
814 acpi_gbl_db_terminate_threads = FALSE;
815 acpi_gbl_shutdown = FALSE;
816 acpi_gbl_ns_lookup_count = 0;
817 acpi_gbl_ps_find_count = 0;
818 acpi_gbl_acpi_hardware_present = TRUE;
819 acpi_gbl_last_owner_id_index = 0;
820 acpi_gbl_next_owner_id_offset = 0;
821 acpi_gbl_trace_method_name = 0;
822 acpi_gbl_trace_dbg_level = 0;
823 acpi_gbl_trace_dbg_layer = 0;
824 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
825 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
826
827 /* Hardware oriented */
828
829 acpi_gbl_events_initialized = FALSE;
830 acpi_gbl_system_awake_and_running = TRUE;
831
832 /* Namespace */
833
834 acpi_gbl_root_node = NULL;
835 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
836 acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
837 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
838 acpi_gbl_root_node_struct.child = NULL;
839 acpi_gbl_root_node_struct.peer = NULL;
840 acpi_gbl_root_node_struct.object = NULL;
841 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
842
843 #ifdef ACPI_DEBUG_OUTPUT
844 acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;
845 #endif
846
847 return_VOID;
848 }
849
850 ACPI_EXPORT_SYMBOL(acpi_dbg_level)
851 ACPI_EXPORT_SYMBOL(acpi_dbg_layer)