utglobal.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  1. /******************************************************************************
  2. *
  3. * Module Name: utglobal - Global variables for the ACPI subsystem
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, 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 *
  61. acpi_format_exception (
  62. acpi_status status)
  63. {
  64. acpi_status sub_status;
  65. const char *exception = NULL;
  66. ACPI_FUNCTION_NAME ("format_exception");
  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 = acpi_gbl_exception_names_pgm [sub_status -1];
  77. }
  78. break;
  79. case AE_CODE_ACPI_TABLES:
  80. if (sub_status <= AE_CODE_TBL_MAX) {
  81. exception = acpi_gbl_exception_names_tbl [sub_status -1];
  82. }
  83. break;
  84. case AE_CODE_AML:
  85. if (sub_status <= AE_CODE_AML_MAX) {
  86. exception = acpi_gbl_exception_names_aml [sub_status -1];
  87. }
  88. break;
  89. case AE_CODE_CONTROL:
  90. if (sub_status <= AE_CODE_CTRL_MAX) {
  91. exception = acpi_gbl_exception_names_ctrl [sub_status -1];
  92. }
  93. break;
  94. default:
  95. break;
  96. }
  97. if (!exception) {
  98. /* Exception code was not recognized */
  99. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
  100. "Unknown exception code: 0x%8.8X\n", status));
  101. return ((const char *) "UNKNOWN_STATUS_CODE");
  102. }
  103. return ((const char *) exception);
  104. }
  105. /*******************************************************************************
  106. *
  107. * Static global variable initialization.
  108. *
  109. ******************************************************************************/
  110. /*
  111. * We want the debug switches statically initialized so they
  112. * are already set when the debugger is entered.
  113. */
  114. /* Debug switch - level and trace mask */
  115. u32 acpi_dbg_level = ACPI_DEBUG_DEFAULT;
  116. EXPORT_SYMBOL(acpi_dbg_level);
  117. /* Debug switch - layer (component) mask */
  118. u32 acpi_dbg_layer = ACPI_COMPONENT_DEFAULT | ACPI_ALL_DRIVERS;
  119. EXPORT_SYMBOL(acpi_dbg_layer);
  120. u32 acpi_gbl_nesting_level = 0;
  121. /* Debugger globals */
  122. u8 acpi_gbl_db_terminate_threads = FALSE;
  123. u8 acpi_gbl_abort_method = FALSE;
  124. u8 acpi_gbl_method_executing = FALSE;
  125. /* System flags */
  126. u32 acpi_gbl_startup_flags = 0;
  127. /* System starts uninitialized */
  128. u8 acpi_gbl_shutdown = TRUE;
  129. const u8 acpi_gbl_decode_to8bit [8] = {1,2,4,8,16,32,64,128};
  130. const char *acpi_gbl_sleep_state_names[ACPI_S_STATE_COUNT] =
  131. {
  132. "\\_S0_",
  133. "\\_S1_",
  134. "\\_S2_",
  135. "\\_S3_",
  136. "\\_S4_",
  137. "\\_S5_"
  138. };
  139. const char *acpi_gbl_highest_dstate_names[4] =
  140. {
  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. {
  152. /* Operating System Vendor Strings */
  153. "Linux",
  154. "Windows 2000",
  155. "Windows 2001",
  156. "Windows 2001.1",
  157. "Windows 2001 SP0",
  158. "Windows 2001 SP1",
  159. "Windows 2001 SP2",
  160. "Windows 2001 SP3",
  161. "Windows 2001 SP4",
  162. /* Feature Group Strings */
  163. "Extended Address Space Descriptor"
  164. };
  165. /*******************************************************************************
  166. *
  167. * Namespace globals
  168. *
  169. ******************************************************************************/
  170. /*
  171. * Predefined ACPI Names (Built-in to the Interpreter)
  172. *
  173. * NOTES:
  174. * 1) _SB_ is defined to be a device to allow \_SB_._INI to be run
  175. * during the initialization sequence.
  176. * 2) _TZ_ is defined to be a thermal zone in order to allow ASL code to
  177. * perform a Notify() operation on it.
  178. */
  179. const struct acpi_predefined_names acpi_gbl_pre_defined_names[] =
  180. { {"_GPE", ACPI_TYPE_LOCAL_SCOPE, NULL},
  181. {"_PR_", ACPI_TYPE_LOCAL_SCOPE, NULL},
  182. {"_SB_", ACPI_TYPE_DEVICE, NULL},
  183. {"_SI_", ACPI_TYPE_LOCAL_SCOPE, NULL},
  184. {"_TZ_", ACPI_TYPE_THERMAL, NULL},
  185. {"_REV", ACPI_TYPE_INTEGER, (char *) ACPI_CA_SUPPORT_LEVEL},
  186. {"_OS_", ACPI_TYPE_STRING, ACPI_OS_NAME},
  187. {"_GL_", ACPI_TYPE_MUTEX, (char *) 1},
  188. #if !defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)
  189. {"_OSI", ACPI_TYPE_METHOD, (char *) 1},
  190. #endif
  191. /* Table terminator */
  192. {NULL, ACPI_TYPE_ANY, NULL}
  193. };
  194. /*
  195. * Properties of the ACPI Object Types, both internal and external.
  196. * The table is indexed by values of acpi_object_type
  197. */
  198. const u8 acpi_gbl_ns_properties[] =
  199. {
  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. {
  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
  252. acpi_ut_hex_to_ascii_char (
  253. acpi_integer integer,
  254. u32 position)
  255. {
  256. return (acpi_gbl_hex_to_ascii[(integer >> position) & 0xF]);
  257. }
  258. /*******************************************************************************
  259. *
  260. * Table name globals
  261. *
  262. * NOTE: This table includes ONLY the ACPI tables that the subsystem consumes.
  263. * it is NOT an exhaustive list of all possible ACPI tables. All ACPI tables
  264. * that are not used by the subsystem are simply ignored.
  265. *
  266. * Do NOT add any table to this list that is not consumed directly by this
  267. * subsystem (No MADT, ECDT, SBST, etc.)
  268. *
  269. ******************************************************************************/
  270. struct acpi_table_list acpi_gbl_table_lists[NUM_ACPI_TABLE_TYPES];
  271. struct acpi_table_support acpi_gbl_table_data[NUM_ACPI_TABLE_TYPES] =
  272. {
  273. /*********** Name, Signature, Global typed pointer Signature size, Type How many allowed?, Contains valid AML? */
  274. /* RSDP 0 */ {RSDP_NAME, RSDP_SIG, NULL, sizeof (RSDP_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE},
  275. /* DSDT 1 */ {DSDT_SIG, DSDT_SIG, (void *) &acpi_gbl_DSDT, sizeof (DSDT_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE | ACPI_TABLE_EXECUTABLE},
  276. /* FADT 2 */ {FADT_SIG, FADT_SIG, (void *) &acpi_gbl_FADT, sizeof (FADT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_SINGLE},
  277. /* FACS 3 */ {FACS_SIG, FACS_SIG, (void *) &acpi_gbl_FACS, sizeof (FACS_SIG)-1, ACPI_TABLE_SECONDARY| ACPI_TABLE_SINGLE},
  278. /* PSDT 4 */ {PSDT_SIG, PSDT_SIG, NULL, sizeof (PSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
  279. /* SSDT 5 */ {SSDT_SIG, SSDT_SIG, NULL, sizeof (SSDT_SIG)-1, ACPI_TABLE_PRIMARY | ACPI_TABLE_MULTIPLE | ACPI_TABLE_EXECUTABLE},
  280. /* XSDT 6 */ {XSDT_SIG, XSDT_SIG, NULL, sizeof (RSDT_SIG)-1, ACPI_TABLE_ROOT | ACPI_TABLE_SINGLE},
  281. };
  282. /******************************************************************************
  283. *
  284. * Event and Hardware globals
  285. *
  286. ******************************************************************************/
  287. struct acpi_bit_register_info acpi_gbl_bit_register_info[ACPI_NUM_BITREG] =
  288. {
  289. /* Name Parent Register Register Bit Position Register Bit Mask */
  290. /* ACPI_BITREG_TIMER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_TIMER_STATUS, ACPI_BITMASK_TIMER_STATUS},
  291. /* ACPI_BITREG_BUS_MASTER_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_BUS_MASTER_STATUS, ACPI_BITMASK_BUS_MASTER_STATUS},
  292. /* ACPI_BITREG_GLOBAL_LOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_STATUS},
  293. /* ACPI_BITREG_POWER_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_STATUS},
  294. /* ACPI_BITREG_SLEEP_BUTTON_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_STATUS},
  295. /* ACPI_BITREG_RT_CLOCK_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_STATUS},
  296. /* ACPI_BITREG_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_WAKE_STATUS, ACPI_BITMASK_WAKE_STATUS},
  297. /* ACPI_BITREG_PCIEXP_WAKE_STATUS */ {ACPI_REGISTER_PM1_STATUS, ACPI_BITPOSITION_PCIEXP_WAKE_STATUS, ACPI_BITMASK_PCIEXP_WAKE_STATUS},
  298. /* ACPI_BITREG_TIMER_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_TIMER_ENABLE, ACPI_BITMASK_TIMER_ENABLE},
  299. /* ACPI_BITREG_GLOBAL_LOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
  300. /* ACPI_BITREG_POWER_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_ENABLE},
  301. /* ACPI_BITREG_SLEEP_BUTTON_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
  302. /* ACPI_BITREG_RT_CLOCK_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_ENABLE},
  303. /* ACPI_BITREG_WAKE_ENABLE */ {ACPI_REGISTER_PM1_ENABLE, 0, 0},
  304. /* ACPI_BITREG_PCIEXP_WAKE_DISABLE */ {ACPI_REGISTER_PM1_ENABLE, ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE, ACPI_BITMASK_PCIEXP_WAKE_DISABLE},
  305. /* ACPI_BITREG_SCI_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SCI_ENABLE, ACPI_BITMASK_SCI_ENABLE},
  306. /* ACPI_BITREG_BUS_MASTER_RLD */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_BUS_MASTER_RLD, ACPI_BITMASK_BUS_MASTER_RLD},
  307. /* ACPI_BITREG_GLOBAL_LOCK_RELEASE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE, ACPI_BITMASK_GLOBAL_LOCK_RELEASE},
  308. /* ACPI_BITREG_SLEEP_TYPE_A */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X},
  309. /* ACPI_BITREG_SLEEP_TYPE_B */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_TYPE_X, ACPI_BITMASK_SLEEP_TYPE_X},
  310. /* ACPI_BITREG_SLEEP_ENABLE */ {ACPI_REGISTER_PM1_CONTROL, ACPI_BITPOSITION_SLEEP_ENABLE, ACPI_BITMASK_SLEEP_ENABLE},
  311. /* ACPI_BITREG_ARB_DIS */ {ACPI_REGISTER_PM2_CONTROL, ACPI_BITPOSITION_ARB_DISABLE, ACPI_BITMASK_ARB_DISABLE}
  312. };
  313. struct acpi_fixed_event_info acpi_gbl_fixed_event_info[ACPI_NUM_FIXED_EVENTS] =
  314. {
  315. /* ACPI_EVENT_PMTIMER */ {ACPI_BITREG_TIMER_STATUS, ACPI_BITREG_TIMER_ENABLE, ACPI_BITMASK_TIMER_STATUS, ACPI_BITMASK_TIMER_ENABLE},
  316. /* ACPI_EVENT_GLOBAL */ {ACPI_BITREG_GLOBAL_LOCK_STATUS, ACPI_BITREG_GLOBAL_LOCK_ENABLE, ACPI_BITMASK_GLOBAL_LOCK_STATUS, ACPI_BITMASK_GLOBAL_LOCK_ENABLE},
  317. /* ACPI_EVENT_POWER_BUTTON */ {ACPI_BITREG_POWER_BUTTON_STATUS, ACPI_BITREG_POWER_BUTTON_ENABLE, ACPI_BITMASK_POWER_BUTTON_STATUS, ACPI_BITMASK_POWER_BUTTON_ENABLE},
  318. /* ACPI_EVENT_SLEEP_BUTTON */ {ACPI_BITREG_SLEEP_BUTTON_STATUS, ACPI_BITREG_SLEEP_BUTTON_ENABLE, ACPI_BITMASK_SLEEP_BUTTON_STATUS, ACPI_BITMASK_SLEEP_BUTTON_ENABLE},
  319. /* ACPI_EVENT_RTC */ {ACPI_BITREG_RT_CLOCK_STATUS, ACPI_BITREG_RT_CLOCK_ENABLE, ACPI_BITMASK_RT_CLOCK_STATUS, ACPI_BITMASK_RT_CLOCK_ENABLE},
  320. };
  321. /*******************************************************************************
  322. *
  323. * FUNCTION: acpi_ut_get_region_name
  324. *
  325. * PARAMETERS: None.
  326. *
  327. * RETURN: Status
  328. *
  329. * DESCRIPTION: Translate a Space ID into a name string (Debug only)
  330. *
  331. ******************************************************************************/
  332. /* Region type decoding */
  333. const char *acpi_gbl_region_types[ACPI_NUM_PREDEFINED_REGIONS] =
  334. {
  335. /*! [Begin] no source code translation (keep these ASL Keywords as-is) */
  336. "SystemMemory",
  337. "SystemIO",
  338. "PCI_Config",
  339. "EmbeddedControl",
  340. "SMBus",
  341. "CMOS",
  342. "PCIBARTarget",
  343. "DataTable"
  344. /*! [End] no source code translation !*/
  345. };
  346. char *
  347. acpi_ut_get_region_name (
  348. u8 space_id)
  349. {
  350. if (space_id >= ACPI_USER_REGION_BEGIN)
  351. {
  352. return ("user_defined_region");
  353. }
  354. else if (space_id >= ACPI_NUM_PREDEFINED_REGIONS)
  355. {
  356. return ("invalid_space_id");
  357. }
  358. return ((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. {
  374. "PM_Timer",
  375. "global_lock",
  376. "power_button",
  377. "sleep_button",
  378. "real_time_clock",
  379. };
  380. char *
  381. acpi_ut_get_event_name (
  382. u32 event_id)
  383. {
  384. if (event_id > ACPI_EVENT_MAX)
  385. {
  386. return ("invalid_event_iD");
  387. }
  388. return ((char *) acpi_gbl_event_types[event_id]);
  389. }
  390. /*******************************************************************************
  391. *
  392. * FUNCTION: acpi_ut_get_type_name
  393. *
  394. * PARAMETERS: None.
  395. *
  396. * RETURN: Status
  397. *
  398. * DESCRIPTION: Translate a Type ID into a name string (Debug only)
  399. *
  400. ******************************************************************************/
  401. /*
  402. * Elements of acpi_gbl_ns_type_names below must match
  403. * one-to-one with values of acpi_object_type
  404. *
  405. * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
  406. * when stored in a table it really means that we have thus far seen no
  407. * evidence to indicate what type is actually going to be stored for this entry.
  408. */
  409. static const char acpi_gbl_bad_type[] = "UNDEFINED";
  410. /* Printable names of the ACPI object types */
  411. static const char *acpi_gbl_ns_type_names[] =
  412. {
  413. /* 00 */ "Untyped",
  414. /* 01 */ "Integer",
  415. /* 02 */ "String",
  416. /* 03 */ "Buffer",
  417. /* 04 */ "Package",
  418. /* 05 */ "field_unit",
  419. /* 06 */ "Device",
  420. /* 07 */ "Event",
  421. /* 08 */ "Method",
  422. /* 09 */ "Mutex",
  423. /* 10 */ "Region",
  424. /* 11 */ "Power",
  425. /* 12 */ "Processor",
  426. /* 13 */ "Thermal",
  427. /* 14 */ "buffer_field",
  428. /* 15 */ "ddb_handle",
  429. /* 16 */ "debug_object",
  430. /* 17 */ "region_field",
  431. /* 18 */ "bank_field",
  432. /* 19 */ "index_field",
  433. /* 20 */ "Reference",
  434. /* 21 */ "Alias",
  435. /* 22 */ "method_alias",
  436. /* 23 */ "Notify",
  437. /* 24 */ "addr_handler",
  438. /* 25 */ "resource_desc",
  439. /* 26 */ "resource_fld",
  440. /* 27 */ "Scope",
  441. /* 28 */ "Extra",
  442. /* 29 */ "Data",
  443. /* 30 */ "Invalid"
  444. };
  445. char *
  446. acpi_ut_get_type_name (
  447. acpi_object_type type)
  448. {
  449. if (type > ACPI_TYPE_INVALID)
  450. {
  451. return ((char *) acpi_gbl_bad_type);
  452. }
  453. return ((char *) acpi_gbl_ns_type_names[type]);
  454. }
  455. char *
  456. acpi_ut_get_object_type_name (
  457. union acpi_operand_object *obj_desc)
  458. {
  459. if (!obj_desc)
  460. {
  461. return ("[NULL Object Descriptor]");
  462. }
  463. return (acpi_ut_get_type_name (ACPI_GET_OBJECT_TYPE (obj_desc)));
  464. }
  465. /*******************************************************************************
  466. *
  467. * FUNCTION: acpi_ut_get_node_name
  468. *
  469. * PARAMETERS: Object - A namespace node
  470. *
  471. * RETURN: Pointer to a string
  472. *
  473. * DESCRIPTION: Validate the node and return the node's ACPI name.
  474. *
  475. ******************************************************************************/
  476. char *
  477. acpi_ut_get_node_name (
  478. void *object)
  479. {
  480. struct acpi_namespace_node *node = (struct acpi_namespace_node *) object;
  481. /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
  482. if (!object)
  483. {
  484. return ("NULL");
  485. }
  486. /* Check for Root node */
  487. if ((object == ACPI_ROOT_OBJECT) ||
  488. (object == acpi_gbl_root_node))
  489. {
  490. return ("\"\\\" ");
  491. }
  492. /* Descriptor must be a namespace node */
  493. if (node->descriptor != ACPI_DESC_TYPE_NAMED)
  494. {
  495. return ("####");
  496. }
  497. /* Name must be a valid ACPI name */
  498. if (!acpi_ut_valid_acpi_name (* (u32 *) node->name.ascii))
  499. {
  500. return ("????");
  501. }
  502. /* Return the name */
  503. return (node->name.ascii);
  504. }
  505. /*******************************************************************************
  506. *
  507. * FUNCTION: acpi_ut_get_descriptor_name
  508. *
  509. * PARAMETERS: Object - An ACPI object
  510. *
  511. * RETURN: Pointer to a string
  512. *
  513. * DESCRIPTION: Validate object and return the descriptor type
  514. *
  515. ******************************************************************************/
  516. /* Printable names of object descriptor types */
  517. static const char *acpi_gbl_desc_type_names[] =
  518. {
  519. /* 00 */ "Invalid",
  520. /* 01 */ "Cached",
  521. /* 02 */ "State-Generic",
  522. /* 03 */ "State-Update",
  523. /* 04 */ "State-Package",
  524. /* 05 */ "State-Control",
  525. /* 06 */ "State-root_parse_scope",
  526. /* 07 */ "State-parse_scope",
  527. /* 08 */ "State-walk_scope",
  528. /* 09 */ "State-Result",
  529. /* 10 */ "State-Notify",
  530. /* 11 */ "State-Thread",
  531. /* 12 */ "Walk",
  532. /* 13 */ "Parser",
  533. /* 14 */ "Operand",
  534. /* 15 */ "Node"
  535. };
  536. char *
  537. acpi_ut_get_descriptor_name (
  538. void *object)
  539. {
  540. if (!object)
  541. {
  542. return ("NULL OBJECT");
  543. }
  544. if (ACPI_GET_DESCRIPTOR_TYPE (object) > ACPI_DESC_TYPE_MAX)
  545. {
  546. return ((char *) acpi_gbl_bad_type);
  547. }
  548. return ((char *) acpi_gbl_desc_type_names[ACPI_GET_DESCRIPTOR_TYPE (object)]);
  549. }
  550. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  551. /*
  552. * Strings and procedures used for debug only
  553. */
  554. /*******************************************************************************
  555. *
  556. * FUNCTION: acpi_ut_get_mutex_name
  557. *
  558. * PARAMETERS: mutex_id - The predefined ID for this mutex.
  559. *
  560. * RETURN: String containing the name of the mutex. Always returns a valid
  561. * pointer.
  562. *
  563. * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
  564. *
  565. ******************************************************************************/
  566. char *
  567. acpi_ut_get_mutex_name (
  568. u32 mutex_id)
  569. {
  570. if (mutex_id > MAX_MUTEX)
  571. {
  572. return ("Invalid Mutex ID");
  573. }
  574. return (acpi_gbl_mutex_names[mutex_id]);
  575. }
  576. #endif
  577. /*******************************************************************************
  578. *
  579. * FUNCTION: acpi_ut_valid_object_type
  580. *
  581. * PARAMETERS: Type - Object type to be validated
  582. *
  583. * RETURN: TRUE if valid object type, FALSE otherwise
  584. *
  585. * DESCRIPTION: Validate an object type
  586. *
  587. ******************************************************************************/
  588. u8
  589. acpi_ut_valid_object_type (
  590. acpi_object_type type)
  591. {
  592. if (type > ACPI_TYPE_LOCAL_MAX)
  593. {
  594. /* Note: Assumes all TYPEs are contiguous (external/local) */
  595. return (FALSE);
  596. }
  597. return (TRUE);
  598. }
  599. /*******************************************************************************
  600. *
  601. * FUNCTION: acpi_ut_allocate_owner_id
  602. *
  603. * PARAMETERS: id_type - Type of ID (method or table)
  604. *
  605. * DESCRIPTION: Allocate a table or method owner id
  606. *
  607. * NOTE: this algorithm has a wraparound problem at 64_k method invocations, and
  608. * should be revisited (TBD)
  609. *
  610. ******************************************************************************/
  611. acpi_owner_id
  612. acpi_ut_allocate_owner_id (
  613. u32 id_type)
  614. {
  615. acpi_owner_id owner_id = 0xFFFF;
  616. ACPI_FUNCTION_TRACE ("ut_allocate_owner_id");
  617. if (ACPI_FAILURE (acpi_ut_acquire_mutex (ACPI_MTX_CACHES)))
  618. {
  619. return (0);
  620. }
  621. switch (id_type)
  622. {
  623. case ACPI_OWNER_TYPE_TABLE:
  624. owner_id = acpi_gbl_next_table_owner_id;
  625. acpi_gbl_next_table_owner_id++;
  626. /* Check for wraparound */
  627. if (acpi_gbl_next_table_owner_id == ACPI_FIRST_METHOD_ID)
  628. {
  629. acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID;
  630. ACPI_REPORT_WARNING (("Table owner ID wraparound\n"));
  631. }
  632. break;
  633. case ACPI_OWNER_TYPE_METHOD:
  634. owner_id = acpi_gbl_next_method_owner_id;
  635. acpi_gbl_next_method_owner_id++;
  636. if (acpi_gbl_next_method_owner_id == ACPI_FIRST_TABLE_ID)
  637. {
  638. /* Check for wraparound */
  639. acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID;
  640. }
  641. break;
  642. default:
  643. break;
  644. }
  645. (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
  646. return_VALUE (owner_id);
  647. }
  648. /*******************************************************************************
  649. *
  650. * FUNCTION: acpi_ut_init_globals
  651. *
  652. * PARAMETERS: None
  653. *
  654. * RETURN: None
  655. *
  656. * DESCRIPTION: Init library globals. All globals that require specific
  657. * initialization should be initialized here!
  658. *
  659. ******************************************************************************/
  660. void
  661. acpi_ut_init_globals (
  662. void)
  663. {
  664. u32 i;
  665. ACPI_FUNCTION_TRACE ("ut_init_globals");
  666. /* Memory allocation and cache lists */
  667. ACPI_MEMSET (acpi_gbl_memory_lists, 0, sizeof (struct acpi_memory_list) * ACPI_NUM_MEM_LISTS);
  668. acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_generic_state *) NULL)->common.next), NULL);
  669. acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL);
  670. acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_parse_object *) NULL)->common.next), NULL);
  671. acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].link_offset = (u16) ACPI_PTR_DIFF (&(((union acpi_operand_object *) NULL)->cache.next), NULL);
  672. acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].link_offset = (u16) ACPI_PTR_DIFF (&(((struct acpi_walk_state *) NULL)->next), NULL);
  673. acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].object_size = sizeof (struct acpi_namespace_node);
  674. acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].object_size = sizeof (union acpi_generic_state);
  675. acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].object_size = sizeof (struct acpi_parse_obj_common);
  676. acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].object_size = sizeof (struct acpi_parse_obj_named);
  677. acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].object_size = sizeof (union acpi_operand_object);
  678. acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].object_size = sizeof (struct acpi_walk_state);
  679. acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].max_cache_depth = ACPI_MAX_STATE_CACHE_DEPTH;
  680. acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].max_cache_depth = ACPI_MAX_PARSE_CACHE_DEPTH;
  681. acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].max_cache_depth = ACPI_MAX_EXTPARSE_CACHE_DEPTH;
  682. acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].max_cache_depth = ACPI_MAX_OBJECT_CACHE_DEPTH;
  683. acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].max_cache_depth = ACPI_MAX_WALK_CACHE_DEPTH;
  684. ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_GLOBAL].list_name = "Global Memory Allocation");
  685. ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_NSNODE].list_name = "Namespace Nodes");
  686. ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_STATE].list_name = "State Object Cache");
  687. ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE].list_name = "Parse Node Cache");
  688. ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_PSNODE_EXT].list_name = "Extended Parse Node Cache");
  689. ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_OPERAND].list_name = "Operand Object Cache");
  690. ACPI_MEM_TRACKING (acpi_gbl_memory_lists[ACPI_MEM_LIST_WALK].list_name = "Tree Walk Node Cache");
  691. /* ACPI table structure */
  692. for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++)
  693. {
  694. acpi_gbl_table_lists[i].next = NULL;
  695. acpi_gbl_table_lists[i].count = 0;
  696. }
  697. /* Mutex locked flags */
  698. for (i = 0; i < NUM_MUTEX; i++)
  699. {
  700. acpi_gbl_mutex_info[i].mutex = NULL;
  701. acpi_gbl_mutex_info[i].owner_id = ACPI_MUTEX_NOT_ACQUIRED;
  702. acpi_gbl_mutex_info[i].use_count = 0;
  703. }
  704. /* GPE support */
  705. acpi_gbl_gpe_xrupt_list_head = NULL;
  706. acpi_gbl_gpe_fadt_blocks[0] = NULL;
  707. acpi_gbl_gpe_fadt_blocks[1] = NULL;
  708. /* Global notify handlers */
  709. acpi_gbl_system_notify.handler = NULL;
  710. acpi_gbl_device_notify.handler = NULL;
  711. acpi_gbl_exception_handler = NULL;
  712. acpi_gbl_init_handler = NULL;
  713. /* Global "typed" ACPI table pointers */
  714. acpi_gbl_RSDP = NULL;
  715. acpi_gbl_XSDT = NULL;
  716. acpi_gbl_FACS = NULL;
  717. acpi_gbl_FADT = NULL;
  718. acpi_gbl_DSDT = NULL;
  719. /* Global Lock support */
  720. acpi_gbl_global_lock_acquired = FALSE;
  721. acpi_gbl_global_lock_thread_count = 0;
  722. acpi_gbl_global_lock_handle = 0;
  723. /* Miscellaneous variables */
  724. acpi_gbl_table_flags = ACPI_PHYSICAL_POINTER;
  725. acpi_gbl_rsdp_original_location = 0;
  726. acpi_gbl_cm_single_step = FALSE;
  727. acpi_gbl_db_terminate_threads = FALSE;
  728. acpi_gbl_shutdown = FALSE;
  729. acpi_gbl_ns_lookup_count = 0;
  730. acpi_gbl_ps_find_count = 0;
  731. acpi_gbl_acpi_hardware_present = TRUE;
  732. acpi_gbl_next_table_owner_id = ACPI_FIRST_TABLE_ID;
  733. acpi_gbl_next_method_owner_id = ACPI_FIRST_METHOD_ID;
  734. acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
  735. acpi_gbl_db_output_flags = ACPI_DB_CONSOLE_OUTPUT;
  736. /* Hardware oriented */
  737. acpi_gbl_events_initialized = FALSE;
  738. acpi_gbl_system_awake_and_running = TRUE;
  739. /* Namespace */
  740. acpi_gbl_root_node = NULL;
  741. acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
  742. acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
  743. acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
  744. acpi_gbl_root_node_struct.child = NULL;
  745. acpi_gbl_root_node_struct.peer = NULL;
  746. acpi_gbl_root_node_struct.object = NULL;
  747. acpi_gbl_root_node_struct.flags = ANOBJ_END_OF_PEER_LIST;
  748. #ifdef ACPI_DEBUG_OUTPUT
  749. acpi_gbl_lowest_stack_pointer = ACPI_SIZE_MAX;
  750. #endif
  751. return_VOID;
  752. }