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