aboutsummaryrefslogtreecommitdiff
path: root/source/components/events/evgpe.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/components/events/evgpe.c')
-rw-r--r--source/components/events/evgpe.c238
1 files changed, 137 insertions, 101 deletions
diff --git a/source/components/events/evgpe.c b/source/components/events/evgpe.c
index ccc154787eb4..415df720a1ae 100644
--- a/source/components/events/evgpe.c
+++ b/source/components/events/evgpe.c
@@ -226,7 +226,7 @@ AcpiEvUpdateGpeEnableMask (
*
* RETURN: Status
*
- * DESCRIPTION: Clear a GPE of stale events and enable it.
+ * DESCRIPTION: Enable a GPE.
*
******************************************************************************/
@@ -240,14 +240,6 @@ AcpiEvEnableGpe (
ACPI_FUNCTION_TRACE (EvEnableGpe);
- /* Clear the GPE (of stale events) */
-
- Status = AcpiHwClearGpe (GpeEventInfo);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
/* Enable the requested GPE */
Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_ENABLE);
@@ -542,17 +534,12 @@ UINT32
AcpiEvGpeDetect (
ACPI_GPE_XRUPT_INFO *GpeXruptList)
{
- ACPI_STATUS Status;
ACPI_GPE_BLOCK_INFO *GpeBlock;
ACPI_NAMESPACE_NODE *GpeDevice;
ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
ACPI_GPE_EVENT_INFO *GpeEventInfo;
UINT32 GpeNumber;
- ACPI_GPE_HANDLER_INFO *GpeHandlerInfo;
UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED;
- UINT8 EnabledStatusByte;
- UINT64 StatusReg;
- UINT64 EnableReg;
ACPI_CPU_FLAGS Flags;
UINT32 i;
UINT32 j;
@@ -608,105 +595,25 @@ AcpiEvGpeDetect (
continue;
}
- /* Read the Status Register */
-
- Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress);
- if (ACPI_FAILURE (Status))
- {
- goto UnlockAndExit;
- }
-
- /* Read the Enable Register */
-
- Status = AcpiHwRead (&EnableReg, &GpeRegisterInfo->EnableAddress);
- if (ACPI_FAILURE (Status))
- {
- goto UnlockAndExit;
- }
-
- ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
- "Read registers for GPE %02X-%02X: Status=%02X, Enable=%02X, "
- "RunEnable=%02X, WakeEnable=%02X\n",
- GpeRegisterInfo->BaseGpeNumber,
- GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1),
- (UINT32) StatusReg, (UINT32) EnableReg,
- GpeRegisterInfo->EnableForRun,
- GpeRegisterInfo->EnableForWake));
-
- /* Check if there is anything active at all in this register */
-
- EnabledStatusByte = (UINT8) (StatusReg & EnableReg);
- if (!EnabledStatusByte)
- {
- /* No active GPEs in this register, move on */
-
- continue;
- }
-
/* Now look at the individual GPEs in this byte register */
for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
{
- /* Examine one GPE bit */
+ /* Detect and dispatch one GPE bit */
GpeEventInfo = &GpeBlock->EventInfo[((ACPI_SIZE) i *
ACPI_GPE_REGISTER_WIDTH) + j];
GpeNumber = j + GpeRegisterInfo->BaseGpeNumber;
-
- if (EnabledStatusByte & (1 << j))
- {
- /* Invoke global event handler if present */
-
- AcpiGpeCount++;
- if (AcpiGbl_GlobalEventHandler)
- {
- AcpiGbl_GlobalEventHandler (ACPI_EVENT_TYPE_GPE,
- GpeDevice, GpeNumber,
- AcpiGbl_GlobalEventHandlerContext);
- }
-
- /* Found an active GPE */
-
- if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) ==
- ACPI_GPE_DISPATCH_RAW_HANDLER)
- {
- /* Dispatch the event to a raw handler */
-
- GpeHandlerInfo = GpeEventInfo->Dispatch.Handler;
-
- /*
- * There is no protection around the namespace node
- * and the GPE handler to ensure a safe destruction
- * because:
- * 1. The namespace node is expected to always
- * exist after loading a table.
- * 2. The GPE handler is expected to be flushed by
- * AcpiOsWaitEventsComplete() before the
- * destruction.
- */
- AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
- IntStatus |= GpeHandlerInfo->Address (
- GpeDevice, GpeNumber, GpeHandlerInfo->Context);
- Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
- }
- else
- {
- /*
- * Dispatch the event to a standard handler or
- * method.
- */
- IntStatus |= AcpiEvGpeDispatch (GpeDevice,
- GpeEventInfo, GpeNumber);
- }
- }
+ AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+ IntStatus |= AcpiEvDetectGpe (
+ GpeDevice, GpeEventInfo, GpeNumber);
+ Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
}
}
GpeBlock = GpeBlock->Next;
}
-UnlockAndExit:
-
AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
return (IntStatus);
}
@@ -894,6 +801,137 @@ AcpiEvFinishGpe (
/*******************************************************************************
*
+ * FUNCTION: AcpiEvDetectGpe
+ *
+ * PARAMETERS: GpeDevice - Device node. NULL for GPE0/GPE1
+ * GpeEventInfo - Info for this GPE
+ * GpeNumber - Number relative to the parent GPE block
+ *
+ * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
+ *
+ * DESCRIPTION: Detect and dispatch a General Purpose Event to either a function
+ * (e.g. EC) or method (e.g. _Lxx/_Exx) handler.
+ * NOTE: GPE is W1C, so it is possible to handle a single GPE from both
+ * task and irq context in parallel as long as the process to
+ * detect and mask the GPE is atomic.
+ * However the atomicity of ACPI_GPE_DISPATCH_RAW_HANDLER is
+ * dependent on the raw handler itself.
+ *
+ ******************************************************************************/
+
+UINT32
+AcpiEvDetectGpe (
+ ACPI_NAMESPACE_NODE *GpeDevice,
+ ACPI_GPE_EVENT_INFO *GpeEventInfo,
+ UINT32 GpeNumber)
+{
+ UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED;
+ UINT8 EnabledStatusByte;
+ UINT64 StatusReg;
+ UINT64 EnableReg;
+ UINT32 RegisterBit;
+ ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
+ ACPI_GPE_HANDLER_INFO *GpeHandlerInfo;
+ ACPI_CPU_FLAGS Flags;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (EvGpeDetect);
+
+
+ Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+
+ /* Get the info block for the entire GPE register */
+
+ GpeRegisterInfo = GpeEventInfo->RegisterInfo;
+
+ /* Get the register bitmask for this GPE */
+
+ RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
+
+ /* GPE currently enabled (enable bit == 1)? */
+
+ Status = AcpiHwRead (&EnableReg, &GpeRegisterInfo->EnableAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+
+ /* GPE currently active (status bit == 1)? */
+
+ Status = AcpiHwRead (&StatusReg, &GpeRegisterInfo->StatusAddress);
+ if (ACPI_FAILURE (Status))
+ {
+ goto ErrorExit;
+ }
+
+ /* Check if there is anything active at all in this GPE */
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS,
+ "Read registers for GPE %02X: Status=%02X, Enable=%02X, "
+ "RunEnable=%02X, WakeEnable=%02X\n",
+ GpeNumber,
+ (UINT32) (StatusReg & RegisterBit),
+ (UINT32) (EnableReg & RegisterBit),
+ GpeRegisterInfo->EnableForRun,
+ GpeRegisterInfo->EnableForWake));
+
+ EnabledStatusByte = (UINT8) (StatusReg & EnableReg);
+ if (!(EnabledStatusByte & RegisterBit))
+ {
+ goto ErrorExit;
+ }
+
+ /* Invoke global event handler if present */
+
+ AcpiGpeCount++;
+ if (AcpiGbl_GlobalEventHandler)
+ {
+ AcpiGbl_GlobalEventHandler (ACPI_EVENT_TYPE_GPE,
+ GpeDevice, GpeNumber,
+ AcpiGbl_GlobalEventHandlerContext);
+ }
+
+ /* Found an active GPE */
+
+ if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) ==
+ ACPI_GPE_DISPATCH_RAW_HANDLER)
+ {
+ /* Dispatch the event to a raw handler */
+
+ GpeHandlerInfo = GpeEventInfo->Dispatch.Handler;
+
+ /*
+ * There is no protection around the namespace node
+ * and the GPE handler to ensure a safe destruction
+ * because:
+ * 1. The namespace node is expected to always
+ * exist after loading a table.
+ * 2. The GPE handler is expected to be flushed by
+ * AcpiOsWaitEventsComplete() before the
+ * destruction.
+ */
+ AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+ IntStatus |= GpeHandlerInfo->Address (
+ GpeDevice, GpeNumber, GpeHandlerInfo->Context);
+ Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
+ }
+ else
+ {
+ /* Dispatch the event to a standard handler or method. */
+
+ IntStatus |= AcpiEvGpeDispatch (GpeDevice,
+ GpeEventInfo, GpeNumber);
+ }
+
+ErrorExit:
+ AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
+ return (IntStatus);
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiEvGpeDispatch
*
* PARAMETERS: GpeDevice - Device node. NULL for GPE0/GPE1
@@ -905,8 +943,6 @@ AcpiEvFinishGpe (
* DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC)
* or method (e.g. _Lxx/_Exx) handler.
*
- * This function executes at interrupt level.
- *
******************************************************************************/
UINT32