utxfinit.c revision 1.1.1.1.6.2 1 /******************************************************************************
2 *
3 * Module Name: utxfinit - External interfaces for ACPICA initialization
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
25 *
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.
29 *
30 * NO WARRANTY
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.
42 */
43
44
45 #define __UTXFINIT_C__
46 #define EXPORT_ACPI_INTERFACES
47
48 #include "acpi.h"
49 #include "accommon.h"
50 #include "acevents.h"
51 #include "acnamesp.h"
52 #include "acdebug.h"
53 #include "actables.h"
54
55 #define _COMPONENT ACPI_UTILITIES
56 ACPI_MODULE_NAME ("utxfinit")
57
58
59 /*******************************************************************************
60 *
61 * FUNCTION: AcpiInitializeSubsystem
62 *
63 * PARAMETERS: None
64 *
65 * RETURN: Status
66 *
67 * DESCRIPTION: Initializes all global variables. This is the first function
68 * called, so any early initialization belongs here.
69 *
70 ******************************************************************************/
71
72 ACPI_STATUS
73 AcpiInitializeSubsystem (
74 void)
75 {
76 ACPI_STATUS Status;
77
78
79 ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
80
81
82 AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
83 ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
84
85 /* Initialize the OS-Dependent layer */
86
87 Status = AcpiOsInitialize ();
88 if (ACPI_FAILURE (Status))
89 {
90 ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
91 return_ACPI_STATUS (Status);
92 }
93
94 /* Initialize all globals used by the subsystem */
95
96 Status = AcpiUtInitGlobals ();
97 if (ACPI_FAILURE (Status))
98 {
99 ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
100 return_ACPI_STATUS (Status);
101 }
102
103 /* Create the default mutex objects */
104
105 Status = AcpiUtMutexInitialize ();
106 if (ACPI_FAILURE (Status))
107 {
108 ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
109 return_ACPI_STATUS (Status);
110 }
111
112 /*
113 * Initialize the namespace manager and
114 * the root of the namespace tree
115 */
116 Status = AcpiNsRootInitialize ();
117 if (ACPI_FAILURE (Status))
118 {
119 ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
120 return_ACPI_STATUS (Status);
121 }
122
123 /* Initialize the global OSI interfaces list with the static names */
124
125 Status = AcpiUtInitializeInterfaces ();
126 if (ACPI_FAILURE (Status))
127 {
128 ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));
129 return_ACPI_STATUS (Status);
130 }
131
132 /* If configured, initialize the AML debugger */
133
134 #ifdef ACPI_DEBUGGER
135 Status = AcpiDbInitialize ();
136 if (ACPI_FAILURE (Status))
137 {
138 ACPI_EXCEPTION ((AE_INFO, Status, "During Debugger initialization"));
139 return_ACPI_STATUS (Status);
140 }
141 #endif
142
143 return_ACPI_STATUS (AE_OK);
144 }
145
146 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem)
147
148
149 /*******************************************************************************
150 *
151 * FUNCTION: AcpiEnableSubsystem
152 *
153 * PARAMETERS: Flags - Init/enable Options
154 *
155 * RETURN: Status
156 *
157 * DESCRIPTION: Completes the subsystem initialization including hardware.
158 * Puts system into ACPI mode if it isn't already.
159 *
160 ******************************************************************************/
161
162 ACPI_STATUS
163 AcpiEnableSubsystem (
164 UINT32 Flags)
165 {
166 ACPI_STATUS Status = AE_OK;
167
168
169 ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
170
171
172 #if (!ACPI_REDUCED_HARDWARE)
173
174 /* Enable ACPI mode */
175
176 if (!(Flags & ACPI_NO_ACPI_ENABLE))
177 {
178 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
179
180 AcpiGbl_OriginalMode = AcpiHwGetMode();
181
182 Status = AcpiEnable ();
183 if (ACPI_FAILURE (Status))
184 {
185 ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
186 return_ACPI_STATUS (Status);
187 }
188 }
189
190 /*
191 * Obtain a permanent mapping for the FACS. This is required for the
192 * Global Lock and the Firmware Waking Vector
193 */
194 Status = AcpiTbInitializeFacs ();
195 if (ACPI_FAILURE (Status))
196 {
197 ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
198 return_ACPI_STATUS (Status);
199 }
200
201 #endif /* !ACPI_REDUCED_HARDWARE */
202
203 /*
204 * Install the default OpRegion handlers. These are installed unless
205 * other handlers have already been installed via the
206 * InstallAddressSpaceHandler interface.
207 */
208 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
209 {
210 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
211 "[Init] Installing default address space handlers\n"));
212
213 Status = AcpiEvInstallRegionHandlers ();
214 if (ACPI_FAILURE (Status))
215 {
216 return_ACPI_STATUS (Status);
217 }
218 }
219
220 #if (!ACPI_REDUCED_HARDWARE)
221 /*
222 * Initialize ACPI Event handling (Fixed and General Purpose)
223 *
224 * Note1: We must have the hardware and events initialized before we can
225 * execute any control methods safely. Any control method can require
226 * ACPI hardware support, so the hardware must be fully initialized before
227 * any method execution!
228 *
229 * Note2: Fixed events are initialized and enabled here. GPEs are
230 * initialized, but cannot be enabled until after the hardware is
231 * completely initialized (SCI and GlobalLock activated) and the various
232 * initialization control methods are run (_REG, _STA, _INI) on the
233 * entire namespace.
234 */
235 if (!(Flags & ACPI_NO_EVENT_INIT))
236 {
237 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
238 "[Init] Initializing ACPI events\n"));
239
240 Status = AcpiEvInitializeEvents ();
241 if (ACPI_FAILURE (Status))
242 {
243 return_ACPI_STATUS (Status);
244 }
245 }
246
247 /*
248 * Install the SCI handler and Global Lock handler. This completes the
249 * hardware initialization.
250 */
251 if (!(Flags & ACPI_NO_HANDLER_INIT))
252 {
253 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
254 "[Init] Installing SCI/GL handlers\n"));
255
256 Status = AcpiEvInstallXruptHandlers ();
257 if (ACPI_FAILURE (Status))
258 {
259 return_ACPI_STATUS (Status);
260 }
261 }
262
263 #endif /* !ACPI_REDUCED_HARDWARE */
264
265 return_ACPI_STATUS (Status);
266 }
267
268 ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem)
269
270
271 /*******************************************************************************
272 *
273 * FUNCTION: AcpiInitializeObjects
274 *
275 * PARAMETERS: Flags - Init/enable Options
276 *
277 * RETURN: Status
278 *
279 * DESCRIPTION: Completes namespace initialization by initializing device
280 * objects and executing AML code for Regions, buffers, etc.
281 *
282 ******************************************************************************/
283
284 ACPI_STATUS
285 AcpiInitializeObjects (
286 UINT32 Flags)
287 {
288 ACPI_STATUS Status = AE_OK;
289
290
291 ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
292
293
294 /*
295 * Run all _REG methods
296 *
297 * Note: Any objects accessed by the _REG methods will be automatically
298 * initialized, even if they contain executable AML (see the call to
299 * AcpiNsInitializeObjects below).
300 */
301 if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
302 {
303 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
304 "[Init] Executing _REG OpRegion methods\n"));
305
306 Status = AcpiEvInitializeOpRegions ();
307 if (ACPI_FAILURE (Status))
308 {
309 return_ACPI_STATUS (Status);
310 }
311 }
312
313 /*
314 * Execute any module-level code that was detected during the table load
315 * phase. Although illegal since ACPI 2.0, there are many machines that
316 * contain this type of code. Each block of detected executable AML code
317 * outside of any control method is wrapped with a temporary control
318 * method object and placed on a global list. The methods on this list
319 * are executed below.
320 */
321 AcpiNsExecModuleCodeList ();
322
323 /*
324 * Initialize the objects that remain uninitialized. This runs the
325 * executable AML that may be part of the declaration of these objects:
326 * OperationRegions, BufferFields, Buffers, and Packages.
327 */
328 if (!(Flags & ACPI_NO_OBJECT_INIT))
329 {
330 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
331 "[Init] Completing Initialization of ACPI Objects\n"));
332
333 Status = AcpiNsInitializeObjects ();
334 if (ACPI_FAILURE (Status))
335 {
336 return_ACPI_STATUS (Status);
337 }
338 }
339
340 /*
341 * Initialize all device objects in the namespace. This runs the device
342 * _STA and _INI methods.
343 */
344 if (!(Flags & ACPI_NO_DEVICE_INIT))
345 {
346 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
347 "[Init] Initializing ACPI Devices\n"));
348
349 Status = AcpiNsInitializeDevices ();
350 if (ACPI_FAILURE (Status))
351 {
352 return_ACPI_STATUS (Status);
353 }
354 }
355
356 /*
357 * Empty the caches (delete the cached objects) on the assumption that
358 * the table load filled them up more than they will be at runtime --
359 * thus wasting non-paged memory.
360 */
361 Status = AcpiPurgeCachedObjects ();
362
363 AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
364 return_ACPI_STATUS (Status);
365 }
366
367 ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects)
368