utxfinit.c 9.5 KB

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