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.
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 */
135 Status = AcpiDbInitialize ();
136 if (ACPI_FAILURE (Status))
138 ACPI_EXCEPTION ((AE_INFO, Status, "During Debugger initialization"));
139 return_ACPI_STATUS (Status);
143 return_ACPI_STATUS (AE_OK);
146 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem)
149 /*******************************************************************************
151 * FUNCTION: AcpiEnableSubsystem
153 * PARAMETERS: Flags - Init/enable Options
157 * DESCRIPTION: Completes the subsystem initialization including hardware.
158 * Puts system into ACPI mode if it isn't already.
160 ******************************************************************************/
163 AcpiEnableSubsystem (
166 ACPI_STATUS Status = AE_OK;
169 ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
172 #if (!ACPI_REDUCED_HARDWARE)
174 /* Enable ACPI mode */
176 if (!(Flags & ACPI_NO_ACPI_ENABLE))
178 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
180 AcpiGbl_OriginalMode = AcpiHwGetMode();
182 Status = AcpiEnable ();
183 if (ACPI_FAILURE (Status))
185 ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
186 return_ACPI_STATUS (Status);
191 * Obtain a permanent mapping for the FACS. This is required for the
192 * Global Lock and the Firmware Waking Vector
194 Status = AcpiTbInitializeFacs ();
195 if (ACPI_FAILURE (Status))
197 ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
198 return_ACPI_STATUS (Status);
201 #endif /* !ACPI_REDUCED_HARDWARE */
204 * Install the default OpRegion handlers. These are installed unless
205 * other handlers have already been installed via the
206 * InstallAddressSpaceHandler interface.
208 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
210 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
211 "[Init] Installing default address space handlers\n"));
213 Status = AcpiEvInstallRegionHandlers ();
214 if (ACPI_FAILURE (Status))
216 return_ACPI_STATUS (Status);
220 #if (!ACPI_REDUCED_HARDWARE)
222 * Initialize ACPI Event handling (Fixed and General Purpose)
224 * Note1: We must have the hardware and events initialized before we can
225 * execute any control methods safely. Any control method can require
226 * ACPI hardware support, so the hardware must be fully initialized before
227 * any method execution!
229 * Note2: Fixed events are initialized and enabled here. GPEs are
230 * initialized, but cannot be enabled until after the hardware is
231 * completely initialized (SCI and GlobalLock activated) and the various
232 * initialization control methods are run (_REG, _STA, _INI) on the
235 if (!(Flags & ACPI_NO_EVENT_INIT))
237 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
238 "[Init] Initializing ACPI events\n"));
240 Status = AcpiEvInitializeEvents ();
241 if (ACPI_FAILURE (Status))
243 return_ACPI_STATUS (Status);
248 * Install the SCI handler and Global Lock handler. This completes the
249 * hardware initialization.
251 if (!(Flags & ACPI_NO_HANDLER_INIT))
253 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
254 "[Init] Installing SCI/GL handlers\n"));
256 Status = AcpiEvInstallXruptHandlers ();
257 if (ACPI_FAILURE (Status))
259 return_ACPI_STATUS (Status);
263 #endif /* !ACPI_REDUCED_HARDWARE */
265 return_ACPI_STATUS (Status);
268 ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem)
271 /*******************************************************************************
273 * FUNCTION: AcpiInitializeObjects
275 * PARAMETERS: Flags - Init/enable Options
279 * DESCRIPTION: Completes namespace initialization by initializing device
280 * objects and executing AML code for Regions, buffers, etc.
282 ******************************************************************************/
285 AcpiInitializeObjects (
288 ACPI_STATUS Status = AE_OK;
291 ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
295 * Run all _REG methods
297 * Note: Any objects accessed by the _REG methods will be automatically
298 * initialized, even if they contain executable AML (see the call to
299 * AcpiNsInitializeObjects below).
301 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
303 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
304 "[Init] Executing _REG OpRegion methods\n"));
306 Status = AcpiEvInitializeOpRegions ();
307 if (ACPI_FAILURE (Status))
309 return_ACPI_STATUS (Status);
314 * Execute any module-level code that was detected during the table load
315 * phase. Although illegal since ACPI 2.0, there are many machines that
316 * contain this type of code. Each block of detected executable AML code
317 * outside of any control method is wrapped with a temporary control
318 * method object and placed on a global list. The methods on this list
319 * are executed below.
321 AcpiNsExecModuleCodeList ();
324 * Initialize the objects that remain uninitialized. This runs the
325 * executable AML that may be part of the declaration of these objects:
326 * OperationRegions, BufferFields, Buffers, and Packages.
328 if (!(Flags & ACPI_NO_OBJECT_INIT))
330 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
331 "[Init] Completing Initialization of ACPI Objects\n"));
333 Status = AcpiNsInitializeObjects ();
334 if (ACPI_FAILURE (Status))
336 return_ACPI_STATUS (Status);
341 * Initialize all device objects in the namespace. This runs the device
342 * _STA and _INI methods.
344 if (!(Flags & ACPI_NO_DEVICE_INIT))
346 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
347 "[Init] Initializing ACPI Devices\n"));
349 Status = AcpiNsInitializeDevices ();
350 if (ACPI_FAILURE (Status))
352 return_ACPI_STATUS (Status);
357 * Empty the caches (delete the cached objects) on the assumption that
358 * the table load filled them up more than they will be at runtime --
359 * thus wasting non-paged memory.
361 Status = AcpiPurgeCachedObjects ();
363 AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
364 return_ACPI_STATUS (Status);
367 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects)