2000-10-28 05:01:06 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Module Name: evxface - External interfaces for ACPI events
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2011-01-13 16:12:34 +00:00
|
|
|
/*
|
2012-01-11 21:25:42 +00:00
|
|
|
* Copyright (C) 2000 - 2012, Intel Corp.
|
2000-12-21 06:56:46 +00:00
|
|
|
* All rights reserved.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2011-01-13 16:12:34 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification.
|
|
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
|
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
|
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
|
|
|
* including a substantially similar Disclaimer requirement for further
|
|
|
|
* binary redistribution.
|
|
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
|
|
|
* of any contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* NO WARRANTY
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
|
|
|
*/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define __EVXFACE_C__
|
|
|
|
|
2009-06-01 19:24:26 +00:00
|
|
|
#include "acpi.h"
|
2009-06-01 21:02:40 +00:00
|
|
|
#include "accommon.h"
|
2009-06-01 19:24:26 +00:00
|
|
|
#include "acnamesp.h"
|
|
|
|
#include "acevents.h"
|
|
|
|
#include "acinterp.h"
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
#define _COMPONENT ACPI_EVENTS
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_MODULE_NAME ("evxface")
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiInstallNotifyHandler
|
|
|
|
*
|
|
|
|
* PARAMETERS: Device - The device for which notifies will be handled
|
|
|
|
* HandlerType - The type of handler:
|
2012-04-20 23:39:48 +00:00
|
|
|
* ACPI_SYSTEM_NOTIFY: System Handler (00-7F)
|
|
|
|
* ACPI_DEVICE_NOTIFY: Device Handler (80-FF)
|
|
|
|
* ACPI_ALL_NOTIFY: Both System and Device
|
2000-10-28 05:01:06 +00:00
|
|
|
* Handler - Address of the handler
|
|
|
|
* Context - Value passed to the handler on each GPE
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2012-04-20 23:39:48 +00:00
|
|
|
* DESCRIPTION: Install a handler for notifications on an ACPI Device,
|
|
|
|
* ThermalZone, or Processor object.
|
|
|
|
*
|
|
|
|
* NOTES: The Root namespace object may have only one handler for each
|
|
|
|
* type of notify (System/Device). Device/Thermal/Processor objects
|
|
|
|
* may have one device notify handler, and multiple system notify
|
|
|
|
* handlers.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiInstallNotifyHandler (
|
|
|
|
ACPI_HANDLE Device,
|
|
|
|
UINT32 HandlerType,
|
2001-05-29 19:52:40 +00:00
|
|
|
ACPI_NOTIFY_HANDLER Handler,
|
2000-10-28 05:01:06 +00:00
|
|
|
void *Context)
|
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Device);
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_OPERAND_OBJECT *ObjDesc;
|
2012-04-20 23:39:48 +00:00
|
|
|
ACPI_OPERAND_OBJECT *HandlerObj;
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_STATUS Status;
|
2012-04-20 23:39:48 +00:00
|
|
|
UINT32 i;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (AcpiInstallNotifyHandler);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
if ((!Device) || (!Handler) || (!HandlerType) ||
|
2000-10-28 05:01:06 +00:00
|
|
|
(HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/*
|
2001-01-31 09:17:50 +00:00
|
|
|
* Root Object:
|
|
|
|
* Registering a notify handler on the root object indicates that the
|
2009-06-01 21:02:40 +00:00
|
|
|
* caller wishes to receive notifications for all objects. Note that
|
2012-04-20 23:39:48 +00:00
|
|
|
* only one global handler can be registered per notify type.
|
|
|
|
* Ensure that a handler is not already installed.
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
|
|
|
if (Device == ACPI_ROOT_OBJECT)
|
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
if (HandlerType & (i+1))
|
|
|
|
{
|
|
|
|
if (AcpiGbl_GlobalNotify[i].Handler)
|
|
|
|
{
|
|
|
|
Status = AE_ALREADY_EXISTS;
|
|
|
|
goto UnlockAndExit;
|
|
|
|
}
|
|
|
|
|
|
|
|
AcpiGbl_GlobalNotify[i].Handler = Handler;
|
|
|
|
AcpiGbl_GlobalNotify[i].Context = Context;
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
goto UnlockAndExit; /* Global notify handler installed, all done */
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-10-31 02:32:29 +00:00
|
|
|
* All Other Objects:
|
2012-04-20 23:39:48 +00:00
|
|
|
* Caller will only receive notifications specific to the target
|
|
|
|
* object. Note that only certain object types are allowed to
|
|
|
|
* receive notifications.
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
2012-04-20 23:39:48 +00:00
|
|
|
|
|
|
|
/* Are Notifies allowed on this object? */
|
|
|
|
|
|
|
|
if (!AcpiEvIsNotifyObject (Node))
|
2001-10-31 02:32:29 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
Status = AE_TYPE;
|
|
|
|
goto UnlockAndExit;
|
|
|
|
}
|
2002-06-30 17:50:46 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Check for an existing internal object, might not exist */
|
|
|
|
|
|
|
|
ObjDesc = AcpiNsGetAttachedObject (Node);
|
|
|
|
if (!ObjDesc)
|
|
|
|
{
|
|
|
|
/* Create a new object */
|
|
|
|
|
|
|
|
ObjDesc = AcpiUtCreateInternalObject (Node->Type);
|
|
|
|
if (!ObjDesc)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
Status = AE_NO_MEMORY;
|
2000-10-28 05:01:06 +00:00
|
|
|
goto UnlockAndExit;
|
|
|
|
}
|
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Attach new object to the Node, remove local reference */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
Status = AcpiNsAttachObject (Device, ObjDesc, Node->Type);
|
|
|
|
AcpiUtRemoveReference (ObjDesc);
|
|
|
|
if (ACPI_FAILURE (Status))
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
goto UnlockAndExit;
|
2001-01-31 09:17:50 +00:00
|
|
|
}
|
2012-04-20 23:39:48 +00:00
|
|
|
}
|
2003-07-13 22:44:13 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Ensure that the handler is not already installed in the lists */
|
2003-07-13 22:44:13 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
|
|
|
|
{
|
|
|
|
if (HandlerType & (i+1))
|
|
|
|
{
|
|
|
|
HandlerObj = ObjDesc->CommonNotify.NotifyList[i];
|
|
|
|
while (HandlerObj)
|
2001-01-31 09:17:50 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
if (HandlerObj->Notify.Handler == Handler)
|
|
|
|
{
|
|
|
|
Status = AE_ALREADY_EXISTS;
|
|
|
|
goto UnlockAndExit;
|
|
|
|
}
|
|
|
|
|
|
|
|
HandlerObj = HandlerObj->Notify.Next[i];
|
2001-01-31 09:17:50 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-20 23:39:48 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Create and populate a new notify handler object */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
HandlerObj = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_NOTIFY);
|
|
|
|
if (!HandlerObj)
|
|
|
|
{
|
|
|
|
Status = AE_NO_MEMORY;
|
|
|
|
goto UnlockAndExit;
|
|
|
|
}
|
2001-01-31 09:17:50 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
HandlerObj->Notify.Node = Node;
|
|
|
|
HandlerObj->Notify.HandlerType = HandlerType;
|
|
|
|
HandlerObj->Notify.Handler = Handler;
|
|
|
|
HandlerObj->Notify.Context = Context;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Install the handler at the list head(s) */
|
2004-05-25 02:34:44 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
|
|
|
|
{
|
|
|
|
if (HandlerType & (i+1))
|
2001-01-31 09:17:50 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
HandlerObj->Notify.Next[i] =
|
|
|
|
ObjDesc->CommonNotify.NotifyList[i];
|
|
|
|
|
|
|
|
ObjDesc->CommonNotify.NotifyList[i] = HandlerObj;
|
2001-01-31 09:17:50 +00:00
|
|
|
}
|
2012-04-20 23:39:48 +00:00
|
|
|
}
|
2004-05-25 02:34:44 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Add an extra reference if handler was installed in both lists */
|
2004-05-25 02:34:44 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
if (HandlerType == ACPI_ALL_NOTIFY)
|
|
|
|
{
|
|
|
|
AcpiUtAddReference (HandlerObj);
|
2001-01-31 09:17:50 +00:00
|
|
|
}
|
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
UnlockAndExit:
|
2002-02-23 05:10:40 +00:00
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiInstallNotifyHandler)
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiRemoveNotifyHandler
|
|
|
|
*
|
2012-04-20 23:39:48 +00:00
|
|
|
* PARAMETERS: Device - The device for which the handler is installed
|
2000-10-28 05:01:06 +00:00
|
|
|
* HandlerType - The type of handler:
|
2012-04-20 23:39:48 +00:00
|
|
|
* ACPI_SYSTEM_NOTIFY: System Handler (00-7F)
|
|
|
|
* ACPI_DEVICE_NOTIFY: Device Handler (80-FF)
|
|
|
|
* ACPI_ALL_NOTIFY: Both System and Device
|
2000-10-28 05:01:06 +00:00
|
|
|
* Handler - Address of the handler
|
2004-12-01 23:14:10 +00:00
|
|
|
*
|
2000-10-28 05:01:06 +00:00
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Remove a handler for notifies on an ACPI device
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiRemoveNotifyHandler (
|
|
|
|
ACPI_HANDLE Device,
|
|
|
|
UINT32 HandlerType,
|
2001-05-29 19:52:40 +00:00
|
|
|
ACPI_NOTIFY_HANDLER Handler)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Device);
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_OPERAND_OBJECT *ObjDesc;
|
2012-04-20 23:39:48 +00:00
|
|
|
ACPI_OPERAND_OBJECT *HandlerObj;
|
|
|
|
ACPI_OPERAND_OBJECT *PreviousHandlerObj;
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_STATUS Status;
|
2012-04-20 23:39:48 +00:00
|
|
|
UINT32 i;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (AcpiRemoveNotifyHandler);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
/* Parameter validation */
|
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
if ((!Device) || (!Handler) || (!HandlerType) ||
|
2000-10-28 05:01:06 +00:00
|
|
|
(HandlerType > ACPI_MAX_NOTIFY_HANDLER_TYPE))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
#ifdef _UNDER_DEVELOPMENT
|
|
|
|
/* Make sure all deferred tasks are completed */
|
|
|
|
|
|
|
|
AcpiOsWaitEventsComplete (NULL);
|
|
|
|
#endif
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Root Object. Global handlers are removed here */
|
2004-12-01 23:14:10 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
if (Device == ACPI_ROOT_OBJECT)
|
2001-10-31 02:32:29 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
|
2001-10-31 02:32:29 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
if (HandlerType & (i+1))
|
|
|
|
{
|
|
|
|
if (!AcpiGbl_GlobalNotify[i].Handler ||
|
|
|
|
(AcpiGbl_GlobalNotify[i].Handler != Handler))
|
|
|
|
{
|
|
|
|
Status = AE_NOT_EXIST;
|
|
|
|
goto UnlockAndExit;
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
|
|
|
|
"Removing global notify handler\n"));
|
|
|
|
|
|
|
|
AcpiGbl_GlobalNotify[i].Handler = NULL;
|
|
|
|
AcpiGbl_GlobalNotify[i].Context = NULL;
|
|
|
|
}
|
2001-01-31 09:17:50 +00:00
|
|
|
}
|
2004-05-25 02:34:44 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
goto UnlockAndExit;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* All other objects: Are Notifies allowed on this object? */
|
2004-12-01 23:14:10 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
if (!AcpiEvIsNotifyObject (Node))
|
2001-10-31 02:32:29 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
Status = AE_TYPE;
|
|
|
|
goto UnlockAndExit;
|
|
|
|
}
|
2002-06-30 17:50:46 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Must have an existing internal object */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
ObjDesc = AcpiNsGetAttachedObject (Node);
|
|
|
|
if (!ObjDesc)
|
|
|
|
{
|
|
|
|
Status = AE_NOT_EXIST;
|
|
|
|
goto UnlockAndExit;
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Internal object exists. Find the handler and remove it */
|
|
|
|
|
|
|
|
for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
|
|
|
|
{
|
|
|
|
if (HandlerType & (i+1))
|
2001-01-31 09:17:50 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
HandlerObj = ObjDesc->CommonNotify.NotifyList[i];
|
|
|
|
PreviousHandlerObj = NULL;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Attempt to find the handler in the handler list */
|
2001-01-31 09:17:50 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
while (HandlerObj &&
|
|
|
|
(HandlerObj->Notify.Handler != Handler))
|
2007-03-22 17:24:05 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
PreviousHandlerObj = HandlerObj;
|
|
|
|
HandlerObj = HandlerObj->Notify.Next[i];
|
2007-03-22 17:24:05 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
if (!HandlerObj)
|
2004-05-25 02:34:44 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
Status = AE_NOT_EXIST;
|
2004-05-25 02:34:44 +00:00
|
|
|
goto UnlockAndExit;
|
|
|
|
}
|
2001-01-31 09:17:50 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
/* Remove the handler object from the list */
|
2004-05-25 02:34:44 +00:00
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
if (PreviousHandlerObj) /* Handler is not at the list head */
|
2007-03-22 17:24:05 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
PreviousHandlerObj->Notify.Next[i] =
|
|
|
|
HandlerObj->Notify.Next[i];
|
2007-03-22 17:24:05 +00:00
|
|
|
}
|
2012-04-20 23:39:48 +00:00
|
|
|
else /* Handler is at the list head */
|
2004-05-25 02:34:44 +00:00
|
|
|
{
|
2012-04-20 23:39:48 +00:00
|
|
|
ObjDesc->CommonNotify.NotifyList[i] =
|
|
|
|
HandlerObj->Notify.Next[i];
|
2004-05-25 02:34:44 +00:00
|
|
|
}
|
|
|
|
|
2012-04-20 23:39:48 +00:00
|
|
|
AcpiUtRemoveReference (HandlerObj);
|
2001-01-31 09:17:50 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UnlockAndExit:
|
2002-02-23 05:10:40 +00:00
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiRemoveNotifyHandler)
|
|
|
|
|
2001-01-31 09:17:50 +00:00
|
|
|
|
2012-02-16 00:24:10 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiInstallExceptionHandler
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handler - Pointer to the handler function for the
|
|
|
|
* event
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Saves the pointer to the handler function
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiInstallExceptionHandler (
|
|
|
|
ACPI_EXCEPTION_HANDLER Handler)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE (AcpiInstallExceptionHandler);
|
|
|
|
|
|
|
|
|
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't allow two handlers. */
|
|
|
|
|
|
|
|
if (AcpiGbl_ExceptionHandler)
|
|
|
|
{
|
|
|
|
Status = AE_ALREADY_EXISTS;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Install the handler */
|
|
|
|
|
|
|
|
AcpiGbl_ExceptionHandler = Handler;
|
|
|
|
|
|
|
|
Cleanup:
|
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_EXPORT_SYMBOL (AcpiInstallExceptionHandler)
|
|
|
|
|
|
|
|
|
|
|
|
#if (!ACPI_REDUCED_HARDWARE)
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiInstallGlobalEventHandler
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handler - Pointer to the global event handler function
|
|
|
|
* Context - Value passed to the handler on each event
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Saves the pointer to the handler function. The global handler
|
|
|
|
* is invoked upon each incoming GPE and Fixed Event. It is
|
|
|
|
* invoked at interrupt level at the time of the event dispatch.
|
|
|
|
* Can be used to update event counters, etc.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiInstallGlobalEventHandler (
|
|
|
|
ACPI_GBL_EVENT_HANDLER Handler,
|
|
|
|
void *Context)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE (AcpiInstallGlobalEventHandler);
|
|
|
|
|
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
|
|
|
if (!Handler)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't allow two handlers. */
|
|
|
|
|
|
|
|
if (AcpiGbl_GlobalEventHandler)
|
|
|
|
{
|
|
|
|
Status = AE_ALREADY_EXISTS;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
AcpiGbl_GlobalEventHandler = Handler;
|
|
|
|
AcpiGbl_GlobalEventHandlerContext = Context;
|
|
|
|
|
|
|
|
|
|
|
|
Cleanup:
|
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_EXPORT_SYMBOL (AcpiInstallGlobalEventHandler)
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiInstallFixedEventHandler
|
|
|
|
*
|
|
|
|
* PARAMETERS: Event - Event type to enable.
|
|
|
|
* Handler - Pointer to the handler function for the
|
|
|
|
* event
|
|
|
|
* Context - Value passed to the handler on each GPE
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Saves the pointer to the handler function and then enables the
|
|
|
|
* event.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiInstallFixedEventHandler (
|
|
|
|
UINT32 Event,
|
|
|
|
ACPI_EVENT_HANDLER Handler,
|
|
|
|
void *Context)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE (AcpiInstallFixedEventHandler);
|
|
|
|
|
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
|
|
|
if (Event > ACPI_EVENT_MAX)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Don't allow two handlers. */
|
|
|
|
|
|
|
|
if (NULL != AcpiGbl_FixedEventHandlers[Event].Handler)
|
|
|
|
{
|
|
|
|
Status = AE_ALREADY_EXISTS;
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Install the handler before enabling the event */
|
|
|
|
|
|
|
|
AcpiGbl_FixedEventHandlers[Event].Handler = Handler;
|
|
|
|
AcpiGbl_FixedEventHandlers[Event].Context = Context;
|
|
|
|
|
|
|
|
Status = AcpiEnableEvent (Event, 0);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
ACPI_WARNING ((AE_INFO, "Could not enable fixed event 0x%X", Event));
|
|
|
|
|
|
|
|
/* Remove the handler */
|
|
|
|
|
|
|
|
AcpiGbl_FixedEventHandlers[Event].Handler = NULL;
|
|
|
|
AcpiGbl_FixedEventHandlers[Event].Context = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
|
|
|
|
"Enabled fixed event %X, Handler=%p\n", Event, Handler));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Cleanup:
|
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_EXPORT_SYMBOL (AcpiInstallFixedEventHandler)
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiRemoveFixedEventHandler
|
|
|
|
*
|
|
|
|
* PARAMETERS: Event - Event type to disable.
|
|
|
|
* Handler - Address of the handler
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Disables the event and unregisters the event handler.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiRemoveFixedEventHandler (
|
|
|
|
UINT32 Event,
|
|
|
|
ACPI_EVENT_HANDLER Handler)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status = AE_OK;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE (AcpiRemoveFixedEventHandler);
|
|
|
|
|
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
|
|
|
if (Event > ACPI_EVENT_MAX)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable the event before removing the handler */
|
|
|
|
|
|
|
|
Status = AcpiDisableEvent (Event, 0);
|
|
|
|
|
|
|
|
/* Always Remove the handler */
|
|
|
|
|
|
|
|
AcpiGbl_FixedEventHandlers[Event].Handler = NULL;
|
|
|
|
AcpiGbl_FixedEventHandlers[Event].Context = NULL;
|
|
|
|
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
ACPI_WARNING ((AE_INFO,
|
|
|
|
"Could not write to fixed event enable register 0x%X", Event));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Disabled fixed event %X\n", Event));
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
ACPI_EXPORT_SYMBOL (AcpiRemoveFixedEventHandler)
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiInstallGpeHandler
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT
|
|
|
|
* defined GPEs)
|
|
|
|
* GpeNumber - The GPE number within the GPE block
|
2000-10-28 05:01:06 +00:00
|
|
|
* Type - Whether this GPE should be treated as an
|
|
|
|
* edge- or level-triggered interrupt.
|
2004-05-25 02:34:44 +00:00
|
|
|
* Address - Address of the handler
|
2000-10-28 05:01:06 +00:00
|
|
|
* Context - Value passed to the handler on each GPE
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Install a handler for a General Purpose Event.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiInstallGpeHandler (
|
2003-07-13 22:44:13 +00:00
|
|
|
ACPI_HANDLE GpeDevice,
|
2000-10-28 05:01:06 +00:00
|
|
|
UINT32 GpeNumber,
|
|
|
|
UINT32 Type,
|
2010-12-09 20:04:14 +00:00
|
|
|
ACPI_GPE_HANDLER Address,
|
2000-10-28 05:01:06 +00:00
|
|
|
void *Context)
|
|
|
|
{
|
2003-04-29 18:39:29 +00:00
|
|
|
ACPI_GPE_EVENT_INFO *GpeEventInfo;
|
2010-12-09 20:04:14 +00:00
|
|
|
ACPI_GPE_HANDLER_INFO *Handler;
|
2004-05-25 02:34:44 +00:00
|
|
|
ACPI_STATUS Status;
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_CPU_FLAGS Flags;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (AcpiInstallGpeHandler);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
/* Parameter validation */
|
|
|
|
|
2010-04-02 16:48:51 +00:00
|
|
|
if ((!Address) || (Type & ~ACPI_GPE_XRUPT_TYPE_MASK))
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2010-12-09 20:04:14 +00:00
|
|
|
/* Allocate and init handler object (before lock) */
|
|
|
|
|
|
|
|
Handler = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_HANDLER_INFO));
|
|
|
|
if (!Handler)
|
|
|
|
{
|
|
|
|
Status = AE_NO_MEMORY;
|
|
|
|
goto UnlockAndExit;
|
|
|
|
}
|
|
|
|
|
|
|
|
Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
|
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
/* Ensure that we have a valid GPE number */
|
|
|
|
|
|
|
|
GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
|
|
|
|
if (!GpeEventInfo)
|
|
|
|
{
|
|
|
|
Status = AE_BAD_PARAMETER;
|
2010-12-09 20:04:14 +00:00
|
|
|
goto FreeAndExit;
|
2003-07-13 22:44:13 +00:00
|
|
|
}
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
/* Make sure that there isn't a handler there already */
|
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
|
|
|
|
ACPI_GPE_DISPATCH_HANDLER)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-11-28 04:29:40 +00:00
|
|
|
Status = AE_ALREADY_EXISTS;
|
2010-12-09 20:04:14 +00:00
|
|
|
goto FreeAndExit;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2010-12-09 20:04:14 +00:00
|
|
|
Handler->Address = Address;
|
|
|
|
Handler->Context = Context;
|
|
|
|
Handler->MethodNode = GpeEventInfo->Dispatch.MethodNode;
|
|
|
|
Handler->OriginalFlags = (UINT8) (GpeEventInfo->Flags &
|
|
|
|
(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2010-12-09 20:04:14 +00:00
|
|
|
/*
|
|
|
|
* If the GPE is associated with a method, it may have been enabled
|
|
|
|
* automatically during initialization, in which case it has to be
|
|
|
|
* disabled now to avoid spurious execution of the handler.
|
|
|
|
*/
|
|
|
|
if (((Handler->OriginalFlags & ACPI_GPE_DISPATCH_METHOD) ||
|
|
|
|
(Handler->OriginalFlags & ACPI_GPE_DISPATCH_NOTIFY)) &&
|
|
|
|
GpeEventInfo->RuntimeCount)
|
2004-05-25 02:34:44 +00:00
|
|
|
{
|
2010-12-09 20:04:14 +00:00
|
|
|
Handler->OriginallyEnabled = TRUE;
|
|
|
|
(void) AcpiEvRemoveGpeReference (GpeEventInfo);
|
2004-05-25 02:34:44 +00:00
|
|
|
|
2010-12-09 20:04:14 +00:00
|
|
|
/* Sanity check of original type against new type */
|
|
|
|
|
|
|
|
if (Type != (UINT32) (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK))
|
|
|
|
{
|
|
|
|
ACPI_WARNING ((AE_INFO, "GPE type mismatch (level/edge)"));
|
|
|
|
}
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2004-05-25 02:34:44 +00:00
|
|
|
/* Install the handler */
|
|
|
|
|
|
|
|
GpeEventInfo->Dispatch.Handler = Handler;
|
|
|
|
|
2010-12-09 20:04:14 +00:00
|
|
|
/* Setup up dispatch flags to indicate handler (vs. method/notify) */
|
2004-05-25 02:34:44 +00:00
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
GpeEventInfo->Flags &= ~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
|
2004-05-25 02:34:44 +00:00
|
|
|
GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_HANDLER);
|
|
|
|
|
2005-11-01 22:11:18 +00:00
|
|
|
AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
UnlockAndExit:
|
2002-02-23 05:10:40 +00:00
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
2010-12-09 20:04:14 +00:00
|
|
|
|
|
|
|
FreeAndExit:
|
|
|
|
AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
|
|
|
|
ACPI_FREE (Handler);
|
|
|
|
goto UnlockAndExit;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiInstallGpeHandler)
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiRemoveGpeHandler
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT
|
|
|
|
* defined GPEs)
|
|
|
|
* GpeNumber - The event to remove a handler
|
2004-05-25 02:34:44 +00:00
|
|
|
* Address - Address of the handler
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Remove a handler for a General Purpose AcpiEvent.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiRemoveGpeHandler (
|
2003-07-13 22:44:13 +00:00
|
|
|
ACPI_HANDLE GpeDevice,
|
2000-10-28 05:01:06 +00:00
|
|
|
UINT32 GpeNumber,
|
2010-12-09 20:04:14 +00:00
|
|
|
ACPI_GPE_HANDLER Address)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2003-04-29 18:39:29 +00:00
|
|
|
ACPI_GPE_EVENT_INFO *GpeEventInfo;
|
2010-12-09 20:04:14 +00:00
|
|
|
ACPI_GPE_HANDLER_INFO *Handler;
|
2004-05-25 02:34:44 +00:00
|
|
|
ACPI_STATUS Status;
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_CPU_FLAGS Flags;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FUNCTION_TRACE (AcpiRemoveGpeHandler);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Parameter validation */
|
|
|
|
|
2004-05-25 02:34:44 +00:00
|
|
|
if (!Address)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
2010-12-09 20:04:14 +00:00
|
|
|
Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
/* Ensure that we have a valid GPE number */
|
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
|
2003-04-29 18:39:29 +00:00
|
|
|
if (!GpeEventInfo)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2003-07-13 22:44:13 +00:00
|
|
|
Status = AE_BAD_PARAMETER;
|
|
|
|
goto UnlockAndExit;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2004-05-25 02:34:44 +00:00
|
|
|
/* Make sure that a handler is indeed installed */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2009-06-01 21:02:40 +00:00
|
|
|
if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) !=
|
|
|
|
ACPI_GPE_DISPATCH_HANDLER)
|
2002-07-09 17:51:31 +00:00
|
|
|
{
|
2004-05-25 02:34:44 +00:00
|
|
|
Status = AE_NOT_EXIST;
|
2003-07-13 22:44:13 +00:00
|
|
|
goto UnlockAndExit;
|
2002-02-23 05:10:40 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/* Make sure that the installed handler is the same */
|
|
|
|
|
2004-05-25 02:34:44 +00:00
|
|
|
if (GpeEventInfo->Dispatch.Handler->Address != Address)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
Status = AE_BAD_PARAMETER;
|
2003-07-13 22:44:13 +00:00
|
|
|
goto UnlockAndExit;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove the handler */
|
|
|
|
|
2004-05-25 02:34:44 +00:00
|
|
|
Handler = GpeEventInfo->Dispatch.Handler;
|
|
|
|
|
|
|
|
/* Restore Method node (if any), set dispatch flags */
|
|
|
|
|
|
|
|
GpeEventInfo->Dispatch.MethodNode = Handler->MethodNode;
|
2010-12-09 20:04:14 +00:00
|
|
|
GpeEventInfo->Flags &=
|
|
|
|
~(ACPI_GPE_XRUPT_TYPE_MASK | ACPI_GPE_DISPATCH_MASK);
|
|
|
|
GpeEventInfo->Flags |= Handler->OriginalFlags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the GPE was previously associated with a method and it was
|
|
|
|
* enabled, it should be enabled at this point to restore the
|
|
|
|
* post-initialization configuration.
|
|
|
|
*/
|
|
|
|
if ((Handler->OriginalFlags & ACPI_GPE_DISPATCH_METHOD) &&
|
|
|
|
Handler->OriginallyEnabled)
|
2004-05-25 02:34:44 +00:00
|
|
|
{
|
2010-12-09 20:04:14 +00:00
|
|
|
(void) AcpiEvAddGpeReference (GpeEventInfo);
|
2004-05-25 02:34:44 +00:00
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2004-05-25 02:34:44 +00:00
|
|
|
/* Now we can free the handler object */
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_FREE (Handler);
|
2004-05-25 02:34:44 +00:00
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
|
2003-07-13 22:44:13 +00:00
|
|
|
UnlockAndExit:
|
2010-12-09 20:04:14 +00:00
|
|
|
AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
|
2002-02-23 05:10:40 +00:00
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiRemoveGpeHandler)
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiAcquireGlobalLock
|
|
|
|
*
|
|
|
|
* PARAMETERS: Timeout - How long the caller is willing to wait
|
2005-11-01 22:11:18 +00:00
|
|
|
* Handle - Where the handle to the lock is returned
|
|
|
|
* (if acquired)
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Acquire the ACPI Global Lock
|
|
|
|
*
|
2007-03-22 17:24:05 +00:00
|
|
|
* Note: Allows callers with the same thread ID to acquire the global lock
|
|
|
|
* multiple times. In other words, externally, the behavior of the global lock
|
|
|
|
* is identical to an AML mutex. On the first acquire, a new handle is
|
|
|
|
* returned. On any subsequent calls to acquire by the same thread, the same
|
|
|
|
* handle is returned.
|
|
|
|
*
|
2000-10-28 05:01:06 +00:00
|
|
|
******************************************************************************/
|
2001-10-31 02:32:29 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_STATUS
|
|
|
|
AcpiAcquireGlobalLock (
|
2002-11-27 18:07:48 +00:00
|
|
|
UINT16 Timeout,
|
2002-02-23 05:10:40 +00:00
|
|
|
UINT32 *Handle)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
if (!Handle)
|
|
|
|
{
|
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
/* Must lock interpreter to prevent race conditions */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiExEnterInterpreter ();
|
|
|
|
|
|
|
|
Status = AcpiExAcquireMutexObject (Timeout,
|
|
|
|
AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ());
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
if (ACPI_SUCCESS (Status))
|
|
|
|
{
|
2007-09-24 17:12:36 +00:00
|
|
|
/* Return the global lock handle (updated in AcpiEvAcquireGlobalLock) */
|
2007-03-22 17:24:05 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
*Handle = AcpiGbl_GlobalLockHandle;
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
AcpiExExitInterpreter ();
|
2000-10-28 05:01:06 +00:00
|
|
|
return (Status);
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiAcquireGlobalLock)
|
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* FUNCTION: AcpiReleaseGlobalLock
|
|
|
|
*
|
|
|
|
* PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
2005-11-01 22:11:18 +00:00
|
|
|
* DESCRIPTION: Release the ACPI Global Lock. The handle must be valid.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiReleaseGlobalLock (
|
2002-02-23 05:10:40 +00:00
|
|
|
UINT32 Handle)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2002-07-09 17:51:31 +00:00
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
2001-10-31 02:32:29 +00:00
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
if (!Handle || (Handle != AcpiGbl_GlobalLockHandle))
|
2002-02-23 05:10:40 +00:00
|
|
|
{
|
|
|
|
return (AE_NOT_ACQUIRED);
|
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex);
|
2002-07-09 17:51:31 +00:00
|
|
|
return (Status);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 17:24:05 +00:00
|
|
|
ACPI_EXPORT_SYMBOL (AcpiReleaseGlobalLock)
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2012-02-16 00:24:10 +00:00
|
|
|
#endif /* !ACPI_REDUCED_HARDWARE */
|