utxfinit.c 10.0 KB

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