ReactOS  0.4.14-dev-317-g96040ec
utxfinit.c
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Module Name: utxfinit - External interfaces for ACPICA initialization
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2019, 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 EXPORT_ACPI_INTERFACES
45 
46 #include "acpi.h"
47 #include "accommon.h"
48 #include "acevents.h"
49 #include "acnamesp.h"
50 #include "acdebug.h"
51 #include "actables.h"
52 
53 #define _COMPONENT ACPI_UTILITIES
54  ACPI_MODULE_NAME ("utxfinit")
55 
56 /* For AcpiExec only */
57 void
59  void);
60 
61 
62 /*******************************************************************************
63  *
64  * FUNCTION: AcpiInitializeSubsystem
65  *
66  * PARAMETERS: None
67  *
68  * RETURN: Status
69  *
70  * DESCRIPTION: Initializes all global variables. This is the first function
71  * called, so any early initialization belongs here.
72  *
73  ******************************************************************************/
74 
77  void)
78 {
80 
81 
83 
84 
85  AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
87 
88  /* Initialize the OS-Dependent layer */
89 
91  if (ACPI_FAILURE (Status))
92  {
93  ACPI_EXCEPTION ((AE_INFO, Status, "During OSL initialization"));
95  }
96 
97  /* Initialize all globals used by the subsystem */
98 
100  if (ACPI_FAILURE (Status))
101  {
102  ACPI_EXCEPTION ((AE_INFO, Status, "During initialization of globals"));
104  }
105 
106  /* Create the default mutex objects */
107 
109  if (ACPI_FAILURE (Status))
110  {
111  ACPI_EXCEPTION ((AE_INFO, Status, "During Global Mutex creation"));
113  }
114 
115  /*
116  * Initialize the namespace manager and
117  * the root of the namespace tree
118  */
120  if (ACPI_FAILURE (Status))
121  {
122  ACPI_EXCEPTION ((AE_INFO, Status, "During Namespace initialization"));
124  }
125 
126  /* Initialize the global OSI interfaces list with the static names */
127 
129  if (ACPI_FAILURE (Status))
130  {
131  ACPI_EXCEPTION ((AE_INFO, Status, "During OSI interfaces initialization"));
133  }
134 
136 }
137 
139 
140 
141 /*******************************************************************************
142  *
143  * FUNCTION: AcpiEnableSubsystem
144  *
145  * PARAMETERS: Flags - Init/enable Options
146  *
147  * RETURN: Status
148  *
149  * DESCRIPTION: Completes the subsystem initialization including hardware.
150  * Puts system into ACPI mode if it isn't already.
151  *
152  ******************************************************************************/
153 
156  UINT32 Flags)
157 {
159 
160 
162 
163 
164  /*
165  * The early initialization phase is complete. The namespace is loaded,
166  * and we can now support address spaces other than Memory, I/O, and
167  * PCI_Config.
168  */
169  AcpiGbl_EarlyInitialization = FALSE;
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"));
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  if (!(Flags & ACPI_NO_FACS_INIT))
194  {
196  if (ACPI_FAILURE (Status))
197  {
198  ACPI_WARNING ((AE_INFO, "Could not map the FACS table"));
200  }
201  }
202 
203  /*
204  * Initialize ACPI Event handling (Fixed and General Purpose)
205  *
206  * Note1: We must have the hardware and events initialized before we can
207  * execute any control methods safely. Any control method can require
208  * ACPI hardware support, so the hardware must be fully initialized before
209  * any method execution!
210  *
211  * Note2: Fixed events are initialized and enabled here. GPEs are
212  * initialized, but cannot be enabled until after the hardware is
213  * completely initialized (SCI and GlobalLock activated) and the various
214  * initialization control methods are run (_REG, _STA, _INI) on the
215  * entire namespace.
216  */
217  if (!(Flags & ACPI_NO_EVENT_INIT))
218  {
220  "[Init] Initializing ACPI events\n"));
221 
223  if (ACPI_FAILURE (Status))
224  {
226  }
227  }
228 
229  /*
230  * Install the SCI handler and Global Lock handler. This completes the
231  * hardware initialization.
232  */
233  if (!(Flags & ACPI_NO_HANDLER_INIT))
234  {
236  "[Init] Installing SCI/GL handlers\n"));
237 
239  if (ACPI_FAILURE (Status))
240  {
242  }
243  }
244 
245 #endif /* !ACPI_REDUCED_HARDWARE */
246 
248 }
249 
251 
252 
253 /*******************************************************************************
254  *
255  * FUNCTION: AcpiInitializeObjects
256  *
257  * PARAMETERS: Flags - Init/enable Options
258  *
259  * RETURN: Status
260  *
261  * DESCRIPTION: Completes namespace initialization by initializing device
262  * objects and executing AML code for Regions, buffers, etc.
263  *
264  ******************************************************************************/
265 
268  UINT32 Flags)
269 {
271 
272 
274 
275 
276 #ifdef ACPI_OBSOLETE_BEHAVIOR
277  /*
278  * 05/2019: Removed, initialization now happens at both object
279  * creation and table load time
280  */
281 
282  /*
283  * Initialize the objects that remain uninitialized. This
284  * runs the executable AML that may be part of the
285  * declaration of these objects: OperationRegions, BufferFields,
286  * BankFields, Buffers, and Packages.
287  */
288  if (!(Flags & ACPI_NO_OBJECT_INIT))
289  {
291  if (ACPI_FAILURE (Status))
292  {
294  }
295  }
296 #endif
297 
298  /*
299  * Initialize all device/region objects in the namespace. This runs
300  * the device _STA and _INI methods and region _REG methods.
301  */
303  {
305  if (ACPI_FAILURE (Status))
306  {
308  }
309  }
310 
311  /*
312  * Empty the caches (delete the cached objects) on the assumption that
313  * the table load filled them up more than they will be at runtime --
314  * thus wasting non-paged memory.
315  */
317 
318  AcpiGbl_StartupFlags |= ACPI_INITIALIZED_OK;
320 }
321 
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
ACPI_STATUS AcpiPurgeCachedObjects(void)
Definition: utxface.c:302
#define ACPI_NO_FACS_INIT
Definition: actypes.h:595
ACPI_STATUS AcpiNsInitializeObjects(void)
Definition: nsinit.c:92
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
void AeDoObjectOverrides(void)
ACPI_STATUS AcpiNsInitializeDevices(UINT32 Flags)
Definition: nsinit.c:157
ACPI_STATUS ACPI_INIT_FUNCTION AcpiEnableSubsystem(UINT32 Flags)
Definition: utxfinit.c:155
ACPI_STATUS AcpiEvInitializeEvents(void)
Definition: evevent.c:77
ACPI_STATUS AcpiEvInstallXruptHandlers(void)
Definition: evevent.c:131
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_STATUS ACPI_INIT_FUNCTION AcpiInitializeSubsystem(void)
Definition: utxfinit.c:76
#define ACPI_NO_DEVICE_INIT
Definition: actypes.h:601
#define ACPI_NO_HANDLER_INIT
Definition: actypes.h:599
#define ACPI_DEBUG_EXEC(a)
Definition: acoutput.h:477
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define ACPI_NO_ACPI_ENABLE
Definition: actypes.h:596
unsigned int UINT32
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
ACPI_STATUS AcpiUtInitializeInterfaces(void)
Definition: utosi.c:148
#define AE_INFO
Definition: acoutput.h:230
ACPI_STATUS AcpiOsInitialize(void)
Definition: osl.c:21
ACPI_STATUS AcpiUtInitGlobals(void)
Definition: utinit.c:131
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_SUBSYSTEM_INITIALIZE
Definition: actypes.h:607
#define ACPI_NO_EVENT_INIT
Definition: actypes.h:598
ACPI_STATUS ACPI_INIT_FUNCTION AcpiInitializeObjects(UINT32 Flags)
Definition: utxfinit.c:267
Status
Definition: gdiplustypes.h:24
#define ACPI_DB_EXEC
Definition: acoutput.h:165
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_EXPORT_SYMBOL_INIT(Symbol)
Definition: actypes.h:339
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
void AcpiUtInitStackPtrTrace(void)
#define ACPI_NO_ADDRESS_SPACE_INIT
Definition: actypes.h:602
#define ACPI_INITIALIZED_OK
Definition: actypes.h:608
#define ACPI_INIT_FUNCTION
Definition: acenv.h:395
ACPI_STATUS AcpiEnable(void)
Definition: evxfevnt.c:68
ACPI_STATUS AcpiTbInitializeFacs(void)
Definition: tbutils.c:75
UINT32 AcpiHwGetMode(void)
Definition: hwacpi.c:179
ACPI_STATUS AcpiNsRootInitialize(void)
Definition: nsaccess.c:73
#define ACPI_NO_OBJECT_INIT
Definition: actypes.h:600
ACPI_STATUS AcpiUtMutexInitialize(void)
Definition: utmutex.c:75
#define AE_OK
Definition: acexcep.h:97