Linux Audio

Check our new training course

Loading...
v5.9
  1// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2/******************************************************************************
  3 *
  4 * Module Name: utxfinit - External interfaces for ACPICA initialization
  5 *
  6 * Copyright (C) 2000 - 2020, Intel Corp.
  7 *
  8 *****************************************************************************/
  9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 10#define EXPORT_ACPI_INTERFACES
 11
 12#include <acpi/acpi.h>
 13#include "accommon.h"
 14#include "acevents.h"
 15#include "acnamesp.h"
 16#include "acdebug.h"
 17#include "actables.h"
 18
 19#define _COMPONENT          ACPI_UTILITIES
 20ACPI_MODULE_NAME("utxfinit")
 21
 22/* For acpi_exec only */
 23void ae_do_object_overrides(void);
 24
 25/*******************************************************************************
 26 *
 27 * FUNCTION:    acpi_initialize_subsystem
 28 *
 29 * PARAMETERS:  None
 30 *
 31 * RETURN:      Status
 32 *
 33 * DESCRIPTION: Initializes all global variables. This is the first function
 34 *              called, so any early initialization belongs here.
 35 *
 36 ******************************************************************************/
 37
 38acpi_status ACPI_INIT_FUNCTION acpi_initialize_subsystem(void)
 39{
 40	acpi_status status;
 41
 42	ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
 43
 44	acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
 45	ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
 46
 47	/* Initialize the OS-Dependent layer */
 48
 49	status = acpi_os_initialize();
 50	if (ACPI_FAILURE(status)) {
 51		ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
 52		return_ACPI_STATUS(status);
 53	}
 54
 55	/* Initialize all globals used by the subsystem */
 56
 57	status = acpi_ut_init_globals();
 58	if (ACPI_FAILURE(status)) {
 59		ACPI_EXCEPTION((AE_INFO, status,
 60				"During initialization of globals"));
 61		return_ACPI_STATUS(status);
 62	}
 63
 64	/* Create the default mutex objects */
 65
 66	status = acpi_ut_mutex_initialize();
 67	if (ACPI_FAILURE(status)) {
 68		ACPI_EXCEPTION((AE_INFO, status,
 69				"During Global Mutex creation"));
 70		return_ACPI_STATUS(status);
 71	}
 72
 73	/*
 74	 * Initialize the namespace manager and
 75	 * the root of the namespace tree
 76	 */
 77	status = acpi_ns_root_initialize();
 78	if (ACPI_FAILURE(status)) {
 79		ACPI_EXCEPTION((AE_INFO, status,
 80				"During Namespace initialization"));
 81		return_ACPI_STATUS(status);
 82	}
 83
 84	/* Initialize the global OSI interfaces list with the static names */
 85
 86	status = acpi_ut_initialize_interfaces();
 87	if (ACPI_FAILURE(status)) {
 88		ACPI_EXCEPTION((AE_INFO, status,
 89				"During OSI interfaces initialization"));
 90		return_ACPI_STATUS(status);
 91	}
 92
 
 
 
 
 
 
 
 
 
 
 
 93	return_ACPI_STATUS(AE_OK);
 94}
 95
 96ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem)
 97
 98/*******************************************************************************
 99 *
100 * FUNCTION:    acpi_enable_subsystem
101 *
102 * PARAMETERS:  flags               - Init/enable Options
103 *
104 * RETURN:      Status
105 *
106 * DESCRIPTION: Completes the subsystem initialization including hardware.
107 *              Puts system into ACPI mode if it isn't already.
108 *
109 ******************************************************************************/
110acpi_status ACPI_INIT_FUNCTION acpi_enable_subsystem(u32 flags)
111{
112	acpi_status status = AE_OK;
113
114	ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
115
116	/*
117	 * The early initialization phase is complete. The namespace is loaded,
118	 * and we can now support address spaces other than Memory, I/O, and
119	 * PCI_Config.
120	 */
121	acpi_gbl_early_initialization = FALSE;
122
123#if (!ACPI_REDUCED_HARDWARE)
124
125	/* Enable ACPI mode */
126
127	if (!(flags & ACPI_NO_ACPI_ENABLE)) {
128		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
129				  "[Init] Going into ACPI mode\n"));
130
131		acpi_gbl_original_mode = acpi_hw_get_mode();
132
133		status = acpi_enable();
134		if (ACPI_FAILURE(status)) {
135			ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
136			return_ACPI_STATUS(status);
137		}
138	}
139
140	/*
141	 * Obtain a permanent mapping for the FACS. This is required for the
142	 * Global Lock and the Firmware Waking Vector
143	 */
144	if (!(flags & ACPI_NO_FACS_INIT)) {
145		status = acpi_tb_initialize_facs();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146		if (ACPI_FAILURE(status)) {
147			ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
148			return_ACPI_STATUS(status);
149		}
150	}
151
152	/*
153	 * Initialize ACPI Event handling (Fixed and General Purpose)
154	 *
155	 * Note1: We must have the hardware and events initialized before we can
156	 * execute any control methods safely. Any control method can require
157	 * ACPI hardware support, so the hardware must be fully initialized before
158	 * any method execution!
159	 *
160	 * Note2: Fixed events are initialized and enabled here. GPEs are
161	 * initialized, but cannot be enabled until after the hardware is
162	 * completely initialized (SCI and global_lock activated) and the various
163	 * initialization control methods are run (_REG, _STA, _INI) on the
164	 * entire namespace.
165	 */
166	if (!(flags & ACPI_NO_EVENT_INIT)) {
167		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
168				  "[Init] Initializing ACPI events\n"));
169
170		status = acpi_ev_initialize_events();
171		if (ACPI_FAILURE(status)) {
172			return_ACPI_STATUS(status);
173		}
174	}
175
176	/*
177	 * Install the SCI handler and Global Lock handler. This completes the
178	 * hardware initialization.
179	 */
180	if (!(flags & ACPI_NO_HANDLER_INIT)) {
181		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
182				  "[Init] Installing SCI/GL handlers\n"));
183
184		status = acpi_ev_install_xrupt_handlers();
185		if (ACPI_FAILURE(status)) {
186			return_ACPI_STATUS(status);
187		}
188	}
189#endif				/* !ACPI_REDUCED_HARDWARE */
190
191	return_ACPI_STATUS(status);
192}
193
194ACPI_EXPORT_SYMBOL_INIT(acpi_enable_subsystem)
195
196/*******************************************************************************
197 *
198 * FUNCTION:    acpi_initialize_objects
199 *
200 * PARAMETERS:  flags               - Init/enable Options
201 *
202 * RETURN:      Status
203 *
204 * DESCRIPTION: Completes namespace initialization by initializing device
205 *              objects and executing AML code for Regions, buffers, etc.
206 *
207 ******************************************************************************/
208acpi_status ACPI_INIT_FUNCTION acpi_initialize_objects(u32 flags)
209{
210	acpi_status status = AE_OK;
211
212	ACPI_FUNCTION_TRACE(acpi_initialize_objects);
213
214#ifdef ACPI_OBSOLETE_BEHAVIOR
215	/*
216	 * 05/2019: Removed, initialization now happens at both object
217	 * creation and table load time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218	 */
 
219
220	/*
221	 * Initialize the objects that remain uninitialized. This
222	 * runs the executable AML that may be part of the
223	 * declaration of these objects: operation_regions, buffer_fields,
224	 * bank_fields, Buffers, and Packages.
225	 */
226	if (!(flags & ACPI_NO_OBJECT_INIT)) {
 
 
 
227		status = acpi_ns_initialize_objects();
228		if (ACPI_FAILURE(status)) {
229			return_ACPI_STATUS(status);
230		}
231	}
232#endif
233
234	/*
235	 * Initialize all device/region objects in the namespace. This runs
236	 * the device _STA and _INI methods and region _REG methods.
237	 */
238	if (!(flags & (ACPI_NO_DEVICE_INIT | ACPI_NO_ADDRESS_SPACE_INIT))) {
239		status = acpi_ns_initialize_devices(flags);
 
 
 
240		if (ACPI_FAILURE(status)) {
241			return_ACPI_STATUS(status);
242		}
243	}
244
245	/*
246	 * Empty the caches (delete the cached objects) on the assumption that
247	 * the table load filled them up more than they will be at runtime --
248	 * thus wasting non-paged memory.
249	 */
250	status = acpi_purge_cached_objects();
251
252	acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
253	return_ACPI_STATUS(status);
254}
255
256ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_objects)
v3.15
 
  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 EXPORT_ACPI_INTERFACES
 45
 46#include <acpi/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
 54ACPI_MODULE_NAME("utxfinit")
 55
 
 
 
 56/*******************************************************************************
 57 *
 58 * FUNCTION:    acpi_initialize_subsystem
 59 *
 60 * PARAMETERS:  None
 61 *
 62 * RETURN:      Status
 63 *
 64 * DESCRIPTION: Initializes all global variables. This is the first function
 65 *              called, so any early initialization belongs here.
 66 *
 67 ******************************************************************************/
 68acpi_status __init acpi_initialize_subsystem(void)
 
 69{
 70	acpi_status status;
 71
 72	ACPI_FUNCTION_TRACE(acpi_initialize_subsystem);
 73
 74	acpi_gbl_startup_flags = ACPI_SUBSYSTEM_INITIALIZE;
 75	ACPI_DEBUG_EXEC(acpi_ut_init_stack_ptr_trace());
 76
 77	/* Initialize the OS-Dependent layer */
 78
 79	status = acpi_os_initialize();
 80	if (ACPI_FAILURE(status)) {
 81		ACPI_EXCEPTION((AE_INFO, status, "During OSL initialization"));
 82		return_ACPI_STATUS(status);
 83	}
 84
 85	/* Initialize all globals used by the subsystem */
 86
 87	status = acpi_ut_init_globals();
 88	if (ACPI_FAILURE(status)) {
 89		ACPI_EXCEPTION((AE_INFO, status,
 90				"During initialization of globals"));
 91		return_ACPI_STATUS(status);
 92	}
 93
 94	/* Create the default mutex objects */
 95
 96	status = acpi_ut_mutex_initialize();
 97	if (ACPI_FAILURE(status)) {
 98		ACPI_EXCEPTION((AE_INFO, status,
 99				"During Global Mutex creation"));
100		return_ACPI_STATUS(status);
101	}
102
103	/*
104	 * Initialize the namespace manager and
105	 * the root of the namespace tree
106	 */
107	status = acpi_ns_root_initialize();
108	if (ACPI_FAILURE(status)) {
109		ACPI_EXCEPTION((AE_INFO, status,
110				"During Namespace initialization"));
111		return_ACPI_STATUS(status);
112	}
113
114	/* Initialize the global OSI interfaces list with the static names */
115
116	status = acpi_ut_initialize_interfaces();
117	if (ACPI_FAILURE(status)) {
118		ACPI_EXCEPTION((AE_INFO, status,
119				"During OSI interfaces initialization"));
120		return_ACPI_STATUS(status);
121	}
122
123	/* If configured, initialize the AML debugger */
124
125#ifdef ACPI_DEBUGGER
126	status = acpi_db_initialize();
127	if (ACPI_FAILURE(status)) {
128		ACPI_EXCEPTION((AE_INFO, status,
129				"During Debugger initialization"));
130		return_ACPI_STATUS(status);
131	}
132#endif
133
134	return_ACPI_STATUS(AE_OK);
135}
136
137ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_subsystem)
138
139/*******************************************************************************
140 *
141 * FUNCTION:    acpi_enable_subsystem
142 *
143 * PARAMETERS:  flags               - Init/enable Options
144 *
145 * RETURN:      Status
146 *
147 * DESCRIPTION: Completes the subsystem initialization including hardware.
148 *              Puts system into ACPI mode if it isn't already.
149 *
150 ******************************************************************************/
151acpi_status __init acpi_enable_subsystem(u32 flags)
152{
153	acpi_status status = AE_OK;
154
155	ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
156
 
 
 
 
 
 
 
157#if (!ACPI_REDUCED_HARDWARE)
158
159	/* Enable ACPI mode */
160
161	if (!(flags & ACPI_NO_ACPI_ENABLE)) {
162		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
163				  "[Init] Going into ACPI mode\n"));
164
165		acpi_gbl_original_mode = acpi_hw_get_mode();
166
167		status = acpi_enable();
168		if (ACPI_FAILURE(status)) {
169			ACPI_WARNING((AE_INFO, "AcpiEnable failed"));
170			return_ACPI_STATUS(status);
171		}
172	}
173
174	/*
175	 * Obtain a permanent mapping for the FACS. This is required for the
176	 * Global Lock and the Firmware Waking Vector
177	 */
178	status = acpi_tb_initialize_facs();
179	if (ACPI_FAILURE(status)) {
180		ACPI_WARNING((AE_INFO, "Could not map the FACS table"));
181		return_ACPI_STATUS(status);
182	}
183#endif				/* !ACPI_REDUCED_HARDWARE */
184
185	/*
186	 * Install the default op_region handlers. These are installed unless
187	 * other handlers have already been installed via the
188	 * install_address_space_handler interface.
189	 */
190	if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
191		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
192				  "[Init] Installing default address space handlers\n"));
193
194		status = acpi_ev_install_region_handlers();
195		if (ACPI_FAILURE(status)) {
 
196			return_ACPI_STATUS(status);
197		}
198	}
199#if (!ACPI_REDUCED_HARDWARE)
200	/*
201	 * Initialize ACPI Event handling (Fixed and General Purpose)
202	 *
203	 * Note1: We must have the hardware and events initialized before we can
204	 * execute any control methods safely. Any control method can require
205	 * ACPI hardware support, so the hardware must be fully initialized before
206	 * any method execution!
207	 *
208	 * Note2: Fixed events are initialized and enabled here. GPEs are
209	 * initialized, but cannot be enabled until after the hardware is
210	 * completely initialized (SCI and global_lock activated) and the various
211	 * initialization control methods are run (_REG, _STA, _INI) on the
212	 * entire namespace.
213	 */
214	if (!(flags & ACPI_NO_EVENT_INIT)) {
215		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
216				  "[Init] Initializing ACPI events\n"));
217
218		status = acpi_ev_initialize_events();
219		if (ACPI_FAILURE(status)) {
220			return_ACPI_STATUS(status);
221		}
222	}
223
224	/*
225	 * Install the SCI handler and Global Lock handler. This completes the
226	 * hardware initialization.
227	 */
228	if (!(flags & ACPI_NO_HANDLER_INIT)) {
229		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
230				  "[Init] Installing SCI/GL handlers\n"));
231
232		status = acpi_ev_install_xrupt_handlers();
233		if (ACPI_FAILURE(status)) {
234			return_ACPI_STATUS(status);
235		}
236	}
237#endif				/* !ACPI_REDUCED_HARDWARE */
238
239	return_ACPI_STATUS(status);
240}
241
242ACPI_EXPORT_SYMBOL_INIT(acpi_enable_subsystem)
243
244/*******************************************************************************
245 *
246 * FUNCTION:    acpi_initialize_objects
247 *
248 * PARAMETERS:  flags               - Init/enable Options
249 *
250 * RETURN:      Status
251 *
252 * DESCRIPTION: Completes namespace initialization by initializing device
253 *              objects and executing AML code for Regions, buffers, etc.
254 *
255 ******************************************************************************/
256acpi_status __init acpi_initialize_objects(u32 flags)
257{
258	acpi_status status = AE_OK;
259
260	ACPI_FUNCTION_TRACE(acpi_initialize_objects);
261
 
262	/*
263	 * Run all _REG methods
264	 *
265	 * Note: Any objects accessed by the _REG methods will be automatically
266	 * initialized, even if they contain executable AML (see the call to
267	 * acpi_ns_initialize_objects below).
268	 */
269	if (!(flags & ACPI_NO_ADDRESS_SPACE_INIT)) {
270		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
271				  "[Init] Executing _REG OpRegion methods\n"));
272
273		status = acpi_ev_initialize_op_regions();
274		if (ACPI_FAILURE(status)) {
275			return_ACPI_STATUS(status);
276		}
277	}
278
279	/*
280	 * Execute any module-level code that was detected during the table load
281	 * phase. Although illegal since ACPI 2.0, there are many machines that
282	 * contain this type of code. Each block of detected executable AML code
283	 * outside of any control method is wrapped with a temporary control
284	 * method object and placed on a global list. The methods on this list
285	 * are executed below.
286	 */
287	acpi_ns_exec_module_code_list();
288
289	/*
290	 * Initialize the objects that remain uninitialized. This runs the
291	 * executable AML that may be part of the declaration of these objects:
292	 * operation_regions, buffer_fields, Buffers, and Packages.
 
293	 */
294	if (!(flags & ACPI_NO_OBJECT_INIT)) {
295		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
296				  "[Init] Completing Initialization of ACPI Objects\n"));
297
298		status = acpi_ns_initialize_objects();
299		if (ACPI_FAILURE(status)) {
300			return_ACPI_STATUS(status);
301		}
302	}
 
303
304	/*
305	 * Initialize all device objects in the namespace. This runs the device
306	 * _STA and _INI methods.
307	 */
308	if (!(flags & ACPI_NO_DEVICE_INIT)) {
309		ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
310				  "[Init] Initializing ACPI Devices\n"));
311
312		status = acpi_ns_initialize_devices();
313		if (ACPI_FAILURE(status)) {
314			return_ACPI_STATUS(status);
315		}
316	}
317
318	/*
319	 * Empty the caches (delete the cached objects) on the assumption that
320	 * the table load filled them up more than they will be at runtime --
321	 * thus wasting non-paged memory.
322	 */
323	status = acpi_purge_cached_objects();
324
325	acpi_gbl_startup_flags |= ACPI_INITIALIZED_OK;
326	return_ACPI_STATUS(status);
327}
328
329ACPI_EXPORT_SYMBOL_INIT(acpi_initialize_objects)