2018-03-15 07:13:07 +08:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
|
2005-04-17 06:20:36 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: utinit - Common ACPI subsystem initialization
|
|
|
|
*
|
2023-04-05 21:38:21 +08:00
|
|
|
* Copyright (C) 2000 - 2023, Intel Corp.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2018-03-15 07:13:07 +08:00
|
|
|
*****************************************************************************/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
2009-01-09 13:30:03 +08:00
|
|
|
#include "accommon.h"
|
|
|
|
#include "acnamesp.h"
|
|
|
|
#include "acevents.h"
|
|
|
|
#include "actables.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_UTILITIES
|
2005-08-05 12:44:28 +08:00
|
|
|
ACPI_MODULE_NAME("utinit")
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-04-19 10:49:35 +08:00
|
|
|
/* Local prototypes */
|
2005-08-05 12:44:28 +08:00
|
|
|
static void acpi_ut_terminate(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-14 18:14:27 +08:00
|
|
|
#if (!ACPI_REDUCED_HARDWARE)
|
|
|
|
|
|
|
|
static void acpi_ut_free_gpe_lists(void);
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define acpi_ut_free_gpe_lists()
|
|
|
|
#endif /* !ACPI_REDUCED_HARDWARE */
|
|
|
|
|
|
|
|
#if (!ACPI_REDUCED_HARDWARE)
|
2005-04-17 06:20:36 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2012-02-14 18:14:27 +08:00
|
|
|
* FUNCTION: acpi_ut_free_gpe_lists
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* PARAMETERS: none
|
|
|
|
*
|
|
|
|
* RETURN: none
|
|
|
|
*
|
2012-02-14 18:14:27 +08:00
|
|
|
* DESCRIPTION: Free global GPE lists
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2012-02-14 18:14:27 +08:00
|
|
|
static void acpi_ut_free_gpe_lists(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-08-05 12:44:28 +08:00
|
|
|
struct acpi_gpe_block_info *gpe_block;
|
|
|
|
struct acpi_gpe_block_info *next_gpe_block;
|
|
|
|
struct acpi_gpe_xrupt_info *gpe_xrupt_info;
|
|
|
|
struct acpi_gpe_xrupt_info *next_gpe_xrupt_info;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Free global GPE blocks and related info structures */
|
|
|
|
|
|
|
|
gpe_xrupt_info = acpi_gbl_gpe_xrupt_list_head;
|
|
|
|
while (gpe_xrupt_info) {
|
|
|
|
gpe_block = gpe_xrupt_info->gpe_block_list_head;
|
|
|
|
while (gpe_block) {
|
|
|
|
next_gpe_block = gpe_block->next;
|
2006-10-03 12:00:00 +08:00
|
|
|
ACPI_FREE(gpe_block->event_info);
|
|
|
|
ACPI_FREE(gpe_block->register_info);
|
|
|
|
ACPI_FREE(gpe_block);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
gpe_block = next_gpe_block;
|
|
|
|
}
|
|
|
|
next_gpe_xrupt_info = gpe_xrupt_info->next;
|
2006-10-03 12:00:00 +08:00
|
|
|
ACPI_FREE(gpe_xrupt_info);
|
2005-04-17 06:20:36 +08:00
|
|
|
gpe_xrupt_info = next_gpe_xrupt_info;
|
|
|
|
}
|
2012-02-14 18:14:27 +08:00
|
|
|
}
|
|
|
|
#endif /* !ACPI_REDUCED_HARDWARE */
|
|
|
|
|
2014-07-08 10:06:39 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ut_init_globals
|
|
|
|
*
|
|
|
|
* PARAMETERS: None
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Initialize ACPICA globals. All globals that require specific
|
|
|
|
* initialization should be initialized here. This allows for
|
|
|
|
* a warm restart.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status acpi_ut_init_globals(void)
|
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
u32 i;
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE(ut_init_globals);
|
|
|
|
|
|
|
|
/* Create all memory caches */
|
|
|
|
|
|
|
|
status = acpi_ut_create_caches();
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return_ACPI_STATUS(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Address Range lists */
|
|
|
|
|
|
|
|
for (i = 0; i < ACPI_ADDRESS_RANGE_MAX; i++) {
|
|
|
|
acpi_gbl_address_range_list[i] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mutex locked flags */
|
|
|
|
|
|
|
|
for (i = 0; i < ACPI_NUM_MUTEX; i++) {
|
|
|
|
acpi_gbl_mutex_info[i].mutex = NULL;
|
|
|
|
acpi_gbl_mutex_info[i].thread_id = ACPI_MUTEX_NOT_ACQUIRED;
|
|
|
|
acpi_gbl_mutex_info[i].use_count = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < ACPI_NUM_OWNERID_MASKS; i++) {
|
|
|
|
acpi_gbl_owner_id_mask[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Last owner_ID is never valid */
|
|
|
|
|
|
|
|
acpi_gbl_owner_id_mask[ACPI_NUM_OWNERID_MASKS - 1] = 0x80000000;
|
|
|
|
|
|
|
|
/* Event counters */
|
|
|
|
|
|
|
|
acpi_method_count = 0;
|
|
|
|
acpi_sci_count = 0;
|
|
|
|
acpi_gpe_count = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
|
|
|
|
acpi_fixed_event_count[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (!ACPI_REDUCED_HARDWARE)
|
|
|
|
|
|
|
|
/* GPE/SCI support */
|
|
|
|
|
|
|
|
acpi_gbl_all_gpes_initialized = FALSE;
|
|
|
|
acpi_gbl_gpe_xrupt_list_head = NULL;
|
|
|
|
acpi_gbl_gpe_fadt_blocks[0] = NULL;
|
|
|
|
acpi_gbl_gpe_fadt_blocks[1] = NULL;
|
|
|
|
acpi_current_gpe_count = 0;
|
|
|
|
|
|
|
|
acpi_gbl_global_event_handler = NULL;
|
|
|
|
acpi_gbl_sci_handler_list = NULL;
|
|
|
|
|
|
|
|
#endif /* !ACPI_REDUCED_HARDWARE */
|
|
|
|
|
|
|
|
/* Global handlers */
|
|
|
|
|
|
|
|
acpi_gbl_global_notify[0].handler = NULL;
|
|
|
|
acpi_gbl_global_notify[1].handler = NULL;
|
|
|
|
acpi_gbl_exception_handler = NULL;
|
|
|
|
acpi_gbl_init_handler = NULL;
|
|
|
|
acpi_gbl_table_handler = NULL;
|
|
|
|
acpi_gbl_interface_handler = NULL;
|
|
|
|
|
|
|
|
/* Global Lock support */
|
|
|
|
|
|
|
|
acpi_gbl_global_lock_semaphore = NULL;
|
|
|
|
acpi_gbl_global_lock_mutex = NULL;
|
|
|
|
acpi_gbl_global_lock_acquired = FALSE;
|
|
|
|
acpi_gbl_global_lock_handle = 0;
|
|
|
|
acpi_gbl_global_lock_present = FALSE;
|
|
|
|
|
|
|
|
/* Miscellaneous variables */
|
|
|
|
|
|
|
|
acpi_gbl_DSDT = NULL;
|
|
|
|
acpi_gbl_cm_single_step = FALSE;
|
|
|
|
acpi_gbl_shutdown = FALSE;
|
|
|
|
acpi_gbl_ns_lookup_count = 0;
|
|
|
|
acpi_gbl_ps_find_count = 0;
|
|
|
|
acpi_gbl_acpi_hardware_present = TRUE;
|
|
|
|
acpi_gbl_last_owner_id_index = 0;
|
|
|
|
acpi_gbl_next_owner_id_offset = 0;
|
|
|
|
acpi_gbl_debugger_configuration = DEBUGGER_THREADING;
|
|
|
|
acpi_gbl_osi_mutex = NULL;
|
|
|
|
|
|
|
|
/* Hardware oriented */
|
|
|
|
|
|
|
|
acpi_gbl_events_initialized = FALSE;
|
|
|
|
acpi_gbl_system_awake_and_running = TRUE;
|
|
|
|
|
|
|
|
/* Namespace */
|
|
|
|
|
|
|
|
acpi_gbl_root_node = NULL;
|
|
|
|
acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
|
|
|
|
acpi_gbl_root_node_struct.descriptor_type = ACPI_DESC_TYPE_NAMED;
|
|
|
|
acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
|
|
|
|
acpi_gbl_root_node_struct.parent = NULL;
|
|
|
|
acpi_gbl_root_node_struct.child = NULL;
|
|
|
|
acpi_gbl_root_node_struct.peer = NULL;
|
|
|
|
acpi_gbl_root_node_struct.object = NULL;
|
|
|
|
|
|
|
|
#ifdef ACPI_DISASSEMBLER
|
|
|
|
acpi_gbl_external_list = NULL;
|
|
|
|
acpi_gbl_num_external_methods = 0;
|
|
|
|
acpi_gbl_resolved_external_methods = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ACPI_DEBUG_OUTPUT
|
|
|
|
acpi_gbl_lowest_stack_pointer = ACPI_CAST_PTR(acpi_size, ACPI_SIZE_MAX);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
|
|
|
|
acpi_gbl_display_final_mem_stats = FALSE;
|
|
|
|
acpi_gbl_disable_mem_tracking = FALSE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
|
|
|
}
|
|
|
|
|
2012-02-14 18:14:27 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ut_terminate
|
|
|
|
*
|
|
|
|
* PARAMETERS: none
|
|
|
|
*
|
|
|
|
* RETURN: none
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Free global memory
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
static void acpi_ut_terminate(void)
|
|
|
|
{
|
|
|
|
ACPI_FUNCTION_TRACE(ut_terminate);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-14 18:14:27 +08:00
|
|
|
acpi_ut_free_gpe_lists();
|
2012-01-12 13:10:32 +08:00
|
|
|
acpi_ut_delete_address_lists();
|
2005-04-17 06:20:36 +08:00
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ut_subsystem_shutdown
|
|
|
|
*
|
2009-07-24 11:25:16 +08:00
|
|
|
* PARAMETERS: None
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2009-07-24 11:25:16 +08:00
|
|
|
* RETURN: None
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2009-07-24 11:25:16 +08:00
|
|
|
* DESCRIPTION: Shutdown the various components. Do not delete the mutex
|
|
|
|
* objects here, because the AML debugger may be still running.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
void acpi_ut_subsystem_shutdown(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
ACPI: ACPICA 20060421
Removed a device initialization optimization introduced in
20051216 where the _STA method was not run unless an _INI
was also present for the same device. This optimization
could cause problems because it could allow _INI methods
to be run within a not-present device subtree (If a
not-present device had no _INI, _STA would not be run,
the not-present status would not be discovered, and the
children of the device would be incorrectly traversed.)
Implemented a new _STA optimization where namespace
subtrees that do not contain _INI are identified and
ignored during device initialization. Selectively running
_STA can significantly improve boot time on large machines
(with assistance from Len Brown.)
Implemented support for the device initialization case
where the returned _STA flags indicate a device not-present
but functioning. In this case, _INI is not run, but the
device children are examined for presence, as per the
ACPI specification.
Implemented an additional change to the IndexField support
in order to conform to MS behavior. The value written to
the Index Register is not simply a byte offset, it is a
byte offset in units of the access width of the parent
Index Field. (Fiodor Suietov)
Defined and deployed a new OSL interface,
acpi_os_validate_address(). This interface is called during
the creation of all AML operation regions, and allows
the host OS to exert control over what addresses it will
allow the AML code to access. Operation Regions whose
addresses are disallowed will cause a runtime exception
when they are actually accessed (will not affect or abort
table loading.)
Defined and deployed a new OSL interface,
acpi_os_validate_interface(). This interface allows the host OS
to match the various "optional" interface/behavior strings
for the _OSI predefined control method as appropriate
(with assistance from Bjorn Helgaas.)
Restructured and corrected various problems in the
exception handling code paths within DsCallControlMethod
and DsTerminateControlMethod in dsmethod (with assistance
from Takayoshi Kochi.)
Modified the Linux source converter to ignore quoted string
literals while converting identifiers from mixed to lower
case. This will correct problems with the disassembler
and other areas where such strings must not be modified.
The ACPI_FUNCTION_* macros no longer require quotes around
the function name. This allows the Linux source converter
to convert the names, now that the converter ignores
quoted strings.
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2006-04-22 05:15:00 +08:00
|
|
|
ACPI_FUNCTION_TRACE(ut_subsystem_shutdown);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-10-19 10:25:42 +08:00
|
|
|
/* Just exit if subsystem is already shutdown */
|
|
|
|
|
|
|
|
if (acpi_gbl_shutdown) {
|
|
|
|
ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
|
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Subsystem appears active, go ahead and shut it down */
|
|
|
|
|
|
|
|
acpi_gbl_shutdown = TRUE;
|
|
|
|
acpi_gbl_startup_flags = 0;
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
|
|
|
|
|
2008-04-10 23:06:38 +08:00
|
|
|
#ifndef ACPI_ASL_COMPILER
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Close the acpi_event Handling */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ev_terminate();
|
2010-08-06 09:35:51 +08:00
|
|
|
|
|
|
|
/* Delete any dynamic _OSI interfaces */
|
|
|
|
|
|
|
|
acpi_ut_interface_terminate();
|
2008-04-10 23:06:38 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Close the Namespace */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ns_terminate();
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-02-03 00:48:18 +08:00
|
|
|
/* Delete the ACPI tables */
|
|
|
|
|
|
|
|
acpi_tb_terminate();
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Close the globals */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
acpi_ut_terminate();
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Purge the local caches */
|
|
|
|
|
2005-08-05 12:44:28 +08:00
|
|
|
(void)acpi_ut_delete_caches();
|
2005-04-17 06:20:36 +08:00
|
|
|
return_VOID;
|
|
|
|
}
|