1 /******************************************************************************
2  *
3  * Name: acglobal.h - Declarations for global variables
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2012, Intel Corp.
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 #ifndef __ACGLOBAL_H__
45 #define __ACGLOBAL_H__
46 
47 /*
48  * Ensure that the globals are actually defined and initialized only once.
49  *
50  * The use of these macros allows a single list of globals (here) in order
51  * to simplify maintenance of the code.
52  */
53 #ifdef DEFINE_ACPI_GLOBALS
54 #define ACPI_EXTERN
55 #define ACPI_INIT_GLOBAL(a,b) a=b
56 #else
57 #define ACPI_EXTERN extern
58 #define ACPI_INIT_GLOBAL(a,b) a
59 #endif
60 
61 #ifdef DEFINE_ACPI_GLOBALS
62 
63 /* Public globals, available from outside ACPICA subsystem */
64 
65 /*****************************************************************************
66  *
67  * Runtime configuration (static defaults that can be overriden at runtime)
68  *
69  ****************************************************************************/
70 
71 /*
72  * Enable "slack" in the AML interpreter?  Default is FALSE, and the
73  * interpreter strictly follows the ACPI specification.  Setting to TRUE
74  * allows the interpreter to ignore certain errors and/or bad AML constructs.
75  *
76  * Currently, these features are enabled by this flag:
77  *
78  * 1) Allow "implicit return" of last value in a control method
79  * 2) Allow access beyond the end of an operation region
80  * 3) Allow access to uninitialized locals/args (auto-init to integer 0)
81  * 4) Allow ANY object type to be a source operand for the Store() operator
82  * 5) Allow unresolved references (invalid target name) in package objects
83  * 6) Enable warning messages for behavior that is not ACPI spec compliant
84  */
85 u8 ACPI_INIT_GLOBAL(acpi_gbl_enable_interpreter_slack, FALSE);
86 
87 /*
88  * Automatically serialize ALL control methods? Default is FALSE, meaning
89  * to use the Serialized/not_serialized method flags on a per method basis.
90  * Only change this if the ASL code is poorly written and cannot handle
91  * reentrancy even though methods are marked "NotSerialized".
92  */
93 u8 ACPI_INIT_GLOBAL(acpi_gbl_all_methods_serialized, FALSE);
94 
95 /*
96  * Create the predefined _OSI method in the namespace? Default is TRUE
97  * because ACPI CA is fully compatible with other ACPI implementations.
98  * Changing this will revert ACPI CA (and machine ASL) to pre-OSI behavior.
99  */
100 u8 ACPI_INIT_GLOBAL(acpi_gbl_create_osi_method, TRUE);
101 
102 /*
103  * Optionally use default values for the ACPI register widths. Set this to
104  * TRUE to use the defaults, if an FADT contains incorrect widths/lengths.
105  */
106 u8 ACPI_INIT_GLOBAL(acpi_gbl_use_default_register_widths, TRUE);
107 
108 /*
109  * Optionally enable output from the AML Debug Object.
110  */
111 bool ACPI_INIT_GLOBAL(acpi_gbl_enable_aml_debug_object, FALSE);
112 
113 /*
114  * Optionally copy the entire DSDT to local memory (instead of simply
115  * mapping it.) There are some BIOSs that corrupt or replace the original
116  * DSDT, creating the need for this option. Default is FALSE, do not copy
117  * the DSDT.
118  */
119 u8 ACPI_INIT_GLOBAL(acpi_gbl_copy_dsdt_locally, FALSE);
120 
121 /*
122  * Optionally truncate I/O addresses to 16 bits. Provides compatibility
123  * with other ACPI implementations. NOTE: During ACPICA initialization,
124  * this value is set to TRUE if any Windows OSI strings have been
125  * requested by the BIOS.
126  */
127 u8 ACPI_INIT_GLOBAL(acpi_gbl_truncate_io_addresses, FALSE);
128 
129 /*
130  * Disable runtime checking and repair of values returned by control methods.
131  * Use only if the repair is causing a problem on a particular machine.
132  */
133 u8 ACPI_INIT_GLOBAL(acpi_gbl_disable_auto_repair, FALSE);
134 
135 /* acpi_gbl_FADT is a local copy of the FADT, converted to a common format. */
136 
137 struct acpi_table_fadt acpi_gbl_FADT;
138 u32 acpi_current_gpe_count;
139 u32 acpi_gbl_trace_flags;
140 acpi_name acpi_gbl_trace_method_name;
141 u8 acpi_gbl_system_awake_and_running;
142 
143 /*
144  * ACPI 5.0 introduces the concept of a "reduced hardware platform", meaning
145  * that the ACPI hardware is no longer required. A flag in the FADT indicates
146  * a reduced HW machine, and that flag is duplicated here for convenience.
147  */
148 u8 acpi_gbl_reduced_hardware;
149 
150 #endif				/* DEFINE_ACPI_GLOBALS */
151 
152 /* Do not disassemble buffers to resource descriptors */
153 
154 ACPI_EXTERN u8 ACPI_INIT_GLOBAL(acpi_gbl_no_resource_disassembly, FALSE);
155 
156 /*****************************************************************************
157  *
158  * Debug support
159  *
160  ****************************************************************************/
161 
162 /* Procedure nesting level for debug output */
163 
164 extern u32 acpi_gbl_nesting_level;
165 
166 ACPI_EXTERN u32 acpi_gpe_count;
167 ACPI_EXTERN u32 acpi_fixed_event_count[ACPI_NUM_FIXED_EVENTS];
168 
169 /* Support for dynamic control method tracing mechanism */
170 
171 ACPI_EXTERN u32 acpi_gbl_original_dbg_level;
172 ACPI_EXTERN u32 acpi_gbl_original_dbg_layer;
173 ACPI_EXTERN u32 acpi_gbl_trace_dbg_level;
174 ACPI_EXTERN u32 acpi_gbl_trace_dbg_layer;
175 
176 /*****************************************************************************
177  *
178  * ACPI Table globals
179  *
180  ****************************************************************************/
181 
182 /*
183  * acpi_gbl_root_table_list is the master list of ACPI tables that were
184  * found in the RSDT/XSDT.
185  */
186 ACPI_EXTERN struct acpi_table_list acpi_gbl_root_table_list;
187 
188 #if (!ACPI_REDUCED_HARDWARE)
189 ACPI_EXTERN struct acpi_table_facs *acpi_gbl_FACS;
190 
191 #endif				/* !ACPI_REDUCED_HARDWARE */
192 
193 /* These addresses are calculated from the FADT Event Block addresses */
194 
195 ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_status;
196 ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1a_enable;
197 
198 ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_status;
199 ACPI_EXTERN struct acpi_generic_address acpi_gbl_xpm1b_enable;
200 
201 /* DSDT information. Used to check for DSDT corruption */
202 
203 ACPI_EXTERN struct acpi_table_header *acpi_gbl_DSDT;
204 ACPI_EXTERN struct acpi_table_header acpi_gbl_original_dsdt_header;
205 
206 /*
207  * Handle both ACPI 1.0 and ACPI 2.0 Integer widths. The integer width is
208  * determined by the revision of the DSDT: If the DSDT revision is less than
209  * 2, use only the lower 32 bits of the internal 64-bit Integer.
210  */
211 ACPI_EXTERN u8 acpi_gbl_integer_bit_width;
212 ACPI_EXTERN u8 acpi_gbl_integer_byte_width;
213 ACPI_EXTERN u8 acpi_gbl_integer_nybble_width;
214 
215 /* Mutex for _OSI support */
216 
217 ACPI_EXTERN acpi_mutex acpi_gbl_osi_mutex;
218 
219 /* Reader/Writer lock is used for namespace walk and dynamic table unload */
220 
221 ACPI_EXTERN struct acpi_rw_lock acpi_gbl_namespace_rw_lock;
222 
223 /*****************************************************************************
224  *
225  * Mutual exclusion within ACPICA subsystem
226  *
227  ****************************************************************************/
228 
229 /*
230  * Predefined mutex objects. This array contains the
231  * actual OS mutex handles, indexed by the local ACPI_MUTEX_HANDLEs.
232  * (The table maps local handles to the real OS handles)
233  */
234 ACPI_EXTERN struct acpi_mutex_info acpi_gbl_mutex_info[ACPI_NUM_MUTEX];
235 
236 /*
237  * Global lock mutex is an actual AML mutex object
238  * Global lock semaphore works in conjunction with the actual global lock
239  * Global lock spinlock is used for "pending" handshake
240  */
241 ACPI_EXTERN union acpi_operand_object *acpi_gbl_global_lock_mutex;
242 ACPI_EXTERN acpi_semaphore acpi_gbl_global_lock_semaphore;
243 ACPI_EXTERN acpi_spinlock acpi_gbl_global_lock_pending_lock;
244 ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
245 ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
246 ACPI_EXTERN u8 acpi_gbl_global_lock_present;
247 ACPI_EXTERN u8 acpi_gbl_global_lock_pending;
248 
249 /*
250  * Spinlocks are used for interfaces that can be possibly called at
251  * interrupt level
252  */
253 ACPI_EXTERN acpi_spinlock acpi_gbl_gpe_lock;	/* For GPE data structs and registers */
254 ACPI_EXTERN acpi_spinlock acpi_gbl_hardware_lock;	/* For ACPI H/W except GPE registers */
255 
256 /*****************************************************************************
257  *
258  * Miscellaneous globals
259  *
260  ****************************************************************************/
261 
262 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
263 
264 /* Lists for tracking memory allocations */
265 
266 ACPI_EXTERN struct acpi_memory_list *acpi_gbl_global_list;
267 ACPI_EXTERN struct acpi_memory_list *acpi_gbl_ns_node_list;
268 ACPI_EXTERN u8 acpi_gbl_display_final_mem_stats;
269 #endif
270 
271 /* Object caches */
272 
273 ACPI_EXTERN acpi_cache_t *acpi_gbl_namespace_cache;
274 ACPI_EXTERN acpi_cache_t *acpi_gbl_state_cache;
275 ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_cache;
276 ACPI_EXTERN acpi_cache_t *acpi_gbl_ps_node_ext_cache;
277 ACPI_EXTERN acpi_cache_t *acpi_gbl_operand_cache;
278 
279 /* Global handlers */
280 
281 ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_device_notify;
282 ACPI_EXTERN struct acpi_object_notify_handler acpi_gbl_system_notify;
283 ACPI_EXTERN acpi_exception_handler acpi_gbl_exception_handler;
284 ACPI_EXTERN acpi_init_handler acpi_gbl_init_handler;
285 ACPI_EXTERN acpi_tbl_handler acpi_gbl_table_handler;
286 ACPI_EXTERN void *acpi_gbl_table_handler_context;
287 ACPI_EXTERN struct acpi_walk_state *acpi_gbl_breakpoint_walk;
288 ACPI_EXTERN acpi_interface_handler acpi_gbl_interface_handler;
289 
290 /* Owner ID support */
291 
292 ACPI_EXTERN u32 acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS];
293 ACPI_EXTERN u8 acpi_gbl_last_owner_id_index;
294 ACPI_EXTERN u8 acpi_gbl_next_owner_id_offset;
295 
296 /* Initialization sequencing */
297 
298 ACPI_EXTERN u8 acpi_gbl_reg_methods_executed;
299 
300 /* Misc */
301 
302 ACPI_EXTERN u32 acpi_gbl_original_mode;
303 ACPI_EXTERN u32 acpi_gbl_rsdp_original_location;
304 ACPI_EXTERN u32 acpi_gbl_ns_lookup_count;
305 ACPI_EXTERN u32 acpi_gbl_ps_find_count;
306 ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save;
307 ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
308 ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
309 ACPI_EXTERN u8 acpi_gbl_acpi_hardware_present;
310 ACPI_EXTERN u8 acpi_gbl_events_initialized;
311 ACPI_EXTERN u8 acpi_gbl_osi_data;
312 ACPI_EXTERN struct acpi_interface_info *acpi_gbl_supported_interfaces;
313 ACPI_EXTERN struct acpi_address_range
314     *acpi_gbl_address_range_list[ACPI_ADDRESS_RANGE_MAX];
315 
316 #ifndef DEFINE_ACPI_GLOBALS
317 
318 /* Other miscellaneous */
319 
320 extern u8 acpi_gbl_shutdown;
321 extern u32 acpi_gbl_startup_flags;
322 extern const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT];
323 extern const char *acpi_gbl_lowest_dstate_names[ACPI_NUM_sx_w_METHODS];
324 extern const char *acpi_gbl_highest_dstate_names[ACPI_NUM_sx_d_METHODS];
325 extern const struct acpi_opcode_info acpi_gbl_aml_op_info[AML_NUM_OPCODES];
326 extern const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS];
327 
328 #endif
329 
330 /* Exception codes */
331 
332 extern char const *acpi_gbl_exception_names_env[];
333 extern char const *acpi_gbl_exception_names_pgm[];
334 extern char const *acpi_gbl_exception_names_tbl[];
335 extern char const *acpi_gbl_exception_names_aml[];
336 extern char const *acpi_gbl_exception_names_ctrl[];
337 
338 /*****************************************************************************
339  *
340  * Namespace globals
341  *
342  ****************************************************************************/
343 
344 #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
345 #define NUM_PREDEFINED_NAMES            10
346 #else
347 #define NUM_PREDEFINED_NAMES            9
348 #endif
349 
350 ACPI_EXTERN struct acpi_namespace_node acpi_gbl_root_node_struct;
351 ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_root_node;
352 ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_fadt_gpe_device;
353 ACPI_EXTERN union acpi_operand_object *acpi_gbl_module_code_list;
354 
355 extern const u8 acpi_gbl_ns_properties[ACPI_NUM_NS_TYPES];
356 extern const struct acpi_predefined_names
357     acpi_gbl_pre_defined_names[NUM_PREDEFINED_NAMES];
358 
359 #ifdef ACPI_DEBUG_OUTPUT
360 ACPI_EXTERN u32 acpi_gbl_current_node_count;
361 ACPI_EXTERN u32 acpi_gbl_current_node_size;
362 ACPI_EXTERN u32 acpi_gbl_max_concurrent_node_count;
363 ACPI_EXTERN acpi_size *acpi_gbl_entry_stack_pointer;
364 ACPI_EXTERN acpi_size *acpi_gbl_lowest_stack_pointer;
365 ACPI_EXTERN u32 acpi_gbl_deepest_nesting;
366 #endif
367 
368 /*****************************************************************************
369  *
370  * Interpreter globals
371  *
372  ****************************************************************************/
373 
374 ACPI_EXTERN struct acpi_thread_state *acpi_gbl_current_walk_list;
375 
376 /* Control method single step flag */
377 
378 ACPI_EXTERN u8 acpi_gbl_cm_single_step;
379 
380 /*****************************************************************************
381  *
382  * Hardware globals
383  *
384  ****************************************************************************/
385 
386 extern struct acpi_bit_register_info
387     acpi_gbl_bit_register_info[ACPI_NUM_BITREG];
388 ACPI_EXTERN u8 acpi_gbl_sleep_type_a;
389 ACPI_EXTERN u8 acpi_gbl_sleep_type_b;
390 
391 /*****************************************************************************
392  *
393  * Event and GPE globals
394  *
395  ****************************************************************************/
396 
397 extern struct acpi_fixed_event_info
398     acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS];
399 ACPI_EXTERN struct acpi_fixed_event_handler
400     acpi_gbl_fixed_event_handlers[ACPI_NUM_FIXED_EVENTS];
401 ACPI_EXTERN struct acpi_gpe_xrupt_info *acpi_gbl_gpe_xrupt_list_head;
402 ACPI_EXTERN struct acpi_gpe_block_info
403 *acpi_gbl_gpe_fadt_blocks[ACPI_MAX_GPE_BLOCKS];
404 
405 #if (!ACPI_REDUCED_HARDWARE)
406 
407 ACPI_EXTERN u8 acpi_gbl_all_gpes_initialized;
408 ACPI_EXTERN ACPI_GBL_EVENT_HANDLER acpi_gbl_global_event_handler;
409 ACPI_EXTERN void *acpi_gbl_global_event_handler_context;
410 
411 #endif				/* !ACPI_REDUCED_HARDWARE */
412 
413 /*****************************************************************************
414  *
415  * Debugger globals
416  *
417  ****************************************************************************/
418 
419 ACPI_EXTERN u8 acpi_gbl_db_output_flags;
420 
421 #ifdef ACPI_DISASSEMBLER
422 
423 ACPI_EXTERN u8 acpi_gbl_db_opt_disasm;
424 ACPI_EXTERN u8 acpi_gbl_db_opt_verbose;
425 #endif
426 
427 #ifdef ACPI_DEBUGGER
428 
429 extern u8 acpi_gbl_method_executing;
430 extern u8 acpi_gbl_abort_method;
431 extern u8 acpi_gbl_db_terminate_threads;
432 
433 ACPI_EXTERN u8 acpi_gbl_db_opt_tables;
434 ACPI_EXTERN u8 acpi_gbl_db_opt_stats;
435 ACPI_EXTERN u8 acpi_gbl_db_opt_ini_methods;
436 
437 ACPI_EXTERN char *acpi_gbl_db_args[ACPI_DEBUGGER_MAX_ARGS];
438 ACPI_EXTERN char acpi_gbl_db_line_buf[80];
439 ACPI_EXTERN char acpi_gbl_db_parsed_buf[80];
440 ACPI_EXTERN char acpi_gbl_db_scope_buf[40];
441 ACPI_EXTERN char acpi_gbl_db_debug_filename[40];
442 ACPI_EXTERN u8 acpi_gbl_db_output_to_file;
443 ACPI_EXTERN char *acpi_gbl_db_buffer;
444 ACPI_EXTERN char *acpi_gbl_db_filename;
445 ACPI_EXTERN u32 acpi_gbl_db_debug_level;
446 ACPI_EXTERN u32 acpi_gbl_db_console_debug_level;
447 ACPI_EXTERN struct acpi_namespace_node *acpi_gbl_db_scope_node;
448 
449 /*
450  * Statistic globals
451  */
452 ACPI_EXTERN u16 acpi_gbl_obj_type_count[ACPI_TYPE_NS_NODE_MAX + 1];
453 ACPI_EXTERN u16 acpi_gbl_node_type_count[ACPI_TYPE_NS_NODE_MAX + 1];
454 ACPI_EXTERN u16 acpi_gbl_obj_type_count_misc;
455 ACPI_EXTERN u16 acpi_gbl_node_type_count_misc;
456 ACPI_EXTERN u32 acpi_gbl_num_nodes;
457 ACPI_EXTERN u32 acpi_gbl_num_objects;
458 
459 ACPI_EXTERN u32 acpi_gbl_size_of_parse_tree;
460 ACPI_EXTERN u32 acpi_gbl_size_of_method_trees;
461 ACPI_EXTERN u32 acpi_gbl_size_of_node_entries;
462 ACPI_EXTERN u32 acpi_gbl_size_of_acpi_objects;
463 
464 #endif				/* ACPI_DEBUGGER */
465 
466 #endif				/* __ACGLOBAL_H__ */
467