1 /******************************************************************************
3 * Module Name: cmglobal - Global variables for the ACPI subsystem
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #define DEFINE_ACPI_GLOBALS
35 #define _COMPONENT ACPI_UTILITIES
36 MODULE_NAME ("cmglobal")
39 /******************************************************************************
41 * Static global variable initialization.
43 ******************************************************************************/
46 * We want the debug switches statically initialized so they
47 * are already set when the debugger is entered.
50 /* Debug switch - level and trace mask */
52 u32 acpi_dbg_level = NORMAL_DEFAULT;
54 /* Debug switch - layer (component) mask */
56 u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT;
57 u32 acpi_gbl_nesting_level = 0;
60 /* Debugger globals */
62 u8 acpi_gbl_db_terminate_threads = FALSE;
63 u8 acpi_gbl_method_executing = FALSE;
67 u32 acpi_gbl_system_flags = 0;
68 u32 acpi_gbl_startup_flags = 0;
70 /* System starts unitialized! */
71 u8 acpi_gbl_shutdown = TRUE;
74 u8 acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128};
77 /******************************************************************************
81 ******************************************************************************/
85 * Names built-in to the interpreter
87 * Initial values are currently supported only for types String and Number.
88 * To avoid type punning, both are specified as strings in this table.
91 * 1) _SB_ is defined to be a device to allow _SB_/_INI to be run
92 * during the initialization sequence.
95 PREDEFINED_NAMES acpi_gbl_pre_defined_names[] =
96 { {"_GPE", INTERNAL_TYPE_DEF_ANY},
97 {"_PR_", INTERNAL_TYPE_DEF_ANY},
98 {"_SB_", ACPI_TYPE_DEVICE},
99 {"_SI_", INTERNAL_TYPE_DEF_ANY},
100 {"_TZ_", INTERNAL_TYPE_DEF_ANY},
101 {"_REV", ACPI_TYPE_INTEGER, "2"},
102 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
103 {"_GL_", ACPI_TYPE_MUTEX, "0"},
104 {NULL, ACPI_TYPE_ANY} /* Table terminator */
109 * Properties of the ACPI Object Types, both internal and external.
111 * Elements of Acpi_ns_properties are bit significant
112 * and the table is indexed by values of ACPI_OBJECT_TYPE
115 u8 acpi_gbl_ns_properties[] =
117 NSP_NORMAL, /* 00 Any */
118 NSP_NORMAL, /* 01 Number */
119 NSP_NORMAL, /* 02 String */
120 NSP_NORMAL, /* 03 Buffer */
121 NSP_LOCAL, /* 04 Package */
122 NSP_NORMAL, /* 05 Field_unit */
123 NSP_NEWSCOPE | NSP_LOCAL, /* 06 Device */
124 NSP_LOCAL, /* 07 Acpi_event */
125 NSP_NEWSCOPE | NSP_LOCAL, /* 08 Method */
126 NSP_LOCAL, /* 09 Mutex */
127 NSP_LOCAL, /* 10 Region */
128 NSP_NEWSCOPE | NSP_LOCAL, /* 11 Power */
129 NSP_NEWSCOPE | NSP_LOCAL, /* 12 Processor */
130 NSP_NEWSCOPE | NSP_LOCAL, /* 13 Thermal */
131 NSP_NORMAL, /* 14 Buffer_field */
132 NSP_NORMAL, /* 15 Ddb_handle */
133 NSP_NORMAL, /* 16 Debug Object */
134 NSP_NORMAL, /* 17 Def_field */
135 NSP_NORMAL, /* 18 Bank_field */
136 NSP_NORMAL, /* 19 Index_field */
137 NSP_NORMAL, /* 20 Reference */
138 NSP_NORMAL, /* 21 Alias */
139 NSP_NORMAL, /* 22 Notify */
140 NSP_NORMAL, /* 23 Address Handler */
141 NSP_NEWSCOPE | NSP_LOCAL, /* 24 Resource */
142 NSP_NORMAL, /* 25 Def_field_defn */
143 NSP_NORMAL, /* 26 Bank_field_defn */
144 NSP_NORMAL, /* 27 Index_field_defn */
145 NSP_NORMAL, /* 28 If */
146 NSP_NORMAL, /* 29 Else */
147 NSP_NORMAL, /* 30 While */
148 NSP_NEWSCOPE, /* 31 Scope */
149 NSP_LOCAL, /* 32 Def_any */
150 NSP_NORMAL, /* 33 Extra */
151 NSP_NORMAL /* 34 Invalid */
155 /* Hex to ASCII conversion table */
157 NATIVE_CHAR acpi_gbl_hex_to_ascii[] =
158 {'0','1','2','3','4','5','6','7',
159 '8','9','A','B','C','D','E','F'};
162 /******************************************************************************
166 * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
167 * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables
168 * that are not used by the subsystem are simply ignored.
170 ******************************************************************************/
173 ACPI_TABLE_DESC acpi_gbl_acpi_tables[NUM_ACPI_TABLES];
176 ACPI_TABLE_SUPPORT acpi_gbl_acpi_table_data[NUM_ACPI_TABLES] =
178 /*********** Name, Signature, Signature size, How many allowed?, Supported? Global typed pointer */
180 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, sizeof (RSDP_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, NULL},
181 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, sizeof (DSDT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &acpi_gbl_DSDT},
182 /* FADT 2 */ {FADT_SIG, FADT_SIG, sizeof (FADT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &acpi_gbl_FADT},
183 /* FACS 3 */ {FACS_SIG, FACS_SIG, sizeof (FACS_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &acpi_gbl_FACS},
184 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, sizeof (PSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL},
185 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, sizeof (SSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL},
186 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, sizeof (RSDT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, NULL},
190 /*****************************************************************************
192 * FUNCTION: Acpi_cm_valid_object_type
196 * RETURN: TRUE if valid object type
198 * DESCRIPTION: Validate an object type
200 ****************************************************************************/
203 acpi_cm_valid_object_type (
207 if (type > ACPI_TYPE_MAX)
209 if ((type < INTERNAL_TYPE_BEGIN) ||
210 (type > INTERNAL_TYPE_MAX))
220 /*****************************************************************************
222 * FUNCTION: Acpi_cm_format_exception
224 * PARAMETERS: Status - Acpi status to be formatted
226 * RETURN: Formatted status string
228 * DESCRIPTION: Convert an ACPI exception to a string
230 ****************************************************************************/
233 acpi_cm_format_exception (
236 NATIVE_CHAR *exception = "UNKNOWN_STATUS";
237 ACPI_STATUS sub_status;
240 sub_status = (status & ~AE_CODE_MASK);
243 switch (status & AE_CODE_MASK)
245 case AE_CODE_ENVIRONMENTAL:
247 if (sub_status <= AE_CODE_ENV_MAX)
249 exception = acpi_gbl_exception_names_env [sub_status];
253 case AE_CODE_PROGRAMMER:
255 if (sub_status <= AE_CODE_PGM_MAX)
257 exception = acpi_gbl_exception_names_pgm [sub_status -1];
261 case AE_CODE_ACPI_TABLES:
263 if (sub_status <= AE_CODE_TBL_MAX)
265 exception = acpi_gbl_exception_names_tbl [sub_status -1];
271 if (sub_status <= AE_CODE_AML_MAX)
273 exception = acpi_gbl_exception_names_aml [sub_status -1];
277 case AE_CODE_CONTROL:
279 if (sub_status <= AE_CODE_CTRL_MAX)
281 exception = acpi_gbl_exception_names_ctrl [sub_status -1];
294 /****************************************************************************
296 * FUNCTION: Acpi_cm_allocate_owner_id
298 * PARAMETERS: Id_type - Type of ID (method or table)
300 * DESCRIPTION: Allocate a table or method owner id
302 ***************************************************************************/
305 acpi_cm_allocate_owner_id (
308 ACPI_OWNER_ID owner_id = 0xFFFF;
311 acpi_cm_acquire_mutex (ACPI_MTX_CACHES);
315 case OWNER_TYPE_TABLE:
317 owner_id = acpi_gbl_next_table_owner_id;
318 acpi_gbl_next_table_owner_id++;
320 if (acpi_gbl_next_table_owner_id == FIRST_METHOD_ID)
322 acpi_gbl_next_table_owner_id = FIRST_TABLE_ID;
327 case OWNER_TYPE_METHOD:
329 owner_id = acpi_gbl_next_method_owner_id;
330 acpi_gbl_next_method_owner_id++;
332 if (acpi_gbl_next_method_owner_id == FIRST_TABLE_ID)
334 acpi_gbl_next_method_owner_id = FIRST_METHOD_ID;
340 acpi_cm_release_mutex (ACPI_MTX_CACHES);
346 /****************************************************************************
348 * FUNCTION: Acpi_cm_init_globals
352 * DESCRIPTION: Init library globals. All globals that require specific
353 * initialization should be initialized here!
355 ***************************************************************************/
358 acpi_cm_init_globals (
364 /* ACPI table structure */
366 for (i = 0; i < NUM_ACPI_TABLES; i++)
368 acpi_gbl_acpi_tables[i].prev = &acpi_gbl_acpi_tables[i];
369 acpi_gbl_acpi_tables[i].next = &acpi_gbl_acpi_tables[i];
370 acpi_gbl_acpi_tables[i].pointer = NULL;
371 acpi_gbl_acpi_tables[i].length = 0;
372 acpi_gbl_acpi_tables[i].allocation = ACPI_MEM_NOT_ALLOCATED;
373 acpi_gbl_acpi_tables[i].count = 0;
377 /* Address Space handler array */
379 for (i = 0; i < ACPI_NUM_ADDRESS_SPACES; i++)
381 acpi_gbl_address_spaces[i].handler = NULL;
382 acpi_gbl_address_spaces[i].context = NULL;
385 /* Mutex locked flags */
387 for (i = 0; i < NUM_MTX; i++)
389 acpi_gbl_acpi_mutex_info[i].mutex = NULL;
390 acpi_gbl_acpi_mutex_info[i].locked = FALSE;
391 acpi_gbl_acpi_mutex_info[i].use_count = 0;
394 /* Global notify handlers */
396 acpi_gbl_sys_notify.handler = NULL;
397 acpi_gbl_drv_notify.handler = NULL;
399 /* Global "typed" ACPI table pointers */
401 acpi_gbl_RSDP = NULL;
402 acpi_gbl_XSDT = NULL;
403 acpi_gbl_FACS = NULL;
404 acpi_gbl_FADT = NULL;
405 acpi_gbl_DSDT = NULL;
408 /* Global Lock support */
410 acpi_gbl_global_lock_acquired = FALSE;
411 acpi_gbl_global_lock_thread_count = 0;
413 /* Miscellaneous variables */
415 acpi_gbl_system_flags = 0;
416 acpi_gbl_startup_flags = 0;
417 acpi_gbl_rsdp_original_location = 0;
418 acpi_gbl_cm_single_step = FALSE;
419 acpi_gbl_db_terminate_threads = FALSE;
420 acpi_gbl_shutdown = FALSE;
421 acpi_gbl_ns_lookup_count = 0;
422 acpi_gbl_ps_find_count = 0;
423 acpi_gbl_acpi_hardware_present = TRUE;
424 acpi_gbl_next_table_owner_id = FIRST_TABLE_ID;
425 acpi_gbl_next_method_owner_id = FIRST_METHOD_ID;
426 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
428 /* Cache of small "state" objects */
430 acpi_gbl_generic_state_cache = NULL;
431 acpi_gbl_generic_state_cache_depth = 0;
432 acpi_gbl_state_cache_requests = 0;
433 acpi_gbl_state_cache_hits = 0;
435 acpi_gbl_parse_cache = NULL;
436 acpi_gbl_parse_cache_depth = 0;
437 acpi_gbl_parse_cache_requests = 0;
438 acpi_gbl_parse_cache_hits = 0;
440 acpi_gbl_ext_parse_cache = NULL;
441 acpi_gbl_ext_parse_cache_depth = 0;
442 acpi_gbl_ext_parse_cache_requests = 0;
443 acpi_gbl_ext_parse_cache_hits = 0;
445 acpi_gbl_object_cache = NULL;
446 acpi_gbl_object_cache_depth = 0;
447 acpi_gbl_object_cache_requests = 0;
448 acpi_gbl_object_cache_hits = 0;
450 acpi_gbl_walk_state_cache = NULL;
451 acpi_gbl_walk_state_cache_depth = 0;
452 acpi_gbl_walk_state_cache_requests = 0;
453 acpi_gbl_walk_state_cache_hits = 0;
455 /* Hardware oriented */
457 acpi_gbl_gpe0enable_register_save = NULL;
458 acpi_gbl_gpe1_enable_register_save = NULL;
459 acpi_gbl_original_mode = SYS_MODE_UNKNOWN; /* original ACPI/legacy mode */
460 acpi_gbl_gpe_registers = NULL;
461 acpi_gbl_gpe_info = NULL;
465 acpi_gbl_root_node = NULL;
467 acpi_gbl_root_node_struct.name = ACPI_ROOT_NAME;
468 acpi_gbl_root_node_struct.data_type = ACPI_DESC_TYPE_NAMED;
469 acpi_gbl_root_node_struct.type = ACPI_TYPE_ANY;
470 acpi_gbl_root_node_struct.child = NULL;
471 acpi_gbl_root_node_struct.peer = NULL;
472 acpi_gbl_root_node_struct.object = NULL;
473 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
475 /* Memory allocation metrics - compiled out in non-debug mode. */
477 INITIALIZE_ALLOCATION_METRICS();