utglobal.c 25.1 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
/******************************************************************************
 *
 * Module Name: utglobal - Global variables for the ACPI subsystem
 *
 *****************************************************************************/

/*
 * Copyright (C) 2000 - 2005, R. Byron Moore
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions, and the following disclaimer,
 *    without modification.
 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 *    substantially similar to the "NO WARRANTY" disclaimer below
 *    ("Disclaimer") and any redistribution must be conditioned upon
 *    including a substantially similar Disclaimer requirement for further
 *    binary redistribution.
 * 3. Neither the names of the above-listed copyright holders nor the names
 *    of any contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * Alternatively, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") version 2 as published by the Free
 * Software Foundation.
 *
 * NO WARRANTY
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES.
 */

#define DEFINE_ACPI_GLOBALS

#include <linux/module.h>
#include <acpi/acpi.h>
#include <acpi/acnamesp.h>

#define _COMPONENT          ACPI_UTILITIES
L
Len Brown 已提交
51
ACPI_MODULE_NAME("utglobal")
L
Linus Torvalds 已提交
52

R
Robert Moore 已提交
53
/*******************************************************************************
L
Linus Torvalds 已提交
54 55 56 57 58
 *
 * FUNCTION:    acpi_format_exception
 *
 * PARAMETERS:  Status       - The acpi_status code to be formatted
 *
R
Robert Moore 已提交
59 60
 * RETURN:      A string containing the exception text. A valid pointer is
 *              always returned.
L
Linus Torvalds 已提交
61 62 63 64
 *
 * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
 *
 ******************************************************************************/
L
Len Brown 已提交
65
const char *acpi_format_exception(acpi_status status)
L
Linus Torvalds 已提交
66
{
L
Len Brown 已提交
67 68
	acpi_status sub_status;
	const char *exception = NULL;
L
Linus Torvalds 已提交
69

L
Len Brown 已提交
70
	ACPI_FUNCTION_NAME("format_exception");
L
Linus Torvalds 已提交
71 72 73 74 75 76 77

	sub_status = (status & ~AE_CODE_MASK);

	switch (status & AE_CODE_MASK) {
	case AE_CODE_ENVIRONMENTAL:

		if (sub_status <= AE_CODE_ENV_MAX) {
L
Len Brown 已提交
78
			exception = acpi_gbl_exception_names_env[sub_status];
L
Linus Torvalds 已提交
79
		}
R
Robert Moore 已提交
80
		break;
L
Linus Torvalds 已提交
81 82 83 84

	case AE_CODE_PROGRAMMER:

		if (sub_status <= AE_CODE_PGM_MAX) {
L
Len Brown 已提交
85 86
			exception =
			    acpi_gbl_exception_names_pgm[sub_status - 1];
L
Linus Torvalds 已提交
87
		}
R
Robert Moore 已提交
88
		break;
L
Linus Torvalds 已提交
89 90 91 92

	case AE_CODE_ACPI_TABLES:

		if (sub_status <= AE_CODE_TBL_MAX) {
L
Len Brown 已提交
93 94
			exception =
			    acpi_gbl_exception_names_tbl[sub_status - 1];
L
Linus Torvalds 已提交
95
		}
R
Robert Moore 已提交
96
		break;
L
Linus Torvalds 已提交
97 98 99 100

	case AE_CODE_AML:

		if (sub_status <= AE_CODE_AML_MAX) {
L
Len Brown 已提交
101 102
			exception =
			    acpi_gbl_exception_names_aml[sub_status - 1];
L
Linus Torvalds 已提交
103
		}
R
Robert Moore 已提交
104
		break;
L
Linus Torvalds 已提交
105 106 107 108

	case AE_CODE_CONTROL:

		if (sub_status <= AE_CODE_CTRL_MAX) {
L
Len Brown 已提交
109 110
			exception =
			    acpi_gbl_exception_names_ctrl[sub_status - 1];
L
Linus Torvalds 已提交
111
		}
R
Robert Moore 已提交
112
		break;
L
Linus Torvalds 已提交
113 114

	default:
R
Robert Moore 已提交
115
		break;
L
Linus Torvalds 已提交
116 117
	}

R
Robert Moore 已提交
118 119
	if (!exception) {
		/* Exception code was not recognized */
L
Linus Torvalds 已提交
120

L
Len Brown 已提交
121 122
		ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
				  "Unknown exception code: 0x%8.8X\n", status));
L
Linus Torvalds 已提交
123

L
Len Brown 已提交
124
		return ((const char *)"UNKNOWN_STATUS_CODE");
R
Robert Moore 已提交
125
	}
L
Linus Torvalds 已提交
126

L
Len Brown 已提交
127
	return ((const char *)exception);
L
Linus Torvalds 已提交
128 129
}

R
Robert Moore 已提交
130
/*******************************************************************************
L
Linus Torvalds 已提交
131 132 133 134 135 136 137 138 139 140 141
 *
 * Static global variable initialization.
 *
 ******************************************************************************/

/*
 * We want the debug switches statically initialized so they
 * are already set when the debugger is entered.
 */

/* Debug switch - level and trace mask */
L
Len Brown 已提交
142
u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
L
Linus Torvalds 已提交
143 144 145 146
EXPORT_SYMBOL(acpi_dbg_level);

/* Debug switch - layer (component) mask */

L
Len Brown 已提交
147
u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
L
Linus Torvalds 已提交
148
EXPORT_SYMBOL(acpi_dbg_layer);
L
Len Brown 已提交
149
u32 acpi_gbl_nesting_level = 0;
L
Linus Torvalds 已提交
150 151 152

/* Debugger globals */

L
Len Brown 已提交
153 154 155
u8 acpi_gbl_db_terminate_threads = FALSE;
u8 acpi_gbl_abort_method = FALSE;
u8 acpi_gbl_method_executing = FALSE;
L
Linus Torvalds 已提交
156 157 158

/* System flags */

L
Len Brown 已提交
159
u32 acpi_gbl_startup_flags = 0;
L
Linus Torvalds 已提交
160 161 162

/* System starts uninitialized */

L
Len Brown 已提交
163
u8 acpi_gbl_shutdown = TRUE;
L
Linus Torvalds 已提交
164

L
Len Brown 已提交
165
const u8 acpi_gbl_decode_to8bit[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
L
Linus Torvalds 已提交
166

L
Len Brown 已提交
167
const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
L
Linus Torvalds 已提交
168 169 170 171 172 173 174 175
	"\\_S0_",
	"\\_S1_",
	"\\_S2_",
	"\\_S3_",
	"\\_S4_",
	"\\_S5_"
};

L
Len Brown 已提交
176
const char *acpi_gbl_highest_dstate_names[4] = {
L
Linus Torvalds 已提交
177 178 179 180 181 182 183 184 185 186
	"_S1D",
	"_S2D",
	"_S3D",
	"_S4D"
};

/*
 * Strings supported by the _OSI predefined (internal) method.
 * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS.
 */
L
Len Brown 已提交
187
const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = {
L
Linus Torvalds 已提交
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
	/* Operating System Vendor Strings */

	"Linux",
	"Windows 2000",
	"Windows 2001",
	"Windows 2001.1",
	"Windows 2001 SP0",
	"Windows 2001 SP1",
	"Windows 2001 SP2",
	"Windows 2001 SP3",
	"Windows 2001 SP4",

	/* Feature Group Strings */

	"Extended Address Space Descriptor"
};

R
Robert Moore 已提交
205
/*******************************************************************************
L
Linus Torvalds 已提交
206 207 208 209 210 211 212 213 214 215 216 217 218 219
 *
 * Namespace globals
 *
 ******************************************************************************/

/*
 * Predefined ACPI Names (Built-in to the Interpreter)
 *
 * NOTES:
 * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
 *    during the initialization sequence.
 * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
 *    perform a Notify() operation on it.
 */
B
Bob Moore 已提交
220 221 222 223 224 225 226 227 228
const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
	{"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
	{"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
	{"_SB_", ACPI_TYPE_DEVICE, NULL},
	{"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
	{"_TZ_", ACPI_TYPE_THERMAL, NULL},
	{"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
	{"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
	{"_GL_", ACPI_TYPE_MUTEX, (char *)1},
L
Linus Torvalds 已提交
229 230

#if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
B
Bob Moore 已提交
231
	{"_OSI", ACPI_TYPE_METHOD, (char *)1},
L
Linus Torvalds 已提交
232 233
#endif

R
Robert Moore 已提交
234 235
	/* Table terminator */

B
Bob Moore 已提交
236
	{NULL, ACPI_TYPE_ANY, NULL}
R
Robert Moore 已提交
237
};
L
Linus Torvalds 已提交
238 239 240 241 242

/*
 * Properties of the ACPI Object Types, both internal and external.
 * The table is indexed by values of acpi_object_type
 */
L
Len Brown 已提交
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
const u8 acpi_gbl_ns_properties[] = {
	ACPI_NS_NORMAL,		/* 00 Any              */
	ACPI_NS_NORMAL,		/* 01 Number           */
	ACPI_NS_NORMAL,		/* 02 String           */
	ACPI_NS_NORMAL,		/* 03 Buffer           */
	ACPI_NS_NORMAL,		/* 04 Package          */
	ACPI_NS_NORMAL,		/* 05 field_unit       */
	ACPI_NS_NEWSCOPE,	/* 06 Device           */
	ACPI_NS_NORMAL,		/* 07 Event            */
	ACPI_NS_NEWSCOPE,	/* 08 Method           */
	ACPI_NS_NORMAL,		/* 09 Mutex            */
	ACPI_NS_NORMAL,		/* 10 Region           */
	ACPI_NS_NEWSCOPE,	/* 11 Power            */
	ACPI_NS_NEWSCOPE,	/* 12 Processor        */
	ACPI_NS_NEWSCOPE,	/* 13 Thermal          */
	ACPI_NS_NORMAL,		/* 14 buffer_field     */
	ACPI_NS_NORMAL,		/* 15 ddb_handle       */
	ACPI_NS_NORMAL,		/* 16 Debug Object     */
	ACPI_NS_NORMAL,		/* 17 def_field        */
	ACPI_NS_NORMAL,		/* 18 bank_field       */
	ACPI_NS_NORMAL,		/* 19 index_field      */
	ACPI_NS_NORMAL,		/* 20 Reference        */
	ACPI_NS_NORMAL,		/* 21 Alias            */
	ACPI_NS_NORMAL,		/* 22 method_alias     */
	ACPI_NS_NORMAL,		/* 23 Notify           */
	ACPI_NS_NORMAL,		/* 24 Address Handler  */
	ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,	/* 25 Resource Desc    */
	ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL,	/* 26 Resource Field   */
	ACPI_NS_NEWSCOPE,	/* 27 Scope            */
	ACPI_NS_NORMAL,		/* 28 Extra            */
	ACPI_NS_NORMAL,		/* 29 Data             */
	ACPI_NS_NORMAL		/* 30 Invalid          */
L
Linus Torvalds 已提交
275 276 277 278
};

/* Hex to ASCII conversion table */

L
Len Brown 已提交
279 280 281
static const char acpi_gbl_hex_to_ascii[] = {
	'0', '1', '2', '3', '4', '5', '6', '7',
	'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
R
Robert Moore 已提交
282 283 284
};

/*******************************************************************************
L
Linus Torvalds 已提交
285 286 287 288 289
 *
 * FUNCTION:    acpi_ut_hex_to_ascii_char
 *
 * PARAMETERS:  Integer             - Contains the hex digit
 *              Position            - bit position of the digit within the
R
Robert Moore 已提交
290
 *                                    integer (multiple of 4)
L
Linus Torvalds 已提交
291
 *
R
Robert Moore 已提交
292
 * RETURN:      The converted Ascii character
L
Linus Torvalds 已提交
293
 *
R
Robert Moore 已提交
294
 * DESCRIPTION: Convert a hex digit to an Ascii character
L
Linus Torvalds 已提交
295
 *
R
Robert Moore 已提交
296
 ******************************************************************************/
L
Linus Torvalds 已提交
297

L
Len Brown 已提交
298
char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position)
L
Linus Torvalds 已提交
299 300 301 302 303
{

	return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
}

R
Robert Moore 已提交
304
/*******************************************************************************
L
Linus Torvalds 已提交
305 306 307 308 309 310 311 312
 *
 * Table name globals
 *
 * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
 * it is NOT an exhaustive list of all possible ACPI tables.  All ACPI tables
 * that are not used by the subsystem are simply ignored.
 *
 * Do NOT add any table to this list that is not consumed directly by this
R
Robert Moore 已提交
313
 * subsystem (No MADT, ECDT, SBST, etc.)
L
Linus Torvalds 已提交
314 315 316
 *
 ******************************************************************************/

L
Len Brown 已提交
317
struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
L
Linus Torvalds 已提交
318

L
Len Brown 已提交
319
struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = {
L
Linus Torvalds 已提交
320 321
	/***********    Name,   Signature, Global typed pointer     Signature size,      Type                  How many allowed?,    Contains valid AML? */

L
Len Brown 已提交
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
	/* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof(RSDP_SIG) - 1,
		      ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
	,
	/* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *)&acpi_gbl_DSDT,
		      sizeof(DSDT_SIG) - 1,
		      ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE |
		      ACPI_TABLE_EXECUTABLE}
	,
	/* FADT 2 */ {FADT_SIG, FADT_SIG, (void *)&acpi_gbl_FADT,
		      sizeof(FADT_SIG) - 1,
		      ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}
	,
	/* FACS 3 */ {FACS_SIG, FACS_SIG, (void *)&acpi_gbl_FACS,
		      sizeof(FACS_SIG) - 1,
		      ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE}
	,
	/* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof(PSDT_SIG) - 1,
		      ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
		      ACPI_TABLE_EXECUTABLE}
	,
	/* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof(SSDT_SIG) - 1,
		      ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
		      ACPI_TABLE_EXECUTABLE}
	,
	/* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof(RSDT_SIG) - 1,
		      ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
	,
L
Linus Torvalds 已提交
349 350 351 352 353 354 355 356
};

/******************************************************************************
 *
 * Event and Hardware globals
 *
 ******************************************************************************/

L
Len Brown 已提交
357
struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
L
Linus Torvalds 已提交
358 359
	/* Name                                     Parent Register             Register Bit Position                   Register Bit Mask       */

L
Len Brown 已提交
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
	/* ACPI_BITREG_TIMER_STATUS         */ {ACPI_REGISTER_PM1_STATUS,
						ACPI_BITPOSITION_TIMER_STATUS,
						ACPI_BITMASK_TIMER_STATUS},
	/* ACPI_BITREG_BUS_MASTER_STATUS    */ {ACPI_REGISTER_PM1_STATUS,
						ACPI_BITPOSITION_BUS_MASTER_STATUS,
						ACPI_BITMASK_BUS_MASTER_STATUS},
	/* ACPI_BITREG_GLOBAL_LOCK_STATUS   */ {ACPI_REGISTER_PM1_STATUS,
						ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,
						ACPI_BITMASK_GLOBAL_LOCK_STATUS},
	/* ACPI_BITREG_POWER_BUTTON_STATUS  */ {ACPI_REGISTER_PM1_STATUS,
						ACPI_BITPOSITION_POWER_BUTTON_STATUS,
						ACPI_BITMASK_POWER_BUTTON_STATUS},
	/* ACPI_BITREG_SLEEP_BUTTON_STATUS  */ {ACPI_REGISTER_PM1_STATUS,
						ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,
						ACPI_BITMASK_SLEEP_BUTTON_STATUS},
	/* ACPI_BITREG_RT_CLOCK_STATUS      */ {ACPI_REGISTER_PM1_STATUS,
						ACPI_BITPOSITION_RT_CLOCK_STATUS,
						ACPI_BITMASK_RT_CLOCK_STATUS},
	/* ACPI_BITREG_WAKE_STATUS          */ {ACPI_REGISTER_PM1_STATUS,
						ACPI_BITPOSITION_WAKE_STATUS,
						ACPI_BITMASK_WAKE_STATUS},
	/* ACPI_BITREG_PCIEXP_WAKE_STATUS   */ {ACPI_REGISTER_PM1_STATUS,
						ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,
						ACPI_BITMASK_PCIEXP_WAKE_STATUS},

	/* ACPI_BITREG_TIMER_ENABLE         */ {ACPI_REGISTER_PM1_ENABLE,
						ACPI_BITPOSITION_TIMER_ENABLE,
						ACPI_BITMASK_TIMER_ENABLE},
	/* ACPI_BITREG_GLOBAL_LOCK_ENABLE   */ {ACPI_REGISTER_PM1_ENABLE,
						ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,
						ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
	/* ACPI_BITREG_POWER_BUTTON_ENABLE  */ {ACPI_REGISTER_PM1_ENABLE,
						ACPI_BITPOSITION_POWER_BUTTON_ENABLE,
						ACPI_BITMASK_POWER_BUTTON_ENABLE},
	/* ACPI_BITREG_SLEEP_BUTTON_ENABLE  */ {ACPI_REGISTER_PM1_ENABLE,
						ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,
						ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
	/* ACPI_BITREG_RT_CLOCK_ENABLE      */ {ACPI_REGISTER_PM1_ENABLE,
						ACPI_BITPOSITION_RT_CLOCK_ENABLE,
						ACPI_BITMASK_RT_CLOCK_ENABLE},
	/* ACPI_BITREG_WAKE_ENABLE          */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
	/* ACPI_BITREG_PCIEXP_WAKE_DISABLE  */ {ACPI_REGISTER_PM1_ENABLE,
						ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
						ACPI_BITMASK_PCIEXP_WAKE_DISABLE},

	/* ACPI_BITREG_SCI_ENABLE           */ {ACPI_REGISTER_PM1_CONTROL,
						ACPI_BITPOSITION_SCI_ENABLE,
						ACPI_BITMASK_SCI_ENABLE},
	/* ACPI_BITREG_BUS_MASTER_RLD       */ {ACPI_REGISTER_PM1_CONTROL,
						ACPI_BITPOSITION_BUS_MASTER_RLD,
						ACPI_BITMASK_BUS_MASTER_RLD},
	/* ACPI_BITREG_GLOBAL_LOCK_RELEASE  */ {ACPI_REGISTER_PM1_CONTROL,
						ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
						ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
	/* ACPI_BITREG_SLEEP_TYPE_A         */ {ACPI_REGISTER_PM1_CONTROL,
						ACPI_BITPOSITION_SLEEP_TYPE_X,
						ACPI_BITMASK_SLEEP_TYPE_X},
	/* ACPI_BITREG_SLEEP_TYPE_B         */ {ACPI_REGISTER_PM1_CONTROL,
						ACPI_BITPOSITION_SLEEP_TYPE_X,
						ACPI_BITMASK_SLEEP_TYPE_X},
	/* ACPI_BITREG_SLEEP_ENABLE         */ {ACPI_REGISTER_PM1_CONTROL,
						ACPI_BITPOSITION_SLEEP_ENABLE,
						ACPI_BITMASK_SLEEP_ENABLE},

	/* ACPI_BITREG_ARB_DIS              */ {ACPI_REGISTER_PM2_CONTROL,
						ACPI_BITPOSITION_ARB_DISABLE,
						ACPI_BITMASK_ARB_DISABLE}
L
Linus Torvalds 已提交
427 428
};

L
Len Brown 已提交
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = {
	/* ACPI_EVENT_PMTIMER       */ {ACPI_BITREG_TIMER_STATUS,
					ACPI_BITREG_TIMER_ENABLE,
					ACPI_BITMASK_TIMER_STATUS,
					ACPI_BITMASK_TIMER_ENABLE},
	/* ACPI_EVENT_GLOBAL        */ {ACPI_BITREG_GLOBAL_LOCK_STATUS,
					ACPI_BITREG_GLOBAL_LOCK_ENABLE,
					ACPI_BITMASK_GLOBAL_LOCK_STATUS,
					ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
	/* ACPI_EVENT_POWER_BUTTON  */ {ACPI_BITREG_POWER_BUTTON_STATUS,
					ACPI_BITREG_POWER_BUTTON_ENABLE,
					ACPI_BITMASK_POWER_BUTTON_STATUS,
					ACPI_BITMASK_POWER_BUTTON_ENABLE},
	/* ACPI_EVENT_SLEEP_BUTTON  */ {ACPI_BITREG_SLEEP_BUTTON_STATUS,
					ACPI_BITREG_SLEEP_BUTTON_ENABLE,
					ACPI_BITMASK_SLEEP_BUTTON_STATUS,
					ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
	/* ACPI_EVENT_RTC           */ {ACPI_BITREG_RT_CLOCK_STATUS,
					ACPI_BITREG_RT_CLOCK_ENABLE,
					ACPI_BITMASK_RT_CLOCK_STATUS,
					ACPI_BITMASK_RT_CLOCK_ENABLE},
L
Linus Torvalds 已提交
450 451
};

R
Robert Moore 已提交
452
/*******************************************************************************
L
Linus Torvalds 已提交
453 454 455 456 457 458 459 460 461
 *
 * FUNCTION:    acpi_ut_get_region_name
 *
 * PARAMETERS:  None.
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
 *
R
Robert Moore 已提交
462
 ******************************************************************************/
L
Linus Torvalds 已提交
463 464 465

/* Region type decoding */

L
Len Brown 已提交
466
const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
L
Linus Torvalds 已提交
467 468 469 470 471 472 473 474 475 476 477 478
/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
	"SystemMemory",
	"SystemIO",
	"PCI_Config",
	"EmbeddedControl",
	"SMBus",
	"CMOS",
	"PCIBARTarget",
	"DataTable"
/*! [End] no source code translation !*/
};

L
Len Brown 已提交
479
char *acpi_ut_get_region_name(u8 space_id)
L
Linus Torvalds 已提交
480 481
{

L
Len Brown 已提交
482
	if (space_id >= ACPI_USER_REGION_BEGIN) {
L
Linus Torvalds 已提交
483
		return ("user_defined_region");
L
Len Brown 已提交
484
	} else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
L
Linus Torvalds 已提交
485 486 487
		return ("invalid_space_id");
	}

B
Bob Moore 已提交
488
	return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
L
Linus Torvalds 已提交
489 490
}

R
Robert Moore 已提交
491
/*******************************************************************************
L
Linus Torvalds 已提交
492 493 494 495 496 497 498 499 500
 *
 * FUNCTION:    acpi_ut_get_event_name
 *
 * PARAMETERS:  None.
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
 *
R
Robert Moore 已提交
501
 ******************************************************************************/
L
Linus Torvalds 已提交
502 503 504

/* Event type decoding */

L
Len Brown 已提交
505
static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
B
Bob Moore 已提交
506
/*! [Begin] no source code translation (keep these strings as-is) */
L
Linus Torvalds 已提交
507
	"PM_Timer",
B
Bob Moore 已提交
508 509 510 511 512
	"GlobalLock",
	"PowerButton",
	"SleepButton",
	"RealTimeClock",
/*! [End] no source code translation !*/
L
Linus Torvalds 已提交
513 514
};

L
Len Brown 已提交
515
char *acpi_ut_get_event_name(u32 event_id)
L
Linus Torvalds 已提交
516 517
{

L
Len Brown 已提交
518
	if (event_id > ACPI_EVENT_MAX) {
L
Linus Torvalds 已提交
519 520 521
		return ("invalid_event_iD");
	}

L
Len Brown 已提交
522
	return ((char *)acpi_gbl_event_types[event_id]);
L
Linus Torvalds 已提交
523 524
}

R
Robert Moore 已提交
525
/*******************************************************************************
L
Linus Torvalds 已提交
526 527 528 529 530 531 532 533 534
 *
 * FUNCTION:    acpi_ut_get_type_name
 *
 * PARAMETERS:  None.
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
 *
R
Robert Moore 已提交
535
 ******************************************************************************/
L
Linus Torvalds 已提交
536 537 538 539 540

/*
 * Elements of acpi_gbl_ns_type_names below must match
 * one-to-one with values of acpi_object_type
 *
R
Robert Moore 已提交
541 542 543
 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
 * when stored in a table it really means that we have thus far seen no
 * evidence to indicate what type is actually going to be stored for this entry.
L
Linus Torvalds 已提交
544
 */
L
Len Brown 已提交
545
static const char acpi_gbl_bad_type[] = "UNDEFINED";
L
Linus Torvalds 已提交
546

R
Robert Moore 已提交
547 548
/* Printable names of the ACPI object types */

L
Len Brown 已提交
549
static const char *acpi_gbl_ns_type_names[] = {
B
Bob Moore 已提交
550
/*! [Begin] no source code translation (keep these strings as-is) */
L
Linus Torvalds 已提交
551 552 553 554 555
	/* 00 */ "Untyped",
	/* 01 */ "Integer",
	/* 02 */ "String",
	/* 03 */ "Buffer",
	/* 04 */ "Package",
B
Bob Moore 已提交
556
	/* 05 */ "FieldUnit",
L
Linus Torvalds 已提交
557 558 559 560 561 562 563 564
	/* 06 */ "Device",
	/* 07 */ "Event",
	/* 08 */ "Method",
	/* 09 */ "Mutex",
	/* 10 */ "Region",
	/* 11 */ "Power",
	/* 12 */ "Processor",
	/* 13 */ "Thermal",
B
Bob Moore 已提交
565 566 567 568 569 570
	/* 14 */ "BufferField",
	/* 15 */ "DdbHandle",
	/* 16 */ "DebugObject",
	/* 17 */ "RegionField",
	/* 18 */ "BankField",
	/* 19 */ "IndexField",
L
Linus Torvalds 已提交
571 572
	/* 20 */ "Reference",
	/* 21 */ "Alias",
B
Bob Moore 已提交
573
	/* 22 */ "MethodAlias",
L
Linus Torvalds 已提交
574
	/* 23 */ "Notify",
B
Bob Moore 已提交
575 576 577
	/* 24 */ "AddrHandler",
	/* 25 */ "ResourceDesc",
	/* 26 */ "ResourceFld",
L
Linus Torvalds 已提交
578 579 580 581
	/* 27 */ "Scope",
	/* 28 */ "Extra",
	/* 29 */ "Data",
	/* 30 */ "Invalid"
B
Bob Moore 已提交
582
/*! [End] no source code translation !*/
L
Linus Torvalds 已提交
583 584
};

L
Len Brown 已提交
585
char *acpi_ut_get_type_name(acpi_object_type type)
L
Linus Torvalds 已提交
586 587
{

L
Len Brown 已提交
588 589
	if (type > ACPI_TYPE_INVALID) {
		return ((char *)acpi_gbl_bad_type);
L
Linus Torvalds 已提交
590 591
	}

L
Len Brown 已提交
592
	return ((char *)acpi_gbl_ns_type_names[type]);
L
Linus Torvalds 已提交
593 594
}

L
Len Brown 已提交
595
char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
L
Linus Torvalds 已提交
596 597
{

L
Len Brown 已提交
598
	if (!obj_desc) {
L
Linus Torvalds 已提交
599 600 601
		return ("[NULL Object Descriptor]");
	}

L
Len Brown 已提交
602
	return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)));
L
Linus Torvalds 已提交
603 604
}

R
Robert Moore 已提交
605
/*******************************************************************************
L
Linus Torvalds 已提交
606 607 608 609 610 611 612 613 614
 *
 * FUNCTION:    acpi_ut_get_node_name
 *
 * PARAMETERS:  Object               - A namespace node
 *
 * RETURN:      Pointer to a string
 *
 * DESCRIPTION: Validate the node and return the node's ACPI name.
 *
R
Robert Moore 已提交
615
 ******************************************************************************/
L
Linus Torvalds 已提交
616

L
Len Brown 已提交
617
char *acpi_ut_get_node_name(void *object)
L
Linus Torvalds 已提交
618
{
L
Len Brown 已提交
619
	struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
L
Linus Torvalds 已提交
620 621 622

	/* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */

L
Len Brown 已提交
623
	if (!object) {
L
Linus Torvalds 已提交
624 625 626 627 628
		return ("NULL");
	}

	/* Check for Root node */

L
Len Brown 已提交
629
	if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
L
Linus Torvalds 已提交
630 631 632 633 634
		return ("\"\\\" ");
	}

	/* Descriptor must be a namespace node */

L
Len Brown 已提交
635
	if (node->descriptor != ACPI_DESC_TYPE_NAMED) {
L
Linus Torvalds 已提交
636 637 638 639 640
		return ("####");
	}

	/* Name must be a valid ACPI name */

B
Bob Moore 已提交
641
	if (!acpi_ut_valid_acpi_name(node->name.integer)) {
L
Linus Torvalds 已提交
642 643 644 645 646 647 648 649
		return ("????");
	}

	/* Return the name */

	return (node->name.ascii);
}

R
Robert Moore 已提交
650
/*******************************************************************************
L
Linus Torvalds 已提交
651 652 653 654 655 656 657 658 659
 *
 * FUNCTION:    acpi_ut_get_descriptor_name
 *
 * PARAMETERS:  Object               - An ACPI object
 *
 * RETURN:      Pointer to a string
 *
 * DESCRIPTION: Validate object and return the descriptor type
 *
R
Robert Moore 已提交
660 661 662
 ******************************************************************************/

/* Printable names of object descriptor types */
L
Linus Torvalds 已提交
663

L
Len Brown 已提交
664
static const char *acpi_gbl_desc_type_names[] = {
B
Bob Moore 已提交
665
/*! [Begin] no source code translation (keep these ASL Keywords as-is) */
L
Linus Torvalds 已提交
666 667 668 669 670 671
	/* 00 */ "Invalid",
	/* 01 */ "Cached",
	/* 02 */ "State-Generic",
	/* 03 */ "State-Update",
	/* 04 */ "State-Package",
	/* 05 */ "State-Control",
B
Bob Moore 已提交
672 673 674
	/* 06 */ "State-RootParseScope",
	/* 07 */ "State-ParseScope",
	/* 08 */ "State-WalkScope",
L
Linus Torvalds 已提交
675 676 677 678 679 680 681
	/* 09 */ "State-Result",
	/* 10 */ "State-Notify",
	/* 11 */ "State-Thread",
	/* 12 */ "Walk",
	/* 13 */ "Parser",
	/* 14 */ "Operand",
	/* 15 */ "Node"
B
Bob Moore 已提交
682
/*! [End] no source code translation !*/
L
Linus Torvalds 已提交
683 684
};

L
Len Brown 已提交
685
char *acpi_ut_get_descriptor_name(void *object)
L
Linus Torvalds 已提交
686 687
{

L
Len Brown 已提交
688
	if (!object) {
L
Linus Torvalds 已提交
689 690 691
		return ("NULL OBJECT");
	}

L
Len Brown 已提交
692
	if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
B
Bob Moore 已提交
693
		return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
L
Linus Torvalds 已提交
694 695
	}

B
Bob Moore 已提交
696 697 698
	return (ACPI_CAST_PTR(char,
			      acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
						       (object)]));
L
Linus Torvalds 已提交
699 700 701 702 703 704 705 706

}

#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
/*
 * Strings and procedures used for debug only
 */

R
Robert Moore 已提交
707
/*******************************************************************************
L
Linus Torvalds 已提交
708 709 710
 *
 * FUNCTION:    acpi_ut_get_mutex_name
 *
R
Robert Moore 已提交
711
 * PARAMETERS:  mutex_id        - The predefined ID for this mutex.
L
Linus Torvalds 已提交
712
 *
R
Robert Moore 已提交
713 714
 * RETURN:      String containing the name of the mutex. Always returns a valid
 *              pointer.
L
Linus Torvalds 已提交
715 716 717
 *
 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
 *
R
Robert Moore 已提交
718
 ******************************************************************************/
L
Linus Torvalds 已提交
719

L
Len Brown 已提交
720
char *acpi_ut_get_mutex_name(u32 mutex_id)
L
Linus Torvalds 已提交
721 722
{

L
Len Brown 已提交
723
	if (mutex_id > MAX_MUTEX) {
L
Linus Torvalds 已提交
724 725 726 727 728 729 730
		return ("Invalid Mutex ID");
	}

	return (acpi_gbl_mutex_names[mutex_id]);
}
#endif

R
Robert Moore 已提交
731
/*******************************************************************************
L
Linus Torvalds 已提交
732 733 734 735 736
 *
 * FUNCTION:    acpi_ut_valid_object_type
 *
 * PARAMETERS:  Type            - Object type to be validated
 *
R
Robert Moore 已提交
737
 * RETURN:      TRUE if valid object type, FALSE otherwise
L
Linus Torvalds 已提交
738 739 740
 *
 * DESCRIPTION: Validate an object type
 *
R
Robert Moore 已提交
741
 ******************************************************************************/
L
Linus Torvalds 已提交
742

L
Len Brown 已提交
743
u8 acpi_ut_valid_object_type(acpi_object_type type)
L
Linus Torvalds 已提交
744 745
{

L
Len Brown 已提交
746
	if (type > ACPI_TYPE_LOCAL_MAX) {
L
Linus Torvalds 已提交
747 748 749 750 751 752 753 754
		/* Note: Assumes all TYPEs are contiguous (external/local) */

		return (FALSE);
	}

	return (TRUE);
}

R
Robert Moore 已提交
755
/*******************************************************************************
L
Linus Torvalds 已提交
756 757 758
 *
 * FUNCTION:    acpi_ut_init_globals
 *
R
Robert Moore 已提交
759 760 761
 * PARAMETERS:  None
 *
 * RETURN:      None
L
Linus Torvalds 已提交
762 763 764 765
 *
 * DESCRIPTION: Init library globals.  All globals that require specific
 *              initialization should be initialized here!
 *
R
Robert Moore 已提交
766
 ******************************************************************************/
L
Linus Torvalds 已提交
767

L
Len Brown 已提交
768
void acpi_ut_init_globals(void)
L
Linus Torvalds 已提交
769
{
L
Len Brown 已提交
770 771
	acpi_status status;
	u32 i;
L
Linus Torvalds 已提交
772

L
Len Brown 已提交
773
	ACPI_FUNCTION_TRACE("ut_init_globals");
L
Linus Torvalds 已提交
774

775 776
	/* Create all memory caches */

L
Len Brown 已提交
777 778
	status = acpi_ut_create_caches();
	if (ACPI_FAILURE(status)) {
779 780
		return;
	}
L
Linus Torvalds 已提交
781 782 783

	/* ACPI table structure */

L
Len Brown 已提交
784 785 786
	for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) {
		acpi_gbl_table_lists[i].next = NULL;
		acpi_gbl_table_lists[i].count = 0;
L
Linus Torvalds 已提交
787 788 789 790
	}

	/* Mutex locked flags */

L
Len Brown 已提交
791 792 793 794
	for (i = 0; i < NUM_MUTEX; i++) {
		acpi_gbl_mutex_info[i].mutex = NULL;
		acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
		acpi_gbl_mutex_info[i].use_count = 0;
L
Linus Torvalds 已提交
795 796
	}

B
Bob Moore 已提交
797 798 799 800 801
	for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
		acpi_gbl_owner_id_mask[i] = 0;
	}
	acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;	/* Last ID is never valid */

L
Linus Torvalds 已提交
802 803
	/* GPE support */

L
Len Brown 已提交
804 805 806
	acpi_gbl_gpe_xrupt_list_head = NULL;
	acpi_gbl_gpe_fadt_blocks[0] = NULL;
	acpi_gbl_gpe_fadt_blocks[1] = NULL;
L
Linus Torvalds 已提交
807 808 809

	/* Global notify handlers */

L
Len Brown 已提交
810 811 812 813
	acpi_gbl_system_notify.handler = NULL;
	acpi_gbl_device_notify.handler = NULL;
	acpi_gbl_exception_handler = NULL;
	acpi_gbl_init_handler = NULL;
L
Linus Torvalds 已提交
814 815 816

	/* Global "typed" ACPI table pointers */

L
Len Brown 已提交
817 818 819 820 821
	acpi_gbl_RSDP = NULL;
	acpi_gbl_XSDT = NULL;
	acpi_gbl_FACS = NULL;
	acpi_gbl_FADT = NULL;
	acpi_gbl_DSDT = NULL;
L
Linus Torvalds 已提交
822 823 824

	/* Global Lock support */

L
Len Brown 已提交
825 826 827
	acpi_gbl_global_lock_acquired = FALSE;
	acpi_gbl_global_lock_thread_count = 0;
	acpi_gbl_global_lock_handle = 0;
L
Linus Torvalds 已提交
828 829 830

	/* Miscellaneous variables */

L
Len Brown 已提交
831 832 833 834 835 836 837 838
	acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER;
	acpi_gbl_rsdp_original_location = 0;
	acpi_gbl_cm_single_step = FALSE;
	acpi_gbl_db_terminate_threads = FALSE;
	acpi_gbl_shutdown = FALSE;
	acpi_gbl_ns_lookup_count = 0;
	acpi_gbl_ps_find_count = 0;
	acpi_gbl_acpi_hardware_present = TRUE;
B
Bob Moore 已提交
839 840
	acpi_gbl_last_owner_id_index = 0;
	acpi_gbl_next_owner_id_offset = 0;
B
Bob Moore 已提交
841 842 843
	acpi_gbl_trace_method_name = 0;
	acpi_gbl_trace_dbg_level = 0;
	acpi_gbl_trace_dbg_layer = 0;
L
Len Brown 已提交
844 845
	acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
	acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
L
Linus Torvalds 已提交
846 847 848

	/* Hardware oriented */

L
Len Brown 已提交
849 850
	acpi_gbl_events_initialized = FALSE;
	acpi_gbl_system_awake_and_running = TRUE;
L
Linus Torvalds 已提交
851 852 853

	/* Namespace */

L
Len Brown 已提交
854
	acpi_gbl_root_node = NULL;
L
Linus Torvalds 已提交
855 856
	acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
	acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
L
Len Brown 已提交
857 858 859 860 861
	acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
	acpi_gbl_root_node_struct.child = NULL;
	acpi_gbl_root_node_struct.peer = NULL;
	acpi_gbl_root_node_struct.object = NULL;
	acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
L
Linus Torvalds 已提交
862 863

#ifdef ACPI_DEBUG_OUTPUT
L
Len Brown 已提交
864
	acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;
L
Linus Torvalds 已提交
865 866 867 868
#endif

	return_VOID;
}