utglobal.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871
  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 <linux/module.h>
  44. #include <acpi/acpi.h>
  45. #include <acpi/acnamesp.h>
  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. EXPORT_SYMBOL(acpi_dbg_level);
  122. /* Debug switch - layer (component) mask */
  123. u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
  124. EXPORT_SYMBOL(acpi_dbg_layer);
  125. u32 acpi_gbl_nesting_level = 0;
  126. /* Debugger globals */
  127. u8 acpi_gbl_db_terminate_threads = FALSE;
  128. u8 acpi_gbl_abort_method = FALSE;
  129. u8 acpi_gbl_method_executing = FALSE;
  130. /* System flags */
  131. u32 acpi_gbl_startup_flags = 0;
  132. /* System starts uninitialized */
  133. u8 acpi_gbl_shutdown = TRUE;
  134. const u8 acpi_gbl_decode_to8bit[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
  135. const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] = {
  136. "\\_S0_",
  137. "\\_S1_",
  138. "\\_S2_",
  139. "\\_S3_",
  140. "\\_S4_",
  141. "\\_S5_"
  142. };
  143. const char *acpi_gbl_highest_dstate_names[4] = {
  144. "_S1D",
  145. "_S2D",
  146. "_S3D",
  147. "_S4D"
  148. };
  149. /*
  150. * Strings supported by the _OSI predefined (internal) method.
  151. * When adding strings, be sure to update ACPI_NUM_OSI_STRINGS.
  152. */
  153. const char *acpi_gbl_valid_osi_strings[ACPI_NUM_OSI_STRINGS] = {
  154. /* Operating System Vendor Strings */
  155. "Linux",
  156. "Windows 2000",
  157. "Windows 2001",
  158. "Windows 2001.1",
  159. "Windows 2001 SP0",
  160. "Windows 2001 SP1",
  161. "Windows 2001 SP2",
  162. "Windows 2001 SP3",
  163. "Windows 2001 SP4",
  164. /* Feature Group Strings */
  165. "Extended Address Space Descriptor"
  166. };
  167. /*******************************************************************************
  168. *
  169. * Namespace globals
  170. *
  171. ******************************************************************************/
  172. /*
  173. * Predefined ACPI Names (Built-in to the Interpreter)
  174. *
  175. * NOTES:
  176. * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
  177. * during the initialization sequence.
  178. * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
  179. * perform a Notify() operation on it.
  180. */
  181. const struct acpi_predefined_names acpi_gbl_pre_defined_names[] = {
  182. {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
  183. {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
  184. {"_SB_", ACPI_TYPE_DEVICE, NULL},
  185. {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
  186. {"_TZ_", ACPI_TYPE_THERMAL, NULL},
  187. {"_REV", ACPI_TYPE_INTEGER, (char *)ACPI_CA_SUPPORT_LEVEL},
  188. {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
  189. {"_GL_", ACPI_TYPE_MUTEX, (char *)1},
  190. #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
  191. {"_OSI", ACPI_TYPE_METHOD, (char *)1},
  192. #endif
  193. /* Table terminator */
  194. {NULL, ACPI_TYPE_ANY, NULL}
  195. };
  196. /*
  197. * Properties of the ACPI Object Types, both internal and external.
  198. * The table is indexed by values of acpi_object_type
  199. */
  200. const u8 acpi_gbl_ns_properties[] = {
  201. ACPI_NS_NORMAL, /* 00 Any */
  202. ACPI_NS_NORMAL, /* 01 Number */
  203. ACPI_NS_NORMAL, /* 02 String */
  204. ACPI_NS_NORMAL, /* 03 Buffer */
  205. ACPI_NS_NORMAL, /* 04 Package */
  206. ACPI_NS_NORMAL, /* 05 field_unit */
  207. ACPI_NS_NEWSCOPE, /* 06 Device */
  208. ACPI_NS_NORMAL, /* 07 Event */
  209. ACPI_NS_NEWSCOPE, /* 08 Method */
  210. ACPI_NS_NORMAL, /* 09 Mutex */
  211. ACPI_NS_NORMAL, /* 10 Region */
  212. ACPI_NS_NEWSCOPE, /* 11 Power */
  213. ACPI_NS_NEWSCOPE, /* 12 Processor */
  214. ACPI_NS_NEWSCOPE, /* 13 Thermal */
  215. ACPI_NS_NORMAL, /* 14 buffer_field */
  216. ACPI_NS_NORMAL, /* 15 ddb_handle */
  217. ACPI_NS_NORMAL, /* 16 Debug Object */
  218. ACPI_NS_NORMAL, /* 17 def_field */
  219. ACPI_NS_NORMAL, /* 18 bank_field */
  220. ACPI_NS_NORMAL, /* 19 index_field */
  221. ACPI_NS_NORMAL, /* 20 Reference */
  222. ACPI_NS_NORMAL, /* 21 Alias */
  223. ACPI_NS_NORMAL, /* 22 method_alias */
  224. ACPI_NS_NORMAL, /* 23 Notify */
  225. ACPI_NS_NORMAL, /* 24 Address Handler */
  226. ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
  227. ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
  228. ACPI_NS_NEWSCOPE, /* 27 Scope */
  229. ACPI_NS_NORMAL, /* 28 Extra */
  230. ACPI_NS_NORMAL, /* 29 Data */
  231. ACPI_NS_NORMAL /* 30 Invalid */
  232. };
  233. /* Hex to ASCII conversion table */
  234. static const char acpi_gbl_hex_to_ascii[] = {
  235. '0', '1', '2', '3', '4', '5', '6', '7',
  236. '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
  237. };
  238. /*******************************************************************************
  239. *
  240. * FUNCTION: acpi_ut_hex_to_ascii_char
  241. *
  242. * PARAMETERS: Integer - Contains the hex digit
  243. * Position - bit position of the digit within the
  244. * integer (multiple of 4)
  245. *
  246. * RETURN: The converted Ascii character
  247. *
  248. * DESCRIPTION: Convert a hex digit to an Ascii character
  249. *
  250. ******************************************************************************/
  251. char acpi_ut_hex_to_ascii_char(acpi_integer integer, u32 position)
  252. {
  253. return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
  254. }
  255. /*******************************************************************************
  256. *
  257. * Table name globals
  258. *
  259. * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
  260. * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables
  261. * that are not used by the subsystem are simply ignored.
  262. *
  263. * Do NOT add any table to this list that is not consumed directly by this
  264. * subsystem (No MADT, ECDT, SBST, etc.)
  265. *
  266. ******************************************************************************/
  267. struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
  268. struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] = {
  269. /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */
  270. /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof(RSDP_SIG) - 1,
  271. ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
  272. ,
  273. /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *)&acpi_gbl_DSDT,
  274. sizeof(DSDT_SIG) - 1,
  275. ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE |
  276. ACPI_TABLE_EXECUTABLE}
  277. ,
  278. /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *)&acpi_gbl_FADT,
  279. sizeof(FADT_SIG) - 1,
  280. ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE}
  281. ,
  282. /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *)&acpi_gbl_FACS,
  283. sizeof(FACS_SIG) - 1,
  284. ACPI_TABLE_SECONDARY | ACPI_TABLE_SINGLE}
  285. ,
  286. /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof(PSDT_SIG) - 1,
  287. ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
  288. ACPI_TABLE_EXECUTABLE}
  289. ,
  290. /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof(SSDT_SIG) - 1,
  291. ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE |
  292. ACPI_TABLE_EXECUTABLE}
  293. ,
  294. /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof(RSDT_SIG) - 1,
  295. ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE}
  296. ,
  297. };
  298. /******************************************************************************
  299. *
  300. * Event and Hardware globals
  301. *
  302. ******************************************************************************/
  303. struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] = {
  304. /* Name Parent Register Register Bit Position Register Bit Mask */
  305. /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  306. ACPI_BITPOSITION_TIMER_STATUS,
  307. ACPI_BITMASK_TIMER_STATUS},
  308. /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  309. ACPI_BITPOSITION_BUS_MASTER_STATUS,
  310. ACPI_BITMASK_BUS_MASTER_STATUS},
  311. /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  312. ACPI_BITPOSITION_GLOBAL_LOCK_STATUS,
  313. ACPI_BITMASK_GLOBAL_LOCK_STATUS},
  314. /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  315. ACPI_BITPOSITION_POWER_BUTTON_STATUS,
  316. ACPI_BITMASK_POWER_BUTTON_STATUS},
  317. /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  318. ACPI_BITPOSITION_SLEEP_BUTTON_STATUS,
  319. ACPI_BITMASK_SLEEP_BUTTON_STATUS},
  320. /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  321. ACPI_BITPOSITION_RT_CLOCK_STATUS,
  322. ACPI_BITMASK_RT_CLOCK_STATUS},
  323. /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  324. ACPI_BITPOSITION_WAKE_STATUS,
  325. ACPI_BITMASK_WAKE_STATUS},
  326. /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS,
  327. ACPI_BITPOSITION_PCIEXP_WAKE_STATUS,
  328. ACPI_BITMASK_PCIEXP_WAKE_STATUS},
  329. /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
  330. ACPI_BITPOSITION_TIMER_ENABLE,
  331. ACPI_BITMASK_TIMER_ENABLE},
  332. /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
  333. ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE,
  334. ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
  335. /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
  336. ACPI_BITPOSITION_POWER_BUTTON_ENABLE,
  337. ACPI_BITMASK_POWER_BUTTON_ENABLE},
  338. /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
  339. ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE,
  340. ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
  341. /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE,
  342. ACPI_BITPOSITION_RT_CLOCK_ENABLE,
  343. ACPI_BITMASK_RT_CLOCK_ENABLE},
  344. /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
  345. /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE,
  346. ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE,
  347. ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
  348. /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
  349. ACPI_BITPOSITION_SCI_ENABLE,
  350. ACPI_BITMASK_SCI_ENABLE},
  351. /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL,
  352. ACPI_BITPOSITION_BUS_MASTER_RLD,
  353. ACPI_BITMASK_BUS_MASTER_RLD},
  354. /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL,
  355. ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE,
  356. ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
  357. /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL,
  358. ACPI_BITPOSITION_SLEEP_TYPE_X,
  359. ACPI_BITMASK_SLEEP_TYPE_X},
  360. /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL,
  361. ACPI_BITPOSITION_SLEEP_TYPE_X,
  362. ACPI_BITMASK_SLEEP_TYPE_X},
  363. /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL,
  364. ACPI_BITPOSITION_SLEEP_ENABLE,
  365. ACPI_BITMASK_SLEEP_ENABLE},
  366. /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL,
  367. ACPI_BITPOSITION_ARB_DISABLE,
  368. ACPI_BITMASK_ARB_DISABLE}
  369. };
  370. struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] = {
  371. /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS,
  372. ACPI_BITREG_TIMER_ENABLE,
  373. ACPI_BITMASK_TIMER_STATUS,
  374. ACPI_BITMASK_TIMER_ENABLE},
  375. /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS,
  376. ACPI_BITREG_GLOBAL_LOCK_ENABLE,
  377. ACPI_BITMASK_GLOBAL_LOCK_STATUS,
  378. ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
  379. /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS,
  380. ACPI_BITREG_POWER_BUTTON_ENABLE,
  381. ACPI_BITMASK_POWER_BUTTON_STATUS,
  382. ACPI_BITMASK_POWER_BUTTON_ENABLE},
  383. /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS,
  384. ACPI_BITREG_SLEEP_BUTTON_ENABLE,
  385. ACPI_BITMASK_SLEEP_BUTTON_STATUS,
  386. ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
  387. /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS,
  388. ACPI_BITREG_RT_CLOCK_ENABLE,
  389. ACPI_BITMASK_RT_CLOCK_STATUS,
  390. ACPI_BITMASK_RT_CLOCK_ENABLE},
  391. };
  392. /*******************************************************************************
  393. *
  394. * FUNCTION: acpi_ut_get_region_name
  395. *
  396. * PARAMETERS: None.
  397. *
  398. * RETURN: Status
  399. *
  400. * DESCRIPTION: Translate a Space ID into a name string (Debug only)
  401. *
  402. ******************************************************************************/
  403. /* Region type decoding */
  404. const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] = {
  405. /*! [Begin] no source code translation (keep these ASL Keywords as-is) */
  406. "SystemMemory",
  407. "SystemIO",
  408. "PCI_Config",
  409. "EmbeddedControl",
  410. "SMBus",
  411. "CMOS",
  412. "PCIBARTarget",
  413. "DataTable"
  414. /*! [End] no source code translation !*/
  415. };
  416. char *acpi_ut_get_region_name(u8 space_id)
  417. {
  418. if (space_id >= ACPI_USER_REGION_BEGIN) {
  419. return ("user_defined_region");
  420. } else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS) {
  421. return ("invalid_space_id");
  422. }
  423. return (ACPI_CAST_PTR(char, acpi_gbl_region_types[space_id]));
  424. }
  425. /*******************************************************************************
  426. *
  427. * FUNCTION: acpi_ut_get_event_name
  428. *
  429. * PARAMETERS: None.
  430. *
  431. * RETURN: Status
  432. *
  433. * DESCRIPTION: Translate a Event ID into a name string (Debug only)
  434. *
  435. ******************************************************************************/
  436. /* Event type decoding */
  437. static const char *acpi_gbl_event_types[ACPI_NUM_FIXED_EVENTS] = {
  438. /*! [Begin] no source code translation (keep these strings as-is) */
  439. "PM_Timer",
  440. "GlobalLock",
  441. "PowerButton",
  442. "SleepButton",
  443. "RealTimeClock",
  444. /*! [End] no source code translation !*/
  445. };
  446. char *acpi_ut_get_event_name(u32 event_id)
  447. {
  448. if (event_id > ACPI_EVENT_MAX) {
  449. return ("invalid_event_iD");
  450. }
  451. return (ACPI_CAST_PTR(char, acpi_gbl_event_types[event_id]));
  452. }
  453. /*******************************************************************************
  454. *
  455. * FUNCTION: acpi_ut_get_type_name
  456. *
  457. * PARAMETERS: None.
  458. *
  459. * RETURN: Status
  460. *
  461. * DESCRIPTION: Translate a Type ID into a name string (Debug only)
  462. *
  463. ******************************************************************************/
  464. /*
  465. * Elements of acpi_gbl_ns_type_names below must match
  466. * one-to-one with values of acpi_object_type
  467. *
  468. * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
  469. * when stored in a table it really means that we have thus far seen no
  470. * evidence to indicate what type is actually going to be stored for this entry.
  471. */
  472. static const char acpi_gbl_bad_type[] = "UNDEFINED";
  473. /* Printable names of the ACPI object types */
  474. static const char *acpi_gbl_ns_type_names[] = {
  475. /*! [Begin] no source code translation (keep these strings as-is) */
  476. /* 00 */ "Untyped",
  477. /* 01 */ "Integer",
  478. /* 02 */ "String",
  479. /* 03 */ "Buffer",
  480. /* 04 */ "Package",
  481. /* 05 */ "FieldUnit",
  482. /* 06 */ "Device",
  483. /* 07 */ "Event",
  484. /* 08 */ "Method",
  485. /* 09 */ "Mutex",
  486. /* 10 */ "Region",
  487. /* 11 */ "Power",
  488. /* 12 */ "Processor",
  489. /* 13 */ "Thermal",
  490. /* 14 */ "BufferField",
  491. /* 15 */ "DdbHandle",
  492. /* 16 */ "DebugObject",
  493. /* 17 */ "RegionField",
  494. /* 18 */ "BankField",
  495. /* 19 */ "IndexField",
  496. /* 20 */ "Reference",
  497. /* 21 */ "Alias",
  498. /* 22 */ "MethodAlias",
  499. /* 23 */ "Notify",
  500. /* 24 */ "AddrHandler",
  501. /* 25 */ "ResourceDesc",
  502. /* 26 */ "ResourceFld",
  503. /* 27 */ "Scope",
  504. /* 28 */ "Extra",
  505. /* 29 */ "Data",
  506. /* 30 */ "Invalid"
  507. /*! [End] no source code translation !*/
  508. };
  509. char *acpi_ut_get_type_name(acpi_object_type type)
  510. {
  511. if (type > ACPI_TYPE_INVALID) {
  512. return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
  513. }
  514. return (ACPI_CAST_PTR(char, acpi_gbl_ns_type_names[type]));
  515. }
  516. char *acpi_ut_get_object_type_name(union acpi_operand_object *obj_desc)
  517. {
  518. if (!obj_desc) {
  519. return ("[NULL Object Descriptor]");
  520. }
  521. return (acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE(obj_desc)));
  522. }
  523. /*******************************************************************************
  524. *
  525. * FUNCTION: acpi_ut_get_node_name
  526. *
  527. * PARAMETERS: Object - A namespace node
  528. *
  529. * RETURN: Pointer to a string
  530. *
  531. * DESCRIPTION: Validate the node and return the node's ACPI name.
  532. *
  533. ******************************************************************************/
  534. char *acpi_ut_get_node_name(void *object)
  535. {
  536. struct acpi_namespace_node *node = (struct acpi_namespace_node *)object;
  537. /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
  538. if (!object) {
  539. return ("NULL");
  540. }
  541. /* Check for Root node */
  542. if ((object == ACPI_ROOT_OBJECT) || (object == acpi_gbl_root_node)) {
  543. return ("\"\\\" ");
  544. }
  545. /* Descriptor must be a namespace node */
  546. if (node->descriptor != ACPI_DESC_TYPE_NAMED) {
  547. return ("####");
  548. }
  549. /* Name must be a valid ACPI name */
  550. if (!acpi_ut_valid_acpi_name(node->name.integer)) {
  551. return ("????");
  552. }
  553. /* Return the name */
  554. return (node->name.ascii);
  555. }
  556. /*******************************************************************************
  557. *
  558. * FUNCTION: acpi_ut_get_descriptor_name
  559. *
  560. * PARAMETERS: Object - An ACPI object
  561. *
  562. * RETURN: Pointer to a string
  563. *
  564. * DESCRIPTION: Validate object and return the descriptor type
  565. *
  566. ******************************************************************************/
  567. /* Printable names of object descriptor types */
  568. static const char *acpi_gbl_desc_type_names[] = {
  569. /*! [Begin] no source code translation (keep these ASL Keywords as-is) */
  570. /* 00 */ "Invalid",
  571. /* 01 */ "Cached",
  572. /* 02 */ "State-Generic",
  573. /* 03 */ "State-Update",
  574. /* 04 */ "State-Package",
  575. /* 05 */ "State-Control",
  576. /* 06 */ "State-RootParseScope",
  577. /* 07 */ "State-ParseScope",
  578. /* 08 */ "State-WalkScope",
  579. /* 09 */ "State-Result",
  580. /* 10 */ "State-Notify",
  581. /* 11 */ "State-Thread",
  582. /* 12 */ "Walk",
  583. /* 13 */ "Parser",
  584. /* 14 */ "Operand",
  585. /* 15 */ "Node"
  586. /*! [End] no source code translation !*/
  587. };
  588. char *acpi_ut_get_descriptor_name(void *object)
  589. {
  590. if (!object) {
  591. return ("NULL OBJECT");
  592. }
  593. if (ACPI_GET_DESCRIPTOR_TYPE(object) > ACPI_DESC_TYPE_MAX) {
  594. return (ACPI_CAST_PTR(char, acpi_gbl_bad_type));
  595. }
  596. return (ACPI_CAST_PTR(char,
  597. acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE
  598. (object)]));
  599. }
  600. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  601. /*
  602. * Strings and procedures used for debug only
  603. */
  604. /*******************************************************************************
  605. *
  606. * FUNCTION: acpi_ut_get_mutex_name
  607. *
  608. * PARAMETERS: mutex_id - The predefined ID for this mutex.
  609. *
  610. * RETURN: String containing the name of the mutex. Always returns a valid
  611. * pointer.
  612. *
  613. * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
  614. *
  615. ******************************************************************************/
  616. char *acpi_ut_get_mutex_name(u32 mutex_id)
  617. {
  618. if (mutex_id > MAX_MUTEX) {
  619. return ("Invalid Mutex ID");
  620. }
  621. return (acpi_gbl_mutex_names[mutex_id]);
  622. }
  623. #endif
  624. /*******************************************************************************
  625. *
  626. * FUNCTION: acpi_ut_valid_object_type
  627. *
  628. * PARAMETERS: Type - Object type to be validated
  629. *
  630. * RETURN: TRUE if valid object type, FALSE otherwise
  631. *
  632. * DESCRIPTION: Validate an object type
  633. *
  634. ******************************************************************************/
  635. u8 acpi_ut_valid_object_type(acpi_object_type type)
  636. {
  637. if (type > ACPI_TYPE_LOCAL_MAX) {
  638. /* Note: Assumes all TYPEs are contiguous (external/local) */
  639. return (FALSE);
  640. }
  641. return (TRUE);
  642. }
  643. /*******************************************************************************
  644. *
  645. * FUNCTION: acpi_ut_init_globals
  646. *
  647. * PARAMETERS: None
  648. *
  649. * RETURN: None
  650. *
  651. * DESCRIPTION: Init library globals. All globals that require specific
  652. * initialization should be initialized here!
  653. *
  654. ******************************************************************************/
  655. void acpi_ut_init_globals(void)
  656. {
  657. acpi_status status;
  658. u32 i;
  659. ACPI_FUNCTION_TRACE("ut_init_globals");
  660. /* Create all memory caches */
  661. status = acpi_ut_create_caches();
  662. if (ACPI_FAILURE(status)) {
  663. return;
  664. }
  665. /* ACPI table structure */
  666. for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) {
  667. acpi_gbl_table_lists[i].next = NULL;
  668. acpi_gbl_table_lists[i].count = 0;
  669. }
  670. /* Mutex locked flags */
  671. for (i = 0; i < NUM_MUTEX; i++) {
  672. acpi_gbl_mutex_info[i].mutex = NULL;
  673. acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
  674. acpi_gbl_mutex_info[i].use_count = 0;
  675. }
  676. for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
  677. acpi_gbl_owner_id_mask[i] = 0;
  678. }
  679. acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000; /* Last ID is never valid */
  680. /* GPE support */
  681. acpi_gbl_gpe_xrupt_list_head = NULL;
  682. acpi_gbl_gpe_fadt_blocks[0] = NULL;
  683. acpi_gbl_gpe_fadt_blocks[1] = NULL;
  684. /* Global notify handlers */
  685. acpi_gbl_system_notify.handler = NULL;
  686. acpi_gbl_device_notify.handler = NULL;
  687. acpi_gbl_exception_handler = NULL;
  688. acpi_gbl_init_handler = NULL;
  689. /* Global "typed" ACPI table pointers */
  690. acpi_gbl_RSDP = NULL;
  691. acpi_gbl_XSDT = NULL;
  692. acpi_gbl_FACS = NULL;
  693. acpi_gbl_FADT = NULL;
  694. acpi_gbl_DSDT = NULL;
  695. /* Global Lock support */
  696. acpi_gbl_global_lock_acquired = FALSE;
  697. acpi_gbl_global_lock_thread_count = 0;
  698. acpi_gbl_global_lock_handle = 0;
  699. /* Miscellaneous variables */
  700. acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER;
  701. acpi_gbl_rsdp_original_location = 0;
  702. acpi_gbl_cm_single_step = FALSE;
  703. acpi_gbl_db_terminate_threads = FALSE;
  704. acpi_gbl_shutdown = FALSE;
  705. acpi_gbl_ns_lookup_count = 0;
  706. acpi_gbl_ps_find_count = 0;
  707. acpi_gbl_acpi_hardware_present = TRUE;
  708. acpi_gbl_last_owner_id_index = 0;
  709. acpi_gbl_next_owner_id_offset = 0;
  710. acpi_gbl_trace_method_name = 0;
  711. acpi_gbl_trace_dbg_level = 0;
  712. acpi_gbl_trace_dbg_layer = 0;
  713. acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
  714. acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
  715. /* Hardware oriented */
  716. acpi_gbl_events_initialized = FALSE;
  717. acpi_gbl_system_awake_and_running = TRUE;
  718. /* Namespace */
  719. acpi_gbl_root_node = NULL;
  720. acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
  721. acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
  722. acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
  723. acpi_gbl_root_node_struct.child = NULL;
  724. acpi_gbl_root_node_struct.peer = NULL;
  725. acpi_gbl_root_node_struct.object = NULL;
  726. acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
  727. #ifdef ACPI_DEBUG_OUTPUT
  728. acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;
  729. #endif
  730. return_VOID;
  731. }