1 /******************************************************************************
3 * Module Name: utxfinit - External interfaces for ACPICA initialization
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, 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.
45 #define __UTXFINIT_C__
46 #define EXPORT_ACPI_INTERFACES
55 #define _COMPONENT ACPI_UTILITIES
56 ACPI_MODULE_NAME ("utxfinit")
59 /*******************************************************************************
61 * FUNCTION: AcpiInitializeSubsystem
67 * DESCRIPTION: Initializes all global variables. This is the first function
68 * called, so any early initialization belongs here.
70 ******************************************************************************/
73 AcpiInitializeSubsystem (
79 ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem
);
82 AcpiGbl_StartupFlags
= ACPI_SUBSYSTEM_INITIALIZE
;
83 ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
85 /* Initialize the OS-Dependent layer */
87 Status
= AcpiOsInitialize ();
88 if (ACPI_FAILURE (Status
))
90 ACPI_EXCEPTION ((AE_INFO
, Status
, "During OSL initialization"));
91 return_ACPI_STATUS (Status
);
94 /* Initialize all globals used by the subsystem */
96 Status
= AcpiUtInitGlobals ();
97 if (ACPI_FAILURE (Status
))
99 ACPI_EXCEPTION ((AE_INFO
, Status
, "During initialization of globals"));
100 return_ACPI_STATUS (Status
);
103 /* Create the default mutex objects */
105 Status
= AcpiUtMutexInitialize ();
106 if (ACPI_FAILURE (Status
))
108 ACPI_EXCEPTION ((AE_INFO
, Status
, "During Global Mutex creation"));
109 return_ACPI_STATUS (Status
);
113 * Initialize the namespace manager and
114 * the root of the namespace tree
116 Status
= AcpiNsRootInitialize ();
117 if (ACPI_FAILURE (Status
))
119 ACPI_EXCEPTION ((AE_INFO
, Status
, "During Namespace initialization"));
120 return_ACPI_STATUS (Status
);
123 /* Initialize the global OSI interfaces list with the static names */
125 Status
= AcpiUtInitializeInterfaces ();
126 if (ACPI_FAILURE (Status
))
128 ACPI_EXCEPTION ((AE_INFO
, Status
, "During OSI interfaces initialization"));
129 return_ACPI_STATUS (Status
);
132 /* If configured, initialize the AML debugger */
134 ACPI_DEBUGGER_EXEC (Status
= AcpiDbInitialize ());
135 return_ACPI_STATUS (Status
);
138 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem
)
141 /*******************************************************************************
143 * FUNCTION: AcpiEnableSubsystem
145 * PARAMETERS: Flags - Init/enable Options
149 * DESCRIPTION: Completes the subsystem initialization including hardware.
150 * Puts system into ACPI mode if it isn't already.
152 ******************************************************************************/
155 AcpiEnableSubsystem (
158 ACPI_STATUS Status
= AE_OK
;
161 ACPI_FUNCTION_TRACE (AcpiEnableSubsystem
);
164 #if (!ACPI_REDUCED_HARDWARE)
166 /* Enable ACPI mode */
168 if (!(Flags
& ACPI_NO_ACPI_ENABLE
))
170 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
, "[Init] Going into ACPI mode\n"));
172 AcpiGbl_OriginalMode
= AcpiHwGetMode();
174 Status
= AcpiEnable ();
175 if (ACPI_FAILURE (Status
))
177 ACPI_WARNING ((AE_INFO
, "AcpiEnable failed"));
178 return_ACPI_STATUS (Status
);
183 * Obtain a permanent mapping for the FACS. This is required for the
184 * Global Lock and the Firmware Waking Vector
186 Status
= AcpiTbInitializeFacs ();
187 if (ACPI_FAILURE (Status
))
189 ACPI_WARNING ((AE_INFO
, "Could not map the FACS table"));
190 return_ACPI_STATUS (Status
);
193 #endif /* !ACPI_REDUCED_HARDWARE */
196 * Install the default OpRegion handlers. These are installed unless
197 * other handlers have already been installed via the
198 * InstallAddressSpaceHandler interface.
200 if (!(Flags
& ACPI_NO_ADDRESS_SPACE_INIT
))
202 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
203 "[Init] Installing default address space handlers\n"));
205 Status
= AcpiEvInstallRegionHandlers ();
206 if (ACPI_FAILURE (Status
))
208 return_ACPI_STATUS (Status
);
212 #if (!ACPI_REDUCED_HARDWARE)
214 * Initialize ACPI Event handling (Fixed and General Purpose)
216 * Note1: We must have the hardware and events initialized before we can
217 * execute any control methods safely. Any control method can require
218 * ACPI hardware support, so the hardware must be fully initialized before
219 * any method execution!
221 * Note2: Fixed events are initialized and enabled here. GPEs are
222 * initialized, but cannot be enabled until after the hardware is
223 * completely initialized (SCI and GlobalLock activated) and the various
224 * initialization control methods are run (_REG, _STA, _INI) on the
227 if (!(Flags
& ACPI_NO_EVENT_INIT
))
229 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
230 "[Init] Initializing ACPI events\n"));
232 Status
= AcpiEvInitializeEvents ();
233 if (ACPI_FAILURE (Status
))
235 return_ACPI_STATUS (Status
);
240 * Install the SCI handler and Global Lock handler. This completes the
241 * hardware initialization.
243 if (!(Flags
& ACPI_NO_HANDLER_INIT
))
245 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
246 "[Init] Installing SCI/GL handlers\n"));
248 Status
= AcpiEvInstallXruptHandlers ();
249 if (ACPI_FAILURE (Status
))
251 return_ACPI_STATUS (Status
);
255 #endif /* !ACPI_REDUCED_HARDWARE */
257 return_ACPI_STATUS (Status
);
260 ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem
)
263 /*******************************************************************************
265 * FUNCTION: AcpiInitializeObjects
267 * PARAMETERS: Flags - Init/enable Options
271 * DESCRIPTION: Completes namespace initialization by initializing device
272 * objects and executing AML code for Regions, buffers, etc.
274 ******************************************************************************/
277 AcpiInitializeObjects (
280 ACPI_STATUS Status
= AE_OK
;
283 ACPI_FUNCTION_TRACE (AcpiInitializeObjects
);
287 * Run all _REG methods
289 * Note: Any objects accessed by the _REG methods will be automatically
290 * initialized, even if they contain executable AML (see the call to
291 * AcpiNsInitializeObjects below).
293 if (!(Flags
& ACPI_NO_ADDRESS_SPACE_INIT
))
295 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
296 "[Init] Executing _REG OpRegion methods\n"));
298 Status
= AcpiEvInitializeOpRegions ();
299 if (ACPI_FAILURE (Status
))
301 return_ACPI_STATUS (Status
);
306 * Execute any module-level code that was detected during the table load
307 * phase. Although illegal since ACPI 2.0, there are many machines that
308 * contain this type of code. Each block of detected executable AML code
309 * outside of any control method is wrapped with a temporary control
310 * method object and placed on a global list. The methods on this list
311 * are executed below.
313 AcpiNsExecModuleCodeList ();
316 * Initialize the objects that remain uninitialized. This runs the
317 * executable AML that may be part of the declaration of these objects:
318 * OperationRegions, BufferFields, Buffers, and Packages.
320 if (!(Flags
& ACPI_NO_OBJECT_INIT
))
322 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
323 "[Init] Completing Initialization of ACPI Objects\n"));
325 Status
= AcpiNsInitializeObjects ();
326 if (ACPI_FAILURE (Status
))
328 return_ACPI_STATUS (Status
);
333 * Initialize all device objects in the namespace. This runs the device
334 * _STA and _INI methods.
336 if (!(Flags
& ACPI_NO_DEVICE_INIT
))
338 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
339 "[Init] Initializing ACPI Devices\n"));
341 Status
= AcpiNsInitializeDevices ();
342 if (ACPI_FAILURE (Status
))
344 return_ACPI_STATUS (Status
);
349 * Empty the caches (delete the cached objects) on the assumption that
350 * the table load filled them up more than they will be at runtime --
351 * thus wasting non-paged memory.
353 Status
= AcpiPurgeCachedObjects ();
355 AcpiGbl_StartupFlags
|= ACPI_INITIALIZED_OK
;
356 return_ACPI_STATUS (Status
);
359 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects
)