utglobal.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781
  1. /******************************************************************************
  2. *
  3. * Module Name: utglobal - Global variables for the ACPI subsystem
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2006, R. Byron Moore
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #define DEFINE_ACPI_GLOBALS
  43. #include <acpi/acpi.h>
  44. #include <acpi/acnamesp.h>
  45. ACPI_EXPORT_SYMBOL(acpi_gbl_FADT)
  46. #define _COMPONENT ACPI_UTILITIES
  47. ACPI_MODULE_NAME("utglobal")
  48. /*******************************************************************************
  49. *
  50. * FUNCTION: acpi_format_exception
  51. *
  52. * PARAMETERS: Status - The acpi_status code to be formatted
  53. *
  54. * RETURN: A string containing the exception text. A valid pointer is
  55. * always returned.
  56. *
  57. * DESCRIPTION: This function translates an ACPI exception into an ASCII string.
  58. *
  59. ******************************************************************************/
  60. const char *acpi_format_exception(acpi_status status)
  61. {
  62. acpi_status sub_status;
  63. const char *exception = NULL;
  64. ACPI_FUNCTION_ENTRY();
  65. /*
  66. * Status is composed of two parts, a "type" and an actual code
  67. */
  68. sub_status = (status & ~AE_CODE_MASK);
  69. switch (status & AE_CODE_MASK) {
  70. case AE_CODE_ENVIRONMENTAL:
  71. if (sub_status <= AE_CODE_ENV_MAX) {
  72. exception = acpi_gbl_exception_names_env[sub_status];
  73. }
  74. break;
  75. case AE_CODE_PROGRAMMER:
  76. if (sub_status <= AE_CODE_PGM_MAX) {
  77. exception =
  78. acpi_gbl_exception_names_pgm[sub_status - 1];
  79. }
  80. break;
  81. case AE_CODE_ACPI_TABLES:
  82. if (sub_status <= AE_CODE_TBL_MAX) {
  83. exception =
  84. acpi_gbl_exception_names_tbl[sub_status - 1];
  85. }
  86. break;
  87. case AE_CODE_AML:
  88. if (sub_status <= AE_CODE_AML_MAX) {
  89. exception =
  90. acpi_gbl_exception_names_aml[sub_status - 1];
  91. }
  92. break;
  93. case AE_CODE_CONTROL:
  94. if (sub_status <= AE_CODE_CTRL_MAX) {
  95. exception =
  96. acpi_gbl_exception_names_ctrl[sub_status - 1];
  97. }
  98. break;
  99. default:
  100. break;
  101. }
  102. if (!exception) {
  103. /* Exception code was not recognized */
  104. ACPI_ERROR((AE_INFO,
  105. "Unknown exception code: 0x%8.8X", status));
  106. exception = "UNKNOWN_STATUS_CODE";
  107. }
  108. return (ACPI_CAST_PTR(const char, exception));
  109. }
  110. /*******************************************************************************
  111. *
  112. * Static global variable initialization.
  113. *
  114. ******************************************************************************/
  115. /*
  116. * We want the debug switches statically initialized so they
  117. * are already set when the debugger is entered.
  118. */
  119. /* Debug switch - level and trace mask */
  120. u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
  121. /* Debug switch - layer (component) mask */
  122. u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
  123. u32 acpi_gbl_nesting_level = 0;
  124. /* Debugger globals */
  125. u8 acpi_gbl_db_terminate_threads = FALSE;
  126. u8 acpi_gbl_abort_method = FALSE;
  127. u8 acpi_gbl_method_executing = FALSE;
  128. /* System flags */
  129. u32 acpi_gbl_startup_flags = 0;
  130. /* System starts uninitialized */
  131. u8 acpi_gbl_shutdown = TRUE;
  132. const u8 acpi_gbl_decode_to8bit[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
  133. const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
  134. "\\_S0_",
  135. "\\_S1_",
  136. "\\_S2_",
  137. "\\_S3_",
  138. "\\_S4_",
  139. "\\_S5_"
  140. };
  141. const char *acpi_gbl_highest_dstate_names[4] = {
  142. "_S1D",
  143. "_S2D",
  144. "_S3D",
  145. "_S4D"
  146. };
  147. /*******************************************************************************
  148. *
  149. * Namespace globals
  150. *
  151. ******************************************************************************/
  152. /*
  153. * Predefined ACPI Names (Built-in to the Interpreter)
  154. *
  155. * NOTES:
  156. * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
  157. * during the initialization sequence.
  158. * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
  159. * perform a Notify() operation on it.
  160. */
  161. const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
  162. {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
  163. {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
  164. {"_SB_", ACPI_TYPE_DEVICE, NULL},
  165. {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
  166. {"_TZ_", ACPI_TYPE_THERMAL, NULL},
  167. {"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
  168. {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
  169. {"_GL_", ACPI_TYPE_MUTEX, (char *)1},
  170. #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
  171. {"_OSI", ACPI_TYPE_METHOD, (char *)1},
  172. #endif
  173. /* Table terminator */
  174. {NULL, ACPI_TYPE_ANY, NULL}
  175. };
  176. /*
  177. * Properties of the ACPI Object Types, both internal and external.
  178. * The table is indexed by values of acpi_object_type
  179. */
  180. const u8 acpi_gbl_ns_properties[] = {
  181. ACPI_NS_NORMAL, /* 00 Any */
  182. ACPI_NS_NORMAL, /* 01 Number */
  183. ACPI_NS_NORMAL, /* 02 String */
  184. ACPI_NS_NORMAL, /* 03 Buffer */
  185. ACPI_NS_NORMAL, /* 04 Package */
  186. ACPI_NS_NORMAL, /* 05 field_unit */
  187. ACPI_NS_NEWSCOPE, /* 06 Device */
  188. ACPI_NS_NORMAL, /* 07 Event */
  189. ACPI_NS_NEWSCOPE, /* 08 Method */
  190. ACPI_NS_NORMAL, /* 09 Mutex */
  191. ACPI_NS_NORMAL, /* 10 Region */
  192. ACPI_NS_NEWSCOPE, /* 11 Power */
  193. ACPI_NS_NEWSCOPE, /* 12 Processor */
  194. ACPI_NS_NEWSCOPE, /* 13 Thermal */
  195. ACPI_NS_NORMAL, /* 14 buffer_field */
  196. ACPI_NS_NORMAL, /* 15 ddb_handle */
  197. ACPI_NS_NORMAL, /* 16 Debug Object */
  198. ACPI_NS_NORMAL, /* 17 def_field */
  199. ACPI_NS_NORMAL, /* 18 bank_field */
  200. ACPI_NS_NORMAL, /* 19 index_field */
  201. ACPI_NS_NORMAL, /* 20 Reference */
  202. ACPI_NS_NORMAL, /* 21 Alias */
  203. ACPI_NS_NORMAL, /* 22 method_alias */
  204. ACPI_NS_NORMAL, /* 23 Notify */
  205. ACPI_NS_NORMAL, /* 24 Address Handler */
  206. ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
  207. ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
  208. ACPI_NS_NEWSCOPE, /* 27 Scope */
  209. ACPI_NS_NORMAL, /* 28 Extra */
  210. ACPI_NS_NORMAL, /* 29 Data */
  211. ACPI_NS_NORMAL /* 30 Invalid */
  212. };
  213. /* Hex to ASCII conversion table */
  214. static const char acpi_gbl_hex_to_ascii[] = {
  215. '0', '1', '2', '3', '4', '5', '6', '7',
  216. '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
  217. };
  218. /*******************************************************************************
  219. *
  220. * FUNCTION: acpi_ut_hex_to_ascii_char
  221. *
  222. * PARAMETERS: Integer - Contains the hex digit
  223. * Position - bit position of the digit within the
  224. * integer (multiple of 4)
  225. *
  226. * RETURN: The converted Ascii character
  227. *
  228. * DESCRIPTION: Convert a hex digit to an Ascii character
  229. *
  230. ******************************************************************************/
  231. char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position)
  232. {
  233. return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
  234. }
  235. /******************************************************************************
  236. *
  237. * Event and Hardware globals
  238. *
  239. ******************************************************************************/
  240. struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
  241. /* Name Parent Register Register Bit Position Register Bit Mask */
  242. /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  243. ACPI_BITPOSITION_TIMER_STATUS,
  244. ACPI_BITMASK_TIMER_STATUS},
  245. /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  246. ACPI_BITPOSITION_BUS_MASTER_STATUS,
  247. ACPI_BITMASK_BUS_MASTER_STATUS},
  248. /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  249. ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,
  250. ACPI_BITMASK_GLOBAL_LOCK_STATUS},
  251. /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  252. ACPI_BITPOSITION_POWER_BUTTON_STATUS,
  253. ACPI_BITMASK_POWER_BUTTON_STATUS},
  254. /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  255. ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,
  256. ACPI_BITMASK_SLEEP_BUTTON_STATUS},
  257. /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  258. ACPI_BITPOSITION_RT_CLOCK_STATUS,
  259. ACPI_BITMASK_RT_CLOCK_STATUS},
  260. /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  261. ACPI_BITPOSITION_WAKE_STATUS,
  262. ACPI_BITMASK_WAKE_STATUS},
  263. /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  264. ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,
  265. ACPI_BITMASK_PCIEXP_WAKE_STATUS},
  266. /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
  267. ACPI_BITPOSITION_TIMER_ENABLE,
  268. ACPI_BITMASK_TIMER_ENABLE},
  269. /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
  270. ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,
  271. ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
  272. /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
  273. ACPI_BITPOSITION_POWER_BUTTON_ENABLE,
  274. ACPI_BITMASK_POWER_BUTTON_ENABLE},
  275. /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
  276. ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,
  277. ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
  278. /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
  279. ACPI_BITPOSITION_RT_CLOCK_ENABLE,
  280. ACPI_BITMASK_RT_CLOCK_ENABLE},
  281. /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
  282. /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE,
  283. ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
  284. ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
  285. /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
  286. ACPI_BITPOSITION_SCI_ENABLE,
  287. ACPI_BITMASK_SCI_ENABLE},
  288. /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL,
  289. ACPI_BITPOSITION_BUS_MASTER_RLD,
  290. ACPI_BITMASK_BUS_MASTER_RLD},
  291. /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL,
  292. ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
  293. ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
  294. /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL,
  295. ACPI_BITPOSITION_SLEEP_TYPE_X,
  296. ACPI_BITMASK_SLEEP_TYPE_X},
  297. /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL,
  298. ACPI_BITPOSITION_SLEEP_TYPE_X,
  299. ACPI_BITMASK_SLEEP_TYPE_X},
  300. /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
  301. ACPI_BITPOSITION_SLEEP_ENABLE,
  302. ACPI_BITMASK_SLEEP_ENABLE},
  303. /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL,
  304. ACPI_BITPOSITION_ARB_DISABLE,
  305. ACPI_BITMASK_ARB_DISABLE}
  306. };
  307. struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = {
  308. /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS,
  309. ACPI_BITREG_TIMER_ENABLE,
  310. ACPI_BITMASK_TIMER_STATUS,
  311. ACPI_BITMASK_TIMER_ENABLE},
  312. /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS,
  313. ACPI_BITREG_GLOBAL_LOCK_ENABLE,
  314. ACPI_BITMASK_GLOBAL_LOCK_STATUS,
  315. ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
  316. /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS,
  317. ACPI_BITREG_POWER_BUTTON_ENABLE,
  318. ACPI_BITMASK_POWER_BUTTON_STATUS,
  319. ACPI_BITMASK_POWER_BUTTON_ENABLE},
  320. /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS,
  321. ACPI_BITREG_SLEEP_BUTTON_ENABLE,
  322. ACPI_BITMASK_SLEEP_BUTTON_STATUS,
  323. ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
  324. /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS,
  325. ACPI_BITREG_RT_CLOCK_ENABLE,
  326. ACPI_BITMASK_RT_CLOCK_STATUS,
  327. ACPI_BITMASK_RT_CLOCK_ENABLE},
  328. };
  329. /*******************************************************************************
  330. *
  331. * FUNCTION: acpi_ut_get_region_name
  332. *
  333. * PARAMETERS: None.
  334. *
  335. * RETURN: Status
  336. *
  337. * DESCRIPTION: Translate a Space ID into a name string (Debug only)
  338. *
  339. ******************************************************************************/
  340. /* Region type decoding */
  341. const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
  342. "SystemMemory",
  343. "SystemIO",
  344. "PCI_Config",
  345. "EmbeddedControl",
  346. "SMBus",
  347. "CMOS",
  348. "PCIBARTarget",
  349. "DataTable"
  350. };
  351. char *acpi_ut_get_region_name(u8 space_id)
  352. {
  353. if (space_id >= ACPI_USER_REGION_BEGIN) {
  354. return ("UserDefinedRegion");
  355. } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
  356. return ("InvalidSpaceId");
  357. }
  358. return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
  359. }
  360. /*******************************************************************************
  361. *
  362. * FUNCTION: acpi_ut_get_event_name
  363. *
  364. * PARAMETERS: None.
  365. *
  366. * RETURN: Status
  367. *
  368. * DESCRIPTION: Translate a Event ID into a name string (Debug only)
  369. *
  370. ******************************************************************************/
  371. /* Event type decoding */
  372. static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
  373. "PM_Timer",
  374. "GlobalLock",
  375. "PowerButton",
  376. "SleepButton",
  377. "RealTimeClock",
  378. };
  379. char *acpi_ut_get_event_name(u32 event_id)
  380. {
  381. if (event_id > ACPI_EVENT_MAX) {
  382. return ("InvalidEventID");
  383. }
  384. return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
  385. }
  386. /*******************************************************************************
  387. *
  388. * FUNCTION: acpi_ut_get_type_name
  389. *
  390. * PARAMETERS: None.
  391. *
  392. * RETURN: Status
  393. *
  394. * DESCRIPTION: Translate a Type ID into a name string (Debug only)
  395. *
  396. ******************************************************************************/
  397. /*
  398. * Elements of acpi_gbl_ns_type_names below must match
  399. * one-to-one with values of acpi_object_type
  400. *
  401. * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
  402. * when stored in a table it really means that we have thus far seen no
  403. * evidence to indicate what type is actually going to be stored for this entry.
  404. */
  405. static const char acpi_gbl_bad_type[] = "UNDEFINED";
  406. /* Printable names of the ACPI object types */
  407. static const char *acpi_gbl_ns_type_names[] = {
  408. /* 00 */ "Untyped",
  409. /* 01 */ "Integer",
  410. /* 02 */ "String",
  411. /* 03 */ "Buffer",
  412. /* 04 */ "Package",
  413. /* 05 */ "FieldUnit",
  414. /* 06 */ "Device",
  415. /* 07 */ "Event",
  416. /* 08 */ "Method",
  417. /* 09 */ "Mutex",
  418. /* 10 */ "Region",
  419. /* 11 */ "Power",
  420. /* 12 */ "Processor",
  421. /* 13 */ "Thermal",
  422. /* 14 */ "BufferField",
  423. /* 15 */ "DdbHandle",
  424. /* 16 */ "DebugObject",
  425. /* 17 */ "RegionField",
  426. /* 18 */ "BankField",
  427. /* 19 */ "IndexField",
  428. /* 20 */ "Reference",
  429. /* 21 */ "Alias",
  430. /* 22 */ "MethodAlias",
  431. /* 23 */ "Notify",
  432. /* 24 */ "AddrHandler",
  433. /* 25 */ "ResourceDesc",
  434. /* 26 */ "ResourceFld",
  435. /* 27 */ "Scope",
  436. /* 28 */ "Extra",
  437. /* 29 */ "Data",
  438. /* 30 */ "Invalid"
  439. };
  440. char *acpi_ut_get_type_name(acpi_object_type type)
  441. {
  442. if (type > ACPI_TYPE_INVALID) {
  443. return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
  444. }
  445. return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
  446. }
  447. char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
  448. {
  449. if (!obj_desc) {
  450. return ("[NULL Object Descriptor]");
  451. }
  452. return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)));
  453. }
  454. /*******************************************************************************
  455. *
  456. * FUNCTION: acpi_ut_get_node_name
  457. *
  458. * PARAMETERS: Object - A namespace node
  459. *
  460. * RETURN: Pointer to a string
  461. *
  462. * DESCRIPTION: Validate the node and return the node's ACPI name.
  463. *
  464. ******************************************************************************/
  465. char *acpi_ut_get_node_name(void *object)
  466. {
  467. struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
  468. /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
  469. if (!object) {
  470. return ("NULL");
  471. }
  472. /* Check for Root node */
  473. if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
  474. return ("\"\\\" ");
  475. }
  476. /* Descriptor must be a namespace node */
  477. if (ACPI_GET_DESCRIPTOR_TYPE(node) != ACPI_DESC_TYPE_NAMED) {
  478. return ("####");
  479. }
  480. /* Name must be a valid ACPI name */
  481. if (!acpi_ut_valid_acpi_name(node->name.integer)) {
  482. node->name.integer = acpi_ut_repair_name(node->name.integer);
  483. }
  484. /* Return the name */
  485. return (node->name.ascii);
  486. }
  487. /*******************************************************************************
  488. *
  489. * FUNCTION: acpi_ut_get_descriptor_name
  490. *
  491. * PARAMETERS: Object - An ACPI object
  492. *
  493. * RETURN: Pointer to a string
  494. *
  495. * DESCRIPTION: Validate object and return the descriptor type
  496. *
  497. ******************************************************************************/
  498. /* Printable names of object descriptor types */
  499. static const char *acpi_gbl_desc_type_names[] = {
  500. /* 00 */ "Invalid",
  501. /* 01 */ "Cached",
  502. /* 02 */ "State-Generic",
  503. /* 03 */ "State-Update",
  504. /* 04 */ "State-Package",
  505. /* 05 */ "State-Control",
  506. /* 06 */ "State-RootParseScope",
  507. /* 07 */ "State-ParseScope",
  508. /* 08 */ "State-WalkScope",
  509. /* 09 */ "State-Result",
  510. /* 10 */ "State-Notify",
  511. /* 11 */ "State-Thread",
  512. /* 12 */ "Walk",
  513. /* 13 */ "Parser",
  514. /* 14 */ "Operand",
  515. /* 15 */ "Node"
  516. };
  517. char *acpi_ut_get_descriptor_name(void *object)
  518. {
  519. if (!object) {
  520. return ("NULL OBJECT");
  521. }
  522. if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
  523. return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
  524. }
  525. return (ACPI_CAST_PTR(char,
  526. acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
  527. (object)]));
  528. }
  529. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  530. /*
  531. * Strings and procedures used for debug only
  532. */
  533. /*******************************************************************************
  534. *
  535. * FUNCTION: acpi_ut_get_mutex_name
  536. *
  537. * PARAMETERS: mutex_id - The predefined ID for this mutex.
  538. *
  539. * RETURN: String containing the name of the mutex. Always returns a valid
  540. * pointer.
  541. *
  542. * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
  543. *
  544. ******************************************************************************/
  545. char *acpi_ut_get_mutex_name(u32 mutex_id)
  546. {
  547. if (mutex_id > ACPI_MAX_MUTEX) {
  548. return ("Invalid Mutex ID");
  549. }
  550. return (acpi_gbl_mutex_names[mutex_id]);
  551. }
  552. #endif
  553. /*******************************************************************************
  554. *
  555. * FUNCTION: acpi_ut_valid_object_type
  556. *
  557. * PARAMETERS: Type - Object type to be validated
  558. *
  559. * RETURN: TRUE if valid object type, FALSE otherwise
  560. *
  561. * DESCRIPTION: Validate an object type
  562. *
  563. ******************************************************************************/
  564. u8 acpi_ut_valid_object_type(acpi_object_type type)
  565. {
  566. if (type > ACPI_TYPE_LOCAL_MAX) {
  567. /* Note: Assumes all TYPEs are contiguous (external/local) */
  568. return (FALSE);
  569. }
  570. return (TRUE);
  571. }
  572. /*******************************************************************************
  573. *
  574. * FUNCTION: acpi_ut_init_globals
  575. *
  576. * PARAMETERS: None
  577. *
  578. * RETURN: None
  579. *
  580. * DESCRIPTION: Init library globals. All globals that require specific
  581. * initialization should be initialized here!
  582. *
  583. ******************************************************************************/
  584. void acpi_ut_init_globals(void)
  585. {
  586. acpi_status status;
  587. u32 i;
  588. ACPI_FUNCTION_TRACE(ut_init_globals);
  589. /* Create all memory caches */
  590. status = acpi_ut_create_caches();
  591. if (ACPI_FAILURE(status)) {
  592. return;
  593. }
  594. /* Mutex locked flags */
  595. for (i = 0; i < ACPI_NUM_MUTEX; i++) {
  596. acpi_gbl_mutex_info[i].mutex = NULL;
  597. acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
  598. acpi_gbl_mutex_info[i].use_count = 0;
  599. }
  600. for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
  601. acpi_gbl_owner_id_mask[i] = 0;
  602. }
  603. acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */
  604. /* GPE support */
  605. acpi_gbl_gpe_xrupt_list_head = NULL;
  606. acpi_gbl_gpe_fadt_blocks[0] = NULL;
  607. acpi_gbl_gpe_fadt_blocks[1] = NULL;
  608. /* Global notify handlers */
  609. acpi_gbl_system_notify.handler = NULL;
  610. acpi_gbl_device_notify.handler = NULL;
  611. acpi_gbl_exception_handler = NULL;
  612. acpi_gbl_init_handler = NULL;
  613. /* Global Lock support */
  614. acpi_gbl_global_lock_semaphore = NULL;
  615. acpi_gbl_global_lock_mutex = NULL;
  616. acpi_gbl_global_lock_acquired = FALSE;
  617. acpi_gbl_global_lock_handle = 0;
  618. /* Miscellaneous variables */
  619. acpi_gbl_cm_single_step = FALSE;
  620. acpi_gbl_db_terminate_threads = FALSE;
  621. acpi_gbl_shutdown = FALSE;
  622. acpi_gbl_ns_lookup_count = 0;
  623. acpi_gbl_ps_find_count = 0;
  624. acpi_gbl_acpi_hardware_present = TRUE;
  625. acpi_gbl_last_owner_id_index = 0;
  626. acpi_gbl_next_owner_id_offset = 0;
  627. acpi_gbl_trace_method_name = 0;
  628. acpi_gbl_trace_dbg_level = 0;
  629. acpi_gbl_trace_dbg_layer = 0;
  630. acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
  631. acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
  632. /* Hardware oriented */
  633. acpi_gbl_events_initialized = FALSE;
  634. acpi_gbl_system_awake_and_running = TRUE;
  635. /* Namespace */
  636. acpi_gbl_root_node = NULL;
  637. acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
  638. acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
  639. acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
  640. acpi_gbl_root_node_struct.child = NULL;
  641. acpi_gbl_root_node_struct.peer = NULL;
  642. acpi_gbl_root_node_struct.object = NULL;
  643. acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
  644. #ifdef ACPI_DEBUG_OUTPUT
  645. acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;
  646. #endif
  647. return_VOID;
  648. }
  649. ACPI_EXPORT_SYMBOL(acpi_dbg_level)
  650. ACPI_EXPORT_SYMBOL(acpi_dbg_layer)