utglobal.c 25 KB

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