utglobal.c 22 KB

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