1 /******************************************************************************
3 * Module Name: utxfinit - External interfaces for ACPICA initialization
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, 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 EXPORT_ACPI_INTERFACES
53 #define _COMPONENT ACPI_UTILITIES
54 ACPI_MODULE_NAME ("utxfinit")
56 /* For AcpiExec only */
62 /*******************************************************************************
64 * FUNCTION: AcpiInitializeSubsystem
70 * DESCRIPTION: Initializes all global variables. This is the first function
71 * called, so any early initialization belongs here.
73 ******************************************************************************/
76 AcpiInitializeSubsystem (
82 ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
85 AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
86 ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
88 /* Initialize the OS-Dependent layer */
90 Status = AcpiOsInitialize ();
91 if (ACPI_FAILURE (Status))
93 ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
94 return_ACPI_STATUS (Status);
97 /* Initialize all globals used by the subsystem */
99 Status = AcpiUtInitGlobals ();
100 if (ACPI_FAILURE (Status))
102 ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
103 return_ACPI_STATUS (Status);
106 /* Create the default mutex objects */
108 Status = AcpiUtMutexInitialize ();
109 if (ACPI_FAILURE (Status))
111 ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
112 return_ACPI_STATUS (Status);
116 * Initialize the namespace manager and
117 * the root of the namespace tree
119 Status = AcpiNsRootInitialize ();
120 if (ACPI_FAILURE (Status))
122 ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
123 return_ACPI_STATUS (Status);
126 /* Initialize the global OSI interfaces list with the static names */
128 Status = AcpiUtInitializeInterfaces ();
129 if (ACPI_FAILURE (Status))
131 ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));
132 return_ACPI_STATUS (Status);
135 /* If configured, initialize the AML debugger */
138 Status = AcpiDbInitialize ();
139 if (ACPI_FAILURE (Status))
141 ACPI_EXCEPTION ((AE_INFO, Status, "During Debugger initialization"));
142 return_ACPI_STATUS (Status);
146 return_ACPI_STATUS (AE_OK);
149 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem)
152 /*******************************************************************************
154 * FUNCTION: AcpiEnableSubsystem
156 * PARAMETERS: Flags - Init/enable Options
160 * DESCRIPTION: Completes the subsystem initialization including hardware.
161 * Puts system into ACPI mode if it isn't already.
163 ******************************************************************************/
166 AcpiEnableSubsystem (
169 ACPI_STATUS Status = AE_OK;
172 ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
175 #if (!ACPI_REDUCED_HARDWARE)
177 /* Enable ACPI mode */
179 if (!(Flags & ACPI_NO_ACPI_ENABLE))
181 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
183 AcpiGbl_OriginalMode = AcpiHwGetMode();
185 Status = AcpiEnable ();
186 if (ACPI_FAILURE (Status))
188 ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
189 return_ACPI_STATUS (Status);
194 * Obtain a permanent mapping for the FACS. This is required for the
195 * Global Lock and the Firmware Waking Vector
197 if (!(Flags & ACPI_NO_FACS_INIT))
199 Status = AcpiTbInitializeFacs ();
200 if (ACPI_FAILURE (Status))
202 ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
203 return_ACPI_STATUS (Status);
207 #endif /* !ACPI_REDUCED_HARDWARE */
210 * Install the default OpRegion handlers. These are installed unless
211 * other handlers have already been installed via the
212 * InstallAddressSpaceHandler interface.
214 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
216 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
217 "[Init] Installing default address space handlers\n"));
219 Status = AcpiEvInstallRegionHandlers ();
220 if (ACPI_FAILURE (Status))
222 return_ACPI_STATUS (Status);
226 #if (!ACPI_REDUCED_HARDWARE)
228 * Initialize ACPI Event handling (Fixed and General Purpose)
230 * Note1: We must have the hardware and events initialized before we can
231 * execute any control methods safely. Any control method can require
232 * ACPI hardware support, so the hardware must be fully initialized before
233 * any method execution!
235 * Note2: Fixed events are initialized and enabled here. GPEs are
236 * initialized, but cannot be enabled until after the hardware is
237 * completely initialized (SCI and GlobalLock activated) and the various
238 * initialization control methods are run (_REG, _STA, _INI) on the
241 if (!(Flags & ACPI_NO_EVENT_INIT))
243 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
244 "[Init] Initializing ACPI events\n"));
246 Status = AcpiEvInitializeEvents ();
247 if (ACPI_FAILURE (Status))
249 return_ACPI_STATUS (Status);
254 * Install the SCI handler and Global Lock handler. This completes the
255 * hardware initialization.
257 if (!(Flags & ACPI_NO_HANDLER_INIT))
259 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
260 "[Init] Installing SCI/GL handlers\n"));
262 Status = AcpiEvInstallXruptHandlers ();
263 if (ACPI_FAILURE (Status))
265 return_ACPI_STATUS (Status);
269 #endif /* !ACPI_REDUCED_HARDWARE */
271 return_ACPI_STATUS (Status);
274 ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem)
277 /*******************************************************************************
279 * FUNCTION: AcpiInitializeObjects
281 * PARAMETERS: Flags - Init/enable Options
285 * DESCRIPTION: Completes namespace initialization by initializing device
286 * objects and executing AML code for Regions, buffers, etc.
288 ******************************************************************************/
291 AcpiInitializeObjects (
294 ACPI_STATUS Status = AE_OK;
297 ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
301 * Run all _REG methods
303 * Note: Any objects accessed by the _REG methods will be automatically
304 * initialized, even if they contain executable AML (see the call to
305 * AcpiNsInitializeObjects below).
307 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
309 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
310 "[Init] Executing _REG OpRegion methods\n"));
312 Status = AcpiEvInitializeOpRegions ();
313 if (ACPI_FAILURE (Status))
315 return_ACPI_STATUS (Status);
321 * This call implements the "initialization file" option for AcpiExec.
322 * This is the precise point that we want to perform the overrides.
324 AeDoObjectOverrides ();
328 * Execute any module-level code that was detected during the table load
329 * phase. Although illegal since ACPI 2.0, there are many machines that
330 * contain this type of code. Each block of detected executable AML code
331 * outside of any control method is wrapped with a temporary control
332 * method object and placed on a global list. The methods on this list
333 * are executed below.
335 AcpiNsExecModuleCodeList ();
338 * Initialize the objects that remain uninitialized. This runs the
339 * executable AML that may be part of the declaration of these objects:
340 * OperationRegions, BufferFields, Buffers, and Packages.
342 if (!(Flags & ACPI_NO_OBJECT_INIT))
344 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
345 "[Init] Completing Initialization of ACPI Objects\n"));
347 Status = AcpiNsInitializeObjects ();
348 if (ACPI_FAILURE (Status))
350 return_ACPI_STATUS (Status);
355 * Initialize all device objects in the namespace. This runs the device
356 * _STA and _INI methods.
358 if (!(Flags & ACPI_NO_DEVICE_INIT))
360 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
361 "[Init] Initializing ACPI Devices\n"));
363 Status = AcpiNsInitializeDevices ();
364 if (ACPI_FAILURE (Status))
366 return_ACPI_STATUS (Status);
371 * Empty the caches (delete the cached objects) on the assumption that
372 * the table load filled them up more than they will be at runtime --
373 * thus wasting non-paged memory.
375 Status = AcpiPurgeCachedObjects ();
377 AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
378 return_ACPI_STATUS (Status);
381 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects)