utxfinit.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. /******************************************************************************
  2. *
  3. * Module Name: utxfinit - External interfaces for ACPICA initialization
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2013, Intel Corp.
  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. #include <linux/export.h>
  43. #include <acpi/acpi.h>
  44. #include "accommon.h"
  45. #include "acevents.h"
  46. #include "acnamesp.h"
  47. #include "acdebug.h"
  48. #include "actables.h"
  49. #define _COMPONENT ACPI_UTILITIES
  50. ACPI_MODULE_NAME("utxfinit")
  51. /*******************************************************************************
  52. *
  53. * FUNCTION: acpi_initialize_subsystem
  54. *
  55. * PARAMETERS: None
  56. *
  57. * RETURN: Status
  58. *
  59. * DESCRIPTION: Initializes all global variables. This is the first function
  60. * called, so any early initialization belongs here.
  61. *
  62. ******************************************************************************/
  63. acpi_status acpi_initialize_subsystem(void)
  64. {
  65. acpi_status status;
  66. ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
  67. acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
  68. ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
  69. /* Initialize the OS-Dependent layer */
  70. status = acpi_os_initialize();
  71. if (ACPI_FAILURE(status)) {
  72. ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
  73. return_ACPI_STATUS(status);
  74. }
  75. /* Initialize all globals used by the subsystem */
  76. status = acpi_ut_init_globals();
  77. if (ACPI_FAILURE(status)) {
  78. ACPI_EXCEPTION((AE_INFO, status,
  79. "During initialization of globals"));
  80. return_ACPI_STATUS(status);
  81. }
  82. /* Create the default mutex objects */
  83. status = acpi_ut_mutex_initialize();
  84. if (ACPI_FAILURE(status)) {
  85. ACPI_EXCEPTION((AE_INFO, status,
  86. "During Global Mutex creation"));
  87. return_ACPI_STATUS(status);
  88. }
  89. /*
  90. * Initialize the namespace manager and
  91. * the root of the namespace tree
  92. */
  93. status = acpi_ns_root_initialize();
  94. if (ACPI_FAILURE(status)) {
  95. ACPI_EXCEPTION((AE_INFO, status,
  96. "During Namespace initialization"));
  97. return_ACPI_STATUS(status);
  98. }
  99. /* Initialize the global OSI interfaces list with the static names */
  100. status = acpi_ut_initialize_interfaces();
  101. if (ACPI_FAILURE(status)) {
  102. ACPI_EXCEPTION((AE_INFO, status,
  103. "During OSI interfaces initialization"));
  104. return_ACPI_STATUS(status);
  105. }
  106. /* If configured, initialize the AML debugger */
  107. ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
  108. return_ACPI_STATUS(status);
  109. }
  110. ACPI_EXPORT_SYMBOL(acpi_initialize_subsystem)
  111. /*******************************************************************************
  112. *
  113. * FUNCTION: acpi_enable_subsystem
  114. *
  115. * PARAMETERS: flags - Init/enable Options
  116. *
  117. * RETURN: Status
  118. *
  119. * DESCRIPTION: Completes the subsystem initialization including hardware.
  120. * Puts system into ACPI mode if it isn't already.
  121. *
  122. ******************************************************************************/
  123. acpi_status acpi_enable_subsystem(u32 flags)
  124. {
  125. acpi_status status = AE_OK;
  126. ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
  127. #if (!ACPI_REDUCED_HARDWARE)
  128. /* Enable ACPI mode */
  129. if (!(flags & ACPI_NO_ACPI_ENABLE)) {
  130. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  131. "[Init] Going into ACPI mode\n"));
  132. acpi_gbl_original_mode = acpi_hw_get_mode();
  133. status = acpi_enable();
  134. if (ACPI_FAILURE(status)) {
  135. ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
  136. return_ACPI_STATUS(status);
  137. }
  138. }
  139. /*
  140. * Obtain a permanent mapping for the FACS. This is required for the
  141. * Global Lock and the Firmware Waking Vector
  142. */
  143. status = acpi_tb_initialize_facs();
  144. if (ACPI_FAILURE(status)) {
  145. ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
  146. return_ACPI_STATUS(status);
  147. }
  148. #endif /* !ACPI_REDUCED_HARDWARE */
  149. /*
  150. * Install the default op_region handlers. These are installed unless
  151. * other handlers have already been installed via the
  152. * install_address_space_handler interface.
  153. */
  154. if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
  155. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  156. "[Init] Installing default address space handlers\n"));
  157. status = acpi_ev_install_region_handlers();
  158. if (ACPI_FAILURE(status)) {
  159. return_ACPI_STATUS(status);
  160. }
  161. }
  162. #if (!ACPI_REDUCED_HARDWARE)
  163. /*
  164. * Initialize ACPI Event handling (Fixed and General Purpose)
  165. *
  166. * Note1: We must have the hardware and events initialized before we can
  167. * execute any control methods safely. Any control method can require
  168. * ACPI hardware support, so the hardware must be fully initialized before
  169. * any method execution!
  170. *
  171. * Note2: Fixed events are initialized and enabled here. GPEs are
  172. * initialized, but cannot be enabled until after the hardware is
  173. * completely initialized (SCI and global_lock activated) and the various
  174. * initialization control methods are run (_REG, _STA, _INI) on the
  175. * entire namespace.
  176. */
  177. if (!(flags & ACPI_NO_EVENT_INIT)) {
  178. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  179. "[Init] Initializing ACPI events\n"));
  180. status = acpi_ev_initialize_events();
  181. if (ACPI_FAILURE(status)) {
  182. return_ACPI_STATUS(status);
  183. }
  184. }
  185. /*
  186. * Install the SCI handler and Global Lock handler. This completes the
  187. * hardware initialization.
  188. */
  189. if (!(flags & ACPI_NO_HANDLER_INIT)) {
  190. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  191. "[Init] Installing SCI/GL handlers\n"));
  192. status = acpi_ev_install_xrupt_handlers();
  193. if (ACPI_FAILURE(status)) {
  194. return_ACPI_STATUS(status);
  195. }
  196. }
  197. #endif /* !ACPI_REDUCED_HARDWARE */
  198. return_ACPI_STATUS(status);
  199. }
  200. ACPI_EXPORT_SYMBOL(acpi_enable_subsystem)
  201. /*******************************************************************************
  202. *
  203. * FUNCTION: acpi_initialize_objects
  204. *
  205. * PARAMETERS: flags - Init/enable Options
  206. *
  207. * RETURN: Status
  208. *
  209. * DESCRIPTION: Completes namespace initialization by initializing device
  210. * objects and executing AML code for Regions, buffers, etc.
  211. *
  212. ******************************************************************************/
  213. acpi_status acpi_initialize_objects(u32 flags)
  214. {
  215. acpi_status status = AE_OK;
  216. ACPI_FUNCTION_TRACE(acpi_initialize_objects);
  217. /*
  218. * Run all _REG methods
  219. *
  220. * Note: Any objects accessed by the _REG methods will be automatically
  221. * initialized, even if they contain executable AML (see the call to
  222. * acpi_ns_initialize_objects below).
  223. */
  224. if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
  225. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  226. "[Init] Executing _REG OpRegion methods\n"));
  227. status = acpi_ev_initialize_op_regions();
  228. if (ACPI_FAILURE(status)) {
  229. return_ACPI_STATUS(status);
  230. }
  231. }
  232. /*
  233. * Execute any module-level code that was detected during the table load
  234. * phase. Although illegal since ACPI 2.0, there are many machines that
  235. * contain this type of code. Each block of detected executable AML code
  236. * outside of any control method is wrapped with a temporary control
  237. * method object and placed on a global list. The methods on this list
  238. * are executed below.
  239. */
  240. acpi_ns_exec_module_code_list();
  241. /*
  242. * Initialize the objects that remain uninitialized. This runs the
  243. * executable AML that may be part of the declaration of these objects:
  244. * operation_regions, buffer_fields, Buffers, and Packages.
  245. */
  246. if (!(flags & ACPI_NO_OBJECT_INIT)) {
  247. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  248. "[Init] Completing Initialization of ACPI Objects\n"));
  249. status = acpi_ns_initialize_objects();
  250. if (ACPI_FAILURE(status)) {
  251. return_ACPI_STATUS(status);
  252. }
  253. }
  254. /*
  255. * Initialize all device objects in the namespace. This runs the device
  256. * _STA and _INI methods.
  257. */
  258. if (!(flags & ACPI_NO_DEVICE_INIT)) {
  259. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  260. "[Init] Initializing ACPI Devices\n"));
  261. status = acpi_ns_initialize_devices();
  262. if (ACPI_FAILURE(status)) {
  263. return_ACPI_STATUS(status);
  264. }
  265. }
  266. /*
  267. * Empty the caches (delete the cached objects) on the assumption that
  268. * the table load filled them up more than they will be at runtime --
  269. * thus wasting non-paged memory.
  270. */
  271. status = acpi_purge_cached_objects();
  272. acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
  273. return_ACPI_STATUS(status);
  274. }
  275. ACPI_EXPORT_SYMBOL(acpi_initialize_objects)