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__
47 #include <contrib/dev/acpica/include/acpi.h>
48 #include <contrib/dev/acpica/include/accommon.h>
49 #include <contrib/dev/acpica/include/acevents.h>
50 #include <contrib/dev/acpica/include/acnamesp.h>
51 #include <contrib/dev/acpica/include/acdebug.h>
52 #include <contrib/dev/acpica/include/actables.h>
54 #define _COMPONENT ACPI_UTILITIES
55 ACPI_MODULE_NAME ("utxfinit")
58 /*******************************************************************************
60 * FUNCTION: AcpiInitializeSubsystem
66 * DESCRIPTION: Initializes all global variables. This is the first function
67 * called, so any early initialization belongs here.
69 ******************************************************************************/
72 AcpiInitializeSubsystem (
78 ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
81 AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
82 ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
84 /* Initialize the OS-Dependent layer */
86 Status = AcpiOsInitialize ();
87 if (ACPI_FAILURE (Status))
89 ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
90 return_ACPI_STATUS (Status);
93 /* Initialize all globals used by the subsystem */
95 Status = AcpiUtInitGlobals ();
96 if (ACPI_FAILURE (Status))
98 ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
99 return_ACPI_STATUS (Status);
102 /* Create the default mutex objects */
104 Status = AcpiUtMutexInitialize ();
105 if (ACPI_FAILURE (Status))
107 ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
108 return_ACPI_STATUS (Status);
112 * Initialize the namespace manager and
113 * the root of the namespace tree
115 Status = AcpiNsRootInitialize ();
116 if (ACPI_FAILURE (Status))
118 ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
119 return_ACPI_STATUS (Status);
122 /* Initialize the global OSI interfaces list with the static names */
124 Status = AcpiUtInitializeInterfaces ();
125 if (ACPI_FAILURE (Status))
127 ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));
128 return_ACPI_STATUS (Status);
131 /* If configured, initialize the AML debugger */
133 ACPI_DEBUGGER_EXEC (Status = AcpiDbInitialize ());
134 return_ACPI_STATUS (Status);
137 ACPI_EXPORT_SYMBOL (AcpiInitializeSubsystem)
140 /*******************************************************************************
142 * FUNCTION: AcpiEnableSubsystem
144 * PARAMETERS: Flags - Init/enable Options
148 * DESCRIPTION: Completes the subsystem initialization including hardware.
149 * Puts system into ACPI mode if it isn't already.
151 ******************************************************************************/
154 AcpiEnableSubsystem (
157 ACPI_STATUS Status = AE_OK;
160 ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
163 #if (!ACPI_REDUCED_HARDWARE)
165 /* Enable ACPI mode */
167 if (!(Flags & ACPI_NO_ACPI_ENABLE))
169 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
171 AcpiGbl_OriginalMode = AcpiHwGetMode();
173 Status = AcpiEnable ();
174 if (ACPI_FAILURE (Status))
176 ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
177 return_ACPI_STATUS (Status);
182 * Obtain a permanent mapping for the FACS. This is required for the
183 * Global Lock and the Firmware Waking Vector
185 Status = AcpiTbInitializeFacs ();
186 if (ACPI_FAILURE (Status))
188 ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
189 return_ACPI_STATUS (Status);
192 #endif /* !ACPI_REDUCED_HARDWARE */
195 * Install the default OpRegion handlers. These are installed unless
196 * other handlers have already been installed via the
197 * InstallAddressSpaceHandler interface.
199 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
201 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
202 "[Init] Installing default address space handlers\n"));
204 Status = AcpiEvInstallRegionHandlers ();
205 if (ACPI_FAILURE (Status))
207 return_ACPI_STATUS (Status);
211 #if (!ACPI_REDUCED_HARDWARE)
213 * Initialize ACPI Event handling (Fixed and General Purpose)
215 * Note1: We must have the hardware and events initialized before we can
216 * execute any control methods safely. Any control method can require
217 * ACPI hardware support, so the hardware must be fully initialized before
218 * any method execution!
220 * Note2: Fixed events are initialized and enabled here. GPEs are
221 * initialized, but cannot be enabled until after the hardware is
222 * completely initialized (SCI and GlobalLock activated) and the various
223 * initialization control methods are run (_REG, _STA, _INI) on the
226 if (!(Flags & ACPI_NO_EVENT_INIT))
228 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
229 "[Init] Initializing ACPI events\n"));
231 Status = AcpiEvInitializeEvents ();
232 if (ACPI_FAILURE (Status))
234 return_ACPI_STATUS (Status);
239 * Install the SCI handler and Global Lock handler. This completes the
240 * hardware initialization.
242 if (!(Flags & ACPI_NO_HANDLER_INIT))
244 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
245 "[Init] Installing SCI/GL handlers\n"));
247 Status = AcpiEvInstallXruptHandlers ();
248 if (ACPI_FAILURE (Status))
250 return_ACPI_STATUS (Status);
254 #endif /* !ACPI_REDUCED_HARDWARE */
256 return_ACPI_STATUS (Status);
259 ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem)
262 /*******************************************************************************
264 * FUNCTION: AcpiInitializeObjects
266 * PARAMETERS: Flags - Init/enable Options
270 * DESCRIPTION: Completes namespace initialization by initializing device
271 * objects and executing AML code for Regions, buffers, etc.
273 ******************************************************************************/
276 AcpiInitializeObjects (
279 ACPI_STATUS Status = AE_OK;
282 ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
286 * Run all _REG methods
288 * Note: Any objects accessed by the _REG methods will be automatically
289 * initialized, even if they contain executable AML (see the call to
290 * AcpiNsInitializeObjects below).
292 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
294 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
295 "[Init] Executing _REG OpRegion methods\n"));
297 Status = AcpiEvInitializeOpRegions ();
298 if (ACPI_FAILURE (Status))
300 return_ACPI_STATUS (Status);
305 * Execute any module-level code that was detected during the table load
306 * phase. Although illegal since ACPI 2.0, there are many machines that
307 * contain this type of code. Each block of detected executable AML code
308 * outside of any control method is wrapped with a temporary control
309 * method object and placed on a global list. The methods on this list
310 * are executed below.
312 AcpiNsExecModuleCodeList ();
315 * Initialize the objects that remain uninitialized. This runs the
316 * executable AML that may be part of the declaration of these objects:
317 * OperationRegions, BufferFields, Buffers, and Packages.
319 if (!(Flags & ACPI_NO_OBJECT_INIT))
321 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
322 "[Init] Completing Initialization of ACPI Objects\n"));
324 Status = AcpiNsInitializeObjects ();
325 if (ACPI_FAILURE (Status))
327 return_ACPI_STATUS (Status);
332 * Initialize all device objects in the namespace. This runs the device
333 * _STA and _INI methods.
335 if (!(Flags & ACPI_NO_DEVICE_INIT))
337 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
338 "[Init] Initializing ACPI Devices\n"));
340 Status = AcpiNsInitializeDevices ();
341 if (ACPI_FAILURE (Status))
343 return_ACPI_STATUS (Status);
348 * Empty the caches (delete the cached objects) on the assumption that
349 * the table load filled them up more than they will be at runtime --
350 * thus wasting non-paged memory.
352 Status = AcpiPurgeCachedObjects ();
354 AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
355 return_ACPI_STATUS (Status);
358 ACPI_EXPORT_SYMBOL (AcpiInitializeObjects)