fat: provide option for setting timezone offset
[linux-2.6/libata-dev.git] / drivers / acpi / acpica / utxfinit.c
blob14f523627a5e9cd60624ef17f9fadd8fd2c9cb16
1 /******************************************************************************
3 * Module Name: utxfinit - External interfaces for ACPICA initialization
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
30 * NO WARRANTY
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 #include <linux/export.h>
45 #include <acpi/acpi.h>
46 #include "accommon.h"
47 #include "acevents.h"
48 #include "acnamesp.h"
49 #include "acdebug.h"
50 #include "actables.h"
52 #define _COMPONENT ACPI_UTILITIES
53 ACPI_MODULE_NAME("utxfinit")
55 /*******************************************************************************
57 * FUNCTION: acpi_initialize_subsystem
59 * PARAMETERS: None
61 * RETURN: Status
63 * DESCRIPTION: Initializes all global variables. This is the first function
64 * called, so any early initialization belongs here.
66 ******************************************************************************/
67 acpi_status acpi_initialize_subsystem(void)
69 acpi_status status;
71 ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
73 acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
74 ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
76 /* Initialize the OS-Dependent layer */
78 status = acpi_os_initialize();
79 if (ACPI_FAILURE(status)) {
80 ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
81 return_ACPI_STATUS(status);
84 /* Initialize all globals used by the subsystem */
86 status = acpi_ut_init_globals();
87 if (ACPI_FAILURE(status)) {
88 ACPI_EXCEPTION((AE_INFO, status,
89 "During initialization of globals"));
90 return_ACPI_STATUS(status);
93 /* Create the default mutex objects */
95 status = acpi_ut_mutex_initialize();
96 if (ACPI_FAILURE(status)) {
97 ACPI_EXCEPTION((AE_INFO, status,
98 "During Global Mutex creation"));
99 return_ACPI_STATUS(status);
103 * Initialize the namespace manager and
104 * the root of the namespace tree
106 status = acpi_ns_root_initialize();
107 if (ACPI_FAILURE(status)) {
108 ACPI_EXCEPTION((AE_INFO, status,
109 "During Namespace initialization"));
110 return_ACPI_STATUS(status);
113 /* Initialize the global OSI interfaces list with the static names */
115 status = acpi_ut_initialize_interfaces();
116 if (ACPI_FAILURE(status)) {
117 ACPI_EXCEPTION((AE_INFO, status,
118 "During OSI interfaces initialization"));
119 return_ACPI_STATUS(status);
122 /* If configured, initialize the AML debugger */
124 ACPI_DEBUGGER_EXEC(status = acpi_db_initialize());
125 return_ACPI_STATUS(status);
127 ACPI_EXPORT_SYMBOL(acpi_initialize_subsystem)
129 /*******************************************************************************
131 * FUNCTION: acpi_enable_subsystem
133 * PARAMETERS: flags - Init/enable Options
135 * RETURN: Status
137 * DESCRIPTION: Completes the subsystem initialization including hardware.
138 * Puts system into ACPI mode if it isn't already.
140 ******************************************************************************/
141 acpi_status acpi_enable_subsystem(u32 flags)
143 acpi_status status = AE_OK;
145 ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
147 #if (!ACPI_REDUCED_HARDWARE)
149 /* Enable ACPI mode */
151 if (!(flags & ACPI_NO_ACPI_ENABLE)) {
152 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
153 "[Init] Going into ACPI mode\n"));
155 acpi_gbl_original_mode = acpi_hw_get_mode();
157 status = acpi_enable();
158 if (ACPI_FAILURE(status)) {
159 ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
160 return_ACPI_STATUS(status);
165 * Obtain a permanent mapping for the FACS. This is required for the
166 * Global Lock and the Firmware Waking Vector
168 status = acpi_tb_initialize_facs();
169 if (ACPI_FAILURE(status)) {
170 ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
171 return_ACPI_STATUS(status);
173 #endif /* !ACPI_REDUCED_HARDWARE */
176 * Install the default op_region handlers. These are installed unless
177 * other handlers have already been installed via the
178 * install_address_space_handler interface.
180 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
181 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
182 "[Init] Installing default address space handlers\n"));
184 status = acpi_ev_install_region_handlers();
185 if (ACPI_FAILURE(status)) {
186 return_ACPI_STATUS(status);
189 #if (!ACPI_REDUCED_HARDWARE)
191 * Initialize ACPI Event handling (Fixed and General Purpose)
193 * Note1: We must have the hardware and events initialized before we can
194 * execute any control methods safely. Any control method can require
195 * ACPI hardware support, so the hardware must be fully initialized before
196 * any method execution!
198 * Note2: Fixed events are initialized and enabled here. GPEs are
199 * initialized, but cannot be enabled until after the hardware is
200 * completely initialized (SCI and global_lock activated) and the various
201 * initialization control methods are run (_REG, _STA, _INI) on the
202 * entire namespace.
204 if (!(flags & ACPI_NO_EVENT_INIT)) {
205 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
206 "[Init] Initializing ACPI events\n"));
208 status = acpi_ev_initialize_events();
209 if (ACPI_FAILURE(status)) {
210 return_ACPI_STATUS(status);
215 * Install the SCI handler and Global Lock handler. This completes the
216 * hardware initialization.
218 if (!(flags & ACPI_NO_HANDLER_INIT)) {
219 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
220 "[Init] Installing SCI/GL handlers\n"));
222 status = acpi_ev_install_xrupt_handlers();
223 if (ACPI_FAILURE(status)) {
224 return_ACPI_STATUS(status);
227 #endif /* !ACPI_REDUCED_HARDWARE */
229 return_ACPI_STATUS(status);
231 ACPI_EXPORT_SYMBOL(acpi_enable_subsystem)
233 /*******************************************************************************
235 * FUNCTION: acpi_initialize_objects
237 * PARAMETERS: flags - Init/enable Options
239 * RETURN: Status
241 * DESCRIPTION: Completes namespace initialization by initializing device
242 * objects and executing AML code for Regions, buffers, etc.
244 ******************************************************************************/
245 acpi_status acpi_initialize_objects(u32 flags)
247 acpi_status status = AE_OK;
249 ACPI_FUNCTION_TRACE(acpi_initialize_objects);
252 * Run all _REG methods
254 * Note: Any objects accessed by the _REG methods will be automatically
255 * initialized, even if they contain executable AML (see the call to
256 * acpi_ns_initialize_objects below).
258 if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
259 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
260 "[Init] Executing _REG OpRegion methods\n"));
262 status = acpi_ev_initialize_op_regions();
263 if (ACPI_FAILURE(status)) {
264 return_ACPI_STATUS(status);
269 * Execute any module-level code that was detected during the table load
270 * phase. Although illegal since ACPI 2.0, there are many machines that
271 * contain this type of code. Each block of detected executable AML code
272 * outside of any control method is wrapped with a temporary control
273 * method object and placed on a global list. The methods on this list
274 * are executed below.
276 acpi_ns_exec_module_code_list();
279 * Initialize the objects that remain uninitialized. This runs the
280 * executable AML that may be part of the declaration of these objects:
281 * operation_regions, buffer_fields, Buffers, and Packages.
283 if (!(flags & ACPI_NO_OBJECT_INIT)) {
284 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
285 "[Init] Completing Initialization of ACPI Objects\n"));
287 status = acpi_ns_initialize_objects();
288 if (ACPI_FAILURE(status)) {
289 return_ACPI_STATUS(status);
294 * Initialize all device objects in the namespace. This runs the device
295 * _STA and _INI methods.
297 if (!(flags & ACPI_NO_DEVICE_INIT)) {
298 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
299 "[Init] Initializing ACPI Devices\n"));
301 status = acpi_ns_initialize_devices();
302 if (ACPI_FAILURE(status)) {
303 return_ACPI_STATUS(status);
308 * Empty the caches (delete the cached objects) on the assumption that
309 * the table load filled them up more than they will be at runtime --
310 * thus wasting non-paged memory.
312 status = acpi_purge_cached_objects();
314 acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
315 return_ACPI_STATUS(status);
317 ACPI_EXPORT_SYMBOL(acpi_initialize_objects)