1 /******************************************************************************
3 * Module Name: utinit - Common ACPI subsystem 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.
53 #define _COMPONENT ACPI_UTILITIES
54 ACPI_MODULE_NAME ("utinit")
56 /* Local prototypes */
58 static void AcpiUtTerminate (
61 #if (!ACPI_REDUCED_HARDWARE)
69 #define AcpiUtFreeGpeLists()
70 #endif /* !ACPI_REDUCED_HARDWARE */
73 #if (!ACPI_REDUCED_HARDWARE)
74 /******************************************************************************
76 * FUNCTION: AcpiUtFreeGpeLists
82 * DESCRIPTION: Free global GPE lists
84 ******************************************************************************/
90 ACPI_GPE_BLOCK_INFO *GpeBlock;
91 ACPI_GPE_BLOCK_INFO *NextGpeBlock;
92 ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
93 ACPI_GPE_XRUPT_INFO *NextGpeXruptInfo;
96 /* Free global GPE blocks and related info structures */
98 GpeXruptInfo = AcpiGbl_GpeXruptListHead;
101 GpeBlock = GpeXruptInfo->GpeBlockListHead;
104 NextGpeBlock = GpeBlock->Next;
105 ACPI_FREE (GpeBlock->EventInfo);
106 ACPI_FREE (GpeBlock->RegisterInfo);
107 ACPI_FREE (GpeBlock);
109 GpeBlock = NextGpeBlock;
111 NextGpeXruptInfo = GpeXruptInfo->Next;
112 ACPI_FREE (GpeXruptInfo);
113 GpeXruptInfo = NextGpeXruptInfo;
116 #endif /* !ACPI_REDUCED_HARDWARE */
119 /*******************************************************************************
121 * FUNCTION: AcpiUtInitGlobals
127 * DESCRIPTION: Initialize ACPICA globals. All globals that require specific
128 * initialization should be initialized here. This allows for
131 ******************************************************************************/
141 ACPI_FUNCTION_TRACE (UtInitGlobals);
144 /* Create all memory caches */
146 Status = AcpiUtCreateCaches ();
147 if (ACPI_FAILURE (Status))
149 return_ACPI_STATUS (Status);
152 /* Address Range lists */
154 for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++)
156 AcpiGbl_AddressRangeList[i] = NULL;
159 /* Mutex locked flags */
161 for (i = 0; i < ACPI_NUM_MUTEX; i++)
163 AcpiGbl_MutexInfo[i].Mutex = NULL;
164 AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
165 AcpiGbl_MutexInfo[i].UseCount = 0;
168 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++)
170 AcpiGbl_OwnerIdMask[i] = 0;
173 /* Last OwnerID is never valid */
175 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
183 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
185 AcpiFixedEventCount[i] = 0;
188 #if (!ACPI_REDUCED_HARDWARE)
190 /* GPE/SCI support */
192 AcpiGbl_AllGpesInitialized = FALSE;
193 AcpiGbl_GpeXruptListHead = NULL;
194 AcpiGbl_GpeFadtBlocks[0] = NULL;
195 AcpiGbl_GpeFadtBlocks[1] = NULL;
196 AcpiCurrentGpeCount = 0;
198 AcpiGbl_GlobalEventHandler = NULL;
199 AcpiGbl_SciHandlerList = NULL;
201 #endif /* !ACPI_REDUCED_HARDWARE */
203 /* Global handlers */
205 AcpiGbl_GlobalNotify[0].Handler = NULL;
206 AcpiGbl_GlobalNotify[1].Handler = NULL;
207 AcpiGbl_ExceptionHandler = NULL;
208 AcpiGbl_InitHandler = NULL;
209 AcpiGbl_TableHandler = NULL;
210 AcpiGbl_InterfaceHandler = NULL;
212 /* Global Lock support */
214 AcpiGbl_GlobalLockSemaphore = NULL;
215 AcpiGbl_GlobalLockMutex = NULL;
216 AcpiGbl_GlobalLockAcquired = FALSE;
217 AcpiGbl_GlobalLockHandle = 0;
218 AcpiGbl_GlobalLockPresent = FALSE;
220 /* Miscellaneous variables */
223 AcpiGbl_CmSingleStep = FALSE;
224 AcpiGbl_Shutdown = FALSE;
225 AcpiGbl_NsLookupCount = 0;
226 AcpiGbl_PsFindCount = 0;
227 AcpiGbl_AcpiHardwarePresent = TRUE;
228 AcpiGbl_LastOwnerIdIndex = 0;
229 AcpiGbl_NextOwnerIdOffset = 0;
230 AcpiGbl_TraceDbgLevel = 0;
231 AcpiGbl_TraceDbgLayer = 0;
232 AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING;
233 AcpiGbl_OsiMutex = NULL;
234 AcpiGbl_RegMethodsExecuted = FALSE;
236 /* Hardware oriented */
238 AcpiGbl_EventsInitialized = FALSE;
239 AcpiGbl_SystemAwakeAndRunning = TRUE;
243 AcpiGbl_ModuleCodeList = NULL;
244 AcpiGbl_RootNode = NULL;
245 AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
246 AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
247 AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
248 AcpiGbl_RootNodeStruct.Parent = NULL;
249 AcpiGbl_RootNodeStruct.Child = NULL;
250 AcpiGbl_RootNodeStruct.Peer = NULL;
251 AcpiGbl_RootNodeStruct.Object = NULL;
254 #ifdef ACPI_DISASSEMBLER
255 AcpiGbl_ExternalList = NULL;
256 AcpiGbl_NumExternalMethods = 0;
257 AcpiGbl_ResolvedExternalMethods = 0;
260 #ifdef ACPI_DEBUG_OUTPUT
261 AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX);
264 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
265 AcpiGbl_DisplayFinalMemStats = FALSE;
266 AcpiGbl_DisableMemTracking = FALSE;
269 ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = FALSE);
271 return_ACPI_STATUS (AE_OK);
275 /******************************************************************************
277 * FUNCTION: AcpiUtTerminate
283 * DESCRIPTION: Free global memory
285 ******************************************************************************/
291 ACPI_FUNCTION_TRACE (UtTerminate);
293 AcpiUtFreeGpeLists ();
294 AcpiUtDeleteAddressLists ();
299 /*******************************************************************************
301 * FUNCTION: AcpiUtSubsystemShutdown
307 * DESCRIPTION: Shutdown the various components. Do not delete the mutex
308 * objects here, because the AML debugger may be still running.
310 ******************************************************************************/
313 AcpiUtSubsystemShutdown (
316 ACPI_FUNCTION_TRACE (UtSubsystemShutdown);
319 #ifndef ACPI_ASL_COMPILER
321 /* Close the AcpiEvent Handling */
325 /* Delete any dynamic _OSI interfaces */
327 AcpiUtInterfaceTerminate ();
330 /* Close the Namespace */
334 /* Delete the ACPI tables */
338 /* Close the globals */
342 /* Purge the local caches */
344 (void) AcpiUtDeleteCaches ();