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 __UTXFINIT_C__
45 #define EXPORT_ACPI_INTERFACES
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 */
134 Status = AcpiDbInitialize ();
135 if (ACPI_FAILURE (Status))
137 ACPI_EXCEPTION ((AE_INFO, Status, "During Debugger initialization"));
138 return_ACPI_STATUS (Status);
142 return_ACPI_STATUS (AE_OK);
145 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem)
148 /*******************************************************************************
150 * FUNCTION: AcpiEnableSubsystem
152 * PARAMETERS: Flags - Init/enable Options
156 * DESCRIPTION: Completes the subsystem initialization including hardware.
157 * Puts system into ACPI mode if it isn't already.
159 ******************************************************************************/
162 AcpiEnableSubsystem (
165 ACPI_STATUS Status = AE_OK;
168 ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
171 #if (!ACPI_REDUCED_HARDWARE)
173 /* Enable ACPI mode */
175 if (!(Flags & ACPI_NO_ACPI_ENABLE))
177 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
179 AcpiGbl_OriginalMode = AcpiHwGetMode();
181 Status = AcpiEnable ();
182 if (ACPI_FAILURE (Status))
184 ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
185 return_ACPI_STATUS (Status);
190 * Obtain a permanent mapping for the FACS. This is required for the
191 * Global Lock and the Firmware Waking Vector
193 Status = AcpiTbInitializeFacs ();
194 if (ACPI_FAILURE (Status))
196 ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
197 return_ACPI_STATUS (Status);
200 #endif /* !ACPI_REDUCED_HARDWARE */
203 * Install the default OpRegion handlers. These are installed unless
204 * other handlers have already been installed via the
205 * InstallAddressSpaceHandler interface.
207 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
209 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
210 "[Init] Installing default address space handlers\n"));
212 Status = AcpiEvInstallRegionHandlers ();
213 if (ACPI_FAILURE (Status))
215 return_ACPI_STATUS (Status);
219 #if (!ACPI_REDUCED_HARDWARE)
221 * Initialize ACPI Event handling (Fixed and General Purpose)
223 * Note1: We must have the hardware and events initialized before we can
224 * execute any control methods safely. Any control method can require
225 * ACPI hardware support, so the hardware must be fully initialized before
226 * any method execution!
228 * Note2: Fixed events are initialized and enabled here. GPEs are
229 * initialized, but cannot be enabled until after the hardware is
230 * completely initialized (SCI and GlobalLock activated) and the various
231 * initialization control methods are run (_REG, _STA, _INI) on the
234 if (!(Flags & ACPI_NO_EVENT_INIT))
236 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
237 "[Init] Initializing ACPI events\n"));
239 Status = AcpiEvInitializeEvents ();
240 if (ACPI_FAILURE (Status))
242 return_ACPI_STATUS (Status);
247 * Install the SCI handler and Global Lock handler. This completes the
248 * hardware initialization.
250 if (!(Flags & ACPI_NO_HANDLER_INIT))
252 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
253 "[Init] Installing SCI/GL handlers\n"));
255 Status = AcpiEvInstallXruptHandlers ();
256 if (ACPI_FAILURE (Status))
258 return_ACPI_STATUS (Status);
262 #endif /* !ACPI_REDUCED_HARDWARE */
264 return_ACPI_STATUS (Status);
267 ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem)
270 /*******************************************************************************
272 * FUNCTION: AcpiInitializeObjects
274 * PARAMETERS: Flags - Init/enable Options
278 * DESCRIPTION: Completes namespace initialization by initializing device
279 * objects and executing AML code for Regions, buffers, etc.
281 ******************************************************************************/
284 AcpiInitializeObjects (
287 ACPI_STATUS Status = AE_OK;
290 ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
294 * Run all _REG methods
296 * Note: Any objects accessed by the _REG methods will be automatically
297 * initialized, even if they contain executable AML (see the call to
298 * AcpiNsInitializeObjects below).
300 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
302 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
303 "[Init] Executing _REG OpRegion methods\n"));
305 Status = AcpiEvInitializeOpRegions ();
306 if (ACPI_FAILURE (Status))
308 return_ACPI_STATUS (Status);
313 * Execute any module-level code that was detected during the table load
314 * phase. Although illegal since ACPI 2.0, there are many machines that
315 * contain this type of code. Each block of detected executable AML code
316 * outside of any control method is wrapped with a temporary control
317 * method object and placed on a global list. The methods on this list
318 * are executed below.
320 AcpiNsExecModuleCodeList ();
323 * Initialize the objects that remain uninitialized. This runs the
324 * executable AML that may be part of the declaration of these objects:
325 * OperationRegions, BufferFields, Buffers, and Packages.
327 if (!(Flags & ACPI_NO_OBJECT_INIT))
329 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
330 "[Init] Completing Initialization of ACPI Objects\n"));
332 Status = AcpiNsInitializeObjects ();
333 if (ACPI_FAILURE (Status))
335 return_ACPI_STATUS (Status);
340 * Initialize all device objects in the namespace. This runs the device
341 * _STA and _INI methods.
343 if (!(Flags & ACPI_NO_DEVICE_INIT))
345 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
346 "[Init] Initializing ACPI Devices\n"));
348 Status = AcpiNsInitializeDevices ();
349 if (ACPI_FAILURE (Status))
351 return_ACPI_STATUS (Status);
356 * Empty the caches (delete the cached objects) on the assumption that
357 * the table load filled them up more than they will be at runtime --
358 * thus wasting non-paged memory.
360 Status = AcpiPurgeCachedObjects ();
362 AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
363 return_ACPI_STATUS (Status);
366 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects)