1 /******************************************************************************
3 * Module Name: utinit - Common ACPI subsystem 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.
50 #define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utinit")
53 /* Local prototypes */
55 static void AcpiUtTerminate (
58 #if (!ACPI_REDUCED_HARDWARE)
66 #define AcpiUtFreeGpeLists()
67 #endif /* !ACPI_REDUCED_HARDWARE */
70 #if (!ACPI_REDUCED_HARDWARE)
71 /******************************************************************************
73 * FUNCTION: AcpiUtFreeGpeLists
79 * DESCRIPTION: Free global GPE lists
81 ******************************************************************************/
87 ACPI_GPE_BLOCK_INFO
*GpeBlock
;
88 ACPI_GPE_BLOCK_INFO
*NextGpeBlock
;
89 ACPI_GPE_XRUPT_INFO
*GpeXruptInfo
;
90 ACPI_GPE_XRUPT_INFO
*NextGpeXruptInfo
;
93 /* Free global GPE blocks and related info structures */
95 GpeXruptInfo
= AcpiGbl_GpeXruptListHead
;
98 GpeBlock
= GpeXruptInfo
->GpeBlockListHead
;
101 NextGpeBlock
= GpeBlock
->Next
;
102 ACPI_FREE (GpeBlock
->EventInfo
);
103 ACPI_FREE (GpeBlock
->RegisterInfo
);
104 ACPI_FREE (GpeBlock
);
106 GpeBlock
= NextGpeBlock
;
108 NextGpeXruptInfo
= GpeXruptInfo
->Next
;
109 ACPI_FREE (GpeXruptInfo
);
110 GpeXruptInfo
= NextGpeXruptInfo
;
113 #endif /* !ACPI_REDUCED_HARDWARE */
116 /*******************************************************************************
118 * FUNCTION: AcpiUtInitGlobals
124 * DESCRIPTION: Initialize ACPICA globals. All globals that require specific
125 * initialization should be initialized here. This allows for
128 ******************************************************************************/
138 ACPI_FUNCTION_TRACE (UtInitGlobals
);
141 /* Create all memory caches */
143 Status
= AcpiUtCreateCaches ();
144 if (ACPI_FAILURE (Status
))
146 return_ACPI_STATUS (Status
);
149 /* Address Range lists */
151 for (i
= 0; i
< ACPI_ADDRESS_RANGE_MAX
; i
++)
153 AcpiGbl_AddressRangeList
[i
] = NULL
;
156 /* Mutex locked flags */
158 for (i
= 0; i
< ACPI_NUM_MUTEX
; i
++)
160 AcpiGbl_MutexInfo
[i
].Mutex
= NULL
;
161 AcpiGbl_MutexInfo
[i
].ThreadId
= ACPI_MUTEX_NOT_ACQUIRED
;
162 AcpiGbl_MutexInfo
[i
].UseCount
= 0;
165 for (i
= 0; i
< ACPI_NUM_OWNERID_MASKS
; i
++)
167 AcpiGbl_OwnerIdMask
[i
] = 0;
170 /* Last OwnerID is never valid */
172 AcpiGbl_OwnerIdMask
[ACPI_NUM_OWNERID_MASKS
- 1] = 0x80000000;
180 for (i
= 0; i
< ACPI_NUM_FIXED_EVENTS
; i
++)
182 AcpiFixedEventCount
[i
] = 0;
185 #if (!ACPI_REDUCED_HARDWARE)
187 /* GPE/SCI support */
189 AcpiGbl_AllGpesInitialized
= FALSE
;
190 AcpiGbl_GpeXruptListHead
= NULL
;
191 AcpiGbl_GpeFadtBlocks
[0] = NULL
;
192 AcpiGbl_GpeFadtBlocks
[1] = NULL
;
193 AcpiCurrentGpeCount
= 0;
195 AcpiGbl_GlobalEventHandler
= NULL
;
196 AcpiGbl_SciHandlerList
= NULL
;
198 #endif /* !ACPI_REDUCED_HARDWARE */
200 /* Global handlers */
202 AcpiGbl_GlobalNotify
[0].Handler
= NULL
;
203 AcpiGbl_GlobalNotify
[1].Handler
= NULL
;
204 AcpiGbl_ExceptionHandler
= NULL
;
205 AcpiGbl_InitHandler
= NULL
;
206 AcpiGbl_TableHandler
= NULL
;
207 AcpiGbl_InterfaceHandler
= NULL
;
209 /* Global Lock support */
211 AcpiGbl_GlobalLockSemaphore
= NULL
;
212 AcpiGbl_GlobalLockMutex
= NULL
;
213 AcpiGbl_GlobalLockAcquired
= FALSE
;
214 AcpiGbl_GlobalLockHandle
= 0;
215 AcpiGbl_GlobalLockPresent
= FALSE
;
217 /* Miscellaneous variables */
220 AcpiGbl_CmSingleStep
= FALSE
;
221 AcpiGbl_Shutdown
= FALSE
;
222 AcpiGbl_NsLookupCount
= 0;
223 AcpiGbl_PsFindCount
= 0;
224 AcpiGbl_AcpiHardwarePresent
= TRUE
;
225 AcpiGbl_LastOwnerIdIndex
= 0;
226 AcpiGbl_NextOwnerIdOffset
= 0;
227 AcpiGbl_DebuggerConfiguration
= DEBUGGER_THREADING
;
228 AcpiGbl_OsiMutex
= NULL
;
229 AcpiGbl_MaxLoopIterations
= 0xFFFF;
231 /* Hardware oriented */
233 AcpiGbl_EventsInitialized
= FALSE
;
234 AcpiGbl_SystemAwakeAndRunning
= TRUE
;
238 AcpiGbl_ModuleCodeList
= NULL
;
239 AcpiGbl_RootNode
= NULL
;
240 AcpiGbl_RootNodeStruct
.Name
.Integer
= ACPI_ROOT_NAME
;
241 AcpiGbl_RootNodeStruct
.DescriptorType
= ACPI_DESC_TYPE_NAMED
;
242 AcpiGbl_RootNodeStruct
.Type
= ACPI_TYPE_DEVICE
;
243 AcpiGbl_RootNodeStruct
.Parent
= NULL
;
244 AcpiGbl_RootNodeStruct
.Child
= NULL
;
245 AcpiGbl_RootNodeStruct
.Peer
= NULL
;
246 AcpiGbl_RootNodeStruct
.Object
= NULL
;
249 #ifdef ACPI_DISASSEMBLER
250 AcpiGbl_ExternalList
= NULL
;
251 AcpiGbl_NumExternalMethods
= 0;
252 AcpiGbl_ResolvedExternalMethods
= 0;
255 #ifdef ACPI_DEBUG_OUTPUT
256 AcpiGbl_LowestStackPointer
= ACPI_CAST_PTR (ACPI_SIZE
, ACPI_SIZE_MAX
);
259 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
260 AcpiGbl_DisplayFinalMemStats
= FALSE
;
261 AcpiGbl_DisableMemTracking
= FALSE
;
264 return_ACPI_STATUS (AE_OK
);
268 /******************************************************************************
270 * FUNCTION: AcpiUtTerminate
276 * DESCRIPTION: Free global memory
278 ******************************************************************************/
284 ACPI_FUNCTION_TRACE (UtTerminate
);
286 AcpiUtFreeGpeLists ();
287 AcpiUtDeleteAddressLists ();
292 /*******************************************************************************
294 * FUNCTION: AcpiUtSubsystemShutdown
300 * DESCRIPTION: Shutdown the various components. Do not delete the mutex
301 * objects here, because the AML debugger may be still running.
303 ******************************************************************************/
306 AcpiUtSubsystemShutdown (
309 ACPI_FUNCTION_TRACE (UtSubsystemShutdown
);
312 /* Just exit if subsystem is already shutdown */
314 if (AcpiGbl_Shutdown
)
316 ACPI_ERROR ((AE_INFO
, "ACPI Subsystem is already terminated"));
320 /* Subsystem appears active, go ahead and shut it down */
322 AcpiGbl_Shutdown
= TRUE
;
323 AcpiGbl_StartupFlags
= 0;
324 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
, "Shutting down ACPI Subsystem\n"));
326 #ifndef ACPI_ASL_COMPILER
328 /* Close the AcpiEvent Handling */
332 /* Delete any dynamic _OSI interfaces */
334 AcpiUtInterfaceTerminate ();
337 /* Close the Namespace */
341 /* Delete the ACPI tables */
345 /* Close the globals */
349 /* Purge the local caches */
351 (void) AcpiUtDeleteCaches ();