2018-03-14 23:13:07 +00:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
|
2005-04-16 22:20:36 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: evmisc - Miscellaneous event manager support functions
|
|
|
|
*
|
2018-01-04 18:06:38 +00:00
|
|
|
* Copyright (C) 2000 - 2018, Intel Corp.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
2018-03-14 23:13:07 +00:00
|
|
|
*****************************************************************************/
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <acpi/acpi.h>
|
2009-01-09 05:30:03 +00:00
|
|
|
#include "accommon.h"
|
|
|
|
#include "acevents.h"
|
|
|
|
#include "acnamesp.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_EVENTS
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_MODULE_NAME("evmisc")
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-04-19 02:49:35 +00:00
|
|
|
/* Local prototypes */
|
2005-08-05 04:44:28 +00:00
|
|
|
static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context);
|
2005-04-19 02:49:35 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_is_notify_object
|
|
|
|
*
|
2012-07-12 01:40:10 +00:00
|
|
|
* PARAMETERS: node - Node to check
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* RETURN: TRUE if notifies allowed on this object
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Check type of node for a object that supports notifies.
|
|
|
|
*
|
|
|
|
* TBD: This could be replaced by a flag bit in the node.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
u8 acpi_ev_is_notify_object(struct acpi_namespace_node *node)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2015-12-29 05:54:36 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
switch (node->type) {
|
|
|
|
case ACPI_TYPE_DEVICE:
|
|
|
|
case ACPI_TYPE_PROCESSOR:
|
|
|
|
case ACPI_TYPE_THERMAL:
|
|
|
|
/*
|
|
|
|
* These are the ONLY objects that can receive ACPI notifications
|
|
|
|
*/
|
|
|
|
return (TRUE);
|
|
|
|
|
|
|
|
default:
|
2013-06-08 00:58:14 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return (FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_queue_notify_request
|
|
|
|
*
|
2012-07-12 01:40:10 +00:00
|
|
|
* PARAMETERS: node - NS node for the notified object
|
2005-04-16 22:20:36 +00:00
|
|
|
* notify_value - Value from the Notify() request
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Dispatch a device notification event to a previously
|
|
|
|
* installed handler.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
acpi_status
|
2016-05-05 04:57:53 +00:00
|
|
|
acpi_ev_queue_notify_request(struct acpi_namespace_node *node, u32 notify_value)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
union acpi_operand_object *obj_desc;
|
2012-05-03 03:08:19 +00:00
|
|
|
union acpi_operand_object *handler_list_head = NULL;
|
|
|
|
union acpi_generic_state *info;
|
|
|
|
u8 handler_list_id = 0;
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_status status = AE_OK;
|
2005-04-16 22:20:36 +00: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-21 21:15:00 +00:00
|
|
|
ACPI_FUNCTION_NAME(ev_queue_notify_request);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
/* Are Notifies allowed on this object? */
|
2006-10-02 04:00:00 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
if (!acpi_ev_is_notify_object(node)) {
|
|
|
|
return (AE_TYPE);
|
|
|
|
}
|
2008-04-10 15:06:44 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
/* Get the correct notify list type (System or Device) */
|
2008-04-10 15:06:44 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
if (notify_value <= ACPI_MAX_SYS_NOTIFY) {
|
|
|
|
handler_list_id = ACPI_SYSTEM_HANDLER_LIST;
|
|
|
|
} else {
|
|
|
|
handler_list_id = ACPI_DEVICE_HANDLER_LIST;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
/* Get the notify object attached to the namespace Node */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
obj_desc = acpi_ns_get_attached_object(node);
|
|
|
|
if (obj_desc) {
|
2008-11-12 08:01:56 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
/* We have an attached object, Get the correct handler list */
|
2008-11-12 08:01:56 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
handler_list_head =
|
|
|
|
obj_desc->common_notify.notify_list[handler_list_id];
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-04-10 15:06:44 +00:00
|
|
|
/*
|
2012-05-03 03:08:19 +00:00
|
|
|
* If there is no notify handler (Global or Local)
|
|
|
|
* for this object, just ignore the notify
|
2008-04-10 15:06:44 +00:00
|
|
|
*/
|
2012-05-03 03:08:19 +00:00
|
|
|
if (!acpi_gbl_global_notify[handler_list_id].handler
|
|
|
|
&& !handler_list_head) {
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
2012-05-03 03:08:19 +00:00
|
|
|
"No notify handler for Notify, ignoring (%4.4s, %X) node %p\n",
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_ut_get_node_name(node), notify_value,
|
|
|
|
node));
|
2012-05-03 03:08:19 +00:00
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup notify info and schedule the notify dispatcher */
|
|
|
|
|
|
|
|
info = acpi_ut_create_generic_state();
|
|
|
|
if (!info) {
|
|
|
|
return (AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
info->common.descriptor_type = ACPI_DESC_TYPE_STATE_NOTIFY;
|
|
|
|
|
|
|
|
info->notify.node = node;
|
|
|
|
info->notify.value = (u16)notify_value;
|
|
|
|
info->notify.handler_list_id = handler_list_id;
|
|
|
|
info->notify.handler_list_head = handler_list_head;
|
|
|
|
info->notify.global = &acpi_gbl_global_notify[handler_list_id];
|
|
|
|
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
|
|
|
"Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n",
|
|
|
|
acpi_ut_get_node_name(node),
|
|
|
|
acpi_ut_get_type_name(node->type), notify_value,
|
2014-04-04 04:37:44 +00:00
|
|
|
acpi_ut_get_notify_name(notify_value, ACPI_TYPE_ANY),
|
|
|
|
node));
|
2012-05-03 03:08:19 +00:00
|
|
|
|
2015-12-29 05:54:36 +00:00
|
|
|
status = acpi_os_execute(OSL_NOTIFY_HANDLER,
|
|
|
|
acpi_ev_notify_dispatch, info);
|
2012-05-03 03:08:19 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
acpi_ut_delete_generic_state(info);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_notify_dispatch
|
|
|
|
*
|
2012-07-12 01:40:10 +00:00
|
|
|
* PARAMETERS: context - To be passed to the notify handler
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* RETURN: None.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Dispatch a device notification event to a previously
|
|
|
|
* installed handler.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
static void ACPI_SYSTEM_XFACE acpi_ev_notify_dispatch(void *context)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-05-03 03:08:19 +00:00
|
|
|
union acpi_generic_state *info = (union acpi_generic_state *)context;
|
2005-08-05 04:44:28 +00:00
|
|
|
union acpi_operand_object *handler_obj;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_FUNCTION_ENTRY();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
/* Invoke a global notify handler if installed */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
if (info->notify.global->handler) {
|
|
|
|
info->notify.global->handler(info->notify.node,
|
|
|
|
info->notify.value,
|
|
|
|
info->notify.global->context);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
/* Now invoke the local notify handler(s) if any are installed */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
handler_obj = info->notify.handler_list_head;
|
|
|
|
while (handler_obj) {
|
|
|
|
handler_obj->notify.handler(info->notify.node,
|
|
|
|
info->notify.value,
|
|
|
|
handler_obj->notify.context);
|
2010-02-17 22:42:59 +00:00
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
handler_obj =
|
|
|
|
handler_obj->notify.next[info->notify.handler_list_id];
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* All done with the info object */
|
|
|
|
|
2012-05-03 03:08:19 +00:00
|
|
|
acpi_ut_delete_generic_state(info);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-02-14 10:14:27 +00:00
|
|
|
#if (!ACPI_REDUCED_HARDWARE)
|
2005-04-16 22:20:36 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_terminate
|
|
|
|
*
|
|
|
|
* PARAMETERS: none
|
|
|
|
*
|
|
|
|
* RETURN: none
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Disable events and free memory allocated for table storage.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
void acpi_ev_terminate(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-06-10 05:42:13 +00:00
|
|
|
u32 i;
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_status status;
|
2005-04-16 22:20:36 +00: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-21 21:15:00 +00:00
|
|
|
ACPI_FUNCTION_TRACE(ev_terminate);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (acpi_gbl_events_initialized) {
|
|
|
|
/*
|
2008-11-12 08:01:56 +00:00
|
|
|
* Disable all event-related functionality. In all cases, on error,
|
|
|
|
* print a message but obviously we don't abort.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Disable all fixed events */
|
|
|
|
|
|
|
|
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
|
2008-06-10 05:42:13 +00:00
|
|
|
status = acpi_disable_event(i, 0);
|
2005-08-05 04:44:28 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-01-27 21:43:00 +00:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2010-03-05 09:56:40 +00:00
|
|
|
"Could not disable fixed event %u",
|
2006-01-27 21:43:00 +00:00
|
|
|
(u32) i));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable all GPEs in all GPE blocks */
|
|
|
|
|
2008-12-30 01:45:17 +00:00
|
|
|
status = acpi_ev_walk_gpe_list(acpi_hw_disable_gpe_block, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-02-02 16:48:22 +00:00
|
|
|
status = acpi_ev_remove_global_lock_handler();
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
ACPI_ERROR((AE_INFO,
|
|
|
|
"Could not remove Global Lock handler"));
|
|
|
|
}
|
2013-06-08 01:00:23 +00:00
|
|
|
|
|
|
|
acpi_gbl_events_initialized = FALSE;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2013-09-23 01:52:05 +00:00
|
|
|
/* Remove SCI handlers */
|
|
|
|
|
|
|
|
status = acpi_ev_remove_all_sci_handlers();
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
ACPI_ERROR((AE_INFO, "Could not remove SCI handler"));
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Deallocate all handler objects installed within GPE info structs */
|
|
|
|
|
2008-12-30 01:45:17 +00:00
|
|
|
status = acpi_ev_walk_gpe_list(acpi_ev_delete_gpe_handlers, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Return to original mode if necessary */
|
|
|
|
|
|
|
|
if (acpi_gbl_original_mode == ACPI_SYS_MODE_LEGACY) {
|
2005-08-05 04:44:28 +00:00
|
|
|
status = acpi_disable();
|
|
|
|
if (ACPI_FAILURE(status)) {
|
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-21 21:15:00 +00:00
|
|
|
ACPI_WARNING((AE_INFO, "AcpiDisable failed"));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return_VOID;
|
|
|
|
}
|
2012-02-14 10:14:27 +00:00
|
|
|
|
|
|
|
#endif /* !ACPI_REDUCED_HARDWARE */
|