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: evevent - Fixed Event handling and dispatch
|
|
|
|
*
|
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"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define _COMPONENT ACPI_EVENTS
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_MODULE_NAME("evevent")
|
2012-02-14 10:14:27 +00:00
|
|
|
#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
|
2005-04-19 02:49:35 +00:00
|
|
|
/* Local prototypes */
|
2005-08-05 04:44:28 +00:00
|
|
|
static acpi_status acpi_ev_fixed_event_initialize(void);
|
2005-04-19 02:49:35 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
static u32 acpi_ev_fixed_event_dispatch(u32 event);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_initialize_events
|
|
|
|
*
|
|
|
|
* PARAMETERS: None
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-04-19 02:49:35 +00:00
|
|
|
* DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE)
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_status acpi_ev_initialize_events(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
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_initialize_events);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-11-16 02:57:28 +00:00
|
|
|
/* If Hardware Reduced flag is set, there are no fixed events */
|
|
|
|
|
|
|
|
if (acpi_gbl_reduced_hardware) {
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
2005-04-19 02:49:35 +00:00
|
|
|
* Initialize the Fixed and General Purpose Events. This is done prior to
|
2008-11-12 08:01:56 +00:00
|
|
|
* enabling SCIs to prevent interrupts from occurring before the handlers
|
|
|
|
* are installed.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2005-08-05 04:44:28 +00:00
|
|
|
status = acpi_ev_fixed_event_initialize();
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-01-27 21:43:00 +00:00
|
|
|
ACPI_EXCEPTION((AE_INFO, status,
|
|
|
|
"Unable to initialize fixed events"));
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
status = acpi_ev_gpe_initialize();
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-01-27 21:43:00 +00:00
|
|
|
ACPI_EXCEPTION((AE_INFO, status,
|
|
|
|
"Unable to initialize general purpose events"));
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_install_xrupt_handlers
|
|
|
|
*
|
|
|
|
* PARAMETERS: None
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Install interrupt handlers for the SCI and Global Lock
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
acpi_status acpi_ev_install_xrupt_handlers(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
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_install_xrupt_handlers);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-11-16 02:57:28 +00:00
|
|
|
/* If Hardware Reduced flag is set, there is no ACPI h/w */
|
|
|
|
|
|
|
|
if (acpi_gbl_reduced_hardware) {
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Install the SCI handler */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
status = acpi_ev_install_sci_handler();
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-01-27 21:43:00 +00:00
|
|
|
ACPI_EXCEPTION((AE_INFO, status,
|
|
|
|
"Unable to install System Control Interrupt handler"));
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Install the handler for the Global Lock */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
status = acpi_ev_init_global_lock_handler();
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2006-01-27 21:43:00 +00:00
|
|
|
ACPI_EXCEPTION((AE_INFO, status,
|
|
|
|
"Unable to initialize Global Lock handler"));
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
acpi_gbl_events_initialized = TRUE;
|
2005-08-05 04:44:28 +00:00
|
|
|
return_ACPI_STATUS(status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_fixed_event_initialize
|
|
|
|
*
|
|
|
|
* PARAMETERS: None
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2009-03-06 01:49:25 +00:00
|
|
|
* DESCRIPTION: Install the fixed event handlers and disable all fixed events.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
static acpi_status acpi_ev_fixed_event_initialize(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
|
|
|
|
|
|
|
/*
|
2008-11-12 08:01:56 +00:00
|
|
|
* Initialize the structure that keeps track of fixed event handlers and
|
|
|
|
* enable the fixed events.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
|
|
|
|
acpi_gbl_fixed_event_handlers[i].handler = NULL;
|
|
|
|
acpi_gbl_fixed_event_handlers[i].context = NULL;
|
|
|
|
|
2009-03-06 01:49:25 +00:00
|
|
|
/* Disable the fixed event */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (acpi_gbl_fixed_event_info[i].enable_register_id != 0xFF) {
|
2005-08-05 04:44:28 +00:00
|
|
|
status =
|
2009-02-23 07:02:07 +00:00
|
|
|
acpi_write_bit_register(acpi_gbl_fixed_event_info
|
2009-03-06 01:49:25 +00:00
|
|
|
[i].enable_register_id,
|
|
|
|
ACPI_DISABLE_EVENT);
|
2005-08-05 04:44:28 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
return (status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_fixed_event_detect
|
|
|
|
*
|
|
|
|
* PARAMETERS: None
|
|
|
|
*
|
|
|
|
* RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
|
|
|
|
*
|
2005-04-19 02:49:35 +00:00
|
|
|
* DESCRIPTION: Checks the PM status register for active fixed events
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
u32 acpi_ev_fixed_event_detect(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2005-08-05 04:44:28 +00:00
|
|
|
u32 int_status = ACPI_INTERRUPT_NOT_HANDLED;
|
|
|
|
u32 fixed_status;
|
|
|
|
u32 fixed_enable;
|
2008-06-10 05:42:13 +00:00
|
|
|
u32 i;
|
2018-03-14 23:13:08 +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_NAME(ev_fixed_event_detect);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the fixed feature status and enable registers, as all the cases
|
2008-11-12 08:01:56 +00:00
|
|
|
* depend on their values. Ignore errors here.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2018-03-14 23:13:08 +00:00
|
|
|
status = acpi_hw_register_read(ACPI_REGISTER_PM1_STATUS, &fixed_status);
|
|
|
|
status |=
|
|
|
|
acpi_hw_register_read(ACPI_REGISTER_PM1_ENABLE, &fixed_enable);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
|
|
|
return (int_status);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_INTERRUPTS,
|
|
|
|
"Fixed Event Block: Enable %08X Status %08X\n",
|
|
|
|
fixed_enable, fixed_status));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for all possible Fixed Events and dispatch those that are active
|
|
|
|
*/
|
|
|
|
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) {
|
2006-10-02 04:00:00 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Both the status and enable bits must be on for this event */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
if ((fixed_status & acpi_gbl_fixed_event_info[i].
|
|
|
|
status_bit_mask)
|
|
|
|
&& (fixed_enable & acpi_gbl_fixed_event_info[i].
|
|
|
|
enable_bit_mask)) {
|
2010-12-13 05:39:26 +00:00
|
|
|
/*
|
|
|
|
* Found an active (signalled) event. Invoke global event
|
|
|
|
* handler if present.
|
|
|
|
*/
|
|
|
|
acpi_fixed_event_count[i]++;
|
|
|
|
if (acpi_gbl_global_event_handler) {
|
|
|
|
acpi_gbl_global_event_handler
|
|
|
|
(ACPI_EVENT_TYPE_FIXED, NULL, i,
|
|
|
|
acpi_gbl_global_event_handler_context);
|
|
|
|
}
|
2006-10-02 04:00:00 +00:00
|
|
|
|
2008-06-10 05:42:13 +00:00
|
|
|
int_status |= acpi_ev_fixed_event_dispatch(i);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int_status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: acpi_ev_fixed_event_dispatch
|
|
|
|
*
|
2012-07-12 01:40:10 +00:00
|
|
|
* PARAMETERS: event - Event type
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Clears the status bit for the requested event, calls the
|
|
|
|
* handler that previously registered for the event.
|
2013-03-08 09:21:41 +00:00
|
|
|
* NOTE: If there is no handler for the event, the event is
|
2013-04-12 00:25:10 +00:00
|
|
|
* disabled to prevent further interrupts.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
static u32 acpi_ev_fixed_event_dispatch(u32 event)
|
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
|
|
|
|
|
|
|
/* Clear the status bit */
|
|
|
|
|
2009-02-23 07:02:07 +00:00
|
|
|
(void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
|
2009-03-06 01:49:25 +00:00
|
|
|
status_register_id, ACPI_CLEAR_STATUS);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
2013-03-08 09:21:41 +00:00
|
|
|
* Make sure that a handler exists. If not, report an error
|
|
|
|
* and disable the event to prevent further interrupts.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2013-03-08 09:21:41 +00:00
|
|
|
if (!acpi_gbl_fixed_event_handlers[event].handler) {
|
2009-02-23 07:02:07 +00:00
|
|
|
(void)acpi_write_bit_register(acpi_gbl_fixed_event_info[event].
|
2009-03-06 01:49:25 +00:00
|
|
|
enable_register_id,
|
|
|
|
ACPI_DISABLE_EVENT);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-01-27 21:43:00 +00:00
|
|
|
ACPI_ERROR((AE_INFO,
|
2013-03-08 09:21:41 +00:00
|
|
|
"No installed handler for fixed event - %s (%u), disabling",
|
|
|
|
acpi_ut_get_event_name(event), event));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return (ACPI_INTERRUPT_NOT_HANDLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Invoke the Fixed Event handler */
|
|
|
|
|
2005-08-05 04:44:28 +00:00
|
|
|
return ((acpi_gbl_fixed_event_handlers[event].
|
|
|
|
handler) (acpi_gbl_fixed_event_handlers[event].context));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2012-02-14 10:14:27 +00:00
|
|
|
|
|
|
|
#endif /* !ACPI_REDUCED_HARDWARE */
|