summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/evevent.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/evevent.c')
-rw-r--r--sys/contrib/dev/acpica/evevent.c209
1 files changed, 109 insertions, 100 deletions
diff --git a/sys/contrib/dev/acpica/evevent.c b/sys/contrib/dev/acpica/evevent.c
index 066946c..5cdfb7f 100644
--- a/sys/contrib/dev/acpica/evevent.c
+++ b/sys/contrib/dev/acpica/evevent.c
@@ -2,7 +2,7 @@
*
* Module Name: evevent - Fixed and General Purpose AcpiEvent
* handling and dispatch
- * $Revision: 17 $
+ * $Revision: 26 $
*
*****************************************************************************/
@@ -205,11 +205,23 @@ AcpiEvInitialize (
/* Install handlers for control method GPE handlers (_Lxx, _Exx) */
- AcpiEvInitGpeControlMethods ();
+ Status = AcpiEvInitGpeControlMethods ();
+ if (ACPI_FAILURE (Status))
+ {
+ DEBUG_PRINT (ACPI_FATAL,
+ ("EvInitialize: Unable to initialize Gpe control methods\n"));
+ return_ACPI_STATUS (Status);
+ }
/* Install the handler for the Global Lock */
Status = AcpiEvInitGlobalLockHandler ();
+ if (ACPI_FAILURE (Status))
+ {
+ DEBUG_PRINT (ACPI_FATAL,
+ ("EvInitialize: Unable to initialize Global Lock handler\n"));
+ return_ACPI_STATUS (Status);
+ }
return_ACPI_STATUS (Status);
@@ -241,16 +253,11 @@ AcpiEvFixedEventInitialize(void)
AcpiGbl_FixedEventHandlers[i].Context = NULL;
}
- AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_PMTIMER +
- TMR_EN, 0);
- AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_GLOBAL +
- TMR_EN, 0);
- AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_POWER_BUTTON +
- TMR_EN, 0);
- AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_SLEEP_BUTTON +
- TMR_EN, 0);
- AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_LOCK, ACPI_EVENT_RTC +
- TMR_EN, 0);
+ AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, TMR_EN, 0);
+ AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, GBL_EN, 0);
+ AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, PWRBTN_EN, 0);
+ AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, SLPBTN_EN, 0);
+ AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RTC_EN, 0);
return (AE_OK);
}
@@ -272,32 +279,22 @@ UINT32
AcpiEvFixedEventDetect(void)
{
UINT32 IntStatus = INTERRUPT_NOT_HANDLED;
- UINT32 StatusRegister = 0;
- UINT32 EnableRegister = 0;
+ UINT32 StatusRegister;
+ UINT32 EnableRegister;
/*
* Read the fixed feature status and enable registers, as all the cases
* depend on their values.
*/
- StatusRegister = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk);
- if (AcpiGbl_FACP->Pm1bEvtBlk)
- {
- StatusRegister |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk);
- }
-
- EnableRegister = (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1aEvtBlk +
- DIV_2 (AcpiGbl_FACP->Pm1EvtLen));
- if (AcpiGbl_FACP->Pm1bEvtBlk)
- {
- EnableRegister |= (UINT32) AcpiOsIn16 (AcpiGbl_FACP->Pm1bEvtBlk +
- DIV_2 (AcpiGbl_FACP->Pm1EvtLen));
- }
+ StatusRegister = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, PM1_STS);
+ EnableRegister = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, PM1_EN);
DEBUG_PRINT (TRACE_INTERRUPTS,
("Fixed AcpiEvent Block: Enable = %08x\tStatus = %08x\n",
EnableRegister, StatusRegister));
+
/* power management timer roll over */
if ((StatusRegister & ACPI_STATUS_PMTIMER) &&
@@ -351,10 +348,38 @@ UINT32
AcpiEvFixedEventDispatch (
UINT32 Event)
{
+ UINT32 RegisterId;
+
/* Clear the status bit */
- AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, TMR_STS +
- Event, 1);
+ switch (Event)
+ {
+ case ACPI_EVENT_PMTIMER:
+ RegisterId = TMR_STS;
+ break;
+
+ case ACPI_EVENT_GLOBAL:
+ RegisterId = GBL_STS;
+ break;
+
+ case ACPI_EVENT_POWER_BUTTON:
+ RegisterId = PWRBTN_STS;
+ break;
+
+ case ACPI_EVENT_SLEEP_BUTTON:
+ RegisterId = SLPBTN_STS;
+ break;
+
+ case ACPI_EVENT_RTC:
+ RegisterId = RTC_STS;
+ break;
+
+ default:
+ return 0;
+ break;
+ }
+
+ AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK, RegisterId, 1);
/*
* Make sure we've got a handler. If not, report an error.
@@ -362,8 +387,10 @@ AcpiEvFixedEventDispatch (
*/
if (NULL == AcpiGbl_FixedEventHandlers[Event].Handler)
{
- AcpiHwRegisterAccess (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK,
- TMR_EN + Event, 0);
+ RegisterId = (PM1_EN | REGISTER_BIT_ID(RegisterId));
+
+ AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_DO_NOT_LOCK,
+ RegisterId, 0);
REPORT_ERROR (
("EvGpeDispatch: No installed handler for fixed event [0x%08X]\n",
@@ -404,29 +431,30 @@ AcpiEvGpeInitialize (void)
FUNCTION_TRACE ("EvGpeInitialize");
- /*******************************************************************/
- /* Setting up various GPE counts */
- /* */
- /* You may ask,why are the GPE register block lengths divided by 2?*/
- /* From the ACPI 2.0 Spec, section, 4.7.1.6 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." */
- /*******************************************************************/
- Gpe0RegisterCount = (UINT16) DIV_2 (AcpiGbl_FACP->Gpe0BlkLen);
- Gpe1RegisterCount = (UINT16) DIV_2 (AcpiGbl_FACP->Gpe1BlkLen);
+ /*
+ * Set up various GPE counts
+ *
+ * You may ask,why are the GPE register block lengths divided by 2?
+ * From the ACPI 2.0 Spec, section, 4.7.1.6 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."
+ */
+
+ Gpe0RegisterCount = (UINT16) DIV_2 (AcpiGbl_FADT->Gpe0BlkLen);
+ Gpe1RegisterCount = (UINT16) DIV_2 (AcpiGbl_FADT->Gpe1BlkLen);
AcpiGbl_GpeRegisterCount = Gpe0RegisterCount + Gpe1RegisterCount;
if (!AcpiGbl_GpeRegisterCount)
{
- REPORT_WARNING (("Zero GPEs are defined in the FACP\n"));
+ REPORT_WARNING (("Zero GPEs are defined in the FADT\n"));
return_ACPI_STATUS (AE_OK);
}
@@ -476,10 +504,10 @@ AcpiEvGpeInitialize (void)
for (i = 0; i < Gpe0RegisterCount; i++)
{
AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr =
- (UINT16) (AcpiGbl_FACP->Gpe0Blk + i);
+ (UINT16) (AcpiGbl_FADT->XGpe0Blk.Address + i);
AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr =
- (UINT16) (AcpiGbl_FACP->Gpe0Blk + i + Gpe0RegisterCount);
+ (UINT16) (AcpiGbl_FADT->XGpe0Blk.Address + i + Gpe0RegisterCount);
AcpiGbl_GpeRegisters[RegisterIndex].GpeBase = (UINT8) MUL_8 (i);
@@ -505,13 +533,13 @@ AcpiEvGpeInitialize (void)
for (i = 0; i < Gpe1RegisterCount; i++)
{
AcpiGbl_GpeRegisters[RegisterIndex].StatusAddr =
- (UINT16) (AcpiGbl_FACP->Gpe1Blk + i);
+ (UINT16) (AcpiGbl_FADT->XGpe1Blk.Address + i);
AcpiGbl_GpeRegisters[RegisterIndex].EnableAddr =
- (UINT16) (AcpiGbl_FACP->Gpe1Blk + i + Gpe1RegisterCount);
+ (UINT16) (AcpiGbl_FADT->XGpe1Blk.Address + i + Gpe1RegisterCount);
AcpiGbl_GpeRegisters[RegisterIndex].GpeBase =
- (UINT8) (AcpiGbl_FACP->Gpe1Base + MUL_8 (i));
+ (UINT8) (AcpiGbl_FADT->Gpe1Base + MUL_8 (i));
for (j = 0; j < 8; j++)
{
@@ -531,9 +559,9 @@ AcpiEvGpeInitialize (void)
}
DEBUG_PRINT (ACPI_INFO,
- ("GPE registers: %d@%X (Blk0) %d@%X (Blk1)\n",
- Gpe0RegisterCount, AcpiGbl_FACP->Gpe0Blk, Gpe1RegisterCount,
- AcpiGbl_FACP->Gpe1Blk));
+ ("GPE registers: %d@%p (Blk0) %d@%p (Blk1)\n",
+ Gpe0RegisterCount, AcpiGbl_FADT->XGpe0Blk.Address, Gpe1RegisterCount,
+ AcpiGbl_FADT->XGpe1Blk.Address));
return_ACPI_STATUS (AE_OK);
}
@@ -561,7 +589,7 @@ AcpiEvGpeInitialize (void)
*
******************************************************************************/
-ACPI_STATUS
+static ACPI_STATUS
AcpiEvSaveMethodInfo (
ACPI_HANDLE ObjHandle,
UINT32 Level,
@@ -686,31 +714,6 @@ AcpiEvInitGpeControlMethods (void)
/******************************************************************************
*
- * FUNCTION: AcpiEvGpeCleanup
- *
- * PARAMETERS: None
- *
- * RETURN: None
- *
- * DESCRIPTION: Cleanup in preparation for unload.
- *
- ******************************************************************************/
-
-void
-AcpiEvGpeCleanup (void)
-{
- FUNCTION_TRACE ("EvGpeCleanup");
-
-
- AcpiCmFree (AcpiGbl_GpeRegisters);
- AcpiCmFree (AcpiGbl_GpeInfo);
-
- return_VOID;
-}
-
-
-/******************************************************************************
- *
* FUNCTION: AcpiEvGpeDetect
*
* PARAMETERS: None
@@ -799,7 +802,7 @@ AcpiEvGpeDetect (void)
*
******************************************************************************/
-void
+static void
AcpiEvAsynchExecuteGpeMethod (
void *Context)
{
@@ -817,21 +820,11 @@ AcpiEvAsynchExecuteGpeMethod (
AcpiCmReleaseMutex (ACPI_MTX_EVENTS);
/*
- * Function Handler (e.g. EC):
- * ---------------------------
- * Execute the installed function handler to handle this event.
- */
- if (GpeInfo.Handler)
- {
- GpeInfo.Handler (GpeInfo.Context);
- }
-
- /*
* Method Handler (_Lxx, _Exx):
* ----------------------------
* AcpiEvaluate the _Lxx/_Exx control method that corresponds to this GPE.
*/
- else if (GpeInfo.MethodHandle)
+ if (GpeInfo.MethodHandle)
{
AcpiNsEvaluateByHandle (GpeInfo.MethodHandle, NULL, NULL);
}
@@ -843,7 +836,7 @@ AcpiEvAsynchExecuteGpeMethod (
* that edge-triggered events are cleared prior to calling (via DPC)
* this function.
*/
- if (GpeInfo.Type | ACPI_EVENT_LEVEL_TRIGGERED)
+ if (GpeInfo.Type & ACPI_EVENT_LEVEL_TRIGGERED)
{
AcpiHwClearGpe (GpeNumber);
}
@@ -907,7 +900,7 @@ AcpiEvGpeDispatch (
* level-triggered events are cleared after the GPE is serviced
* (see AcpiEvAsynchExecuteGpeMethod).
*/
- if (AcpiGbl_GpeInfo [GpeNumber].Type | ACPI_EVENT_EDGE_TRIGGERED)
+ if (AcpiGbl_GpeInfo[GpeNumber].Type & ACPI_EVENT_EDGE_TRIGGERED)
{
AcpiHwClearGpe (GpeNumber);
}
@@ -918,8 +911,7 @@ AcpiEvGpeDispatch (
* Queue the handler, which is either an installable function handler
* (e.g. EC) or a control method (e.g. _Lxx/_Exx) for later execution.
*/
- if (AcpiGbl_GpeInfo [GpeNumber].Handler ||
- AcpiGbl_GpeInfo [GpeNumber].MethodHandle)
+ if (AcpiGbl_GpeInfo[GpeNumber].MethodHandle)
{
if (ACPI_FAILURE (AcpiOsQueueForExecution (OSD_PRIORITY_GPE,
AcpiEvAsynchExecuteGpeMethod,
@@ -935,7 +927,24 @@ AcpiEvGpeDispatch (
GpeNumber));
}
}
+ else if (AcpiGbl_GpeInfo[GpeNumber].Handler)
+ {
+ ACPI_GPE_LEVEL_INFO GpeInfo;
+ /*
+ * Function Handler (e.g. EC):
+ * ---------------------------
+ * Execute the installed function handler to handle this event.
+ * Without queueing.
+ */
+ AcpiCmAcquireMutex (ACPI_MTX_EVENTS);
+ GpeInfo = AcpiGbl_GpeInfo [GpeNumber];
+ AcpiCmReleaseMutex (ACPI_MTX_EVENTS);
+ if (GpeInfo.Handler)
+ {
+ GpeInfo.Handler (GpeInfo.Context);
+ }
+ }
/*
* Non Handled GPEs:
* -----------------
OpenPOWER on IntegriCloud