utxfinit.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. /* If configured, initialize the AML debugger */
  109. #ifdef ACPI_DEBUGGER
  110. status = acpi_db_initialize();
  111. if (ACPI_FAILURE(status)) {
  112. ACPI_EXCEPTION((AE_INFO, status,
  113. "During Debugger initialization"));
  114. return_ACPI_STATUS(status);
  115. }
  116. #endif
  117. return_ACPI_STATUS(AE_OK);
  118. }
  119. ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem)
  120. /*******************************************************************************
  121. *
  122. * FUNCTION: acpi_enable_subsystem
  123. *
  124. * PARAMETERS: flags - Init/enable Options
  125. *
  126. * RETURN: Status
  127. *
  128. * DESCRIPTION: Completes the subsystem initialization including hardware.
  129. * Puts system into ACPI mode if it isn't already.
  130. *
  131. ******************************************************************************/
  132. acpi_status __init acpi_enable_subsystem(u32 flags)
  133. {
  134. acpi_status status = AE_OK;
  135. ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
  136. #if (!ACPI_REDUCED_HARDWARE)
  137. /* Enable ACPI mode */
  138. if (!(flags & ACPI_NO_ACPI_ENABLE)) {
  139. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  140. "[Init] Going into ACPI mode\n"));
  141. acpi_gbl_original_mode = acpi_hw_get_mode();
  142. status = acpi_enable();
  143. if (ACPI_FAILURE(status)) {
  144. ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
  145. return_ACPI_STATUS(status);
  146. }
  147. }
  148. /*
  149. * Obtain a permanent mapping for the FACS. This is required for the
  150. * Global Lock and the Firmware Waking Vector
  151. */
  152. status = acpi_tb_initialize_facs();
  153. if (ACPI_FAILURE(status)) {
  154. ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
  155. return_ACPI_STATUS(status);
  156. }
  157. #endif /* !ACPI_REDUCED_HARDWARE */
  158. /*
  159. * Install the default op_region handlers. These are installed unless
  160. * other handlers have already been installed via the
  161. * install_address_space_handler interface.
  162. */
  163. if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
  164. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  165. "[Init] Installing default address space handlers\n"));
  166. status = acpi_ev_install_region_handlers();
  167. if (ACPI_FAILURE(status)) {
  168. return_ACPI_STATUS(status);
  169. }
  170. }
  171. #if (!ACPI_REDUCED_HARDWARE)
  172. /*
  173. * Initialize ACPI Event handling (Fixed and General Purpose)
  174. *
  175. * Note1: We must have the hardware and events initialized before we can
  176. * execute any control methods safely. Any control method can require
  177. * ACPI hardware support, so the hardware must be fully initialized before
  178. * any method execution!
  179. *
  180. * Note2: Fixed events are initialized and enabled here. GPEs are
  181. * initialized, but cannot be enabled until after the hardware is
  182. * completely initialized (SCI and global_lock activated) and the various
  183. * initialization control methods are run (_REG, _STA, _INI) on the
  184. * entire namespace.
  185. */
  186. if (!(flags & ACPI_NO_EVENT_INIT)) {
  187. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  188. "[Init] Initializing ACPI events\n"));
  189. status = acpi_ev_initialize_events();
  190. if (ACPI_FAILURE(status)) {
  191. return_ACPI_STATUS(status);
  192. }
  193. }
  194. /*
  195. * Install the SCI handler and Global Lock handler. This completes the
  196. * hardware initialization.
  197. */
  198. if (!(flags & ACPI_NO_HANDLER_INIT)) {
  199. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  200. "[Init] Installing SCI/GL handlers\n"));
  201. status = acpi_ev_install_xrupt_handlers();
  202. if (ACPI_FAILURE(status)) {
  203. return_ACPI_STATUS(status);
  204. }
  205. }
  206. #endif /* !ACPI_REDUCED_HARDWARE */
  207. return_ACPI_STATUS(status);
  208. }
  209. ACPI_EXPORT_SYMBOL_INIT(acpi_enable_subsystem)
  210. /*******************************************************************************
  211. *
  212. * FUNCTION: acpi_initialize_objects
  213. *
  214. * PARAMETERS: flags - Init/enable Options
  215. *
  216. * RETURN: Status
  217. *
  218. * DESCRIPTION: Completes namespace initialization by initializing device
  219. * objects and executing AML code for Regions, buffers, etc.
  220. *
  221. ******************************************************************************/
  222. acpi_status __init acpi_initialize_objects(u32 flags)
  223. {
  224. acpi_status status = AE_OK;
  225. ACPI_FUNCTION_TRACE(acpi_initialize_objects);
  226. /*
  227. * Run all _REG methods
  228. *
  229. * Note: Any objects accessed by the _REG methods will be automatically
  230. * initialized, even if they contain executable AML (see the call to
  231. * acpi_ns_initialize_objects below).
  232. */
  233. if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
  234. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  235. "[Init] Executing _REG OpRegion methods\n"));
  236. status = acpi_ev_initialize_op_regions();
  237. if (ACPI_FAILURE(status)) {
  238. return_ACPI_STATUS(status);
  239. }
  240. }
  241. #ifdef ACPI_EXEC_APP
  242. /*
  243. * This call implements the "initialization file" option for acpi_exec.
  244. * This is the precise point that we want to perform the overrides.
  245. */
  246. ae_do_object_overrides();
  247. #endif
  248. /*
  249. * Execute any module-level code that was detected during the table load
  250. * phase. Although illegal since ACPI 2.0, there are many machines that
  251. * contain this type of code. Each block of detected executable AML code
  252. * outside of any control method is wrapped with a temporary control
  253. * method object and placed on a global list. The methods on this list
  254. * are executed below.
  255. */
  256. acpi_ns_exec_module_code_list();
  257. /*
  258. * Initialize the objects that remain uninitialized. This runs the
  259. * executable AML that may be part of the declaration of these objects:
  260. * operation_regions, buffer_fields, Buffers, and Packages.
  261. */
  262. if (!(flags & ACPI_NO_OBJECT_INIT)) {
  263. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  264. "[Init] Completing Initialization of ACPI Objects\n"));
  265. status = acpi_ns_initialize_objects();
  266. if (ACPI_FAILURE(status)) {
  267. return_ACPI_STATUS(status);
  268. }
  269. }
  270. /*
  271. * Initialize all device objects in the namespace. This runs the device
  272. * _STA and _INI methods.
  273. */
  274. if (!(flags & ACPI_NO_DEVICE_INIT)) {
  275. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  276. "[Init] Initializing ACPI Devices\n"));
  277. status = acpi_ns_initialize_devices();
  278. if (ACPI_FAILURE(status)) {
  279. return_ACPI_STATUS(status);
  280. }
  281. }
  282. /*
  283. * Empty the caches (delete the cached objects) on the assumption that
  284. * the table load filled them up more than they will be at runtime --
  285. * thus wasting non-paged memory.
  286. */
  287. status = acpi_purge_cached_objects();
  288. acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
  289. return_ACPI_STATUS(status);
  290. }
  291. ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_objects)