evgpeinit.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: evgpeinit - System GPE initialization and update
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, 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 _COMPONENT ACPI_EVENTS
ACPI_MODULE_NAME ("evgpeinit")
#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
/*
* Note: History of _PRW support in ACPICA
*
* Originally (2000 - 2010), the GPE initialization code performed a walk of
* the entire namespace to execute the _PRW methods and detect all GPEs
* capable of waking the system.
*
* As of 10/2010, the _PRW method execution has been removed since it is
* actually unnecessary. The host OS must in fact execute all _PRW methods
* in order to identify the device/power-resource dependencies. We now put
* the onus on the host OS to identify the wake GPEs as part of this process
* and to inform ACPICA of these GPEs via the AcpiSetupGpeForWake interface. This
* not only reduces the complexity of the ACPICA initialization code, but in
* some cases (on systems with very large namespaces) it should reduce the
* kernel boot time as well.
*/
/*******************************************************************************
*
* FUNCTION: AcpiEvGpeInitialize
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Initialize the GPE data structures and the FADT GPE 0/1 blocks
*
******************************************************************************/
void)
{
UINT32 RegisterCount0 = 0;
UINT32 RegisterCount1 = 0;
UINT32 GpeNumberMax = 0;
"Initializing General Purpose Events (GPEs):\n"));
if (ACPI_FAILURE (Status))
{
}
/*
* Initialize the GPE Block(s) defined in the FADT
*
* Why the GPE register block lengths are divided by 2: From the ACPI
* Spec, section "General-Purpose Event Registers", we have:
*
* "Each register block contains two registers of equal length
* GPEx_STS and GPEx_EN (where x is 0 or 1). The length of the
* GPE0_STS and GPE0_EN registers is equal to half the GPE0_LEN
* The length of the GPE1_STS and GPE1_EN registers is equal to
* half the GPE1_LEN. If a generic register block is not supported
* then its respective block pointer and block length values in the
* FADT table contain zeros. The GPE0_LEN and GPE1_LEN do not need
* to be the same size."
*/
/*
* Determine the maximum GPE number for this machine.
*
* Note: both GPE0 and GPE1 are optional, and either can exist without
* the other.
*
* If EITHER the register length OR the block address are zero, then that
* particular block is not supported.
*/
if (AcpiGbl_FADT.Gpe0BlockLength &&
{
/* GPE block 0 exists (has both length and address > 0) */
/* Install GPE Block 0 */
RegisterCount0, 0,
if (ACPI_FAILURE (Status))
{
"Could not create GPE Block 0"));
}
}
if (AcpiGbl_FADT.Gpe1BlockLength &&
{
/* GPE block 1 exists (has both length and address > 0) */
if ((RegisterCount0) &&
{
"GPE0 block (GPE 0 to %u) overlaps the GPE1 block "
"(GPE %u to %u) - Ignoring GPE1",
/* Ignore GPE1 block by setting the register count to zero */
RegisterCount1 = 0;
}
else
{
/* Install GPE Block 1 */
if (ACPI_FAILURE (Status))
{
"Could not create GPE Block 1"));
}
/*
* GPE0 and GPE1 do not have to be contiguous in the GPE number
* space. However, GPE0 always starts at GPE number zero.
*/
}
}
/* Exit if there are no GPE registers */
if ((RegisterCount0 + RegisterCount1) == 0)
{
/* GPEs are not required by ACPI, this is OK */
"There are no GPE blocks defined in the FADT\n"));
goto Cleanup;
}
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
}
/*******************************************************************************
*
* FUNCTION: AcpiEvUpdateGpes
*
* PARAMETERS: TableOwnerId - ID of the newly-loaded ACPI table
*
* RETURN: None
*
* DESCRIPTION: Check for new GPE methods (_Lxx/_Exx) made available as a
* result of a Load() or LoadTable() operation. If new GPE
* methods have been installed, register the new methods.
*
******************************************************************************/
void
{
/*
* Find any _Lxx/_Exx GPE methods that have just been loaded.
*
* Any GPEs that correspond to new _Lxx/_Exx methods are immediately
* enabled.
*
* Examine the namespace underneath each GpeDevice within the
* GpeBlock lists.
*/
if (ACPI_FAILURE (Status))
{
return;
}
/* Walk the interrupt level descriptor list */
while (GpeXruptInfo)
{
/* Walk all Gpe Blocks attached to this interrupt level */
while (GpeBlock)
{
if (ACPI_FAILURE (Status))
{
"While decoding _Lxx/_Exx methods"));
}
}
}
{
}
(void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
return;
}
/*******************************************************************************
*
* FUNCTION: AcpiEvMatchGpeMethod
*
* PARAMETERS: Callback from WalkNamespace
*
* RETURN: Status
*
* DESCRIPTION: Called from AcpiWalkNamespace. Expects each object to be a
* control method under the _GPE portion of the namespace.
* Extract the name and GPE type from the object, saving this
* information for quick lookup during GPE dispatch. Allows a
* per-OwnerId evaluation if ExecuteByOwnerId is TRUE in the
* WalkInfo parameter block.
*
* The name of each GPE control method is of the form:
* "_Lxx" or "_Exx", where:
* L - means that the GPE is level triggered
* E - means that the GPE is edge triggered
* xx - is the GPE number [in HEX]
*
* If WalkInfo->ExecuteByOwnerId is TRUE, we only execute examine GPE methods
* with that owner.
*
******************************************************************************/
void *Context,
void **ReturnValue)
{
/* Check if requested OwnerId matches this OwnerId */
if ((WalkInfo->ExecuteByOwnerId) &&
{
}
/*
* Match and decode the _Lxx and _Exx GPE method names
*
* 1) Extract the method name and null terminate it
*/
Name[ACPI_NAME_SIZE] = 0;
/* 2) Name must begin with an underscore */
if (Name[0] != '_')
{
}
/*
* of the method name
*/
switch (Name[1])
{
case 'L':
break;
case 'E':
break;
default:
/* Unknown method type, just ignore it */
"Ignoring unknown GPE method type: %s "
"(name not of form _Lxx or _Exx)", Name));
}
/* 4) The last two characters of the name are the hex GPE Number */
if (GpeNumber == ACPI_UINT32_MAX)
{
/* Conversion failed; invalid method, just ignore it */
"Could not extract GPE number from name: %s "
"(name is not of form _Lxx or _Exx)", Name));
}
/* Ensure that we have a valid GPE number for this GPE block */
if (!GpeEventInfo)
{
/*
* This GpeNumber is not valid for this GPE block, just ignore it.
* However, it may be valid for a different GPE block, since GPE0
* and GPE1 methods both appear under \_GPE.
*/
}
{
/* If there is already a handler, ignore this GPE method */
}
{
/*
* If there is already a method, ignore this method. But check
* for a type mismatch (if both the _Lxx AND _Exx exist)
*/
{
"For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods",
}
}
/* Disable the GPE in case it's been enabled already. */
/*
* Add the GPE information from above to the GpeEventInfo block for
* use during dispatch of this GPE.
*/
"Registered GPE method %s as GPE number 0x%.2X\n",
}
#endif /* !ACPI_REDUCED_HARDWARE */