1 /******************************************************************************
3 * Module Name: utxfinit - External interfaces for ACPICA initialization
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, 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 (!AcpiGbl_OverrideDefaultRegionHandlers)
138 * Install the default operation region handlers. These are the
139 * handlers that are defined by the ACPI specification to be
140 * "always accessible" -- namely, SystemMemory, SystemIO, and
141 * PCI_Config. This also means that no _REG methods need to be
142 * run for these address spaces. We need to have these handlers
143 * installed before any AML code can be executed, especially any
144 * module-level code (11/2015).
146 Status = AcpiEvInstallRegionHandlers ();
147 if (ACPI_FAILURE (Status))
149 ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization"));
150 return_ACPI_STATUS (Status);
154 return_ACPI_STATUS (AE_OK);
157 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem)
160 /*******************************************************************************
162 * FUNCTION: AcpiEnableSubsystem
164 * PARAMETERS: Flags - Init/enable Options
168 * DESCRIPTION: Completes the subsystem initialization including hardware.
169 * Puts system into ACPI mode if it isn't already.
171 ******************************************************************************/
174 AcpiEnableSubsystem (
177 ACPI_STATUS Status = AE_OK;
180 ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
184 * The early initialization phase is complete. The namespace is loaded,
185 * and we can now support address spaces other than Memory, I/O, and
188 AcpiGbl_EarlyInitialization = FALSE;
190 if (AcpiGbl_OverrideDefaultRegionHandlers)
193 * Install the default operation region handlers. These are the
194 * handlers that are defined by the ACPI specification to be
195 * "always accessible" -- namely, SystemMemory, SystemIO, and
196 * PCI_Config. This also means that no _REG methods need to be
197 * run for these address spaces. We need to have these handlers
198 * installed before any AML code can be executed, especially any
199 * module-level code (11/2015).
201 Status = AcpiEvInstallRegionHandlers ();
202 if (ACPI_FAILURE (Status))
204 ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization"));
205 return_ACPI_STATUS (Status);
210 #if (!ACPI_REDUCED_HARDWARE)
212 /* Enable ACPI mode */
214 if (!(Flags & ACPI_NO_ACPI_ENABLE))
216 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
218 AcpiGbl_OriginalMode = AcpiHwGetMode();
220 Status = AcpiEnable ();
221 if (ACPI_FAILURE (Status))
223 ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
224 return_ACPI_STATUS (Status);
229 * Obtain a permanent mapping for the FACS. This is required for the
230 * Global Lock and the Firmware Waking Vector
232 if (!(Flags & ACPI_NO_FACS_INIT))
234 Status = AcpiTbInitializeFacs ();
235 if (ACPI_FAILURE (Status))
237 ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
238 return_ACPI_STATUS (Status);
243 * Initialize ACPI Event handling (Fixed and General Purpose)
245 * Note1: We must have the hardware and events initialized before we can
246 * execute any control methods safely. Any control method can require
247 * ACPI hardware support, so the hardware must be fully initialized before
248 * any method execution!
250 * Note2: Fixed events are initialized and enabled here. GPEs are
251 * initialized, but cannot be enabled until after the hardware is
252 * completely initialized (SCI and GlobalLock activated) and the various
253 * initialization control methods are run (_REG, _STA, _INI) on the
256 if (!(Flags & ACPI_NO_EVENT_INIT))
258 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
259 "[Init] Initializing ACPI events\n"));
261 Status = AcpiEvInitializeEvents ();
262 if (ACPI_FAILURE (Status))
264 return_ACPI_STATUS (Status);
269 * Install the SCI handler and Global Lock handler. This completes the
270 * hardware initialization.
272 if (!(Flags & ACPI_NO_HANDLER_INIT))
274 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
275 "[Init] Installing SCI/GL handlers\n"));
277 Status = AcpiEvInstallXruptHandlers ();
278 if (ACPI_FAILURE (Status))
280 return_ACPI_STATUS (Status);
284 #endif /* !ACPI_REDUCED_HARDWARE */
286 return_ACPI_STATUS (Status);
289 ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem)
292 /*******************************************************************************
294 * FUNCTION: AcpiInitializeObjects
296 * PARAMETERS: Flags - Init/enable Options
300 * DESCRIPTION: Completes namespace initialization by initializing device
301 * objects and executing AML code for Regions, buffers, etc.
303 ******************************************************************************/
306 AcpiInitializeObjects (
309 ACPI_STATUS Status = AE_OK;
312 ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
316 * Run all _REG methods
318 * Note: Any objects accessed by the _REG methods will be automatically
319 * initialized, even if they contain executable AML (see the call to
320 * AcpiNsInitializeObjects below).
322 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
324 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
325 "[Init] Executing _REG OpRegion methods\n"));
327 Status = AcpiEvInitializeOpRegions ();
328 if (ACPI_FAILURE (Status))
330 return_ACPI_STATUS (Status);
336 * This call implements the "initialization file" option for AcpiExec.
337 * This is the precise point that we want to perform the overrides.
339 AeDoObjectOverrides ();
343 * Execute any module-level code that was detected during the table load
344 * phase. Although illegal since ACPI 2.0, there are many machines that
345 * contain this type of code. Each block of detected executable AML code
346 * outside of any control method is wrapped with a temporary control
347 * method object and placed on a global list. The methods on this list
348 * are executed below.
350 * This case executes the module-level code for all tables only after
351 * all of the tables have been loaded. It is a legacy option and is
352 * not compatible with other ACPI implementations. See AcpiNsLoadTable.
354 if (AcpiGbl_GroupModuleLevelCode)
356 AcpiNsExecModuleCodeList ();
360 * Initialize the objects that remain uninitialized. This runs the
361 * executable AML that may be part of the declaration of these objects:
362 * OperationRegions, BufferFields, Buffers, and Packages.
364 if (!(Flags & ACPI_NO_OBJECT_INIT))
366 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
367 "[Init] Completing Initialization of ACPI Objects\n"));
369 Status = AcpiNsInitializeObjects ();
370 if (ACPI_FAILURE (Status))
372 return_ACPI_STATUS (Status);
377 * Initialize all device objects in the namespace. This runs the device
378 * _STA and _INI methods.
380 if (!(Flags & ACPI_NO_DEVICE_INIT))
382 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
383 "[Init] Initializing ACPI Devices\n"));
385 Status = AcpiNsInitializeDevices ();
386 if (ACPI_FAILURE (Status))
388 return_ACPI_STATUS (Status);
393 * Empty the caches (delete the cached objects) on the assumption that
394 * the table load filled them up more than they will be at runtime --
395 * thus wasting non-paged memory.
397 Status = AcpiPurgeCachedObjects ();
399 AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
400 return_ACPI_STATUS (Status);
403 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects)