utglobal.c 30 KB

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