utinit.c revision 1.1.1.4 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: utinit - Common ACPI subsystem initialization
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.1.1.2 jruoho /*
8 1.1.1.4 christos * Copyright (C) 2000 - 2014, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.1.1.2 jruoho * Redistribution and use in source and binary forms, with or without
12 1.1.1.2 jruoho * modification, are permitted provided that the following conditions
13 1.1.1.2 jruoho * are met:
14 1.1.1.2 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.1.1.2 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.1.1.2 jruoho * without modification.
17 1.1.1.2 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.2 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.2 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.2 jruoho * including a substantially similar Disclaimer requirement for further
21 1.1.1.2 jruoho * binary redistribution.
22 1.1.1.2 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.2 jruoho * of any contributors may be used to endorse or promote products derived
24 1.1.1.2 jruoho * from this software without specific prior written permission.
25 1.1.1.2 jruoho *
26 1.1.1.2 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.1.1.2 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.2 jruoho * Software Foundation.
29 1.1.1.2 jruoho *
30 1.1.1.2 jruoho * NO WARRANTY
31 1.1.1.2 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.2 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.2 jruoho * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.2 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.2 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.2 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.2 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.2 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.2 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.2 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.2 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.2 jruoho */
43 1.1 jruoho
44 1.1 jruoho #define __UTINIT_C__
45 1.1 jruoho
46 1.1 jruoho #include "acpi.h"
47 1.1 jruoho #include "accommon.h"
48 1.1 jruoho #include "acnamesp.h"
49 1.1 jruoho #include "acevents.h"
50 1.1 jruoho #include "actables.h"
51 1.1 jruoho
52 1.1 jruoho #define _COMPONENT ACPI_UTILITIES
53 1.1 jruoho ACPI_MODULE_NAME ("utinit")
54 1.1 jruoho
55 1.1 jruoho /* Local prototypes */
56 1.1 jruoho
57 1.1 jruoho static void AcpiUtTerminate (
58 1.1 jruoho void);
59 1.1 jruoho
60 1.1.1.3 christos #if (!ACPI_REDUCED_HARDWARE)
61 1.1 jruoho
62 1.1.1.3 christos static void
63 1.1.1.3 christos AcpiUtFreeGpeLists (
64 1.1.1.3 christos void);
65 1.1.1.3 christos
66 1.1.1.3 christos #else
67 1.1.1.3 christos
68 1.1.1.3 christos #define AcpiUtFreeGpeLists()
69 1.1.1.3 christos #endif /* !ACPI_REDUCED_HARDWARE */
70 1.1.1.3 christos
71 1.1.1.3 christos
72 1.1.1.3 christos #if (!ACPI_REDUCED_HARDWARE)
73 1.1 jruoho /******************************************************************************
74 1.1 jruoho *
75 1.1.1.3 christos * FUNCTION: AcpiUtFreeGpeLists
76 1.1 jruoho *
77 1.1 jruoho * PARAMETERS: none
78 1.1 jruoho *
79 1.1 jruoho * RETURN: none
80 1.1 jruoho *
81 1.1.1.3 christos * DESCRIPTION: Free global GPE lists
82 1.1 jruoho *
83 1.1 jruoho ******************************************************************************/
84 1.1 jruoho
85 1.1 jruoho static void
86 1.1.1.3 christos AcpiUtFreeGpeLists (
87 1.1 jruoho void)
88 1.1 jruoho {
89 1.1 jruoho ACPI_GPE_BLOCK_INFO *GpeBlock;
90 1.1 jruoho ACPI_GPE_BLOCK_INFO *NextGpeBlock;
91 1.1 jruoho ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
92 1.1 jruoho ACPI_GPE_XRUPT_INFO *NextGpeXruptInfo;
93 1.1 jruoho
94 1.1 jruoho
95 1.1 jruoho /* Free global GPE blocks and related info structures */
96 1.1 jruoho
97 1.1 jruoho GpeXruptInfo = AcpiGbl_GpeXruptListHead;
98 1.1 jruoho while (GpeXruptInfo)
99 1.1 jruoho {
100 1.1 jruoho GpeBlock = GpeXruptInfo->GpeBlockListHead;
101 1.1 jruoho while (GpeBlock)
102 1.1 jruoho {
103 1.1 jruoho NextGpeBlock = GpeBlock->Next;
104 1.1 jruoho ACPI_FREE (GpeBlock->EventInfo);
105 1.1 jruoho ACPI_FREE (GpeBlock->RegisterInfo);
106 1.1 jruoho ACPI_FREE (GpeBlock);
107 1.1 jruoho
108 1.1 jruoho GpeBlock = NextGpeBlock;
109 1.1 jruoho }
110 1.1 jruoho NextGpeXruptInfo = GpeXruptInfo->Next;
111 1.1 jruoho ACPI_FREE (GpeXruptInfo);
112 1.1 jruoho GpeXruptInfo = NextGpeXruptInfo;
113 1.1 jruoho }
114 1.1.1.3 christos }
115 1.1.1.3 christos #endif /* !ACPI_REDUCED_HARDWARE */
116 1.1.1.3 christos
117 1.1.1.3 christos
118 1.1.1.4 christos /*******************************************************************************
119 1.1.1.4 christos *
120 1.1.1.4 christos * FUNCTION: AcpiUtInitGlobals
121 1.1.1.4 christos *
122 1.1.1.4 christos * PARAMETERS: None
123 1.1.1.4 christos *
124 1.1.1.4 christos * RETURN: Status
125 1.1.1.4 christos *
126 1.1.1.4 christos * DESCRIPTION: Initialize ACPICA globals. All globals that require specific
127 1.1.1.4 christos * initialization should be initialized here. This allows for
128 1.1.1.4 christos * a warm restart.
129 1.1.1.4 christos *
130 1.1.1.4 christos ******************************************************************************/
131 1.1.1.4 christos
132 1.1.1.4 christos ACPI_STATUS
133 1.1.1.4 christos AcpiUtInitGlobals (
134 1.1.1.4 christos void)
135 1.1.1.4 christos {
136 1.1.1.4 christos ACPI_STATUS Status;
137 1.1.1.4 christos UINT32 i;
138 1.1.1.4 christos
139 1.1.1.4 christos
140 1.1.1.4 christos ACPI_FUNCTION_TRACE (UtInitGlobals);
141 1.1.1.4 christos
142 1.1.1.4 christos
143 1.1.1.4 christos /* Create all memory caches */
144 1.1.1.4 christos
145 1.1.1.4 christos Status = AcpiUtCreateCaches ();
146 1.1.1.4 christos if (ACPI_FAILURE (Status))
147 1.1.1.4 christos {
148 1.1.1.4 christos return_ACPI_STATUS (Status);
149 1.1.1.4 christos }
150 1.1.1.4 christos
151 1.1.1.4 christos /* Address Range lists */
152 1.1.1.4 christos
153 1.1.1.4 christos for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++)
154 1.1.1.4 christos {
155 1.1.1.4 christos AcpiGbl_AddressRangeList[i] = NULL;
156 1.1.1.4 christos }
157 1.1.1.4 christos
158 1.1.1.4 christos /* Mutex locked flags */
159 1.1.1.4 christos
160 1.1.1.4 christos for (i = 0; i < ACPI_NUM_MUTEX; i++)
161 1.1.1.4 christos {
162 1.1.1.4 christos AcpiGbl_MutexInfo[i].Mutex = NULL;
163 1.1.1.4 christos AcpiGbl_MutexInfo[i].ThreadId = ACPI_MUTEX_NOT_ACQUIRED;
164 1.1.1.4 christos AcpiGbl_MutexInfo[i].UseCount = 0;
165 1.1.1.4 christos }
166 1.1.1.4 christos
167 1.1.1.4 christos for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++)
168 1.1.1.4 christos {
169 1.1.1.4 christos AcpiGbl_OwnerIdMask[i] = 0;
170 1.1.1.4 christos }
171 1.1.1.4 christos
172 1.1.1.4 christos /* Last OwnerID is never valid */
173 1.1.1.4 christos
174 1.1.1.4 christos AcpiGbl_OwnerIdMask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
175 1.1.1.4 christos
176 1.1.1.4 christos /* Event counters */
177 1.1.1.4 christos
178 1.1.1.4 christos AcpiMethodCount = 0;
179 1.1.1.4 christos AcpiSciCount = 0;
180 1.1.1.4 christos AcpiGpeCount = 0;
181 1.1.1.4 christos
182 1.1.1.4 christos for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
183 1.1.1.4 christos {
184 1.1.1.4 christos AcpiFixedEventCount[i] = 0;
185 1.1.1.4 christos }
186 1.1.1.4 christos
187 1.1.1.4 christos #if (!ACPI_REDUCED_HARDWARE)
188 1.1.1.4 christos
189 1.1.1.4 christos /* GPE/SCI support */
190 1.1.1.4 christos
191 1.1.1.4 christos AcpiGbl_AllGpesInitialized = FALSE;
192 1.1.1.4 christos AcpiGbl_GpeXruptListHead = NULL;
193 1.1.1.4 christos AcpiGbl_GpeFadtBlocks[0] = NULL;
194 1.1.1.4 christos AcpiGbl_GpeFadtBlocks[1] = NULL;
195 1.1.1.4 christos AcpiCurrentGpeCount = 0;
196 1.1.1.4 christos
197 1.1.1.4 christos AcpiGbl_GlobalEventHandler = NULL;
198 1.1.1.4 christos AcpiGbl_SciHandlerList = NULL;
199 1.1.1.4 christos
200 1.1.1.4 christos #endif /* !ACPI_REDUCED_HARDWARE */
201 1.1.1.4 christos
202 1.1.1.4 christos /* Global handlers */
203 1.1.1.4 christos
204 1.1.1.4 christos AcpiGbl_GlobalNotify[0].Handler = NULL;
205 1.1.1.4 christos AcpiGbl_GlobalNotify[1].Handler = NULL;
206 1.1.1.4 christos AcpiGbl_ExceptionHandler = NULL;
207 1.1.1.4 christos AcpiGbl_InitHandler = NULL;
208 1.1.1.4 christos AcpiGbl_TableHandler = NULL;
209 1.1.1.4 christos AcpiGbl_InterfaceHandler = NULL;
210 1.1.1.4 christos
211 1.1.1.4 christos /* Global Lock support */
212 1.1.1.4 christos
213 1.1.1.4 christos AcpiGbl_GlobalLockSemaphore = NULL;
214 1.1.1.4 christos AcpiGbl_GlobalLockMutex = NULL;
215 1.1.1.4 christos AcpiGbl_GlobalLockAcquired = FALSE;
216 1.1.1.4 christos AcpiGbl_GlobalLockHandle = 0;
217 1.1.1.4 christos AcpiGbl_GlobalLockPresent = FALSE;
218 1.1.1.4 christos
219 1.1.1.4 christos /* Miscellaneous variables */
220 1.1.1.4 christos
221 1.1.1.4 christos AcpiGbl_DSDT = NULL;
222 1.1.1.4 christos AcpiGbl_CmSingleStep = FALSE;
223 1.1.1.4 christos AcpiGbl_Shutdown = FALSE;
224 1.1.1.4 christos AcpiGbl_NsLookupCount = 0;
225 1.1.1.4 christos AcpiGbl_PsFindCount = 0;
226 1.1.1.4 christos AcpiGbl_AcpiHardwarePresent = TRUE;
227 1.1.1.4 christos AcpiGbl_LastOwnerIdIndex = 0;
228 1.1.1.4 christos AcpiGbl_NextOwnerIdOffset = 0;
229 1.1.1.4 christos AcpiGbl_TraceDbgLevel = 0;
230 1.1.1.4 christos AcpiGbl_TraceDbgLayer = 0;
231 1.1.1.4 christos AcpiGbl_DebuggerConfiguration = DEBUGGER_THREADING;
232 1.1.1.4 christos AcpiGbl_OsiMutex = NULL;
233 1.1.1.4 christos AcpiGbl_RegMethodsExecuted = FALSE;
234 1.1.1.4 christos
235 1.1.1.4 christos /* Hardware oriented */
236 1.1.1.4 christos
237 1.1.1.4 christos AcpiGbl_EventsInitialized = FALSE;
238 1.1.1.4 christos AcpiGbl_SystemAwakeAndRunning = TRUE;
239 1.1.1.4 christos
240 1.1.1.4 christos /* Namespace */
241 1.1.1.4 christos
242 1.1.1.4 christos AcpiGbl_ModuleCodeList = NULL;
243 1.1.1.4 christos AcpiGbl_RootNode = NULL;
244 1.1.1.4 christos AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
245 1.1.1.4 christos AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
246 1.1.1.4 christos AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
247 1.1.1.4 christos AcpiGbl_RootNodeStruct.Parent = NULL;
248 1.1.1.4 christos AcpiGbl_RootNodeStruct.Child = NULL;
249 1.1.1.4 christos AcpiGbl_RootNodeStruct.Peer = NULL;
250 1.1.1.4 christos AcpiGbl_RootNodeStruct.Object = NULL;
251 1.1.1.4 christos
252 1.1.1.4 christos
253 1.1.1.4 christos #ifdef ACPI_DISASSEMBLER
254 1.1.1.4 christos AcpiGbl_ExternalList = NULL;
255 1.1.1.4 christos AcpiGbl_NumExternalMethods = 0;
256 1.1.1.4 christos AcpiGbl_ResolvedExternalMethods = 0;
257 1.1.1.4 christos #endif
258 1.1.1.4 christos
259 1.1.1.4 christos #ifdef ACPI_DEBUG_OUTPUT
260 1.1.1.4 christos AcpiGbl_LowestStackPointer = ACPI_CAST_PTR (ACPI_SIZE, ACPI_SIZE_MAX);
261 1.1.1.4 christos #endif
262 1.1.1.4 christos
263 1.1.1.4 christos #ifdef ACPI_DBG_TRACK_ALLOCATIONS
264 1.1.1.4 christos AcpiGbl_DisplayFinalMemStats = FALSE;
265 1.1.1.4 christos AcpiGbl_DisableMemTracking = FALSE;
266 1.1.1.4 christos #endif
267 1.1.1.4 christos
268 1.1.1.4 christos ACPI_DEBUGGER_EXEC (AcpiGbl_DbTerminateThreads = FALSE);
269 1.1.1.4 christos
270 1.1.1.4 christos return_ACPI_STATUS (AE_OK);
271 1.1.1.4 christos }
272 1.1.1.4 christos
273 1.1.1.4 christos
274 1.1.1.3 christos /******************************************************************************
275 1.1.1.3 christos *
276 1.1.1.3 christos * FUNCTION: AcpiUtTerminate
277 1.1.1.3 christos *
278 1.1.1.3 christos * PARAMETERS: none
279 1.1.1.3 christos *
280 1.1.1.3 christos * RETURN: none
281 1.1.1.3 christos *
282 1.1.1.3 christos * DESCRIPTION: Free global memory
283 1.1.1.3 christos *
284 1.1.1.3 christos ******************************************************************************/
285 1.1 jruoho
286 1.1.1.3 christos static void
287 1.1.1.3 christos AcpiUtTerminate (
288 1.1.1.3 christos void)
289 1.1.1.3 christos {
290 1.1.1.3 christos ACPI_FUNCTION_TRACE (UtTerminate);
291 1.1.1.3 christos
292 1.1.1.3 christos AcpiUtFreeGpeLists ();
293 1.1.1.3 christos AcpiUtDeleteAddressLists ();
294 1.1 jruoho return_VOID;
295 1.1 jruoho }
296 1.1 jruoho
297 1.1 jruoho
298 1.1 jruoho /*******************************************************************************
299 1.1 jruoho *
300 1.1 jruoho * FUNCTION: AcpiUtSubsystemShutdown
301 1.1 jruoho *
302 1.1 jruoho * PARAMETERS: None
303 1.1 jruoho *
304 1.1 jruoho * RETURN: None
305 1.1 jruoho *
306 1.1 jruoho * DESCRIPTION: Shutdown the various components. Do not delete the mutex
307 1.1 jruoho * objects here, because the AML debugger may be still running.
308 1.1 jruoho *
309 1.1 jruoho ******************************************************************************/
310 1.1 jruoho
311 1.1 jruoho void
312 1.1 jruoho AcpiUtSubsystemShutdown (
313 1.1 jruoho void)
314 1.1 jruoho {
315 1.1 jruoho ACPI_FUNCTION_TRACE (UtSubsystemShutdown);
316 1.1 jruoho
317 1.1 jruoho
318 1.1 jruoho #ifndef ACPI_ASL_COMPILER
319 1.1 jruoho
320 1.1 jruoho /* Close the AcpiEvent Handling */
321 1.1 jruoho
322 1.1 jruoho AcpiEvTerminate ();
323 1.1.1.2 jruoho
324 1.1.1.2 jruoho /* Delete any dynamic _OSI interfaces */
325 1.1.1.2 jruoho
326 1.1.1.2 jruoho AcpiUtInterfaceTerminate ();
327 1.1 jruoho #endif
328 1.1 jruoho
329 1.1 jruoho /* Close the Namespace */
330 1.1 jruoho
331 1.1 jruoho AcpiNsTerminate ();
332 1.1 jruoho
333 1.1 jruoho /* Delete the ACPI tables */
334 1.1 jruoho
335 1.1 jruoho AcpiTbTerminate ();
336 1.1 jruoho
337 1.1 jruoho /* Close the globals */
338 1.1 jruoho
339 1.1 jruoho AcpiUtTerminate ();
340 1.1 jruoho
341 1.1 jruoho /* Purge the local caches */
342 1.1 jruoho
343 1.1 jruoho (void) AcpiUtDeleteCaches ();
344 1.1 jruoho return_VOID;
345 1.1 jruoho }
346