utxfinit.c revision 1.1.1.1.10.3 1 1.1.1.1.10.2 tls /******************************************************************************
2 1.1.1.1.10.2 tls *
3 1.1.1.1.10.2 tls * Module Name: utxfinit - External interfaces for ACPICA initialization
4 1.1.1.1.10.2 tls *
5 1.1.1.1.10.2 tls *****************************************************************************/
6 1.1.1.1.10.2 tls
7 1.1.1.1.10.2 tls /*
8 1.1.1.1.10.3 jdolecek * Copyright (C) 2000 - 2017, Intel Corp.
9 1.1.1.1.10.2 tls * All rights reserved.
10 1.1.1.1.10.2 tls *
11 1.1.1.1.10.2 tls * Redistribution and use in source and binary forms, with or without
12 1.1.1.1.10.2 tls * modification, are permitted provided that the following conditions
13 1.1.1.1.10.2 tls * are met:
14 1.1.1.1.10.2 tls * 1. Redistributions of source code must retain the above copyright
15 1.1.1.1.10.2 tls * notice, this list of conditions, and the following disclaimer,
16 1.1.1.1.10.2 tls * without modification.
17 1.1.1.1.10.2 tls * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.1.10.2 tls * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.1.10.2 tls * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.1.10.2 tls * including a substantially similar Disclaimer requirement for further
21 1.1.1.1.10.2 tls * binary redistribution.
22 1.1.1.1.10.2 tls * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.1.10.2 tls * of any contributors may be used to endorse or promote products derived
24 1.1.1.1.10.2 tls * from this software without specific prior written permission.
25 1.1.1.1.10.2 tls *
26 1.1.1.1.10.2 tls * Alternatively, this software may be distributed under the terms of the
27 1.1.1.1.10.2 tls * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.1.10.2 tls * Software Foundation.
29 1.1.1.1.10.2 tls *
30 1.1.1.1.10.2 tls * NO WARRANTY
31 1.1.1.1.10.2 tls * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.1.10.2 tls * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.1.10.2 tls * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.1.10.2 tls * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.1.10.2 tls * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.1.10.2 tls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.1.10.2 tls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.1.10.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.1.10.2 tls * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.1.10.2 tls * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.1.10.2 tls * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.1.10.2 tls */
43 1.1.1.1.10.2 tls
44 1.1.1.1.10.2 tls #define EXPORT_ACPI_INTERFACES
45 1.1.1.1.10.2 tls
46 1.1.1.1.10.2 tls #include "acpi.h"
47 1.1.1.1.10.2 tls #include "accommon.h"
48 1.1.1.1.10.2 tls #include "acevents.h"
49 1.1.1.1.10.2 tls #include "acnamesp.h"
50 1.1.1.1.10.2 tls #include "acdebug.h"
51 1.1.1.1.10.2 tls #include "actables.h"
52 1.1.1.1.10.2 tls
53 1.1.1.1.10.2 tls #define _COMPONENT ACPI_UTILITIES
54 1.1.1.1.10.2 tls ACPI_MODULE_NAME ("utxfinit")
55 1.1.1.1.10.2 tls
56 1.1.1.1.10.3 jdolecek /* For AcpiExec only */
57 1.1.1.1.10.3 jdolecek void
58 1.1.1.1.10.3 jdolecek AeDoObjectOverrides (
59 1.1.1.1.10.3 jdolecek void);
60 1.1.1.1.10.3 jdolecek
61 1.1.1.1.10.2 tls
62 1.1.1.1.10.2 tls /*******************************************************************************
63 1.1.1.1.10.2 tls *
64 1.1.1.1.10.2 tls * FUNCTION: AcpiInitializeSubsystem
65 1.1.1.1.10.2 tls *
66 1.1.1.1.10.2 tls * PARAMETERS: None
67 1.1.1.1.10.2 tls *
68 1.1.1.1.10.2 tls * RETURN: Status
69 1.1.1.1.10.2 tls *
70 1.1.1.1.10.2 tls * DESCRIPTION: Initializes all global variables. This is the first function
71 1.1.1.1.10.2 tls * called, so any early initialization belongs here.
72 1.1.1.1.10.2 tls *
73 1.1.1.1.10.2 tls ******************************************************************************/
74 1.1.1.1.10.2 tls
75 1.1.1.1.10.3 jdolecek ACPI_STATUS ACPI_INIT_FUNCTION
76 1.1.1.1.10.2 tls AcpiInitializeSubsystem (
77 1.1.1.1.10.2 tls void)
78 1.1.1.1.10.2 tls {
79 1.1.1.1.10.2 tls ACPI_STATUS Status;
80 1.1.1.1.10.2 tls
81 1.1.1.1.10.2 tls
82 1.1.1.1.10.2 tls ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
83 1.1.1.1.10.2 tls
84 1.1.1.1.10.2 tls
85 1.1.1.1.10.2 tls AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
86 1.1.1.1.10.2 tls ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
87 1.1.1.1.10.2 tls
88 1.1.1.1.10.2 tls /* Initialize the OS-Dependent layer */
89 1.1.1.1.10.2 tls
90 1.1.1.1.10.2 tls Status = AcpiOsInitialize ();
91 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
92 1.1.1.1.10.2 tls {
93 1.1.1.1.10.2 tls ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
94 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
95 1.1.1.1.10.2 tls }
96 1.1.1.1.10.2 tls
97 1.1.1.1.10.2 tls /* Initialize all globals used by the subsystem */
98 1.1.1.1.10.2 tls
99 1.1.1.1.10.2 tls Status = AcpiUtInitGlobals ();
100 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
101 1.1.1.1.10.2 tls {
102 1.1.1.1.10.2 tls ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
103 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
104 1.1.1.1.10.2 tls }
105 1.1.1.1.10.2 tls
106 1.1.1.1.10.2 tls /* Create the default mutex objects */
107 1.1.1.1.10.2 tls
108 1.1.1.1.10.2 tls Status = AcpiUtMutexInitialize ();
109 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
110 1.1.1.1.10.2 tls {
111 1.1.1.1.10.2 tls ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
112 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
113 1.1.1.1.10.2 tls }
114 1.1.1.1.10.2 tls
115 1.1.1.1.10.2 tls /*
116 1.1.1.1.10.2 tls * Initialize the namespace manager and
117 1.1.1.1.10.2 tls * the root of the namespace tree
118 1.1.1.1.10.2 tls */
119 1.1.1.1.10.2 tls Status = AcpiNsRootInitialize ();
120 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
121 1.1.1.1.10.2 tls {
122 1.1.1.1.10.2 tls ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
123 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
124 1.1.1.1.10.2 tls }
125 1.1.1.1.10.2 tls
126 1.1.1.1.10.2 tls /* Initialize the global OSI interfaces list with the static names */
127 1.1.1.1.10.2 tls
128 1.1.1.1.10.2 tls Status = AcpiUtInitializeInterfaces ();
129 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
130 1.1.1.1.10.2 tls {
131 1.1.1.1.10.2 tls ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));
132 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
133 1.1.1.1.10.2 tls }
134 1.1.1.1.10.2 tls
135 1.1.1.1.10.2 tls return_ACPI_STATUS (AE_OK);
136 1.1.1.1.10.2 tls }
137 1.1.1.1.10.2 tls
138 1.1.1.1.10.2 tls ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeSubsystem)
139 1.1.1.1.10.2 tls
140 1.1.1.1.10.2 tls
141 1.1.1.1.10.2 tls /*******************************************************************************
142 1.1.1.1.10.2 tls *
143 1.1.1.1.10.2 tls * FUNCTION: AcpiEnableSubsystem
144 1.1.1.1.10.2 tls *
145 1.1.1.1.10.2 tls * PARAMETERS: Flags - Init/enable Options
146 1.1.1.1.10.2 tls *
147 1.1.1.1.10.2 tls * RETURN: Status
148 1.1.1.1.10.2 tls *
149 1.1.1.1.10.2 tls * DESCRIPTION: Completes the subsystem initialization including hardware.
150 1.1.1.1.10.2 tls * Puts system into ACPI mode if it isn't already.
151 1.1.1.1.10.2 tls *
152 1.1.1.1.10.2 tls ******************************************************************************/
153 1.1.1.1.10.2 tls
154 1.1.1.1.10.3 jdolecek ACPI_STATUS ACPI_INIT_FUNCTION
155 1.1.1.1.10.2 tls AcpiEnableSubsystem (
156 1.1.1.1.10.2 tls UINT32 Flags)
157 1.1.1.1.10.2 tls {
158 1.1.1.1.10.2 tls ACPI_STATUS Status = AE_OK;
159 1.1.1.1.10.2 tls
160 1.1.1.1.10.2 tls
161 1.1.1.1.10.2 tls ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
162 1.1.1.1.10.2 tls
163 1.1.1.1.10.2 tls
164 1.1.1.1.10.3 jdolecek /*
165 1.1.1.1.10.3 jdolecek * The early initialization phase is complete. The namespace is loaded,
166 1.1.1.1.10.3 jdolecek * and we can now support address spaces other than Memory, I/O, and
167 1.1.1.1.10.3 jdolecek * PCI_Config.
168 1.1.1.1.10.3 jdolecek */
169 1.1.1.1.10.3 jdolecek AcpiGbl_EarlyInitialization = FALSE;
170 1.1.1.1.10.3 jdolecek
171 1.1.1.1.10.2 tls #if (!ACPI_REDUCED_HARDWARE)
172 1.1.1.1.10.2 tls
173 1.1.1.1.10.2 tls /* Enable ACPI mode */
174 1.1.1.1.10.2 tls
175 1.1.1.1.10.2 tls if (!(Flags & ACPI_NO_ACPI_ENABLE))
176 1.1.1.1.10.2 tls {
177 1.1.1.1.10.2 tls ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Init] Going into ACPI mode\n"));
178 1.1.1.1.10.2 tls
179 1.1.1.1.10.2 tls AcpiGbl_OriginalMode = AcpiHwGetMode();
180 1.1.1.1.10.2 tls
181 1.1.1.1.10.2 tls Status = AcpiEnable ();
182 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
183 1.1.1.1.10.2 tls {
184 1.1.1.1.10.2 tls ACPI_WARNING ((AE_INFO, "AcpiEnable failed"));
185 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
186 1.1.1.1.10.2 tls }
187 1.1.1.1.10.2 tls }
188 1.1.1.1.10.2 tls
189 1.1.1.1.10.2 tls /*
190 1.1.1.1.10.2 tls * Obtain a permanent mapping for the FACS. This is required for the
191 1.1.1.1.10.2 tls * Global Lock and the Firmware Waking Vector
192 1.1.1.1.10.2 tls */
193 1.1.1.1.10.3 jdolecek if (!(Flags & ACPI_NO_FACS_INIT))
194 1.1.1.1.10.2 tls {
195 1.1.1.1.10.3 jdolecek Status = AcpiTbInitializeFacs ();
196 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
197 1.1.1.1.10.2 tls {
198 1.1.1.1.10.3 jdolecek ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
199 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
200 1.1.1.1.10.2 tls }
201 1.1.1.1.10.2 tls }
202 1.1.1.1.10.2 tls
203 1.1.1.1.10.2 tls /*
204 1.1.1.1.10.2 tls * Initialize ACPI Event handling (Fixed and General Purpose)
205 1.1.1.1.10.2 tls *
206 1.1.1.1.10.2 tls * Note1: We must have the hardware and events initialized before we can
207 1.1.1.1.10.2 tls * execute any control methods safely. Any control method can require
208 1.1.1.1.10.2 tls * ACPI hardware support, so the hardware must be fully initialized before
209 1.1.1.1.10.2 tls * any method execution!
210 1.1.1.1.10.2 tls *
211 1.1.1.1.10.2 tls * Note2: Fixed events are initialized and enabled here. GPEs are
212 1.1.1.1.10.2 tls * initialized, but cannot be enabled until after the hardware is
213 1.1.1.1.10.2 tls * completely initialized (SCI and GlobalLock activated) and the various
214 1.1.1.1.10.2 tls * initialization control methods are run (_REG, _STA, _INI) on the
215 1.1.1.1.10.2 tls * entire namespace.
216 1.1.1.1.10.2 tls */
217 1.1.1.1.10.2 tls if (!(Flags & ACPI_NO_EVENT_INIT))
218 1.1.1.1.10.2 tls {
219 1.1.1.1.10.2 tls ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
220 1.1.1.1.10.2 tls "[Init] Initializing ACPI events\n"));
221 1.1.1.1.10.2 tls
222 1.1.1.1.10.2 tls Status = AcpiEvInitializeEvents ();
223 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
224 1.1.1.1.10.2 tls {
225 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
226 1.1.1.1.10.2 tls }
227 1.1.1.1.10.2 tls }
228 1.1.1.1.10.2 tls
229 1.1.1.1.10.2 tls /*
230 1.1.1.1.10.2 tls * Install the SCI handler and Global Lock handler. This completes the
231 1.1.1.1.10.2 tls * hardware initialization.
232 1.1.1.1.10.2 tls */
233 1.1.1.1.10.2 tls if (!(Flags & ACPI_NO_HANDLER_INIT))
234 1.1.1.1.10.2 tls {
235 1.1.1.1.10.2 tls ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
236 1.1.1.1.10.2 tls "[Init] Installing SCI/GL handlers\n"));
237 1.1.1.1.10.2 tls
238 1.1.1.1.10.2 tls Status = AcpiEvInstallXruptHandlers ();
239 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
240 1.1.1.1.10.2 tls {
241 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
242 1.1.1.1.10.2 tls }
243 1.1.1.1.10.2 tls }
244 1.1.1.1.10.2 tls
245 1.1.1.1.10.2 tls #endif /* !ACPI_REDUCED_HARDWARE */
246 1.1.1.1.10.2 tls
247 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
248 1.1.1.1.10.2 tls }
249 1.1.1.1.10.2 tls
250 1.1.1.1.10.2 tls ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem)
251 1.1.1.1.10.2 tls
252 1.1.1.1.10.2 tls
253 1.1.1.1.10.2 tls /*******************************************************************************
254 1.1.1.1.10.2 tls *
255 1.1.1.1.10.2 tls * FUNCTION: AcpiInitializeObjects
256 1.1.1.1.10.2 tls *
257 1.1.1.1.10.2 tls * PARAMETERS: Flags - Init/enable Options
258 1.1.1.1.10.2 tls *
259 1.1.1.1.10.2 tls * RETURN: Status
260 1.1.1.1.10.2 tls *
261 1.1.1.1.10.2 tls * DESCRIPTION: Completes namespace initialization by initializing device
262 1.1.1.1.10.2 tls * objects and executing AML code for Regions, buffers, etc.
263 1.1.1.1.10.2 tls *
264 1.1.1.1.10.2 tls ******************************************************************************/
265 1.1.1.1.10.2 tls
266 1.1.1.1.10.3 jdolecek ACPI_STATUS ACPI_INIT_FUNCTION
267 1.1.1.1.10.2 tls AcpiInitializeObjects (
268 1.1.1.1.10.2 tls UINT32 Flags)
269 1.1.1.1.10.2 tls {
270 1.1.1.1.10.2 tls ACPI_STATUS Status = AE_OK;
271 1.1.1.1.10.2 tls
272 1.1.1.1.10.2 tls
273 1.1.1.1.10.2 tls ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
274 1.1.1.1.10.2 tls
275 1.1.1.1.10.2 tls
276 1.1.1.1.10.3 jdolecek #ifdef ACPI_EXEC_APP
277 1.1.1.1.10.2 tls /*
278 1.1.1.1.10.3 jdolecek * This call implements the "initialization file" option for AcpiExec.
279 1.1.1.1.10.3 jdolecek * This is the precise point that we want to perform the overrides.
280 1.1.1.1.10.2 tls */
281 1.1.1.1.10.3 jdolecek AeDoObjectOverrides ();
282 1.1.1.1.10.3 jdolecek #endif
283 1.1.1.1.10.2 tls
284 1.1.1.1.10.2 tls /*
285 1.1.1.1.10.2 tls * Execute any module-level code that was detected during the table load
286 1.1.1.1.10.2 tls * phase. Although illegal since ACPI 2.0, there are many machines that
287 1.1.1.1.10.2 tls * contain this type of code. Each block of detected executable AML code
288 1.1.1.1.10.2 tls * outside of any control method is wrapped with a temporary control
289 1.1.1.1.10.2 tls * method object and placed on a global list. The methods on this list
290 1.1.1.1.10.2 tls * are executed below.
291 1.1.1.1.10.3 jdolecek *
292 1.1.1.1.10.3 jdolecek * This case executes the module-level code for all tables only after
293 1.1.1.1.10.3 jdolecek * all of the tables have been loaded. It is a legacy option and is
294 1.1.1.1.10.3 jdolecek * not compatible with other ACPI implementations. See AcpiNsLoadTable.
295 1.1.1.1.10.2 tls */
296 1.1.1.1.10.3 jdolecek if (!AcpiGbl_ParseTableAsTermList && AcpiGbl_GroupModuleLevelCode)
297 1.1.1.1.10.2 tls {
298 1.1.1.1.10.3 jdolecek AcpiNsExecModuleCodeList ();
299 1.1.1.1.10.2 tls
300 1.1.1.1.10.3 jdolecek /*
301 1.1.1.1.10.3 jdolecek * Initialize the objects that remain uninitialized. This
302 1.1.1.1.10.3 jdolecek * runs the executable AML that may be part of the
303 1.1.1.1.10.3 jdolecek * declaration of these objects:
304 1.1.1.1.10.3 jdolecek * OperationRegions, BufferFields, Buffers, and Packages.
305 1.1.1.1.10.3 jdolecek */
306 1.1.1.1.10.3 jdolecek if (!(Flags & ACPI_NO_OBJECT_INIT))
307 1.1.1.1.10.2 tls {
308 1.1.1.1.10.3 jdolecek Status = AcpiNsInitializeObjects ();
309 1.1.1.1.10.3 jdolecek if (ACPI_FAILURE (Status))
310 1.1.1.1.10.3 jdolecek {
311 1.1.1.1.10.3 jdolecek return_ACPI_STATUS (Status);
312 1.1.1.1.10.3 jdolecek }
313 1.1.1.1.10.2 tls }
314 1.1.1.1.10.2 tls }
315 1.1.1.1.10.2 tls
316 1.1.1.1.10.2 tls /*
317 1.1.1.1.10.3 jdolecek * Initialize all device/region objects in the namespace. This runs
318 1.1.1.1.10.3 jdolecek * the device _STA and _INI methods and region _REG methods.
319 1.1.1.1.10.2 tls */
320 1.1.1.1.10.3 jdolecek if (!(Flags & (ACPI_NO_DEVICE_INIT | ACPI_NO_ADDRESS_SPACE_INIT)))
321 1.1.1.1.10.2 tls {
322 1.1.1.1.10.3 jdolecek Status = AcpiNsInitializeDevices (Flags);
323 1.1.1.1.10.2 tls if (ACPI_FAILURE (Status))
324 1.1.1.1.10.2 tls {
325 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
326 1.1.1.1.10.2 tls }
327 1.1.1.1.10.2 tls }
328 1.1.1.1.10.2 tls
329 1.1.1.1.10.2 tls /*
330 1.1.1.1.10.2 tls * Empty the caches (delete the cached objects) on the assumption that
331 1.1.1.1.10.2 tls * the table load filled them up more than they will be at runtime --
332 1.1.1.1.10.2 tls * thus wasting non-paged memory.
333 1.1.1.1.10.2 tls */
334 1.1.1.1.10.2 tls Status = AcpiPurgeCachedObjects ();
335 1.1.1.1.10.2 tls
336 1.1.1.1.10.2 tls AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
337 1.1.1.1.10.2 tls return_ACPI_STATUS (Status);
338 1.1.1.1.10.2 tls }
339 1.1.1.1.10.2 tls
340 1.1.1.1.10.2 tls ACPI_EXPORT_SYMBOL_INIT (AcpiInitializeObjects)
341