blob: 8653dda4f813cb50ecc270a91151392a7f3d9a23 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: utglobal - Global variables for the ACPI subsystem
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2005, 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 <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <acpi/acpi.h>
48#include <acpi/acnamesp.h>
49
50#define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utglobal")
52
53
Robert Moore44f6c012005-04-18 22:49:35 -040054/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 *
56 * FUNCTION: acpi_format_exception
57 *
58 * PARAMETERS: Status - The acpi_status code to be formatted
59 *
Robert Moore44f6c012005-04-18 22:49:35 -040060 * RETURN: A string containing the exception text. A valid pointer is
61 * always returned.
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 *
63 * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
64 *
65 ******************************************************************************/
66
67const char *
68acpi_format_exception (
69 acpi_status status)
70{
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 acpi_status sub_status;
Robert Moore44f6c012005-04-18 22:49:35 -040072 const char *exception = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74
75 ACPI_FUNCTION_NAME ("format_exception");
76
77
78 sub_status = (status & ~AE_CODE_MASK);
79
80 switch (status & AE_CODE_MASK) {
81 case AE_CODE_ENVIRONMENTAL:
82
83 if (sub_status <= AE_CODE_ENV_MAX) {
84 exception = acpi_gbl_exception_names_env [sub_status];
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 }
Robert Moore44f6c012005-04-18 22:49:35 -040086 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087
88 case AE_CODE_PROGRAMMER:
89
90 if (sub_status <= AE_CODE_PGM_MAX) {
91 exception = acpi_gbl_exception_names_pgm [sub_status -1];
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 }
Robert Moore44f6c012005-04-18 22:49:35 -040093 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95 case AE_CODE_ACPI_TABLES:
96
97 if (sub_status <= AE_CODE_TBL_MAX) {
98 exception = acpi_gbl_exception_names_tbl [sub_status -1];
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 }
Robert Moore44f6c012005-04-18 22:49:35 -0400100 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101
102 case AE_CODE_AML:
103
104 if (sub_status <= AE_CODE_AML_MAX) {
105 exception = acpi_gbl_exception_names_aml [sub_status -1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 }
Robert Moore44f6c012005-04-18 22:49:35 -0400107 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
109 case AE_CODE_CONTROL:
110
111 if (sub_status <= AE_CODE_CTRL_MAX) {
112 exception = acpi_gbl_exception_names_ctrl [sub_status -1];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 }
Robert Moore44f6c012005-04-18 22:49:35 -0400114 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
116 default:
Robert Moore44f6c012005-04-18 22:49:35 -0400117 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 }
119
Robert Moore44f6c012005-04-18 22:49:35 -0400120 if (!exception) {
121 /* Exception code was not recognized */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
Robert Moore44f6c012005-04-18 22:49:35 -0400123 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
124 "Unknown exception code: 0x%8.8X\n", status));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
Robert Moore44f6c012005-04-18 22:49:35 -0400126 return ((const char *) "UNKNOWN_STATUS_CODE");
127 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 return ((const char *) exception);
130}
131
132
Robert Moore44f6c012005-04-18 22:49:35 -0400133/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 *
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 */
145u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
146EXPORT_SYMBOL(acpi_dbg_level);
147
148/* Debug switch - layer (component) mask */
149
150u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
151EXPORT_SYMBOL(acpi_dbg_layer);
152u32 acpi_gbl_nesting_level = 0;
153
154
155/* Debugger globals */
156
157u8 acpi_gbl_db_terminate_threads = FALSE;
158u8 acpi_gbl_abort_method = FALSE;
159u8 acpi_gbl_method_executing = FALSE;
160
161/* System flags */
162
163u32 acpi_gbl_startup_flags = 0;
164
165/* System starts uninitialized */
166
167u8 acpi_gbl_shutdown = TRUE;
168
169const u8 acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128};
170
171const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] =
172{
173 "\\_S0_",
174 "\\_S1_",
175 "\\_S2_",
176 "\\_S3_",
177 "\\_S4_",
178 "\\_S5_"
179};
180
181const char *acpi_gbl_highest_dstate_names[4] =
182{
183 "_S1D",
184 "_S2D",
185 "_S3D",
186 "_S4D"
187};
188
189/*
190 * Strings supported by the _OSI predefined (internal) method.
191 * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS.
192 */
193const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] =
194{
195 /* Operating System Vendor Strings */
196
197 "Linux",
198 "Windows 2000",
199 "Windows 2001",
200 "Windows 2001.1",
201 "Windows 2001 SP0",
202 "Windows 2001 SP1",
203 "Windows 2001 SP2",
204 "Windows 2001 SP3",
205 "Windows 2001 SP4",
206
207 /* Feature Group Strings */
208
209 "Extended Address Space Descriptor"
210};
211
212
Robert Moore44f6c012005-04-18 22:49:35 -0400213/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 *
215 * Namespace globals
216 *
217 ******************************************************************************/
218
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219/*
220 * Predefined ACPI Names (Built-in to the Interpreter)
221 *
222 * NOTES:
223 * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
224 * during the initialization sequence.
225 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
226 * perform a Notify() operation on it.
227 */
228const struct acpi_predefined_names acpi_gbl_pre_defined_names[] =
229{ {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
230 {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
231 {"_SB_", ACPI_TYPE_DEVICE, NULL},
232 {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
233 {"_TZ_", ACPI_TYPE_THERMAL, NULL},
234 {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL},
235 {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
236 {"_GL_", ACPI_TYPE_MUTEX, (char *) 1},
237
238#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
239 {"_OSI", ACPI_TYPE_METHOD, (char *) 1},
240#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
Robert Moore44f6c012005-04-18 22:49:35 -0400242 /* Table terminator */
243
244 {NULL, ACPI_TYPE_ANY, NULL}
245};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247/*
248 * Properties of the ACPI Object Types, both internal and external.
249 * The table is indexed by values of acpi_object_type
250 */
251const u8 acpi_gbl_ns_properties[] =
252{
253 ACPI_NS_NORMAL, /* 00 Any */
254 ACPI_NS_NORMAL, /* 01 Number */
255 ACPI_NS_NORMAL, /* 02 String */
256 ACPI_NS_NORMAL, /* 03 Buffer */
257 ACPI_NS_NORMAL, /* 04 Package */
258 ACPI_NS_NORMAL, /* 05 field_unit */
259 ACPI_NS_NEWSCOPE, /* 06 Device */
260 ACPI_NS_NORMAL, /* 07 Event */
261 ACPI_NS_NEWSCOPE, /* 08 Method */
262 ACPI_NS_NORMAL, /* 09 Mutex */
263 ACPI_NS_NORMAL, /* 10 Region */
264 ACPI_NS_NEWSCOPE, /* 11 Power */
265 ACPI_NS_NEWSCOPE, /* 12 Processor */
266 ACPI_NS_NEWSCOPE, /* 13 Thermal */
267 ACPI_NS_NORMAL, /* 14 buffer_field */
268 ACPI_NS_NORMAL, /* 15 ddb_handle */
269 ACPI_NS_NORMAL, /* 16 Debug Object */
270 ACPI_NS_NORMAL, /* 17 def_field */
271 ACPI_NS_NORMAL, /* 18 bank_field */
272 ACPI_NS_NORMAL, /* 19 index_field */
273 ACPI_NS_NORMAL, /* 20 Reference */
274 ACPI_NS_NORMAL, /* 21 Alias */
275 ACPI_NS_NORMAL, /* 22 method_alias */
276 ACPI_NS_NORMAL, /* 23 Notify */
277 ACPI_NS_NORMAL, /* 24 Address Handler */
278 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
279 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
280 ACPI_NS_NEWSCOPE, /* 27 Scope */
281 ACPI_NS_NORMAL, /* 28 Extra */
282 ACPI_NS_NORMAL, /* 29 Data */
283 ACPI_NS_NORMAL /* 30 Invalid */
284};
285
286
287/* Hex to ASCII conversion table */
288
289static const char acpi_gbl_hex_to_ascii[] =
Robert Moore44f6c012005-04-18 22:49:35 -0400290{
291 '0','1','2','3','4','5','6','7',
292 '8','9','A','B','C','D','E','F'
293};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
Robert Moore44f6c012005-04-18 22:49:35 -0400295
296/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 *
298 * FUNCTION: acpi_ut_hex_to_ascii_char
299 *
300 * PARAMETERS: Integer - Contains the hex digit
301 * Position - bit position of the digit within the
Robert Moore44f6c012005-04-18 22:49:35 -0400302 * integer (multiple of 4)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 *
Robert Moore44f6c012005-04-18 22:49:35 -0400304 * RETURN: The converted Ascii character
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 *
Robert Moore44f6c012005-04-18 22:49:35 -0400306 * DESCRIPTION: Convert a hex digit to an Ascii character
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 *
Robert Moore44f6c012005-04-18 22:49:35 -0400308 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309
310char
311acpi_ut_hex_to_ascii_char (
312 acpi_integer integer,
313 u32 position)
314{
315
316 return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
317}
318
319
Robert Moore44f6c012005-04-18 22:49:35 -0400320/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 *
322 * Table name globals
323 *
324 * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
325 * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables
326 * that are not used by the subsystem are simply ignored.
327 *
328 * Do NOT add any table to this list that is not consumed directly by this
Robert Moore44f6c012005-04-18 22:49:35 -0400329 * subsystem (No MADT, ECDT, SBST, etc.)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 *
331 ******************************************************************************/
332
333struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
334
335struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] =
336{
337 /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */
338
339 /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE},
340 /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *) &acpi_gbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE},
341 /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *) &acpi_gbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE},
342 /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *) &acpi_gbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE},
343 /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
344 /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
345 /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE},
346};
347
348
349/******************************************************************************
350 *
351 * Event and Hardware globals
352 *
353 ******************************************************************************/
354
355struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] =
356{
357 /* Name Parent Register Register Bit Position Register Bit Mask */
358
359 /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS},
360 /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS},
361 /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS},
362 /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS},
363 /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS},
364 /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS},
365 /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS},
366 /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS},
367
368 /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE},
369 /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
370 /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE},
371 /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
372 /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE},
373 /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
374 /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
375
376 /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE},
377 /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD},
378 /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
379 /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X},
380 /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X},
381 /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE},
382
383 /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE}
384};
385
386
387struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
388{
389 /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE},
390 /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
391 /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE},
392 /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
393 /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE},
394};
395
Robert Moore44f6c012005-04-18 22:49:35 -0400396/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 *
398 * FUNCTION: acpi_ut_get_region_name
399 *
400 * PARAMETERS: None.
401 *
402 * RETURN: Status
403 *
404 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
405 *
Robert Moore44f6c012005-04-18 22:49:35 -0400406 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407
408/* Region type decoding */
409
410const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] =
411{
412/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
413 "SystemMemory",
414 "SystemIO",
415 "PCI_Config",
416 "EmbeddedControl",
417 "SMBus",
418 "CMOS",
419 "PCIBARTarget",
420 "DataTable"
421/*! [End] no source code translation !*/
422};
423
424
425char *
426acpi_ut_get_region_name (
427 u8 space_id)
428{
429
430 if (space_id >= ACPI_USER_REGION_BEGIN)
431 {
432 return ("user_defined_region");
433 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS)
435 {
436 return ("invalid_space_id");
437 }
438
439 return ((char *) acpi_gbl_region_types[space_id]);
440}
441
442
Robert Moore44f6c012005-04-18 22:49:35 -0400443/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 *
445 * FUNCTION: acpi_ut_get_event_name
446 *
447 * PARAMETERS: None.
448 *
449 * RETURN: Status
450 *
451 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
452 *
Robert Moore44f6c012005-04-18 22:49:35 -0400453 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
455/* Event type decoding */
456
457static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] =
458{
459 "PM_Timer",
460 "global_lock",
461 "power_button",
462 "sleep_button",
463 "real_time_clock",
464};
465
466
467char *
468acpi_ut_get_event_name (
469 u32 event_id)
470{
471
472 if (event_id > ACPI_EVENT_MAX)
473 {
474 return ("invalid_event_iD");
475 }
476
477 return ((char *) acpi_gbl_event_types[event_id]);
478}
479
480
Robert Moore44f6c012005-04-18 22:49:35 -0400481/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 *
483 * FUNCTION: acpi_ut_get_type_name
484 *
485 * PARAMETERS: None.
486 *
487 * RETURN: Status
488 *
489 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
490 *
Robert Moore44f6c012005-04-18 22:49:35 -0400491 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492
493/*
494 * Elements of acpi_gbl_ns_type_names below must match
495 * one-to-one with values of acpi_object_type
496 *
Robert Moore44f6c012005-04-18 22:49:35 -0400497 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
498 * when stored in a table it really means that we have thus far seen no
499 * evidence to indicate what type is actually going to be stored for this entry.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 */
501static const char acpi_gbl_bad_type[] = "UNDEFINED";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502
Robert Moore44f6c012005-04-18 22:49:35 -0400503/* Printable names of the ACPI object types */
504
505static const char *acpi_gbl_ns_type_names[] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506{
507 /* 00 */ "Untyped",
508 /* 01 */ "Integer",
509 /* 02 */ "String",
510 /* 03 */ "Buffer",
511 /* 04 */ "Package",
512 /* 05 */ "field_unit",
513 /* 06 */ "Device",
514 /* 07 */ "Event",
515 /* 08 */ "Method",
516 /* 09 */ "Mutex",
517 /* 10 */ "Region",
518 /* 11 */ "Power",
519 /* 12 */ "Processor",
520 /* 13 */ "Thermal",
521 /* 14 */ "buffer_field",
522 /* 15 */ "ddb_handle",
523 /* 16 */ "debug_object",
524 /* 17 */ "region_field",
525 /* 18 */ "bank_field",
526 /* 19 */ "index_field",
527 /* 20 */ "Reference",
528 /* 21 */ "Alias",
529 /* 22 */ "method_alias",
530 /* 23 */ "Notify",
531 /* 24 */ "addr_handler",
532 /* 25 */ "resource_desc",
533 /* 26 */ "resource_fld",
534 /* 27 */ "Scope",
535 /* 28 */ "Extra",
536 /* 29 */ "Data",
537 /* 30 */ "Invalid"
538};
539
540
541char *
542acpi_ut_get_type_name (
543 acpi_object_type type)
544{
545
546 if (type > ACPI_TYPE_INVALID)
547 {
548 return ((char *) acpi_gbl_bad_type);
549 }
550
551 return ((char *) acpi_gbl_ns_type_names[type]);
552}
553
554
555char *
556acpi_ut_get_object_type_name (
557 union acpi_operand_object *obj_desc)
558{
559
560 if (!obj_desc)
561 {
562 return ("[NULL Object Descriptor]");
563 }
564
565 return (acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)));
566}
567
568
Robert Moore44f6c012005-04-18 22:49:35 -0400569/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 *
571 * FUNCTION: acpi_ut_get_node_name
572 *
573 * PARAMETERS: Object - A namespace node
574 *
575 * RETURN: Pointer to a string
576 *
577 * DESCRIPTION: Validate the node and return the node's ACPI name.
578 *
Robert Moore44f6c012005-04-18 22:49:35 -0400579 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580
581char *
582acpi_ut_get_node_name (
583 void *object)
584{
585 struct acpi_namespace_node *node = (struct acpi_namespace_node *) object;
586
587
588 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
589
590 if (!object)
591 {
592 return ("NULL");
593 }
594
595 /* Check for Root node */
596
597 if ((object == ACPI_ROOT_OBJECT) ||
598 (object == acpi_gbl_root_node))
599 {
600 return ("\"\\\" ");
601 }
602
603 /* Descriptor must be a namespace node */
604
605 if (node->descriptor != ACPI_DESC_TYPE_NAMED)
606 {
607 return ("####");
608 }
609
610 /* Name must be a valid ACPI name */
611
612 if (!acpi_ut_valid_acpi_name (* (u32 *) node->name.ascii))
613 {
614 return ("????");
615 }
616
617 /* Return the name */
618
619 return (node->name.ascii);
620}
621
622
Robert Moore44f6c012005-04-18 22:49:35 -0400623/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 *
625 * FUNCTION: acpi_ut_get_descriptor_name
626 *
627 * PARAMETERS: Object - An ACPI object
628 *
629 * RETURN: Pointer to a string
630 *
631 * DESCRIPTION: Validate object and return the descriptor type
632 *
Robert Moore44f6c012005-04-18 22:49:35 -0400633 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634
Robert Moore44f6c012005-04-18 22:49:35 -0400635/* Printable names of object descriptor types */
636
637static const char *acpi_gbl_desc_type_names[] =
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638{
639 /* 00 */ "Invalid",
640 /* 01 */ "Cached",
641 /* 02 */ "State-Generic",
642 /* 03 */ "State-Update",
643 /* 04 */ "State-Package",
644 /* 05 */ "State-Control",
645 /* 06 */ "State-root_parse_scope",
646 /* 07 */ "State-parse_scope",
647 /* 08 */ "State-walk_scope",
648 /* 09 */ "State-Result",
649 /* 10 */ "State-Notify",
650 /* 11 */ "State-Thread",
651 /* 12 */ "Walk",
652 /* 13 */ "Parser",
653 /* 14 */ "Operand",
654 /* 15 */ "Node"
655};
656
657
658char *
659acpi_ut_get_descriptor_name (
660 void *object)
661{
662
663 if (!object)
664 {
665 return ("NULL OBJECT");
666 }
667
668 if (ACPI_GET_DESCRIPTOR_TYPE (object) > ACPI_DESC_TYPE_MAX)
669 {
670 return ((char *) acpi_gbl_bad_type);
671 }
672
673 return ((char *) acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE (object)]);
674
675}
676
677
678#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
679/*
680 * Strings and procedures used for debug only
681 */
682
Robert Moore44f6c012005-04-18 22:49:35 -0400683/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 *
685 * FUNCTION: acpi_ut_get_mutex_name
686 *
Robert Moore44f6c012005-04-18 22:49:35 -0400687 * PARAMETERS: mutex_id - The predefined ID for this mutex.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 *
Robert Moore44f6c012005-04-18 22:49:35 -0400689 * RETURN: String containing the name of the mutex. Always returns a valid
690 * pointer.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 *
692 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
693 *
Robert Moore44f6c012005-04-18 22:49:35 -0400694 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695
696char *
697acpi_ut_get_mutex_name (
698 u32 mutex_id)
699{
700
701 if (mutex_id > MAX_MUTEX)
702 {
703 return ("Invalid Mutex ID");
704 }
705
706 return (acpi_gbl_mutex_names[mutex_id]);
707}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708#endif
709
710
Robert Moore44f6c012005-04-18 22:49:35 -0400711/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 *
713 * FUNCTION: acpi_ut_valid_object_type
714 *
715 * PARAMETERS: Type - Object type to be validated
716 *
Robert Moore44f6c012005-04-18 22:49:35 -0400717 * RETURN: TRUE if valid object type, FALSE otherwise
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 *
719 * DESCRIPTION: Validate an object type
720 *
Robert Moore44f6c012005-04-18 22:49:35 -0400721 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722
723u8
724acpi_ut_valid_object_type (
725 acpi_object_type type)
726{
727
728 if (type > ACPI_TYPE_LOCAL_MAX)
729 {
730 /* Note: Assumes all TYPEs are contiguous (external/local) */
731
732 return (FALSE);
733 }
734
735 return (TRUE);
736}
737
738
Robert Moore44f6c012005-04-18 22:49:35 -0400739/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 *
741 * FUNCTION: acpi_ut_allocate_owner_id
742 *
743 * PARAMETERS: id_type - Type of ID (method or table)
744 *
745 * DESCRIPTION: Allocate a table or method owner id
746 *
Robert Moore44f6c012005-04-18 22:49:35 -0400747 * NOTE: this algorithm has a wraparound problem at 64_k method invocations, and
748 * should be revisited (TBD)
749 *
750 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751
752acpi_owner_id
753acpi_ut_allocate_owner_id (
754 u32 id_type)
755{
756 acpi_owner_id owner_id = 0xFFFF;
757
758
759 ACPI_FUNCTION_TRACE ("ut_allocate_owner_id");
760
761
762 if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES)))
763 {
764 return (0);
765 }
766
767 switch (id_type)
768 {
769 case ACPI_OWNER_TYPE_TABLE:
770
771 owner_id = acpi_gbl_next_table_owner_id;
772 acpi_gbl_next_table_owner_id++;
773
774 /* Check for wraparound */
775
776 if (acpi_gbl_next_table_owner_id == ACPI_FIRST_METHOD_ID)
777 {
778 acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID;
779 ACPI_REPORT_WARNING (("Table owner ID wraparound\n"));
780 }
781 break;
782
783
784 case ACPI_OWNER_TYPE_METHOD:
785
786 owner_id = acpi_gbl_next_method_owner_id;
787 acpi_gbl_next_method_owner_id++;
788
789 if (acpi_gbl_next_method_owner_id == ACPI_FIRST_TABLE_ID)
790 {
791 /* Check for wraparound */
792
793 acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID;
794 }
795 break;
796
797 default:
798 break;
799 }
800
801 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
802 return_VALUE (owner_id);
803}
804
805
Robert Moore44f6c012005-04-18 22:49:35 -0400806/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 *
808 * FUNCTION: acpi_ut_init_globals
809 *
Robert Moore44f6c012005-04-18 22:49:35 -0400810 * PARAMETERS: None
811 *
812 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 *
814 * DESCRIPTION: Init library globals. All globals that require specific
815 * initialization should be initialized here!
816 *
Robert Moore44f6c012005-04-18 22:49:35 -0400817 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818
819void
820acpi_ut_init_globals (
821 void)
822{
Robert Moore73459f72005-06-24 00:00:00 -0400823 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 u32 i;
825
826
827 ACPI_FUNCTION_TRACE ("ut_init_globals");
828
829
Robert Moore73459f72005-06-24 00:00:00 -0400830 /* Create all memory caches */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831
Robert Moore73459f72005-06-24 00:00:00 -0400832 status = acpi_ut_create_caches ();
833 if (ACPI_FAILURE (status))
834 {
835 return;
836 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837
838 /* ACPI table structure */
839
840 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++)
841 {
842 acpi_gbl_table_lists[i].next = NULL;
843 acpi_gbl_table_lists[i].count = 0;
844 }
845
846 /* Mutex locked flags */
847
848 for (i = 0; i < NUM_MUTEX; i++)
849 {
850 acpi_gbl_mutex_info[i].mutex = NULL;
851 acpi_gbl_mutex_info[i].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
852 acpi_gbl_mutex_info[i].use_count = 0;
853 }
854
855 /* GPE support */
856
857 acpi_gbl_gpe_xrupt_list_head = NULL;
858 acpi_gbl_gpe_fadt_blocks[0] = NULL;
859 acpi_gbl_gpe_fadt_blocks[1] = NULL;
860
861 /* Global notify handlers */
862
863 acpi_gbl_system_notify.handler = NULL;
864 acpi_gbl_device_notify.handler = NULL;
865 acpi_gbl_exception_handler = NULL;
866 acpi_gbl_init_handler = NULL;
867
868 /* Global "typed" ACPI table pointers */
869
870 acpi_gbl_RSDP = NULL;
871 acpi_gbl_XSDT = NULL;
872 acpi_gbl_FACS = NULL;
873 acpi_gbl_FADT = NULL;
874 acpi_gbl_DSDT = NULL;
875
876 /* Global Lock support */
877
878 acpi_gbl_global_lock_acquired = FALSE;
879 acpi_gbl_global_lock_thread_count = 0;
880 acpi_gbl_global_lock_handle = 0;
881
882 /* Miscellaneous variables */
883
884 acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER;
885 acpi_gbl_rsdp_original_location = 0;
886 acpi_gbl_cm_single_step = FALSE;
887 acpi_gbl_db_terminate_threads = FALSE;
888 acpi_gbl_shutdown = FALSE;
889 acpi_gbl_ns_lookup_count = 0;
890 acpi_gbl_ps_find_count = 0;
891 acpi_gbl_acpi_hardware_present = TRUE;
892 acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID;
893 acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID;
894 acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
895 acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
896
897 /* Hardware oriented */
898
899 acpi_gbl_events_initialized = FALSE;
900 acpi_gbl_system_awake_and_running = TRUE;
901
902 /* Namespace */
903
904 acpi_gbl_root_node = NULL;
905
906 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
907 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
908 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
909 acpi_gbl_root_node_struct.child = NULL;
910 acpi_gbl_root_node_struct.peer = NULL;
911 acpi_gbl_root_node_struct.object = NULL;
912 acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
913
914
915#ifdef ACPI_DEBUG_OUTPUT
916 acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;
917#endif
918
919 return_VOID;
920}
921
922