Commit 7b738064 authored by Bob Moore's avatar Bob Moore Committed by Rafael J. Wysocki

ACPICA: Cleanup code related to the per-table module level improvement

ACPICA commit 071eff738c59eda1792ac24b3b688b61691d7e7c

This patch collects cleanups from per-table module level improvement. By
splitting this patch from that commit, we can make per-table module level
improvement clearer for the revewers. This is a no-op change.

Link: https://github.com/acpica/acpica/commit/071eff73Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 3c5d3d25
...@@ -145,6 +145,7 @@ ACPI_GLOBAL(acpi_cache_t *, acpi_gbl_operand_cache); ...@@ -145,6 +145,7 @@ ACPI_GLOBAL(acpi_cache_t *, acpi_gbl_operand_cache);
ACPI_INIT_GLOBAL(u32, acpi_gbl_startup_flags, 0); ACPI_INIT_GLOBAL(u32, acpi_gbl_startup_flags, 0);
ACPI_INIT_GLOBAL(u8, acpi_gbl_shutdown, TRUE); ACPI_INIT_GLOBAL(u8, acpi_gbl_shutdown, TRUE);
ACPI_INIT_GLOBAL(u8, acpi_gbl_early_initialization, TRUE);
/* Global handlers */ /* Global handlers */
......
...@@ -55,6 +55,10 @@ static acpi_status ...@@ -55,6 +55,10 @@ static acpi_status
acpi_ev_install_handler(acpi_handle obj_handle, acpi_ev_install_handler(acpi_handle obj_handle,
u32 level, void *context, void **return_value); u32 level, void *context, void **return_value);
static union acpi_operand_object
*acpi_ev_find_region_handler(acpi_adr_space_type space_id,
union acpi_operand_object *handler_obj);
/* These are the address spaces that will get default handlers */ /* These are the address spaces that will get default handlers */
u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = { u8 acpi_gbl_default_address_spaces[ACPI_NUM_DEFAULT_SPACES] = {
...@@ -307,6 +311,43 @@ acpi_ev_install_handler(acpi_handle obj_handle, ...@@ -307,6 +311,43 @@ acpi_ev_install_handler(acpi_handle obj_handle,
return (status); return (status);
} }
/*******************************************************************************
*
* FUNCTION: acpi_ev_find_region_handler
*
* PARAMETERS: space_id - The address space ID
* handler_obj - Head of the handler object list
*
* RETURN: Matching handler object. NULL if space ID not matched
*
* DESCRIPTION: Search a handler object list for a match on the address
* space ID.
*
******************************************************************************/
static union acpi_operand_object
*acpi_ev_find_region_handler(acpi_adr_space_type space_id,
union acpi_operand_object *handler_obj)
{
/* Walk the handler list for this device */
while (handler_obj) {
/* Same space_id indicates a handler is installed */
if (handler_obj->address_space.space_id == space_id) {
return (handler_obj);
}
/* Next handler object */
handler_obj = handler_obj->address_space.next;
}
return (NULL);
}
/******************************************************************************* /*******************************************************************************
* *
* FUNCTION: acpi_ev_install_space_handler * FUNCTION: acpi_ev_install_space_handler
...@@ -332,15 +373,15 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node, ...@@ -332,15 +373,15 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
{ {
union acpi_operand_object *obj_desc; union acpi_operand_object *obj_desc;
union acpi_operand_object *handler_obj; union acpi_operand_object *handler_obj;
acpi_status status; acpi_status status = AE_OK;
acpi_object_type type; acpi_object_type type;
u8 flags = 0; u8 flags = 0;
ACPI_FUNCTION_TRACE(ev_install_space_handler); ACPI_FUNCTION_TRACE(ev_install_space_handler);
/* /*
* This registration is valid for only the types below and the root. This * This registration is valid for only the types below and the root.
* is where the default handlers get placed. * The root node is where the default handlers get installed.
*/ */
if ((node->type != ACPI_TYPE_DEVICE) && if ((node->type != ACPI_TYPE_DEVICE) &&
(node->type != ACPI_TYPE_PROCESSOR) && (node->type != ACPI_TYPE_PROCESSOR) &&
...@@ -407,38 +448,29 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node, ...@@ -407,38 +448,29 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
obj_desc = acpi_ns_get_attached_object(node); obj_desc = acpi_ns_get_attached_object(node);
if (obj_desc) { if (obj_desc) {
/* /*
* The attached device object already exists. Make sure the handler * The attached device object already exists. Now make sure
* is not already installed. * the handler is not already installed.
*/ */
handler_obj = obj_desc->device.handler; handler_obj = acpi_ev_find_region_handler(space_id,
obj_desc->device.
/* Walk the handler list for this device */ handler);
while (handler_obj) {
/* Same space_id indicates a handler already installed */ if (handler_obj) {
if (handler_obj->address_space.handler == handler) {
if (handler_obj->address_space.space_id == space_id) { /*
if (handler_obj->address_space.handler == * It is (relatively) OK to attempt to install the SAME
handler) { * handler twice. This can easily happen with the
/* * PCI_Config space.
* It is (relatively) OK to attempt to install the SAME */
* handler twice. This can easily happen with the status = AE_SAME_HANDLER;
* PCI_Config space.
*/
status = AE_SAME_HANDLER;
goto unlock_and_exit;
} else {
/* A handler is already installed */
status = AE_ALREADY_EXISTS;
}
goto unlock_and_exit; goto unlock_and_exit;
} } else {
/* A handler is already installed */
/* Walk the linked list of handlers */ status = AE_ALREADY_EXISTS;
}
handler_obj = handler_obj->address_space.next; goto unlock_and_exit;
} }
} else { } else {
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
...@@ -477,7 +509,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node, ...@@ -477,7 +509,8 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
} }
ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, ACPI_DEBUG_PRINT((ACPI_DB_OPREGION,
"Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n", "Installing address handler for region %s(%X) "
"on Device %4.4s %p(%p)\n",
acpi_ut_get_region_name(space_id), space_id, acpi_ut_get_region_name(space_id), space_id,
acpi_ut_get_node_name(node), node, obj_desc)); acpi_ut_get_node_name(node), node, obj_desc));
...@@ -515,19 +548,17 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node, ...@@ -515,19 +548,17 @@ acpi_ev_install_space_handler(struct acpi_namespace_node * node,
obj_desc->device.handler = handler_obj; obj_desc->device.handler = handler_obj;
/* /*
* Walk the namespace finding all of the regions this * Walk the namespace finding all of the regions this handler will
* handler will manage. * manage.
* *
* Start at the device and search the branch toward * Start at the device and search the branch toward the leaf nodes
* the leaf nodes until either the leaf is encountered or * until either the leaf is encountered or a device is detected that
* a device is detected that has an address handler of the * has an address handler of the same type.
* same type.
* *
* In either case, back up and search down the remainder * In either case, back up and search down the remainder of the branch
* of the branch
*/ */
status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node, ACPI_UINT32_MAX, status = acpi_ns_walk_namespace(ACPI_TYPE_ANY, node,
ACPI_NS_WALK_UNLOCK, ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
acpi_ev_install_handler, NULL, acpi_ev_install_handler, NULL,
handler_obj, NULL); handler_obj, NULL);
......
...@@ -127,6 +127,12 @@ acpi_status acpi_ev_initialize_op_regions(void) ...@@ -127,6 +127,12 @@ acpi_status acpi_ev_initialize_op_regions(void)
* DESCRIPTION: Dispatch an address space or operation region access to * DESCRIPTION: Dispatch an address space or operation region access to
* a previously installed handler. * a previously installed handler.
* *
* NOTE: During early initialization, we always install the default region
* handlers for Memory, I/O and PCI_Config. This ensures that these operation
* region address spaces are always available as per the ACPI specification.
* This is especially needed in order to support the execution of
* module-level AML code during loading of the ACPI tables.
*
******************************************************************************/ ******************************************************************************/
acpi_status acpi_status
......
...@@ -552,7 +552,7 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj, ...@@ -552,7 +552,7 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
/* /*
* The following loop depends upon the root Node having no parent * The following loop depends upon the root Node having no parent
* ie: acpi_gbl_root_node->parent_entry being set to NULL * ie: acpi_gbl_root_node->Parent being set to NULL
*/ */
while (node) { while (node) {
......
...@@ -508,7 +508,8 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc, ...@@ -508,7 +508,8 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
if (next) { if (next) {
acpi_os_printf("(%s %2.2X)", acpi_os_printf("(%s %2.2X)",
acpi_ut_get_object_type_name acpi_ut_get_object_type_name
(next), next->common.type); (next),
next->address_space.space_id);
while (next->address_space.next) { while (next->address_space.next) {
if ((next->common.type == if ((next->common.type ==
...@@ -520,7 +521,8 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc, ...@@ -520,7 +521,8 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
acpi_os_printf("->%p(%s %2.2X)", next, acpi_os_printf("->%p(%s %2.2X)", next,
acpi_ut_get_object_type_name acpi_ut_get_object_type_name
(next), (next),
next->common.type); next->address_space.
space_id);
if ((next == start) || (next == data)) { if ((next == start) || (next == data)) {
acpi_os_printf acpi_os_printf
......
...@@ -147,6 +147,13 @@ acpi_status __init acpi_enable_subsystem(u32 flags) ...@@ -147,6 +147,13 @@ acpi_status __init acpi_enable_subsystem(u32 flags)
ACPI_FUNCTION_TRACE(acpi_enable_subsystem); ACPI_FUNCTION_TRACE(acpi_enable_subsystem);
/*
* The early initialization phase is complete. The namespace is loaded,
* and we can now support address spaces other than Memory, I/O, and
* PCI_Config.
*/
acpi_gbl_early_initialization = FALSE;
#if (!ACPI_REDUCED_HARDWARE) #if (!ACPI_REDUCED_HARDWARE)
/* Enable ACPI mode */ /* Enable ACPI mode */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment