1 /******************************************************************************
3 * Module Name: utxfinit - External interfaces for ACPICA initialization
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2014, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #define EXPORT_ACPI_INTERFACES
46 #include <acpi/acpi.h>
53 #define _COMPONENT ACPI_UTILITIES
54 ACPI_MODULE_NAME("utxfinit")
56 /*******************************************************************************
58 * FUNCTION: acpi_initialize_subsystem
64 * DESCRIPTION: Initializes all global variables. This is the first function
65 * called, so any early initialization belongs here.
67 ******************************************************************************/
68 acpi_status __init
acpi_initialize_subsystem(void)
72 ACPI_FUNCTION_TRACE(acpi_initialize_subsystem
);
74 acpi_gbl_startup_flags
= ACPI_SUBSYSTEM_INITIALIZE
;
75 ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
77 /* Initialize the OS-Dependent layer */
79 status
= acpi_os_initialize();
80 if (ACPI_FAILURE(status
)) {
81 ACPI_EXCEPTION((AE_INFO
, status
, "During OSL initialization"));
82 return_ACPI_STATUS(status
);
85 /* Initialize all globals used by the subsystem */
87 status
= acpi_ut_init_globals();
88 if (ACPI_FAILURE(status
)) {
89 ACPI_EXCEPTION((AE_INFO
, status
,
90 "During initialization of globals"));
91 return_ACPI_STATUS(status
);
94 /* Create the default mutex objects */
96 status
= acpi_ut_mutex_initialize();
97 if (ACPI_FAILURE(status
)) {
98 ACPI_EXCEPTION((AE_INFO
, status
,
99 "During Global Mutex creation"));
100 return_ACPI_STATUS(status
);
104 * Initialize the namespace manager and
105 * the root of the namespace tree
107 status
= acpi_ns_root_initialize();
108 if (ACPI_FAILURE(status
)) {
109 ACPI_EXCEPTION((AE_INFO
, status
,
110 "During Namespace initialization"));
111 return_ACPI_STATUS(status
);
114 /* Initialize the global OSI interfaces list with the static names */
116 status
= acpi_ut_initialize_interfaces();
117 if (ACPI_FAILURE(status
)) {
118 ACPI_EXCEPTION((AE_INFO
, status
,
119 "During OSI interfaces initialization"));
120 return_ACPI_STATUS(status
);
123 /* If configured, initialize the AML debugger */
126 status
= acpi_db_initialize();
127 if (ACPI_FAILURE(status
)) {
128 ACPI_EXCEPTION((AE_INFO
, status
,
129 "During Debugger initialization"));
130 return_ACPI_STATUS(status
);
134 return_ACPI_STATUS(AE_OK
);
137 ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem
)
139 /*******************************************************************************
141 * FUNCTION: acpi_enable_subsystem
143 * PARAMETERS: flags - Init/enable Options
147 * DESCRIPTION: Completes the subsystem initialization including hardware.
148 * Puts system into ACPI mode if it isn't already.
150 ******************************************************************************/
151 acpi_status __init
acpi_enable_subsystem(u32 flags
)
153 acpi_status status
= AE_OK
;
155 ACPI_FUNCTION_TRACE(acpi_enable_subsystem
);
157 #if (!ACPI_REDUCED_HARDWARE)
159 /* Enable ACPI mode */
161 if (!(flags
& ACPI_NO_ACPI_ENABLE
)) {
162 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
163 "[Init] Going into ACPI mode\n"));
165 acpi_gbl_original_mode
= acpi_hw_get_mode();
167 status
= acpi_enable();
168 if (ACPI_FAILURE(status
)) {
169 ACPI_WARNING((AE_INFO
, "AcpiEnable failed"));
170 return_ACPI_STATUS(status
);
175 * Obtain a permanent mapping for the FACS. This is required for the
176 * Global Lock and the Firmware Waking Vector
178 if (!(flags
& ACPI_NO_FACS_INIT
)) {
179 status
= acpi_tb_initialize_facs();
180 if (ACPI_FAILURE(status
)) {
181 ACPI_WARNING((AE_INFO
, "Could not map the FACS table"));
182 return_ACPI_STATUS(status
);
185 #endif /* !ACPI_REDUCED_HARDWARE */
188 * Install the default op_region handlers. These are installed unless
189 * other handlers have already been installed via the
190 * install_address_space_handler interface.
192 if (!(flags
& ACPI_NO_ADDRESS_SPACE_INIT
)) {
193 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
194 "[Init] Installing default address space handlers\n"));
196 status
= acpi_ev_install_region_handlers();
197 if (ACPI_FAILURE(status
)) {
198 return_ACPI_STATUS(status
);
201 #if (!ACPI_REDUCED_HARDWARE)
203 * Initialize ACPI Event handling (Fixed and General Purpose)
205 * Note1: We must have the hardware and events initialized before we can
206 * execute any control methods safely. Any control method can require
207 * ACPI hardware support, so the hardware must be fully initialized before
208 * any method execution!
210 * Note2: Fixed events are initialized and enabled here. GPEs are
211 * initialized, but cannot be enabled until after the hardware is
212 * completely initialized (SCI and global_lock activated) and the various
213 * initialization control methods are run (_REG, _STA, _INI) on the
216 if (!(flags
& ACPI_NO_EVENT_INIT
)) {
217 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
218 "[Init] Initializing ACPI events\n"));
220 status
= acpi_ev_initialize_events();
221 if (ACPI_FAILURE(status
)) {
222 return_ACPI_STATUS(status
);
227 * Install the SCI handler and Global Lock handler. This completes the
228 * hardware initialization.
230 if (!(flags
& ACPI_NO_HANDLER_INIT
)) {
231 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
232 "[Init] Installing SCI/GL handlers\n"));
234 status
= acpi_ev_install_xrupt_handlers();
235 if (ACPI_FAILURE(status
)) {
236 return_ACPI_STATUS(status
);
239 #endif /* !ACPI_REDUCED_HARDWARE */
241 return_ACPI_STATUS(status
);
244 ACPI_EXPORT_SYMBOL_INIT(acpi_enable_subsystem
)
246 /*******************************************************************************
248 * FUNCTION: acpi_initialize_objects
250 * PARAMETERS: flags - Init/enable Options
254 * DESCRIPTION: Completes namespace initialization by initializing device
255 * objects and executing AML code for Regions, buffers, etc.
257 ******************************************************************************/
258 acpi_status __init
acpi_initialize_objects(u32 flags
)
260 acpi_status status
= AE_OK
;
262 ACPI_FUNCTION_TRACE(acpi_initialize_objects
);
265 * Run all _REG methods
267 * Note: Any objects accessed by the _REG methods will be automatically
268 * initialized, even if they contain executable AML (see the call to
269 * acpi_ns_initialize_objects below).
271 if (!(flags
& ACPI_NO_ADDRESS_SPACE_INIT
)) {
272 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
273 "[Init] Executing _REG OpRegion methods\n"));
275 status
= acpi_ev_initialize_op_regions();
276 if (ACPI_FAILURE(status
)) {
277 return_ACPI_STATUS(status
);
282 * Execute any module-level code that was detected during the table load
283 * phase. Although illegal since ACPI 2.0, there are many machines that
284 * contain this type of code. Each block of detected executable AML code
285 * outside of any control method is wrapped with a temporary control
286 * method object and placed on a global list. The methods on this list
287 * are executed below.
289 acpi_ns_exec_module_code_list();
292 * Initialize the objects that remain uninitialized. This runs the
293 * executable AML that may be part of the declaration of these objects:
294 * operation_regions, buffer_fields, Buffers, and Packages.
296 if (!(flags
& ACPI_NO_OBJECT_INIT
)) {
297 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
298 "[Init] Completing Initialization of ACPI Objects\n"));
300 status
= acpi_ns_initialize_objects();
301 if (ACPI_FAILURE(status
)) {
302 return_ACPI_STATUS(status
);
307 * Initialize all device objects in the namespace. This runs the device
308 * _STA and _INI methods.
310 if (!(flags
& ACPI_NO_DEVICE_INIT
)) {
311 ACPI_DEBUG_PRINT((ACPI_DB_EXEC
,
312 "[Init] Initializing ACPI Devices\n"));
314 status
= acpi_ns_initialize_devices();
315 if (ACPI_FAILURE(status
)) {
316 return_ACPI_STATUS(status
);
321 * Empty the caches (delete the cached objects) on the assumption that
322 * the table load filled them up more than they will be at runtime --
323 * thus wasting non-paged memory.
325 status
= acpi_purge_cached_objects();
327 acpi_gbl_startup_flags
|= ACPI_INITIALIZED_OK
;
328 return_ACPI_STATUS(status
);
331 ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_objects
)