/******************************************************************************
*
* Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2016, Intel Corp.
* All rights reserved.
*
* 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.
*/
#define EXPORT_ACPI_INTERFACES
#include "acpi.h"
#include "accommon.h"
#include "acevents.h"
#include "acnamesp.h"
ACPI_MODULE_NAME ("evxfgpe")
#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
/*******************************************************************************
*
* FUNCTION: AcpiUpdateAllGpes
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Complete GPE initialization and enable all GPEs that have
* associated _Lxx or _Exx methods and are not pointed to by any
* device _PRW methods (this indicates that these GPEs are
* generally intended for system or device wakeup. Such GPEs
* have to be enabled directly when the devices whose _PRW
* methods point to them are set up for wakeup signaling.)
*
* NOTE: Should be called after any GPEs are added to the system. Primarily,
* after the system _PRW methods have been run, but also after a GPE Block
* Device has been added or if any new GPE methods have been added via a
* dynamic table load.
*
******************************************************************************/
void)
{
if (ACPI_FAILURE (Status))
{
}
{
goto UnlockAndExit;
}
if (ACPI_SUCCESS (Status))
{
}
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
}
/*******************************************************************************
*
* FUNCTION: AcpiEnableGpe
*
* GpeNumber - GPE level within the GPE block
*
* RETURN: Status
*
* DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
* hardware-enabled.
*
******************************************************************************/
{
/*
* Ensure that we have a valid GPE number and that there is some way
* of handling the GPE (handler or a GPE method). In other words, we
* won't allow a valid GPE to be enabled if there is no way to handle it.
*/
if (GpeEventInfo)
{
{
}
else
{
}
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDisableGpe
*
* GpeNumber - GPE level within the GPE block
*
* RETURN: Status
*
* DESCRIPTION: Remove a reference to a GPE. When the last reference is
* removed, only then is the GPE disabled (for runtime GPEs), or
* the GPE mask bit disabled (for wake GPEs)
*
******************************************************************************/
{
/* Ensure that we have a valid GPE number */
if (GpeEventInfo)
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiSetGpe
*
* GpeNumber - GPE level within the GPE block
* Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
*
* RETURN: Status
*
* DESCRIPTION: Enable or disable an individual GPE. This function bypasses
* the reference count mechanism used in the AcpiEnableGpe(),
* AcpiDisableGpe() interfaces.
* This API is typically used by the GPE raw handler mode driver
* to switch between the polling mode and the interrupt mode after
* the driver has enabled the GPE.
* The APIs should be invoked in this order:
* AcpiEnableGpe() <- Ensure the reference count > 0
* AcpiSetGpe(ACPI_GPE_DISABLE) <- Enter polling mode
* AcpiSetGpe(ACPI_GPE_ENABLE) <- Leave polling mode
* AcpiDisableGpe() <- Decrease the reference count
*
* Note: If a GPE is shared by 2 silicon components, then both the drivers
* should support GPE polling mode or disabling the GPE for long period
* for one driver may break the other. So use it with care since all
* firmware _Lxx/_Exx handlers currently rely on the GPE interrupt mode.
*
******************************************************************************/
{
/* Ensure that we have a valid GPE number */
if (!GpeEventInfo)
{
goto UnlockAndExit;
}
/* Perform the action */
switch (Action)
{
case ACPI_GPE_ENABLE:
break;
case ACPI_GPE_DISABLE:
break;
default:
break;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiMarkGpeForWake
*
* GpeNumber - GPE level within the GPE block
*
* RETURN: Status
*
* DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply
* sets the ACPI_GPE_CAN_WAKE flag.
*
* Some potential callers of AcpiSetupGpeForWake may know in advance that
* there won't be any notify handlers installed for device wake notifications
* from the given GPE (one example is a button GPE in Linux). For these cases,
* AcpiMarkGpeForWake should be used instead of AcpiSetupGpeForWake.
* This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to
* setup implicit wake notification for it (since there's no handler method).
*
******************************************************************************/
{
/* Ensure that we have a valid GPE number */
if (GpeEventInfo)
{
/* Mark the GPE as a possible wake event */
}
}
/*******************************************************************************
*
* FUNCTION: AcpiSetupGpeForWake
*
* PARAMETERS: WakeDevice - Device associated with the GPE (via _PRW)
* GpeNumber - GPE level within the GPE block
*
* RETURN: Status
*
* DESCRIPTION: Mark a GPE as having the ability to wake the system. This
* interface is intended to be used as the host executes the
* _PRW methods (Power Resources for Wake) in the system tables.
* Each _PRW appears under a Device Object (The WakeDevice), and
* contains the info for the wake GPE associated with the
* WakeDevice.
*
******************************************************************************/
{
/* Parameter Validation */
if (!WakeDevice)
{
/*
* By forcing WakeDevice to be valid, we automatically enable the
* implicit notify feature on all hosts.
*/
}
/* Handle root object case */
if (WakeDevice == ACPI_ROOT_OBJECT)
{
}
else
{
}
/* Validate WakeDevice is of type Device */
{
}
/*
* Allocate a new notify object up front, in case it is needed.
* Memory allocation while holding a spinlock is a big no-no
* on some hosts.
*/
if (!NewNotify)
{
}
/* Ensure that we have a valid GPE number */
if (!GpeEventInfo)
{
goto UnlockAndExit;
}
/*
* If there is no method or handler for this GPE, then the
* WakeDevice will be notified whenever this GPE fires. This is
* known as an "implicit notify". Note: The GPE is assumed to be
* level-triggered (for windows compatibility).
*/
{
/*
* This is the first device for implicit notify on this GPE.
* Just set the flags here, and enter the NOTIFY block below.
*/
}
/*
* If we already have an implicit notify on this GPE, add
* this device to the notify list.
*/
{
/* Ensure that the device is not already in the list */
while (Notify)
{
{
goto UnlockAndExit;
}
}
/* Add this device to the notify list for this GPE */
}
/* Mark the GPE as a possible wake event */
/* Delete the notify object if it was not used above */
if (NewNotify)
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiSetGpeWakeMask
*
* GpeNumber - GPE level within the GPE block
* Action - Enable or Disable
*
* RETURN: Status
*
* DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
* already be marked as a WAKE GPE.
*
******************************************************************************/
{
/*
* Ensure that we have a valid GPE number and that this GPE is in
* fact a wake GPE
*/
if (!GpeEventInfo)
{
goto UnlockAndExit;
}
{
goto UnlockAndExit;
}
if (!GpeRegisterInfo)
{
goto UnlockAndExit;
}
/* Perform the action */
switch (Action)
{
case ACPI_GPE_ENABLE:
break;
case ACPI_GPE_DISABLE:
break;
default:
break;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiClearGpe
*
* GpeNumber - GPE level within the GPE block
*
* RETURN: Status
*
* DESCRIPTION: Clear an ACPI event (general purpose)
*
******************************************************************************/
{
/* Ensure that we have a valid GPE number */
if (!GpeEventInfo)
{
goto UnlockAndExit;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiGetGpeStatus
*
* GpeNumber - GPE level within the GPE block
* EventStatus - Where the current status of the event
* will be returned
*
* RETURN: Status
*
* DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
*
******************************************************************************/
{
/* Ensure that we have a valid GPE number */
if (!GpeEventInfo)
{
goto UnlockAndExit;
}
/* Obtain status on the requested GPE number */
}
/*******************************************************************************
*
* FUNCTION: AcpiFinishGpe
*
* PARAMETERS: GpeDevice - Namespace node for the GPE Block
* (NULL for FADT defined GPEs)
* GpeNumber - GPE level within the GPE block
*
* RETURN: Status
*
* DESCRIPTION: Clear and conditionally reenable a GPE. This completes the GPE
* processing. Intended for use by asynchronous host-installed
* GPE handlers. The GPE is only reenabled if the EnableForRun bit
* is set in the GPE info.
*
******************************************************************************/
{
/* Ensure that we have a valid GPE number */
if (!GpeEventInfo)
{
goto UnlockAndExit;
}
}
/******************************************************************************
*
* FUNCTION: AcpiDisableAllGpes
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Disable and clear all GPEs in all GPE blocks
*
******************************************************************************/
void)
{
if (ACPI_FAILURE (Status))
{
}
Status = AcpiHwDisableAllGpes ();
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
}
/******************************************************************************
*
* FUNCTION: AcpiEnableAllRuntimeGpes
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
*
******************************************************************************/
void)
{
if (ACPI_FAILURE (Status))
{
}
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
}
/******************************************************************************
*
* FUNCTION: AcpiEnableAllWakeupGpes
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Enable all "wakeup" GPEs and disable all of the other GPEs, in
* all GPE blocks.
*
******************************************************************************/
void)
{
if (ACPI_FAILURE (Status))
{
}
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
}
/*******************************************************************************
*
* FUNCTION: AcpiInstallGpeBlock
*
* PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
* GpeBlockAddress - Address and SpaceID
* RegisterCount - Number of GPE register pairs in the block
* InterruptNumber - H/W interrupt for the block
*
* RETURN: Status
*
* DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
* enabled here.
*
******************************************************************************/
{
if ((!GpeDevice) ||
(!GpeBlockAddress) ||
(!RegisterCount))
{
}
if (ACPI_FAILURE (Status))
{
}
if (!Node)
{
goto UnlockAndExit;
}
/* Validate the parent device */
{
goto UnlockAndExit;
}
{
goto UnlockAndExit;
}
/*
* For user-installed GPE Block Devices, the GpeBlockBaseNumber
* is always zero
*/
0, InterruptNumber, &GpeBlock);
if (ACPI_FAILURE (Status))
{
goto UnlockAndExit;
}
/* Install block in the DeviceObject attached to the node */
if (!ObjDesc)
{
/*
* No object, create a new one (Device nodes do not always have
* an attached object)
*/
if (!ObjDesc)
{
goto UnlockAndExit;
}
/* Remove local reference to the object */
if (ACPI_FAILURE (Status))
{
goto UnlockAndExit;
}
}
/* Now install the GPE block in the DeviceObject */
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
}
/*******************************************************************************
*
* FUNCTION: AcpiRemoveGpeBlock
*
* PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
*
* RETURN: Status
*
* DESCRIPTION: Remove a previously installed block of GPE registers
*
******************************************************************************/
{
if (!GpeDevice)
{
}
if (ACPI_FAILURE (Status))
{
}
if (!Node)
{
goto UnlockAndExit;
}
/* Validate the parent device */
{
goto UnlockAndExit;
}
/* Get the DeviceObject attached to the node */
if (!ObjDesc ||
{
}
/* Delete the GPE block (but not the DeviceObject) */
if (ACPI_SUCCESS (Status))
{
}
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
}
/*******************************************************************************
*
* FUNCTION: AcpiGetGpeDevice
*
* PARAMETERS: Index - System GPE index (0-CurrentGpeCount)
* GpeDevice - Where the parent GPE Device is returned
*
* RETURN: Status
*
* DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
* gpe device indicates that the gpe number is contained in one of
* the FADT-defined gpe blocks. Otherwise, the GPE block device.
*
******************************************************************************/
{
if (!GpeDevice)
{
}
if (Index >= AcpiCurrentGpeCount)
{
}
/* Setup and walk the GPE list */
Info.NextBlockBaseIndex = 0;
if (ACPI_FAILURE (Status))
{
}
}
#endif /* !ACPI_REDUCED_HARDWARE */