utglobal.c 24.0 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7
/******************************************************************************
 *
 * Module Name: utglobal - Global variables for the ACPI subsystem
 *
 *****************************************************************************/

/*
8
 * Copyright (C) 2000 - 2010, Intel Corp.
L
Linus Torvalds 已提交
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
 * 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 <acpi/acpi.h>
L
Len Brown 已提交
47 48
#include "accommon.h"
#include "acnamesp.h"
L
Linus Torvalds 已提交
49 50

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

R
Robert Moore 已提交
53
/*******************************************************************************
L
Linus Torvalds 已提交
54 55 56 57 58 59 60 61 62
 *
 * 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 已提交
63
u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
L
Linus Torvalds 已提交
64 65 66

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

67
u32 acpi_dbg_layer = 0;
L
Len Brown 已提交
68
u32 acpi_gbl_nesting_level = 0;
L
Linus Torvalds 已提交
69 70 71

/* Debugger globals */

L
Len Brown 已提交
72 73 74
u8 acpi_gbl_db_terminate_threads = FALSE;
u8 acpi_gbl_abort_method = FALSE;
u8 acpi_gbl_method_executing = FALSE;
L
Linus Torvalds 已提交
75 76 77

/* System flags */

L
Len Brown 已提交
78
u32 acpi_gbl_startup_flags = 0;
L
Linus Torvalds 已提交
79 80 81

/* System starts uninitialized */

L
Len Brown 已提交
82
u8 acpi_gbl_shutdown = TRUE;
L
Linus Torvalds 已提交
83

L
Len Brown 已提交
84
const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
L
Linus Torvalds 已提交
85 86 87 88 89 90 91 92
	"\\_S0_",
	"\\_S1_",
	"\\_S2_",
	"\\_S3_",
	"\\_S4_",
	"\\_S5_"
};

93 94 95 96 97 98 99 100 101
const char *acpi_gbl_lowest_dstate_names[ACPI_NUM_sx_w_METHODS] = {
	"_S0W",
	"_S1W",
	"_S2W",
	"_S3W",
	"_S4W"
};

const char *acpi_gbl_highest_dstate_names[ACPI_NUM_sx_d_METHODS] = {
L
Linus Torvalds 已提交
102 103 104 105 106 107
	"_S1D",
	"_S2D",
	"_S3D",
	"_S4D"
};

R
Robert Moore 已提交
108
/*******************************************************************************
L
Linus Torvalds 已提交
109
 *
110 111 112 113 114 115 116 117 118
 * FUNCTION:    acpi_format_exception
 *
 * PARAMETERS:  Status       - The acpi_status code to be formatted
 *
 * RETURN:      A string containing the exception text. A valid pointer is
 *              always returned.
 *
 * DESCRIPTION: This function translates an ACPI exception into an ASCII string
 *              It is here instead of utxface.c so it is always present.
L
Linus Torvalds 已提交
119 120 121
 *
 ******************************************************************************/

122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
const char *acpi_format_exception(acpi_status status)
{
	const char *exception = NULL;

	ACPI_FUNCTION_ENTRY();

	exception = acpi_ut_validate_exception(status);
	if (!exception) {

		/* Exception code was not recognized */

		ACPI_ERROR((AE_INFO,
			    "Unknown exception code: 0x%8.8X", status));

		exception = "UNKNOWN_STATUS_CODE";
137
		dump_stack();
138 139 140 141 142 143 144 145 146 147 148 149
	}

	return (ACPI_CAST_PTR(const char, exception));
}

ACPI_EXPORT_SYMBOL(acpi_format_exception)

/*******************************************************************************
 *
 * Namespace globals
 *
 ******************************************************************************/
L
Linus Torvalds 已提交
150 151 152 153 154 155 156
/*
 * 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
157 158 159
 *    perform a Notify() operation on it. 09/2010: Changed to type Device.
 *    This still allows notifies, but does not confuse host code that
 *    searches for valid thermal_zone objects.
L
Linus Torvalds 已提交
160
 */
B
Bob Moore 已提交
161 162 163 164 165
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},
166
	{"_TZ_", ACPI_TYPE_DEVICE, NULL},
B
Bob Moore 已提交
167 168 169
	{"_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 已提交
170 171

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

R
Robert Moore 已提交
175 176
	/* Table terminator */

B
Bob Moore 已提交
177
	{NULL, ACPI_TYPE_ANY, NULL}
R
Robert Moore 已提交
178
};
L
Linus Torvalds 已提交
179 180 181 182 183

/*
 * Properties of the ACPI Object Types, both internal and external.
 * The table is indexed by values of acpi_object_type
 */
L
Len Brown 已提交
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
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 已提交
216 217 218 219
};

/* Hex to ASCII conversion table */

L
Len Brown 已提交
220 221 222
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 已提交
223 224 225
};

/*******************************************************************************
L
Linus Torvalds 已提交
226 227 228 229 230
 *
 * FUNCTION:    acpi_ut_hex_to_ascii_char
 *
 * PARAMETERS:  Integer             - Contains the hex digit
 *              Position            - bit position of the digit within the
R
Robert Moore 已提交
231
 *                                    integer (multiple of 4)
L
Linus Torvalds 已提交
232
 *
R
Robert Moore 已提交
233
 * RETURN:      The converted Ascii character
L
Linus Torvalds 已提交
234
 *
R
Robert Moore 已提交
235
 * DESCRIPTION: Convert a hex digit to an Ascii character
L
Linus Torvalds 已提交
236
 *
R
Robert Moore 已提交
237
 ******************************************************************************/
L
Linus Torvalds 已提交
238

239
char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
L
Linus Torvalds 已提交
240 241 242 243 244 245 246 247 248 249 250
{

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

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

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

L
Len Brown 已提交
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
	/* 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_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},
307 308 309
	/* ACPI_BITREG_SLEEP_TYPE           */ {ACPI_REGISTER_PM1_CONTROL,
						ACPI_BITPOSITION_SLEEP_TYPE,
						ACPI_BITMASK_SLEEP_TYPE},
L
Len Brown 已提交
310 311 312 313 314 315 316
	/* 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 已提交
317 318
};

L
Len Brown 已提交
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
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 已提交
340 341
};

R
Robert Moore 已提交
342
/*******************************************************************************
L
Linus Torvalds 已提交
343 344 345 346 347 348 349 350 351
 *
 * FUNCTION:    acpi_ut_get_region_name
 *
 * PARAMETERS:  None.
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
 *
R
Robert Moore 已提交
352
 ******************************************************************************/
L
Linus Torvalds 已提交
353 354 355

/* Region type decoding */

L
Len Brown 已提交
356
const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
L
Linus Torvalds 已提交
357 358 359 360 361
	"SystemMemory",
	"SystemIO",
	"PCI_Config",
	"EmbeddedControl",
	"SMBus",
362
	"SystemCMOS",
L
Linus Torvalds 已提交
363
	"PCIBARTarget",
364
	"IPMI",
L
Linus Torvalds 已提交
365 366 367
	"DataTable"
};

L
Len Brown 已提交
368
char *acpi_ut_get_region_name(u8 space_id)
L
Linus Torvalds 已提交
369 370
{

L
Len Brown 已提交
371
	if (space_id >= ACPI_USER_REGION_BEGIN) {
B
Bob Moore 已提交
372
		return ("UserDefinedRegion");
L
Len Brown 已提交
373
	} else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
B
Bob Moore 已提交
374
		return ("InvalidSpaceId");
L
Linus Torvalds 已提交
375 376
	}

B
Bob Moore 已提交
377
	return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
L
Linus Torvalds 已提交
378 379
}

R
Robert Moore 已提交
380
/*******************************************************************************
L
Linus Torvalds 已提交
381 382 383 384 385 386 387 388 389
 *
 * FUNCTION:    acpi_ut_get_event_name
 *
 * PARAMETERS:  None.
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
 *
R
Robert Moore 已提交
390
 ******************************************************************************/
L
Linus Torvalds 已提交
391 392 393

/* Event type decoding */

L
Len Brown 已提交
394
static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
L
Linus Torvalds 已提交
395
	"PM_Timer",
B
Bob Moore 已提交
396 397 398 399
	"GlobalLock",
	"PowerButton",
	"SleepButton",
	"RealTimeClock",
L
Linus Torvalds 已提交
400 401
};

L
Len Brown 已提交
402
char *acpi_ut_get_event_name(u32 event_id)
L
Linus Torvalds 已提交
403 404
{

L
Len Brown 已提交
405
	if (event_id > ACPI_EVENT_MAX) {
B
Bob Moore 已提交
406
		return ("InvalidEventID");
L
Linus Torvalds 已提交
407 408
	}

B
Bob Moore 已提交
409
	return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
L
Linus Torvalds 已提交
410 411
}

R
Robert Moore 已提交
412
/*******************************************************************************
L
Linus Torvalds 已提交
413 414 415 416 417 418 419 420 421
 *
 * FUNCTION:    acpi_ut_get_type_name
 *
 * PARAMETERS:  None.
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
 *
R
Robert Moore 已提交
422
 ******************************************************************************/
L
Linus Torvalds 已提交
423 424 425 426 427

/*
 * Elements of acpi_gbl_ns_type_names below must match
 * one-to-one with values of acpi_object_type
 *
R
Robert Moore 已提交
428 429 430
 * 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 已提交
431
 */
L
Len Brown 已提交
432
static const char acpi_gbl_bad_type[] = "UNDEFINED";
L
Linus Torvalds 已提交
433

R
Robert Moore 已提交
434 435
/* Printable names of the ACPI object types */

L
Len Brown 已提交
436
static const char *acpi_gbl_ns_type_names[] = {
L
Linus Torvalds 已提交
437 438 439 440 441
	/* 00 */ "Untyped",
	/* 01 */ "Integer",
	/* 02 */ "String",
	/* 03 */ "Buffer",
	/* 04 */ "Package",
B
Bob Moore 已提交
442
	/* 05 */ "FieldUnit",
L
Linus Torvalds 已提交
443 444 445 446 447 448 449 450
	/* 06 */ "Device",
	/* 07 */ "Event",
	/* 08 */ "Method",
	/* 09 */ "Mutex",
	/* 10 */ "Region",
	/* 11 */ "Power",
	/* 12 */ "Processor",
	/* 13 */ "Thermal",
B
Bob Moore 已提交
451 452 453 454 455 456
	/* 14 */ "BufferField",
	/* 15 */ "DdbHandle",
	/* 16 */ "DebugObject",
	/* 17 */ "RegionField",
	/* 18 */ "BankField",
	/* 19 */ "IndexField",
L
Linus Torvalds 已提交
457 458
	/* 20 */ "Reference",
	/* 21 */ "Alias",
B
Bob Moore 已提交
459
	/* 22 */ "MethodAlias",
L
Linus Torvalds 已提交
460
	/* 23 */ "Notify",
B
Bob Moore 已提交
461 462 463
	/* 24 */ "AddrHandler",
	/* 25 */ "ResourceDesc",
	/* 26 */ "ResourceFld",
L
Linus Torvalds 已提交
464 465 466 467 468 469
	/* 27 */ "Scope",
	/* 28 */ "Extra",
	/* 29 */ "Data",
	/* 30 */ "Invalid"
};

L
Len Brown 已提交
470
char *acpi_ut_get_type_name(acpi_object_type type)
L
Linus Torvalds 已提交
471 472
{

L
Len Brown 已提交
473
	if (type > ACPI_TYPE_INVALID) {
B
Bob Moore 已提交
474
		return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
L
Linus Torvalds 已提交
475 476
	}

B
Bob Moore 已提交
477
	return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
L
Linus Torvalds 已提交
478 479
}

L
Len Brown 已提交
480
char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
L
Linus Torvalds 已提交
481 482
{

L
Len Brown 已提交
483
	if (!obj_desc) {
L
Linus Torvalds 已提交
484 485 486
		return ("[NULL Object Descriptor]");
	}

487
	return (acpi_ut_get_type_name(obj_desc->common.type));
L
Linus Torvalds 已提交
488 489
}

R
Robert Moore 已提交
490
/*******************************************************************************
L
Linus Torvalds 已提交
491 492 493 494 495 496 497 498 499
 *
 * 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 已提交
500
 ******************************************************************************/
L
Linus Torvalds 已提交
501

L
Len Brown 已提交
502
char *acpi_ut_get_node_name(void *object)
L
Linus Torvalds 已提交
503
{
L
Len Brown 已提交
504
	struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
L
Linus Torvalds 已提交
505 506 507

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

L
Len Brown 已提交
508
	if (!object) {
L
Linus Torvalds 已提交
509 510 511 512 513
		return ("NULL");
	}

	/* Check for Root node */

L
Len Brown 已提交
514
	if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
L
Linus Torvalds 已提交
515 516 517 518 519
		return ("\"\\\" ");
	}

	/* Descriptor must be a namespace node */

B
Bob Moore 已提交
520
	if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
L
Linus Torvalds 已提交
521 522 523 524 525
		return ("####");
	}

	/* Name must be a valid ACPI name */

B
Bob Moore 已提交
526
	if (!acpi_ut_valid_acpi_name(node->name.integer)) {
527
		node->name.integer = acpi_ut_repair_name(node->name.ascii);
L
Linus Torvalds 已提交
528 529 530 531 532 533 534
	}

	/* Return the name */

	return (node->name.ascii);
}

R
Robert Moore 已提交
535
/*******************************************************************************
L
Linus Torvalds 已提交
536 537 538 539 540 541 542 543 544
 *
 * 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 已提交
545 546 547
 ******************************************************************************/

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

L
Len Brown 已提交
549
static const char *acpi_gbl_desc_type_names[] = {
L
Linus Torvalds 已提交
550 551 552 553 554 555
	/* 00 */ "Invalid",
	/* 01 */ "Cached",
	/* 02 */ "State-Generic",
	/* 03 */ "State-Update",
	/* 04 */ "State-Package",
	/* 05 */ "State-Control",
B
Bob Moore 已提交
556 557 558
	/* 06 */ "State-RootParseScope",
	/* 07 */ "State-ParseScope",
	/* 08 */ "State-WalkScope",
L
Linus Torvalds 已提交
559 560 561 562 563 564 565 566 567
	/* 09 */ "State-Result",
	/* 10 */ "State-Notify",
	/* 11 */ "State-Thread",
	/* 12 */ "Walk",
	/* 13 */ "Parser",
	/* 14 */ "Operand",
	/* 15 */ "Node"
};

L
Len Brown 已提交
568
char *acpi_ut_get_descriptor_name(void *object)
L
Linus Torvalds 已提交
569 570
{

L
Len Brown 已提交
571
	if (!object) {
L
Linus Torvalds 已提交
572 573 574
		return ("NULL OBJECT");
	}

L
Len Brown 已提交
575
	if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
B
Bob Moore 已提交
576
		return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
L
Linus Torvalds 已提交
577 578
	}

B
Bob Moore 已提交
579 580 581
	return (ACPI_CAST_PTR(char,
			      acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
						       (object)]));
L
Linus Torvalds 已提交
582 583 584

}

585 586 587 588 589 590 591 592 593 594 595 596 597 598
/*******************************************************************************
 *
 * FUNCTION:    acpi_ut_get_reference_name
 *
 * PARAMETERS:  Object               - An ACPI reference object
 *
 * RETURN:      Pointer to a string
 *
 * DESCRIPTION: Decode a reference object sub-type to a string.
 *
 ******************************************************************************/

/* Printable names of reference object sub-types */

599 600 601 602 603 604 605 606 607 608
static const char *acpi_gbl_ref_class_names[] = {
	/* 00 */ "Local",
	/* 01 */ "Argument",
	/* 02 */ "RefOf",
	/* 03 */ "Index",
	/* 04 */ "DdbHandle",
	/* 05 */ "Named Object",
	/* 06 */ "Debug"
};

609 610
const char *acpi_ut_get_reference_name(union acpi_operand_object *object)
{
611 612
	if (!object)
		return "NULL Object";
613

614 615
	if (ACPI_GET_DESCRIPTOR_TYPE(object) != ACPI_DESC_TYPE_OPERAND)
		return "Not an Operand object";
616

617 618
	if (object->common.type != ACPI_TYPE_LOCAL_REFERENCE)
		return "Not a Reference object";
619

620 621
	if (object->reference.class > ACPI_REFCLASS_MAX)
		return "Unknown Reference class";
622

623
	return acpi_gbl_ref_class_names[object->reference.class];
624 625
}

L
Linus Torvalds 已提交
626 627 628 629 630
#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
/*
 * Strings and procedures used for debug only
 */

R
Robert Moore 已提交
631
/*******************************************************************************
L
Linus Torvalds 已提交
632 633 634
 *
 * FUNCTION:    acpi_ut_get_mutex_name
 *
R
Robert Moore 已提交
635
 * PARAMETERS:  mutex_id        - The predefined ID for this mutex.
L
Linus Torvalds 已提交
636
 *
R
Robert Moore 已提交
637 638
 * RETURN:      String containing the name of the mutex. Always returns a valid
 *              pointer.
L
Linus Torvalds 已提交
639 640 641
 *
 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
 *
R
Robert Moore 已提交
642
 ******************************************************************************/
L
Linus Torvalds 已提交
643

L
Len Brown 已提交
644
char *acpi_ut_get_mutex_name(u32 mutex_id)
L
Linus Torvalds 已提交
645 646
{

B
Bob Moore 已提交
647
	if (mutex_id > ACPI_MAX_MUTEX) {
L
Linus Torvalds 已提交
648 649 650 651 652
		return ("Invalid Mutex ID");
	}

	return (acpi_gbl_mutex_names[mutex_id]);
}
Z
Zhang Rui 已提交
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694

/*******************************************************************************
 *
 * FUNCTION:    acpi_ut_get_notify_name
 *
 * PARAMETERS:  notify_value    - Value from the Notify() request
 *
 * RETURN:      String corresponding to the Notify Value.
 *
 * DESCRIPTION: Translate a Notify Value to a notify namestring.
 *
 ******************************************************************************/

/* Names for Notify() values, used for debug output */

static const char *acpi_gbl_notify_value_names[] = {
	"Bus Check",
	"Device Check",
	"Device Wake",
	"Eject Request",
	"Device Check Light",
	"Frequency Mismatch",
	"Bus Mode Mismatch",
	"Power Fault",
	"Capabilities Check",
	"Device PLD Check",
	"Reserved",
	"System Locality Update"
};

const char *acpi_ut_get_notify_name(u32 notify_value)
{

	if (notify_value <= ACPI_NOTIFY_MAX) {
		return (acpi_gbl_notify_value_names[notify_value]);
	} else if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
		return ("Reserved");
	} else {		/* Greater or equal to 0x80 */

		return ("**Device Specific**");
	}
}
L
Linus Torvalds 已提交
695 696
#endif

R
Robert Moore 已提交
697
/*******************************************************************************
L
Linus Torvalds 已提交
698 699 700 701 702
 *
 * FUNCTION:    acpi_ut_valid_object_type
 *
 * PARAMETERS:  Type            - Object type to be validated
 *
R
Robert Moore 已提交
703
 * RETURN:      TRUE if valid object type, FALSE otherwise
L
Linus Torvalds 已提交
704 705 706
 *
 * DESCRIPTION: Validate an object type
 *
R
Robert Moore 已提交
707
 ******************************************************************************/
L
Linus Torvalds 已提交
708

L
Len Brown 已提交
709
u8 acpi_ut_valid_object_type(acpi_object_type type)
L
Linus Torvalds 已提交
710 711
{

L
Len Brown 已提交
712
	if (type > ACPI_TYPE_LOCAL_MAX) {
B
Bob Moore 已提交
713

L
Linus Torvalds 已提交
714 715 716 717 718 719 720 721
		/* Note: Assumes all TYPEs are contiguous (external/local) */

		return (FALSE);
	}

	return (TRUE);
}

R
Robert Moore 已提交
722
/*******************************************************************************
L
Linus Torvalds 已提交
723 724 725
 *
 * FUNCTION:    acpi_ut_init_globals
 *
R
Robert Moore 已提交
726 727
 * PARAMETERS:  None
 *
728
 * RETURN:      Status
L
Linus Torvalds 已提交
729 730 731 732
 *
 * DESCRIPTION: Init library globals.  All globals that require specific
 *              initialization should be initialized here!
 *
R
Robert Moore 已提交
733
 ******************************************************************************/
L
Linus Torvalds 已提交
734

735
acpi_status acpi_ut_init_globals(void)
L
Linus Torvalds 已提交
736
{
L
Len Brown 已提交
737 738
	acpi_status status;
	u32 i;
L
Linus Torvalds 已提交
739

B
Bob Moore 已提交
740
	ACPI_FUNCTION_TRACE(ut_init_globals);
L
Linus Torvalds 已提交
741

742 743
	/* Create all memory caches */

L
Len Brown 已提交
744 745
	status = acpi_ut_create_caches();
	if (ACPI_FAILURE(status)) {
746
		return_ACPI_STATUS(status);
747
	}
L
Linus Torvalds 已提交
748 749 750

	/* Mutex locked flags */

B
Bob Moore 已提交
751
	for (i = 0; i < ACPI_NUM_MUTEX; i++) {
L
Len Brown 已提交
752 753 754
		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 已提交
755 756
	}

B
Bob Moore 已提交
757 758 759
	for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
		acpi_gbl_owner_id_mask[i] = 0;
	}
760 761 762 763

	/* Last owner_iD is never valid */

	acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
B
Bob Moore 已提交
764

L
Linus Torvalds 已提交
765 766
	/* GPE support */

L
Len Brown 已提交
767 768 769
	acpi_gbl_gpe_xrupt_list_head = NULL;
	acpi_gbl_gpe_fadt_blocks[0] = NULL;
	acpi_gbl_gpe_fadt_blocks[1] = NULL;
770
	acpi_current_gpe_count = 0;
L
Linus Torvalds 已提交
771

772
	/* Global handlers */
L
Linus Torvalds 已提交
773

L
Len Brown 已提交
774 775 776 777
	acpi_gbl_system_notify.handler = NULL;
	acpi_gbl_device_notify.handler = NULL;
	acpi_gbl_exception_handler = NULL;
	acpi_gbl_init_handler = NULL;
778
	acpi_gbl_table_handler = NULL;
779
	acpi_gbl_interface_handler = NULL;
L
Linus Torvalds 已提交
780 781 782

	/* Global Lock support */

B
Bob Moore 已提交
783
	acpi_gbl_global_lock_semaphore = NULL;
784
	acpi_gbl_global_lock_mutex = NULL;
L
Len Brown 已提交
785 786
	acpi_gbl_global_lock_acquired = FALSE;
	acpi_gbl_global_lock_handle = 0;
787
	acpi_gbl_global_lock_present = FALSE;
L
Linus Torvalds 已提交
788 789 790

	/* Miscellaneous variables */

B
Bob Moore 已提交
791
	acpi_gbl_DSDT = NULL;
L
Len Brown 已提交
792 793 794 795 796 797
	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 已提交
798 799
	acpi_gbl_last_owner_id_index = 0;
	acpi_gbl_next_owner_id_offset = 0;
B
Bob Moore 已提交
800 801 802
	acpi_gbl_trace_method_name = 0;
	acpi_gbl_trace_dbg_level = 0;
	acpi_gbl_trace_dbg_layer = 0;
L
Len Brown 已提交
803 804
	acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
	acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
B
Bob Moore 已提交
805
	acpi_gbl_osi_data = 0;
806
	acpi_gbl_osi_mutex = NULL;
L
Linus Torvalds 已提交
807 808 809

	/* Hardware oriented */

L
Len Brown 已提交
810 811
	acpi_gbl_events_initialized = FALSE;
	acpi_gbl_system_awake_and_running = TRUE;
L
Linus Torvalds 已提交
812 813 814

	/* Namespace */

815
	acpi_gbl_module_code_list = NULL;
L
Len Brown 已提交
816
	acpi_gbl_root_node = NULL;
L
Linus Torvalds 已提交
817
	acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
B
Bob Moore 已提交
818
	acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
L
Len Brown 已提交
819
	acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
820
	acpi_gbl_root_node_struct.parent = NULL;
L
Len Brown 已提交
821 822 823
	acpi_gbl_root_node_struct.child = NULL;
	acpi_gbl_root_node_struct.peer = NULL;
	acpi_gbl_root_node_struct.object = NULL;
L
Linus Torvalds 已提交
824 825

#ifdef ACPI_DEBUG_OUTPUT
826
	acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
L
Linus Torvalds 已提交
827 828
#endif

829 830 831 832
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
	acpi_gbl_display_final_mem_stats = FALSE;
#endif

833
	return_ACPI_STATUS(AE_OK);
L
Linus Torvalds 已提交
834
}
B
Bob Moore 已提交
835

836
ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
B
Bob Moore 已提交
837
ACPI_EXPORT_SYMBOL(acpi_dbg_level)
838
ACPI_EXPORT_SYMBOL(acpi_dbg_layer)
839
ACPI_EXPORT_SYMBOL(acpi_current_gpe_count)