1 /******************************************************************************
3 * Module Name: utglobal - Global variables for the ACPI subsystem
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2005, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
44 #define DEFINE_ACPI_GLOBALS
46 #include <linux/module.h>
48 #include <acpi/acpi.h>
49 #include <acpi/acnamesp.h>
51 #define _COMPONENT ACPI_UTILITIES
52 ACPI_MODULE_NAME ("utglobal")
55 /******************************************************************************
57 * FUNCTION: acpi_format_exception
59 * PARAMETERS: Status - The acpi_status code to be formatted
61 * RETURN: A string containing the exception text
63 * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
65 ******************************************************************************/
68 acpi_format_exception (
71 const char *exception = "UNKNOWN_STATUS_CODE";
72 acpi_status sub_status;
75 ACPI_FUNCTION_NAME ("format_exception");
78 sub_status = (status & ~AE_CODE_MASK);
80 switch (status & AE_CODE_MASK) {
81 case AE_CODE_ENVIRONMENTAL:
83 if (sub_status <= AE_CODE_ENV_MAX) {
84 exception = acpi_gbl_exception_names_env [sub_status];
89 case AE_CODE_PROGRAMMER:
91 if (sub_status <= AE_CODE_PGM_MAX) {
92 exception = acpi_gbl_exception_names_pgm [sub_status -1];
97 case AE_CODE_ACPI_TABLES:
99 if (sub_status <= AE_CODE_TBL_MAX) {
100 exception = acpi_gbl_exception_names_tbl [sub_status -1];
107 if (sub_status <= AE_CODE_AML_MAX) {
108 exception = acpi_gbl_exception_names_aml [sub_status -1];
113 case AE_CODE_CONTROL:
115 if (sub_status <= AE_CODE_CTRL_MAX) {
116 exception = acpi_gbl_exception_names_ctrl [sub_status -1];
126 return ((const char *) exception);
130 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown exception code: 0x%8.8X\n", status));
131 return ((const char *) exception);
135 /******************************************************************************
137 * Static global variable initialization.
139 ******************************************************************************/
142 * We want the debug switches statically initialized so they
143 * are already set when the debugger is entered.
146 /* Debug switch - level and trace mask */
147 u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
148 EXPORT_SYMBOL(acpi_dbg_level);
150 /* Debug switch - layer (component) mask */
152 u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
153 EXPORT_SYMBOL(acpi_dbg_layer);
154 u32 acpi_gbl_nesting_level = 0;
157 /* Debugger globals */
159 u8 acpi_gbl_db_terminate_threads = FALSE;
160 u8 acpi_gbl_abort_method = FALSE;
161 u8 acpi_gbl_method_executing = FALSE;
165 u32 acpi_gbl_startup_flags = 0;
167 /* System starts uninitialized */
169 u8 acpi_gbl_shutdown = TRUE;
171 const u8 acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128};
173 const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] =
183 const char *acpi_gbl_highest_dstate_names[4] =
192 * Strings supported by the _OSI predefined (internal) method.
193 * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS.
195 const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] =
209 /******************************************************************************
213 ******************************************************************************/
217 * Predefined ACPI Names (Built-in to the Interpreter)
220 * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
221 * during the initialization sequence.
222 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
223 * perform a Notify() operation on it.
225 const struct acpi_predefined_names acpi_gbl_pre_defined_names[] =
226 { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
227 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
228 {"_SB_", ACPI_TYPE_DEVICE, NULL},
229 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
230 {"_TZ_", ACPI_TYPE_THERMAL, NULL},
231 {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL},
232 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
233 {"_GL_", ACPI_TYPE_MUTEX, (char *) 1},
235 #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
236 {"_OSI", ACPI_TYPE_METHOD, (char *) 1},
238 {NULL, ACPI_TYPE_ANY, NULL} /* Table terminator */
243 * Properties of the ACPI Object Types, both internal and external.
244 * The table is indexed by values of acpi_object_type
246 const u8 acpi_gbl_ns_properties[] =
248 ACPI_NS_NORMAL, /* 00 Any */
249 ACPI_NS_NORMAL, /* 01 Number */
250 ACPI_NS_NORMAL, /* 02 String */
251 ACPI_NS_NORMAL, /* 03 Buffer */
252 ACPI_NS_NORMAL, /* 04 Package */
253 ACPI_NS_NORMAL, /* 05 field_unit */
254 ACPI_NS_NEWSCOPE, /* 06 Device */
255 ACPI_NS_NORMAL, /* 07 Event */
256 ACPI_NS_NEWSCOPE, /* 08 Method */
257 ACPI_NS_NORMAL, /* 09 Mutex */
258 ACPI_NS_NORMAL, /* 10 Region */
259 ACPI_NS_NEWSCOPE, /* 11 Power */
260 ACPI_NS_NEWSCOPE, /* 12 Processor */
261 ACPI_NS_NEWSCOPE, /* 13 Thermal */
262 ACPI_NS_NORMAL, /* 14 buffer_field */
263 ACPI_NS_NORMAL, /* 15 ddb_handle */
264 ACPI_NS_NORMAL, /* 16 Debug Object */
265 ACPI_NS_NORMAL, /* 17 def_field */
266 ACPI_NS_NORMAL, /* 18 bank_field */
267 ACPI_NS_NORMAL, /* 19 index_field */
268 ACPI_NS_NORMAL, /* 20 Reference */
269 ACPI_NS_NORMAL, /* 21 Alias */
270 ACPI_NS_NORMAL, /* 22 method_alias */
271 ACPI_NS_NORMAL, /* 23 Notify */
272 ACPI_NS_NORMAL, /* 24 Address Handler */
273 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
274 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
275 ACPI_NS_NEWSCOPE, /* 27 Scope */
276 ACPI_NS_NORMAL, /* 28 Extra */
277 ACPI_NS_NORMAL, /* 29 Data */
278 ACPI_NS_NORMAL /* 30 Invalid */
282 /* Hex to ASCII conversion table */
284 static const char acpi_gbl_hex_to_ascii[] =
285 {'0','1','2','3','4','5','6','7',
286 '8','9','A','B','C','D','E','F'};
288 /*****************************************************************************
290 * FUNCTION: acpi_ut_hex_to_ascii_char
292 * PARAMETERS: Integer - Contains the hex digit
293 * Position - bit position of the digit within the
296 * RETURN: Ascii character
298 * DESCRIPTION: Convert a hex digit to an ascii character
300 ****************************************************************************/
303 acpi_ut_hex_to_ascii_char (
304 acpi_integer integer,
308 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
312 /******************************************************************************
316 * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
317 * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables
318 * that are not used by the subsystem are simply ignored.
320 * Do NOT add any table to this list that is not consumed directly by this
323 ******************************************************************************/
325 struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
327 struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] =
329 /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */
331 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE},
332 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *) &acpi_gbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE},
333 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *) &acpi_gbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE},
334 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *) &acpi_gbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE},
335 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
336 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
337 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE},
341 /******************************************************************************
343 * Event and Hardware globals
345 ******************************************************************************/
347 struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] =
349 /* Name Parent Register Register Bit Position Register Bit Mask */
351 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS},
352 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS},
353 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS},
354 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS},
355 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS},
356 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS},
357 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS},
359 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE},
360 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
361 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE},
362 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
363 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE},
364 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
366 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE},
367 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD},
368 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
369 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X},
370 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X},
371 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE},
373 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE}
377 struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
379 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE},
380 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
381 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE},
382 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
383 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE},
386 /*****************************************************************************
388 * FUNCTION: acpi_ut_get_region_name
394 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
396 ****************************************************************************/
398 /* Region type decoding */
400 const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] =
402 /*! [Begin] no source code translation (keep these ASL Keywords as-is) */
411 /*! [End] no source code translation !*/
416 acpi_ut_get_region_name (
420 if (space_id >= ACPI_USER_REGION_BEGIN)
422 return ("user_defined_region");
425 else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS)
427 return ("invalid_space_id");
430 return ((char *) acpi_gbl_region_types[space_id]);
434 /*****************************************************************************
436 * FUNCTION: acpi_ut_get_event_name
442 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
444 ****************************************************************************/
446 /* Event type decoding */
448 static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] =
459 acpi_ut_get_event_name (
463 if (event_id > ACPI_EVENT_MAX)
465 return ("invalid_event_iD");
468 return ((char *) acpi_gbl_event_types[event_id]);
472 /*****************************************************************************
474 * FUNCTION: acpi_ut_get_type_name
480 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
482 ****************************************************************************/
485 * Elements of acpi_gbl_ns_type_names below must match
486 * one-to-one with values of acpi_object_type
488 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; when
489 * stored in a table it really means that we have thus far seen no evidence to
490 * indicate what type is actually going to be stored for this entry.
492 static const char acpi_gbl_bad_type[] = "UNDEFINED";
493 #define TYPE_NAME_LENGTH 12 /* Maximum length of each string */
495 static const char *acpi_gbl_ns_type_names[] = /* printable names of ACPI types */
502 /* 05 */ "field_unit",
509 /* 12 */ "Processor",
511 /* 14 */ "buffer_field",
512 /* 15 */ "ddb_handle",
513 /* 16 */ "debug_object",
514 /* 17 */ "region_field",
515 /* 18 */ "bank_field",
516 /* 19 */ "index_field",
517 /* 20 */ "Reference",
519 /* 22 */ "method_alias",
521 /* 24 */ "addr_handler",
522 /* 25 */ "resource_desc",
523 /* 26 */ "resource_fld",
532 acpi_ut_get_type_name (
533 acpi_object_type type)
536 if (type > ACPI_TYPE_INVALID)
538 return ((char *) acpi_gbl_bad_type);
541 return ((char *) acpi_gbl_ns_type_names[type]);
546 acpi_ut_get_object_type_name (
547 union acpi_operand_object *obj_desc)
552 return ("[NULL Object Descriptor]");
555 return (acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)));
559 /*****************************************************************************
561 * FUNCTION: acpi_ut_get_node_name
563 * PARAMETERS: Object - A namespace node
565 * RETURN: Pointer to a string
567 * DESCRIPTION: Validate the node and return the node's ACPI name.
569 ****************************************************************************/
572 acpi_ut_get_node_name (
575 struct acpi_namespace_node *node = (struct acpi_namespace_node *) object;
578 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
585 /* Check for Root node */
587 if ((object == ACPI_ROOT_OBJECT) ||
588 (object == acpi_gbl_root_node))
593 /* Descriptor must be a namespace node */
595 if (node->descriptor != ACPI_DESC_TYPE_NAMED)
600 /* Name must be a valid ACPI name */
602 if (!acpi_ut_valid_acpi_name (* (u32 *) node->name.ascii))
607 /* Return the name */
609 return (node->name.ascii);
613 /*****************************************************************************
615 * FUNCTION: acpi_ut_get_descriptor_name
617 * PARAMETERS: Object - An ACPI object
619 * RETURN: Pointer to a string
621 * DESCRIPTION: Validate object and return the descriptor type
623 ****************************************************************************/
625 static const char *acpi_gbl_desc_type_names[] = /* printable names of descriptor types */
629 /* 02 */ "State-Generic",
630 /* 03 */ "State-Update",
631 /* 04 */ "State-Package",
632 /* 05 */ "State-Control",
633 /* 06 */ "State-root_parse_scope",
634 /* 07 */ "State-parse_scope",
635 /* 08 */ "State-walk_scope",
636 /* 09 */ "State-Result",
637 /* 10 */ "State-Notify",
638 /* 11 */ "State-Thread",
647 acpi_ut_get_descriptor_name (
653 return ("NULL OBJECT");
656 if (ACPI_GET_DESCRIPTOR_TYPE (object) > ACPI_DESC_TYPE_MAX)
658 return ((char *) acpi_gbl_bad_type);
661 return ((char *) acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE (object)]);
666 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
668 * Strings and procedures used for debug only
671 /*****************************************************************************
673 * FUNCTION: acpi_ut_get_mutex_name
679 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
681 ****************************************************************************/
684 acpi_ut_get_mutex_name (
688 if (mutex_id > MAX_MUTEX)
690 return ("Invalid Mutex ID");
693 return (acpi_gbl_mutex_names[mutex_id]);
699 /*****************************************************************************
701 * FUNCTION: acpi_ut_valid_object_type
703 * PARAMETERS: Type - Object type to be validated
705 * RETURN: TRUE if valid object type
707 * DESCRIPTION: Validate an object type
709 ****************************************************************************/
712 acpi_ut_valid_object_type (
713 acpi_object_type type)
716 if (type > ACPI_TYPE_LOCAL_MAX)
718 /* Note: Assumes all TYPEs are contiguous (external/local) */
727 /****************************************************************************
729 * FUNCTION: acpi_ut_allocate_owner_id
731 * PARAMETERS: id_type - Type of ID (method or table)
733 * DESCRIPTION: Allocate a table or method owner id
735 ***************************************************************************/
738 acpi_ut_allocate_owner_id (
741 acpi_owner_id owner_id = 0xFFFF;
744 ACPI_FUNCTION_TRACE ("ut_allocate_owner_id");
747 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES)))
754 case ACPI_OWNER_TYPE_TABLE:
756 owner_id = acpi_gbl_next_table_owner_id;
757 acpi_gbl_next_table_owner_id++;
759 /* Check for wraparound */
761 if (acpi_gbl_next_table_owner_id == ACPI_FIRST_METHOD_ID)
763 acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID;
764 ACPI_REPORT_WARNING (("Table owner ID wraparound\n"));
769 case ACPI_OWNER_TYPE_METHOD:
771 owner_id = acpi_gbl_next_method_owner_id;
772 acpi_gbl_next_method_owner_id++;
774 if (acpi_gbl_next_method_owner_id == ACPI_FIRST_TABLE_ID)
776 /* Check for wraparound */
778 acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID;
786 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
787 return_VALUE (owner_id);
791 /****************************************************************************
793 * FUNCTION: acpi_ut_init_globals
797 * DESCRIPTION: Init library globals. All globals that require specific
798 * initialization should be initialized here!
800 ***************************************************************************/
803 acpi_ut_init_globals (
809 ACPI_FUNCTION_TRACE ("ut_init_globals");
812 /* Memory allocation and cache lists */
814 ACPI_MEMSET (acpi_gbl_memory_lists, 0, sizeof (struct acpi_memory_list) * ACPI_NUM_MEM_LISTS);
816 acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_generic_state *) NULL)->common.next), NULL);
817 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL);
818 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL);
819 acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_operand_object *) NULL)->cache.next), NULL);
820 acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset = (u16) ACPI_PTR_DIFF (&(((struct acpi_walk_state *) NULL)->next), NULL);
822 acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size = sizeof (struct acpi_namespace_node);
823 acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size = sizeof (union acpi_generic_state);
824 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size = sizeof (struct acpi_parse_obj_common);
825 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (struct acpi_parse_obj_named);
826 acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size = sizeof (union acpi_operand_object);
827 acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size = sizeof (struct acpi_walk_state);
829 acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth = ACPI_MAX_STATE_CACHE_DEPTH;
830 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = ACPI_MAX_PARSE_CACHE_DEPTH;
831 acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = ACPI_MAX_EXTPARSE_CACHE_DEPTH;
832 acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = ACPI_MAX_OBJECT_CACHE_DEPTH;
833 acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth = ACPI_MAX_WALK_CACHE_DEPTH;
835 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].list_name = "Global Memory Allocation");
836 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].list_name = "Namespace Nodes");
837 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].list_name = "State Object Cache");
838 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].list_name = "Parse Node Cache");
839 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].list_name = "Extended Parse Node Cache");
840 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].list_name = "Operand Object Cache");
841 ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].list_name = "Tree Walk Node Cache");
843 /* ACPI table structure */
845 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++)
847 acpi_gbl_table_lists[i].next = NULL;
848 acpi_gbl_table_lists[i].count = 0;
851 /* Mutex locked flags */
853 for (i = 0; i < NUM_MUTEX; i++)
855 acpi_gbl_mutex_info[i].mutex = NULL;
856 acpi_gbl_mutex_info[i].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
857 acpi_gbl_mutex_info[i].use_count = 0;
862 acpi_gbl_gpe_xrupt_list_head = NULL;
863 acpi_gbl_gpe_fadt_blocks[0] = NULL;
864 acpi_gbl_gpe_fadt_blocks[1] = NULL;
866 /* Global notify handlers */
868 acpi_gbl_system_notify.handler = NULL;
869 acpi_gbl_device_notify.handler = NULL;
870 acpi_gbl_exception_handler = NULL;
871 acpi_gbl_init_handler = NULL;
873 /* Global "typed" ACPI table pointers */
875 acpi_gbl_RSDP = NULL;
876 acpi_gbl_XSDT = NULL;
877 acpi_gbl_FACS = NULL;
878 acpi_gbl_FADT = NULL;
879 acpi_gbl_DSDT = NULL;
881 /* Global Lock support */
883 acpi_gbl_global_lock_acquired = FALSE;
884 acpi_gbl_global_lock_thread_count = 0;
885 acpi_gbl_global_lock_handle = 0;
887 /* Miscellaneous variables */
889 acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER;
890 acpi_gbl_rsdp_original_location = 0;
891 acpi_gbl_cm_single_step = FALSE;
892 acpi_gbl_db_terminate_threads = FALSE;
893 acpi_gbl_shutdown = FALSE;
894 acpi_gbl_ns_lookup_count = 0;
895 acpi_gbl_ps_find_count = 0;
896 acpi_gbl_acpi_hardware_present = TRUE;
897 acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID;
898 acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID;
899 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
900 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
902 /* Hardware oriented */
904 acpi_gbl_events_initialized = FALSE;
905 acpi_gbl_system_awake_and_running = TRUE;
909 acpi_gbl_root_node = NULL;
911 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
912 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
913 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
914 acpi_gbl_root_node_struct.child = NULL;
915 acpi_gbl_root_node_struct.peer = NULL;
916 acpi_gbl_root_node_struct.object = NULL;
917 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
920 #ifdef ACPI_DEBUG_OUTPUT
921 acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;