1 /******************************************************************************
3 * Module Name: cmglobal - Global variables for the ACPI subsystem
6 *****************************************************************************/
9 * Copyright (C) 2000 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 MISCELLANEOUS
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
= 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 PREDEFINED_NAMES acpi_gbl_pre_defined_names
[] =
93 {"_GPE", INTERNAL_TYPE_DEF_ANY
},
94 {"_PR_", INTERNAL_TYPE_DEF_ANY
},
95 {"_SB_", INTERNAL_TYPE_DEF_ANY
},
96 {"_SI_", INTERNAL_TYPE_DEF_ANY
},
97 {"_TZ_", INTERNAL_TYPE_DEF_ANY
},
98 {"_REV", ACPI_TYPE_NUMBER
, "2"},
99 {"_OS_", ACPI_TYPE_STRING
, ACPI_OS_NAME
},
100 {"_GL_", ACPI_TYPE_MUTEX
, "0"},
102 /* Table terminator */
104 {NULL
, ACPI_TYPE_ANY
}
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 /******************************************************************************
159 * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
160 * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables
161 * that are not used by the subsystem are simply ignored.
163 ******************************************************************************/
166 ACPI_TABLE_DESC acpi_gbl_acpi_tables
[NUM_ACPI_TABLES
];
169 ACPI_TABLE_SUPPORT acpi_gbl_acpi_table_data
[NUM_ACPI_TABLES
] =
171 /*********** Name, Signature, Signature size, How many allowed?, Supported? Global typed pointer */
173 /* RSDP 0 */ {RSDP_NAME
, RSDP_SIG
, sizeof (RSDP_SIG
)-1, ACPI_TABLE_SINGLE
, AE_OK
, NULL
},
174 /* DSDT 1 */ {DSDT_SIG
, DSDT_SIG
, sizeof (DSDT_SIG
)-1, ACPI_TABLE_SINGLE
, AE_OK
, (void **) &acpi_gbl_DSDT
},
175 /* FADT 2 */ {FADT_SIG
, FADT_SIG
, sizeof (FADT_SIG
)-1, ACPI_TABLE_SINGLE
, AE_OK
, (void **) &acpi_gbl_FADT
},
176 /* FACS 3 */ {FACS_SIG
, FACS_SIG
, sizeof (FACS_SIG
)-1, ACPI_TABLE_SINGLE
, AE_OK
, (void **) &acpi_gbl_FACS
},
177 /* PSDT 4 */ {PSDT_SIG
, PSDT_SIG
, sizeof (PSDT_SIG
)-1, ACPI_TABLE_MULTIPLE
, AE_OK
, NULL
},
178 /* SSDT 5 */ {SSDT_SIG
, SSDT_SIG
, sizeof (SSDT_SIG
)-1, ACPI_TABLE_MULTIPLE
, AE_OK
, NULL
},
179 /* XSDT 6 */ {XSDT_SIG
, XSDT_SIG
, sizeof (RSDT_SIG
)-1, ACPI_TABLE_SINGLE
, AE_OK
, NULL
},
183 /*****************************************************************************
185 * FUNCTION: Acpi_cm_valid_object_type
189 * RETURN: TRUE if valid object type
191 * DESCRIPTION: Validate an object type
193 ****************************************************************************/
196 acpi_cm_valid_object_type (
200 if (type
> ACPI_TYPE_MAX
) {
201 if ((type
< INTERNAL_TYPE_BEGIN
) ||
202 (type
> INTERNAL_TYPE_MAX
))
212 /*****************************************************************************
214 * FUNCTION: Acpi_cm_format_exception
216 * PARAMETERS: Status - Acpi status to be formatted
218 * RETURN: Formatted status string
220 * DESCRIPTION: Convert an ACPI exception to a string
222 ****************************************************************************/
225 acpi_cm_format_exception (
228 NATIVE_CHAR
*exception
= "UNKNOWN_STATUS";
229 ACPI_STATUS sub_status
;
232 sub_status
= (status
& ~AE_CODE_MASK
);
235 switch (status
& AE_CODE_MASK
)
237 case AE_CODE_ENVIRONMENTAL
:
239 if (sub_status
<= AE_CODE_ENV_MAX
) {
240 exception
= acpi_gbl_exception_names_env
[sub_status
];
244 case AE_CODE_PROGRAMMER
:
246 if (sub_status
<= AE_CODE_PGM_MAX
) {
247 exception
= acpi_gbl_exception_names_pgm
[sub_status
-1];
251 case AE_CODE_ACPI_TABLES
:
253 if (sub_status
<= AE_CODE_TBL_MAX
) {
254 exception
= acpi_gbl_exception_names_tbl
[sub_status
-1];
260 if (sub_status
<= AE_CODE_AML_MAX
) {
261 exception
= acpi_gbl_exception_names_aml
[sub_status
-1];
265 case AE_CODE_CONTROL
:
267 if (sub_status
<= AE_CODE_CTRL_MAX
) {
268 exception
= acpi_gbl_exception_names_ctrl
[sub_status
-1];
281 /****************************************************************************
283 * FUNCTION: Acpi_cm_allocate_owner_id
285 * PARAMETERS: Id_type - Type of ID (method or table)
287 * DESCRIPTION: Allocate a table or method owner id
289 ***************************************************************************/
292 acpi_cm_allocate_owner_id (
295 ACPI_OWNER_ID owner_id
= 0xFFFF;
298 acpi_cm_acquire_mutex (ACPI_MTX_CACHES
);
302 case OWNER_TYPE_TABLE
:
304 owner_id
= acpi_gbl_next_table_owner_id
;
305 acpi_gbl_next_table_owner_id
++;
307 if (acpi_gbl_next_table_owner_id
== FIRST_METHOD_ID
) {
308 acpi_gbl_next_table_owner_id
= FIRST_TABLE_ID
;
313 case OWNER_TYPE_METHOD
:
315 owner_id
= acpi_gbl_next_method_owner_id
;
316 acpi_gbl_next_method_owner_id
++;
318 if (acpi_gbl_next_method_owner_id
== FIRST_TABLE_ID
) {
319 acpi_gbl_next_method_owner_id
= FIRST_METHOD_ID
;
325 acpi_cm_release_mutex (ACPI_MTX_CACHES
);
331 /****************************************************************************
333 * FUNCTION: Acpi_cm_init_globals
337 * DESCRIPTION: Init library globals. All globals that require specific
338 * initialization should be initialized here!
340 ***************************************************************************/
343 acpi_cm_init_globals (
349 /* ACPI table structure */
351 for (i
= 0; i
< NUM_ACPI_TABLES
; i
++) {
352 acpi_gbl_acpi_tables
[i
].prev
= &acpi_gbl_acpi_tables
[i
];
353 acpi_gbl_acpi_tables
[i
].next
= &acpi_gbl_acpi_tables
[i
];
354 acpi_gbl_acpi_tables
[i
].pointer
= NULL
;
355 acpi_gbl_acpi_tables
[i
].length
= 0;
356 acpi_gbl_acpi_tables
[i
].allocation
= ACPI_MEM_NOT_ALLOCATED
;
357 acpi_gbl_acpi_tables
[i
].count
= 0;
361 /* Address Space handler array */
363 for (i
= 0; i
< ACPI_NUM_ADDRESS_SPACES
; i
++) {
364 acpi_gbl_address_spaces
[i
].handler
= NULL
;
365 acpi_gbl_address_spaces
[i
].context
= NULL
;
368 /* Mutex locked flags */
370 for (i
= 0; i
< NUM_MTX
; i
++) {
371 acpi_gbl_acpi_mutex_info
[i
].mutex
= NULL
;
372 acpi_gbl_acpi_mutex_info
[i
].locked
= FALSE
;
373 acpi_gbl_acpi_mutex_info
[i
].use_count
= 0;
376 /* Global notify handlers */
378 acpi_gbl_sys_notify
.handler
= NULL
;
379 acpi_gbl_drv_notify
.handler
= NULL
;
381 /* Global "typed" ACPI table pointers */
383 acpi_gbl_RSDP
= NULL
;
384 acpi_gbl_XSDT
= NULL
;
385 acpi_gbl_FACS
= NULL
;
386 acpi_gbl_FADT
= NULL
;
387 acpi_gbl_DSDT
= NULL
;
390 /* Global Lock support */
392 acpi_gbl_global_lock_acquired
= FALSE
;
393 acpi_gbl_global_lock_thread_count
= 0;
395 /* Miscellaneous variables */
397 acpi_gbl_system_flags
= 0;
398 acpi_gbl_startup_flags
= 0;
399 acpi_gbl_global_lock_set
= FALSE
;
400 acpi_gbl_rsdp_original_location
= 0;
401 acpi_gbl_cm_single_step
= FALSE
;
402 acpi_gbl_db_terminate_threads
= FALSE
;
403 acpi_gbl_shutdown
= FALSE
;
404 acpi_gbl_ns_lookup_count
= 0;
405 acpi_gbl_ps_find_count
= 0;
406 acpi_gbl_acpi_hardware_present
= TRUE
;
407 acpi_gbl_next_table_owner_id
= FIRST_TABLE_ID
;
408 acpi_gbl_next_method_owner_id
= FIRST_METHOD_ID
;
409 acpi_gbl_debugger_configuration
= DEBUGGER_THREADING
;
411 /* Cache of small "state" objects */
413 acpi_gbl_generic_state_cache
= NULL
;
414 acpi_gbl_generic_state_cache_depth
= 0;
415 acpi_gbl_state_cache_requests
= 0;
416 acpi_gbl_state_cache_hits
= 0;
418 acpi_gbl_parse_cache
= NULL
;
419 acpi_gbl_parse_cache_depth
= 0;
420 acpi_gbl_parse_cache_requests
= 0;
421 acpi_gbl_parse_cache_hits
= 0;
423 acpi_gbl_ext_parse_cache
= NULL
;
424 acpi_gbl_ext_parse_cache_depth
= 0;
425 acpi_gbl_ext_parse_cache_requests
= 0;
426 acpi_gbl_ext_parse_cache_hits
= 0;
428 acpi_gbl_object_cache
= NULL
;
429 acpi_gbl_object_cache_depth
= 0;
430 acpi_gbl_object_cache_requests
= 0;
431 acpi_gbl_object_cache_hits
= 0;
433 acpi_gbl_walk_state_cache
= NULL
;
434 acpi_gbl_walk_state_cache_depth
= 0;
435 acpi_gbl_walk_state_cache_requests
= 0;
436 acpi_gbl_walk_state_cache_hits
= 0;
438 /* Hardware oriented */
440 acpi_gbl_gpe0enable_register_save
= NULL
;
441 acpi_gbl_gpe1_enable_register_save
= NULL
;
442 acpi_gbl_original_mode
= SYS_MODE_UNKNOWN
; /* original ACPI/legacy mode */
443 acpi_gbl_gpe_registers
= NULL
;
444 acpi_gbl_gpe_info
= NULL
;
448 acpi_gbl_root_node
= NULL
;
450 acpi_gbl_root_node_struct
.name
= ACPI_ROOT_NAME
;
451 acpi_gbl_root_node_struct
.data_type
= ACPI_DESC_TYPE_NAMED
;
452 acpi_gbl_root_node_struct
.type
= ACPI_TYPE_ANY
;
453 acpi_gbl_root_node_struct
.child
= NULL
;
454 acpi_gbl_root_node_struct
.peer
= NULL
;
455 acpi_gbl_root_node_struct
.object
= NULL
;
456 acpi_gbl_root_node_struct
.flags
= ANOBJ_END_OF_PEER_LIST
;
458 /* Memory allocation metrics - compiled out in non-debug mode. */
460 INITIALIZE_ALLOCATION_METRICS();