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.
52 #define _COMPONENT ACPI_UTILITIES
53 ACPI_MODULE_NAME ("utinit")
55 /* Local prototypes */
57 static void AcpiUtTerminate (
60 #if (!ACPI_REDUCED_HARDWARE)
68 #define AcpiUtFreeGpeLists()
69 #endif /* !ACPI_REDUCED_HARDWARE */
72 #if (!ACPI_REDUCED_HARDWARE)
73 /******************************************************************************
75 * FUNCTION: AcpiUtFreeGpeLists
81 * DESCRIPTION: Free global GPE lists
83 ******************************************************************************/
89 ACPI_GPE_BLOCK_INFO *GpeBlock;
90 ACPI_GPE_BLOCK_INFO *NextGpeBlock;
91 ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
92 ACPI_GPE_XRUPT_INFO *NextGpeXruptInfo;
95 /* Free global GPE blocks and related info structures */
97 GpeXruptInfo = AcpiGbl_GpeXruptListHead;
100 GpeBlock = GpeXruptInfo->GpeBlockListHead;
103 NextGpeBlock = GpeBlock->Next;
104 ACPI_FREE (GpeBlock->EventInfo);
105 ACPI_FREE (GpeBlock->RegisterInfo);
106 ACPI_FREE (GpeBlock);
108 GpeBlock = NextGpeBlock;
110 NextGpeXruptInfo = GpeXruptInfo->Next;
111 ACPI_FREE (GpeXruptInfo);
112 GpeXruptInfo = NextGpeXruptInfo;
115 #endif /* !ACPI_REDUCED_HARDWARE */
118 /*******************************************************************************
120 * FUNCTION: AcpiUtInitGlobals
126 * DESCRIPTION: Initialize ACPICA globals. All globals that require specific
127 * initialization should be initialized here. This allows for
130 ******************************************************************************/
140 ACPI_FUNCTION_TRACE (UtInitGlobals);
143 /* Create all memory caches */
145 Status = AcpiUtCreateCaches ();
146 if (ACPI_FAILURE (Status))
148 return_ACPI_STATUS (Status);
151 /* Address Range lists */
153 for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++)
155 AcpiGbl_AddressRangeList[i] = NULL;
158 /* Mutex locked flags */
160 for (i = 0; i < ACPI_NUM_MUTEX; i++)
162 AcpiGbl_MutexInfo[i].Mutex = NULL;
163 AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
164 AcpiGbl_MutexInfo[i].UseCount = 0;
167 for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++)
169 AcpiGbl_OwnerIdMask[i] = 0;
172 /* Last OwnerID is never valid */
174 AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
182 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
184 AcpiFixedEventCount[i] = 0;
187 #if (!ACPI_REDUCED_HARDWARE)
189 /* GPE/SCI support */
191 AcpiGbl_AllGpesInitialized = FALSE;
192 AcpiGbl_GpeXruptListHead = NULL;
193 AcpiGbl_GpeFadtBlocks[0] = NULL;
194 AcpiGbl_GpeFadtBlocks[1] = NULL;
195 AcpiCurrentGpeCount = 0;
197 AcpiGbl_GlobalEventHandler = NULL;
198 AcpiGbl_SciHandlerList = NULL;
200 #endif /* !ACPI_REDUCED_HARDWARE */
202 /* Global handlers */
204 AcpiGbl_GlobalNotify[0].Handler = NULL;
205 AcpiGbl_GlobalNotify[1].Handler = NULL;
206 AcpiGbl_ExceptionHandler = NULL;
207 AcpiGbl_InitHandler = NULL;
208 AcpiGbl_TableHandler = NULL;
209 AcpiGbl_InterfaceHandler = NULL;
211 /* Global Lock support */
213 AcpiGbl_GlobalLockSemaphore = NULL;
214 AcpiGbl_GlobalLockMutex = NULL;
215 AcpiGbl_GlobalLockAcquired = FALSE;
216 AcpiGbl_GlobalLockHandle = 0;
217 AcpiGbl_GlobalLockPresent = FALSE;
219 /* Miscellaneous variables */
222 AcpiGbl_CmSingleStep = FALSE;
223 AcpiGbl_Shutdown = FALSE;
224 AcpiGbl_NsLookupCount = 0;
225 AcpiGbl_PsFindCount = 0;
226 AcpiGbl_AcpiHardwarePresent = TRUE;
227 AcpiGbl_LastOwnerIdIndex = 0;
228 AcpiGbl_NextOwnerIdOffset = 0;
229 AcpiGbl_TraceDbgLevel = 0;
230 AcpiGbl_TraceDbgLayer = 0;
231 AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING;
232 AcpiGbl_OsiMutex = NULL;
233 AcpiGbl_RegMethodsExecuted = FALSE;
235 /* Hardware oriented */
237 AcpiGbl_EventsInitialized = FALSE;
238 AcpiGbl_SystemAwakeAndRunning = TRUE;
242 AcpiGbl_ModuleCodeList = NULL;
243 AcpiGbl_RootNode = NULL;
244 AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
245 AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
246 AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
247 AcpiGbl_RootNodeStruct.Parent = NULL;
248 AcpiGbl_RootNodeStruct.Child = NULL;
249 AcpiGbl_RootNodeStruct.Peer = NULL;
250 AcpiGbl_RootNodeStruct.Object = NULL;
253 #ifdef ACPI_DISASSEMBLER
254 AcpiGbl_ExternalList = NULL;
255 AcpiGbl_NumExternalMethods = 0;
256 AcpiGbl_ResolvedExternalMethods = 0;
259 #ifdef ACPI_DEBUG_OUTPUT
260 AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX);
263 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
264 AcpiGbl_DisplayFinalMemStats = FALSE;
265 AcpiGbl_DisableMemTracking = FALSE;
268 ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = FALSE);
270 return_ACPI_STATUS (AE_OK);
274 /******************************************************************************
276 * FUNCTION: AcpiUtTerminate
282 * DESCRIPTION: Free global memory
284 ******************************************************************************/
290 ACPI_FUNCTION_TRACE (UtTerminate);
292 AcpiUtFreeGpeLists ();
293 AcpiUtDeleteAddressLists ();
298 /*******************************************************************************
300 * FUNCTION: AcpiUtSubsystemShutdown
306 * DESCRIPTION: Shutdown the various components. Do not delete the mutex
307 * objects here, because the AML debugger may be still running.
309 ******************************************************************************/
312 AcpiUtSubsystemShutdown (
315 ACPI_FUNCTION_TRACE (UtSubsystemShutdown);
318 #ifndef ACPI_ASL_COMPILER
320 /* Close the AcpiEvent Handling */
324 /* Delete any dynamic _OSI interfaces */
326 AcpiUtInterfaceTerminate ();
329 /* Close the Namespace */
333 /* Delete the ACPI tables */
337 /* Close the globals */
341 /* Purge the local caches */
343 (void) AcpiUtDeleteCaches ();