utxfinit.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. /******************************************************************************
  2. *
  3. * Module Name: utxfinit - External interfaces for ACPICA initialization
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2016, 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. /*
  128. * The early initialization phase is complete. The namespace is loaded,
  129. * and we can now support address spaces other than Memory, I/O, and
  130. * PCI_Config.
  131. */
  132. acpi_gbl_early_initialization = FALSE;
  133. /*
  134. * Install the default operation region handlers. These are the
  135. * handlers that are defined by the ACPI specification to be
  136. * "always accessible" -- namely, system_memory, system_IO, and
  137. * PCI_Config. This also means that no _REG methods need to be
  138. * run for these address spaces. We need to have these handlers
  139. * installed before any AML code can be executed, especially any
  140. * module-level code (11/2015).
  141. */
  142. if (!acpi_gbl_group_module_level_code) {
  143. status = acpi_ev_install_region_handlers();
  144. if (ACPI_FAILURE(status)) {
  145. ACPI_EXCEPTION((AE_INFO, status,
  146. "During Region initialization"));
  147. return_ACPI_STATUS(status);
  148. }
  149. }
  150. #if (!ACPI_REDUCED_HARDWARE)
  151. /* Enable ACPI mode */
  152. if (!(flags & ACPI_NO_ACPI_ENABLE)) {
  153. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  154. "[Init] Going into ACPI mode\n"));
  155. acpi_gbl_original_mode = acpi_hw_get_mode();
  156. status = acpi_enable();
  157. if (ACPI_FAILURE(status)) {
  158. ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
  159. return_ACPI_STATUS(status);
  160. }
  161. }
  162. /*
  163. * Obtain a permanent mapping for the FACS. This is required for the
  164. * Global Lock and the Firmware Waking Vector
  165. */
  166. if (!(flags & ACPI_NO_FACS_INIT)) {
  167. status = acpi_tb_initialize_facs();
  168. if (ACPI_FAILURE(status)) {
  169. ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
  170. return_ACPI_STATUS(status);
  171. }
  172. }
  173. /*
  174. * Initialize ACPI Event handling (Fixed and General Purpose)
  175. *
  176. * Note1: We must have the hardware and events initialized before we can
  177. * execute any control methods safely. Any control method can require
  178. * ACPI hardware support, so the hardware must be fully initialized before
  179. * any method execution!
  180. *
  181. * Note2: Fixed events are initialized and enabled here. GPEs are
  182. * initialized, but cannot be enabled until after the hardware is
  183. * completely initialized (SCI and global_lock activated) and the various
  184. * initialization control methods are run (_REG, _STA, _INI) on the
  185. * entire namespace.
  186. */
  187. if (!(flags & ACPI_NO_EVENT_INIT)) {
  188. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  189. "[Init] Initializing ACPI events\n"));
  190. status = acpi_ev_initialize_events();
  191. if (ACPI_FAILURE(status)) {
  192. return_ACPI_STATUS(status);
  193. }
  194. }
  195. /*
  196. * Install the SCI handler and Global Lock handler. This completes the
  197. * hardware initialization.
  198. */
  199. if (!(flags & ACPI_NO_HANDLER_INIT)) {
  200. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  201. "[Init] Installing SCI/GL handlers\n"));
  202. status = acpi_ev_install_xrupt_handlers();
  203. if (ACPI_FAILURE(status)) {
  204. return_ACPI_STATUS(status);
  205. }
  206. }
  207. #endif /* !ACPI_REDUCED_HARDWARE */
  208. return_ACPI_STATUS(status);
  209. }
  210. ACPI_EXPORT_SYMBOL_INIT(acpi_enable_subsystem)
  211. /*******************************************************************************
  212. *
  213. * FUNCTION: acpi_initialize_objects
  214. *
  215. * PARAMETERS: flags - Init/enable Options
  216. *
  217. * RETURN: Status
  218. *
  219. * DESCRIPTION: Completes namespace initialization by initializing device
  220. * objects and executing AML code for Regions, buffers, etc.
  221. *
  222. ******************************************************************************/
  223. acpi_status __init acpi_initialize_objects(u32 flags)
  224. {
  225. acpi_status status = AE_OK;
  226. ACPI_FUNCTION_TRACE(acpi_initialize_objects);
  227. #ifdef ACPI_EXEC_APP
  228. /*
  229. * This call implements the "initialization file" option for acpi_exec.
  230. * This is the precise point that we want to perform the overrides.
  231. */
  232. ae_do_object_overrides();
  233. #endif
  234. /*
  235. * Execute any module-level code that was detected during the table load
  236. * phase. Although illegal since ACPI 2.0, there are many machines that
  237. * contain this type of code. Each block of detected executable AML code
  238. * outside of any control method is wrapped with a temporary control
  239. * method object and placed on a global list. The methods on this list
  240. * are executed below.
  241. *
  242. * This case executes the module-level code for all tables only after
  243. * all of the tables have been loaded. It is a legacy option and is
  244. * not compatible with other ACPI implementations. See acpi_ns_load_table.
  245. */
  246. if (acpi_gbl_group_module_level_code) {
  247. acpi_ns_exec_module_code_list();
  248. }
  249. /*
  250. * Initialize the objects that remain uninitialized. This runs the
  251. * executable AML that may be part of the declaration of these objects:
  252. * operation_regions, buffer_fields, Buffers, and Packages.
  253. */
  254. if (!(flags & ACPI_NO_OBJECT_INIT)) {
  255. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  256. "[Init] Completing Initialization of ACPI Objects\n"));
  257. status = acpi_ns_initialize_objects();
  258. if (ACPI_FAILURE(status)) {
  259. return_ACPI_STATUS(status);
  260. }
  261. }
  262. acpi_gbl_reg_methods_enabled = TRUE;
  263. /*
  264. * Initialize all device/region objects in the namespace. This runs
  265. * the device _STA and _INI methods and region _REG methods.
  266. */
  267. if (!(flags & (ACPI_NO_DEVICE_INIT | ACPI_NO_ADDRESS_SPACE_INIT))) {
  268. status = acpi_ns_initialize_devices(flags);
  269. if (ACPI_FAILURE(status)) {
  270. return_ACPI_STATUS(status);
  271. }
  272. }
  273. /*
  274. * Empty the caches (delete the cached objects) on the assumption that
  275. * the table load filled them up more than they will be at runtime --
  276. * thus wasting non-paged memory.
  277. */
  278. status = acpi_purge_cached_objects();
  279. acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
  280. return_ACPI_STATUS(status);
  281. }
  282. ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_objects)