utxfinit.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /******************************************************************************
  3. *
  4. * Module Name: utxfinit - External interfaces for ACPICA initialization
  5. *
  6. * Copyright (C) 2000 - 2022, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #define EXPORT_ACPI_INTERFACES
  10. #include <acpi/acpi.h>
  11. #include "accommon.h"
  12. #include "acevents.h"
  13. #include "acnamesp.h"
  14. #include "acdebug.h"
  15. #include "actables.h"
  16. #define _COMPONENT ACPI_UTILITIES
  17. ACPI_MODULE_NAME("utxfinit")
  18. /* For acpi_exec only */
  19. void ae_do_object_overrides(void);
  20. /*******************************************************************************
  21. *
  22. * FUNCTION: acpi_initialize_subsystem
  23. *
  24. * PARAMETERS: None
  25. *
  26. * RETURN: Status
  27. *
  28. * DESCRIPTION: Initializes all global variables. This is the first function
  29. * called, so any early initialization belongs here.
  30. *
  31. ******************************************************************************/
  32. acpi_status ACPI_INIT_FUNCTION acpi_initialize_subsystem(void)
  33. {
  34. acpi_status status;
  35. ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
  36. acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
  37. ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
  38. /* Initialize the OS-Dependent layer */
  39. status = acpi_os_initialize();
  40. if (ACPI_FAILURE(status)) {
  41. ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
  42. return_ACPI_STATUS(status);
  43. }
  44. /* Initialize all globals used by the subsystem */
  45. status = acpi_ut_init_globals();
  46. if (ACPI_FAILURE(status)) {
  47. ACPI_EXCEPTION((AE_INFO, status,
  48. "During initialization of globals"));
  49. return_ACPI_STATUS(status);
  50. }
  51. /* Create the default mutex objects */
  52. status = acpi_ut_mutex_initialize();
  53. if (ACPI_FAILURE(status)) {
  54. ACPI_EXCEPTION((AE_INFO, status,
  55. "During Global Mutex creation"));
  56. return_ACPI_STATUS(status);
  57. }
  58. /*
  59. * Initialize the namespace manager and
  60. * the root of the namespace tree
  61. */
  62. status = acpi_ns_root_initialize();
  63. if (ACPI_FAILURE(status)) {
  64. ACPI_EXCEPTION((AE_INFO, status,
  65. "During Namespace initialization"));
  66. return_ACPI_STATUS(status);
  67. }
  68. /* Initialize the global OSI interfaces list with the static names */
  69. status = acpi_ut_initialize_interfaces();
  70. if (ACPI_FAILURE(status)) {
  71. ACPI_EXCEPTION((AE_INFO, status,
  72. "During OSI interfaces initialization"));
  73. return_ACPI_STATUS(status);
  74. }
  75. return_ACPI_STATUS(AE_OK);
  76. }
  77. ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem)
  78. /*******************************************************************************
  79. *
  80. * FUNCTION: acpi_enable_subsystem
  81. *
  82. * PARAMETERS: flags - Init/enable Options
  83. *
  84. * RETURN: Status
  85. *
  86. * DESCRIPTION: Completes the subsystem initialization including hardware.
  87. * Puts system into ACPI mode if it isn't already.
  88. *
  89. ******************************************************************************/
  90. acpi_status ACPI_INIT_FUNCTION acpi_enable_subsystem(u32 flags)
  91. {
  92. acpi_status status = AE_OK;
  93. ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
  94. /*
  95. * The early initialization phase is complete. The namespace is loaded,
  96. * and we can now support address spaces other than Memory, I/O, and
  97. * PCI_Config.
  98. */
  99. acpi_gbl_early_initialization = FALSE;
  100. #if (!ACPI_REDUCED_HARDWARE)
  101. /* Enable ACPI mode */
  102. if (!(flags & ACPI_NO_ACPI_ENABLE)) {
  103. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  104. "[Init] Going into ACPI mode\n"));
  105. acpi_gbl_original_mode = acpi_hw_get_mode();
  106. status = acpi_enable();
  107. if (ACPI_FAILURE(status)) {
  108. ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
  109. return_ACPI_STATUS(status);
  110. }
  111. }
  112. /*
  113. * Obtain a permanent mapping for the FACS. This is required for the
  114. * Global Lock and the Firmware Waking Vector
  115. */
  116. if (!(flags & ACPI_NO_FACS_INIT)) {
  117. status = acpi_tb_initialize_facs();
  118. if (ACPI_FAILURE(status)) {
  119. ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
  120. return_ACPI_STATUS(status);
  121. }
  122. }
  123. /*
  124. * Initialize ACPI Event handling (Fixed and General Purpose)
  125. *
  126. * Note1: We must have the hardware and events initialized before we can
  127. * execute any control methods safely. Any control method can require
  128. * ACPI hardware support, so the hardware must be fully initialized before
  129. * any method execution!
  130. *
  131. * Note2: Fixed events are initialized and enabled here. GPEs are
  132. * initialized, but cannot be enabled until after the hardware is
  133. * completely initialized (SCI and global_lock activated) and the various
  134. * initialization control methods are run (_REG, _STA, _INI) on the
  135. * entire namespace.
  136. */
  137. if (!(flags & ACPI_NO_EVENT_INIT)) {
  138. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  139. "[Init] Initializing ACPI events\n"));
  140. status = acpi_ev_initialize_events();
  141. if (ACPI_FAILURE(status)) {
  142. return_ACPI_STATUS(status);
  143. }
  144. }
  145. /*
  146. * Install the SCI handler and Global Lock handler. This completes the
  147. * hardware initialization.
  148. */
  149. if (!(flags & ACPI_NO_HANDLER_INIT)) {
  150. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  151. "[Init] Installing SCI/GL handlers\n"));
  152. status = acpi_ev_install_xrupt_handlers();
  153. if (ACPI_FAILURE(status)) {
  154. return_ACPI_STATUS(status);
  155. }
  156. }
  157. #endif /* !ACPI_REDUCED_HARDWARE */
  158. return_ACPI_STATUS(status);
  159. }
  160. ACPI_EXPORT_SYMBOL_INIT(acpi_enable_subsystem)
  161. /*******************************************************************************
  162. *
  163. * FUNCTION: acpi_initialize_objects
  164. *
  165. * PARAMETERS: flags - Init/enable Options
  166. *
  167. * RETURN: Status
  168. *
  169. * DESCRIPTION: Completes namespace initialization by initializing device
  170. * objects and executing AML code for Regions, buffers, etc.
  171. *
  172. ******************************************************************************/
  173. acpi_status ACPI_INIT_FUNCTION acpi_initialize_objects(u32 flags)
  174. {
  175. acpi_status status = AE_OK;
  176. ACPI_FUNCTION_TRACE(acpi_initialize_objects);
  177. #ifdef ACPI_OBSOLETE_BEHAVIOR
  178. /*
  179. * 05/2019: Removed, initialization now happens at both object
  180. * creation and table load time
  181. */
  182. /*
  183. * Initialize the objects that remain uninitialized. This
  184. * runs the executable AML that may be part of the
  185. * declaration of these objects: operation_regions, buffer_fields,
  186. * bank_fields, Buffers, and Packages.
  187. */
  188. if (!(flags & ACPI_NO_OBJECT_INIT)) {
  189. status = acpi_ns_initialize_objects();
  190. if (ACPI_FAILURE(status)) {
  191. return_ACPI_STATUS(status);
  192. }
  193. }
  194. #endif
  195. /*
  196. * Initialize all device/region objects in the namespace. This runs
  197. * the device _STA and _INI methods and region _REG methods.
  198. */
  199. if (!(flags & (ACPI_NO_DEVICE_INIT | ACPI_NO_ADDRESS_SPACE_INIT))) {
  200. status = acpi_ns_initialize_devices(flags);
  201. if (ACPI_FAILURE(status)) {
  202. return_ACPI_STATUS(status);
  203. }
  204. }
  205. /*
  206. * Empty the caches (delete the cached objects) on the assumption that
  207. * the table load filled them up more than they will be at runtime --
  208. * thus wasting non-paged memory.
  209. */
  210. status = acpi_purge_cached_objects();
  211. acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
  212. return_ACPI_STATUS(status);
  213. }
  214. ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_objects)