1 /******************************************************************************
3 * Module Name: evgpe - General Purpose Event handling and dispatch
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2017, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
49 #define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME ("evgpe")
52 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
54 /* Local prototypes */
56 static void ACPI_SYSTEM_XFACE
57 AcpiEvAsynchExecuteGpeMethod (
60 static void ACPI_SYSTEM_XFACE
61 AcpiEvAsynchEnableGpe (
65 /*******************************************************************************
67 * FUNCTION: AcpiEvUpdateGpeEnableMask
69 * PARAMETERS: GpeEventInfo - GPE to update
73 * DESCRIPTION: Updates GPE register enable mask based upon whether there are
74 * runtime references to this GPE
76 ******************************************************************************/
79 AcpiEvUpdateGpeEnableMask (
80 ACPI_GPE_EVENT_INFO
*GpeEventInfo
)
82 ACPI_GPE_REGISTER_INFO
*GpeRegisterInfo
;
86 ACPI_FUNCTION_TRACE (EvUpdateGpeEnableMask
);
89 GpeRegisterInfo
= GpeEventInfo
->RegisterInfo
;
92 return_ACPI_STATUS (AE_NOT_EXIST
);
95 RegisterBit
= AcpiHwGetGpeRegisterBit (GpeEventInfo
);
97 /* Clear the run bit up front */
99 ACPI_CLEAR_BIT (GpeRegisterInfo
->EnableForRun
, RegisterBit
);
101 /* Set the mask bit only if there are references to this GPE */
103 if (GpeEventInfo
->RuntimeCount
)
105 ACPI_SET_BIT (GpeRegisterInfo
->EnableForRun
, (UINT8
) RegisterBit
);
108 GpeRegisterInfo
->EnableMask
= GpeRegisterInfo
->EnableForRun
;
109 return_ACPI_STATUS (AE_OK
);
113 /*******************************************************************************
115 * FUNCTION: AcpiEvEnableGpe
117 * PARAMETERS: GpeEventInfo - GPE to enable
121 * DESCRIPTION: Clear a GPE of stale events and enable it.
123 ******************************************************************************/
127 ACPI_GPE_EVENT_INFO
*GpeEventInfo
)
132 ACPI_FUNCTION_TRACE (EvEnableGpe
);
135 /* Clear the GPE (of stale events) */
137 Status
= AcpiHwClearGpe (GpeEventInfo
);
138 if (ACPI_FAILURE (Status
))
140 return_ACPI_STATUS (Status
);
143 /* Enable the requested GPE */
145 Status
= AcpiHwLowSetGpe (GpeEventInfo
, ACPI_GPE_ENABLE
);
146 return_ACPI_STATUS (Status
);
150 /*******************************************************************************
152 * FUNCTION: AcpiEvMaskGpe
154 * PARAMETERS: GpeEventInfo - GPE to be blocked/unblocked
155 * IsMasked - Whether the GPE is masked or not
159 * DESCRIPTION: Unconditionally mask/unmask a GPE during runtime.
161 ******************************************************************************/
165 ACPI_GPE_EVENT_INFO
*GpeEventInfo
,
168 ACPI_GPE_REGISTER_INFO
*GpeRegisterInfo
;
172 ACPI_FUNCTION_TRACE (EvMaskGpe
);
175 GpeRegisterInfo
= GpeEventInfo
->RegisterInfo
;
176 if (!GpeRegisterInfo
)
178 return_ACPI_STATUS (AE_NOT_EXIST
);
181 RegisterBit
= AcpiHwGetGpeRegisterBit (GpeEventInfo
);
183 /* Perform the action */
187 if (RegisterBit
& GpeRegisterInfo
->MaskForRun
)
189 return_ACPI_STATUS (AE_BAD_PARAMETER
);
192 (void) AcpiHwLowSetGpe (GpeEventInfo
, ACPI_GPE_DISABLE
);
193 ACPI_SET_BIT (GpeRegisterInfo
->MaskForRun
, (UINT8
) RegisterBit
);
197 if (!(RegisterBit
& GpeRegisterInfo
->MaskForRun
))
199 return_ACPI_STATUS (AE_BAD_PARAMETER
);
202 ACPI_CLEAR_BIT (GpeRegisterInfo
->MaskForRun
, (UINT8
) RegisterBit
);
203 if (GpeEventInfo
->RuntimeCount
&&
204 !GpeEventInfo
->DisableForDispatch
)
206 (void) AcpiHwLowSetGpe (GpeEventInfo
, ACPI_GPE_ENABLE
);
210 return_ACPI_STATUS (AE_OK
);
214 /*******************************************************************************
216 * FUNCTION: AcpiEvAddGpeReference
218 * PARAMETERS: GpeEventInfo - Add a reference to this GPE
222 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
225 ******************************************************************************/
228 AcpiEvAddGpeReference (
229 ACPI_GPE_EVENT_INFO
*GpeEventInfo
)
231 ACPI_STATUS Status
= AE_OK
;
234 ACPI_FUNCTION_TRACE (EvAddGpeReference
);
237 if (GpeEventInfo
->RuntimeCount
== ACPI_UINT8_MAX
)
239 return_ACPI_STATUS (AE_LIMIT
);
242 GpeEventInfo
->RuntimeCount
++;
243 if (GpeEventInfo
->RuntimeCount
== 1)
245 /* Enable on first reference */
247 Status
= AcpiEvUpdateGpeEnableMask (GpeEventInfo
);
248 if (ACPI_SUCCESS (Status
))
250 Status
= AcpiEvEnableGpe (GpeEventInfo
);
253 if (ACPI_FAILURE (Status
))
255 GpeEventInfo
->RuntimeCount
--;
259 return_ACPI_STATUS (Status
);
263 /*******************************************************************************
265 * FUNCTION: AcpiEvRemoveGpeReference
267 * PARAMETERS: GpeEventInfo - Remove a reference to this GPE
271 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
272 * removed, the GPE is hardware-disabled.
274 ******************************************************************************/
277 AcpiEvRemoveGpeReference (
278 ACPI_GPE_EVENT_INFO
*GpeEventInfo
)
280 ACPI_STATUS Status
= AE_OK
;
283 ACPI_FUNCTION_TRACE (EvRemoveGpeReference
);
286 if (!GpeEventInfo
->RuntimeCount
)
288 return_ACPI_STATUS (AE_LIMIT
);
291 GpeEventInfo
->RuntimeCount
--;
292 if (!GpeEventInfo
->RuntimeCount
)
294 /* Disable on last reference */
296 Status
= AcpiEvUpdateGpeEnableMask (GpeEventInfo
);
297 if (ACPI_SUCCESS (Status
))
299 Status
= AcpiHwLowSetGpe (GpeEventInfo
, ACPI_GPE_DISABLE
);
302 if (ACPI_FAILURE (Status
))
304 GpeEventInfo
->RuntimeCount
++;
308 return_ACPI_STATUS (Status
);
312 /*******************************************************************************
314 * FUNCTION: AcpiEvLowGetGpeInfo
316 * PARAMETERS: GpeNumber - Raw GPE number
317 * GpeBlock - A GPE info block
319 * RETURN: A GPE EventInfo struct. NULL if not a valid GPE (The GpeNumber
320 * is not within the specified GPE block)
322 * DESCRIPTION: Returns the EventInfo struct associated with this GPE. This is
323 * the low-level implementation of EvGetGpeEventInfo.
325 ******************************************************************************/
327 ACPI_GPE_EVENT_INFO
*
328 AcpiEvLowGetGpeInfo (
330 ACPI_GPE_BLOCK_INFO
*GpeBlock
)
336 * Validate that the GpeNumber is within the specified GpeBlock.
340 (GpeNumber
< GpeBlock
->BlockBaseNumber
))
345 GpeIndex
= GpeNumber
- GpeBlock
->BlockBaseNumber
;
346 if (GpeIndex
>= GpeBlock
->GpeCount
)
351 return (&GpeBlock
->EventInfo
[GpeIndex
]);
355 /*******************************************************************************
357 * FUNCTION: AcpiEvGetGpeEventInfo
359 * PARAMETERS: GpeDevice - Device node. NULL for GPE0/GPE1
360 * GpeNumber - Raw GPE number
362 * RETURN: A GPE EventInfo struct. NULL if not a valid GPE
364 * DESCRIPTION: Returns the EventInfo struct associated with this GPE.
365 * Validates the GpeBlock and the GpeNumber
367 * Should be called only when the GPE lists are semaphore locked
368 * and not subject to change.
370 ******************************************************************************/
372 ACPI_GPE_EVENT_INFO
*
373 AcpiEvGetGpeEventInfo (
374 ACPI_HANDLE GpeDevice
,
377 ACPI_OPERAND_OBJECT
*ObjDesc
;
378 ACPI_GPE_EVENT_INFO
*GpeInfo
;
382 ACPI_FUNCTION_ENTRY ();
385 /* A NULL GpeDevice means use the FADT-defined GPE block(s) */
389 /* Examine GPE Block 0 and 1 (These blocks are permanent) */
391 for (i
= 0; i
< ACPI_MAX_GPE_BLOCKS
; i
++)
393 GpeInfo
= AcpiEvLowGetGpeInfo (GpeNumber
,
394 AcpiGbl_GpeFadtBlocks
[i
]);
401 /* The GpeNumber was not in the range of either FADT GPE block */
406 /* A Non-NULL GpeDevice means this is a GPE Block Device */
408 ObjDesc
= AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE
*) GpeDevice
);
410 !ObjDesc
->Device
.GpeBlock
)
415 return (AcpiEvLowGetGpeInfo (GpeNumber
, ObjDesc
->Device
.GpeBlock
));
419 /*******************************************************************************
421 * FUNCTION: AcpiEvGpeDetect
423 * PARAMETERS: GpeXruptList - Interrupt block for this interrupt.
424 * Can have multiple GPE blocks attached.
426 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
428 * DESCRIPTION: Detect if any GP events have occurred. This function is
429 * executed at interrupt level.
431 ******************************************************************************/
435 ACPI_GPE_XRUPT_INFO
*GpeXruptList
)
438 ACPI_GPE_BLOCK_INFO
*GpeBlock
;
439 ACPI_NAMESPACE_NODE
*GpeDevice
;
440 ACPI_GPE_REGISTER_INFO
*GpeRegisterInfo
;
441 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
443 ACPI_GPE_HANDLER_INFO
*GpeHandlerInfo
;
444 UINT32 IntStatus
= ACPI_INTERRUPT_NOT_HANDLED
;
445 UINT8 EnabledStatusByte
;
448 ACPI_CPU_FLAGS Flags
;
453 ACPI_FUNCTION_NAME (EvGpeDetect
);
455 /* Check for the case where there are no GPEs */
463 * We need to obtain the GPE lock for both the data structs and registers
464 * Note: Not necessary to obtain the hardware lock, since the GPE
465 * registers are owned by the GpeLock.
467 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
469 /* Examine all GPE blocks attached to this interrupt level */
471 GpeBlock
= GpeXruptList
->GpeBlockListHead
;
474 GpeDevice
= GpeBlock
->Node
;
477 * Read all of the 8-bit GPE status and enable registers in this GPE
478 * block, saving all of them. Find all currently active GP events.
480 for (i
= 0; i
< GpeBlock
->RegisterCount
; i
++)
482 /* Get the next status/enable pair */
484 GpeRegisterInfo
= &GpeBlock
->RegisterInfo
[i
];
487 * Optimization: If there are no GPEs enabled within this
488 * register, we can safely ignore the entire register.
490 if (!(GpeRegisterInfo
->EnableForRun
|
491 GpeRegisterInfo
->EnableForWake
))
493 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS
,
494 "Ignore disabled registers for GPE %02X-%02X: "
495 "RunEnable=%02X, WakeEnable=%02X\n",
496 GpeRegisterInfo
->BaseGpeNumber
,
497 GpeRegisterInfo
->BaseGpeNumber
+ (ACPI_GPE_REGISTER_WIDTH
- 1),
498 GpeRegisterInfo
->EnableForRun
,
499 GpeRegisterInfo
->EnableForWake
));
503 /* Read the Status Register */
505 Status
= AcpiHwRead (&StatusReg
, &GpeRegisterInfo
->StatusAddress
);
506 if (ACPI_FAILURE (Status
))
511 /* Read the Enable Register */
513 Status
= AcpiHwRead (&EnableReg
, &GpeRegisterInfo
->EnableAddress
);
514 if (ACPI_FAILURE (Status
))
519 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS
,
520 "Read registers for GPE %02X-%02X: Status=%02X, Enable=%02X, "
521 "RunEnable=%02X, WakeEnable=%02X\n",
522 GpeRegisterInfo
->BaseGpeNumber
,
523 GpeRegisterInfo
->BaseGpeNumber
+ (ACPI_GPE_REGISTER_WIDTH
- 1),
524 StatusReg
, EnableReg
,
525 GpeRegisterInfo
->EnableForRun
,
526 GpeRegisterInfo
->EnableForWake
));
528 /* Check if there is anything active at all in this register */
530 EnabledStatusByte
= (UINT8
) (StatusReg
& EnableReg
);
531 if (!EnabledStatusByte
)
533 /* No active GPEs in this register, move on */
538 /* Now look at the individual GPEs in this byte register */
540 for (j
= 0; j
< ACPI_GPE_REGISTER_WIDTH
; j
++)
542 /* Examine one GPE bit */
544 GpeEventInfo
= &GpeBlock
->EventInfo
[((ACPI_SIZE
) i
*
545 ACPI_GPE_REGISTER_WIDTH
) + j
];
546 GpeNumber
= j
+ GpeRegisterInfo
->BaseGpeNumber
;
548 if (EnabledStatusByte
& (1 << j
))
550 /* Invoke global event handler if present */
553 if (AcpiGbl_GlobalEventHandler
)
555 AcpiGbl_GlobalEventHandler (ACPI_EVENT_TYPE_GPE
,
556 GpeDevice
, GpeNumber
,
557 AcpiGbl_GlobalEventHandlerContext
);
560 /* Found an active GPE */
562 if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo
->Flags
) ==
563 ACPI_GPE_DISPATCH_RAW_HANDLER
)
565 /* Dispatch the event to a raw handler */
567 GpeHandlerInfo
= GpeEventInfo
->Dispatch
.Handler
;
570 * There is no protection around the namespace node
571 * and the GPE handler to ensure a safe destruction
573 * 1. The namespace node is expected to always
574 * exist after loading a table.
575 * 2. The GPE handler is expected to be flushed by
576 * AcpiOsWaitEventsComplete() before the
579 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
580 IntStatus
|= GpeHandlerInfo
->Address (
581 GpeDevice
, GpeNumber
, GpeHandlerInfo
->Context
);
582 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
587 * Dispatch the event to a standard handler or
590 IntStatus
|= AcpiEvGpeDispatch (GpeDevice
,
591 GpeEventInfo
, GpeNumber
);
597 GpeBlock
= GpeBlock
->Next
;
602 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
607 /*******************************************************************************
609 * FUNCTION: AcpiEvAsynchExecuteGpeMethod
611 * PARAMETERS: Context (GpeEventInfo) - Info for this GPE
615 * DESCRIPTION: Perform the actual execution of a GPE control method. This
616 * function is called from an invocation of AcpiOsExecute and
617 * therefore does NOT execute at interrupt level - so that
618 * the control method itself is not executed in the context of
619 * an interrupt handler.
621 ******************************************************************************/
623 static void ACPI_SYSTEM_XFACE
624 AcpiEvAsynchExecuteGpeMethod (
627 ACPI_GPE_EVENT_INFO
*GpeEventInfo
= Context
;
628 ACPI_STATUS Status
= AE_OK
;
629 ACPI_EVALUATE_INFO
*Info
;
630 ACPI_GPE_NOTIFY_INFO
*Notify
;
633 ACPI_FUNCTION_TRACE (EvAsynchExecuteGpeMethod
);
636 /* Do the correct dispatch - normal method or implicit notify */
638 switch (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo
->Flags
))
640 case ACPI_GPE_DISPATCH_NOTIFY
:
643 * Dispatch a DEVICE_WAKE notify to the appropriate handler.
644 * NOTE: the request is queued for execution after this method
645 * completes. The notify handlers are NOT invoked synchronously
646 * from this thread -- because handlers may in turn run other
649 * June 2012: Expand implicit notify mechanism to support
650 * notifies on multiple device objects.
652 Notify
= GpeEventInfo
->Dispatch
.NotifyList
;
653 while (ACPI_SUCCESS (Status
) && Notify
)
655 Status
= AcpiEvQueueNotifyRequest (
656 Notify
->DeviceNode
, ACPI_NOTIFY_DEVICE_WAKE
);
658 Notify
= Notify
->Next
;
662 case ACPI_GPE_DISPATCH_METHOD
:
664 /* Allocate the evaluation information block */
666 Info
= ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO
));
669 Status
= AE_NO_MEMORY
;
674 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the
675 * _Lxx/_Exx control method that corresponds to this GPE
677 Info
->PrefixNode
= GpeEventInfo
->Dispatch
.MethodNode
;
678 Info
->Flags
= ACPI_IGNORE_RETURN_VALUE
;
680 Status
= AcpiNsEvaluate (Info
);
684 if (ACPI_FAILURE (Status
))
686 ACPI_EXCEPTION ((AE_INFO
, Status
,
687 "while evaluating GPE method [%4.4s]",
688 AcpiUtGetNodeName (GpeEventInfo
->Dispatch
.MethodNode
)));
694 goto ErrorExit
; /* Should never happen */
697 /* Defer enabling of GPE until all notify handlers are done */
699 Status
= AcpiOsExecute (OSL_NOTIFY_HANDLER
,
700 AcpiEvAsynchEnableGpe
, GpeEventInfo
);
701 if (ACPI_SUCCESS (Status
))
707 AcpiEvAsynchEnableGpe (GpeEventInfo
);
712 /*******************************************************************************
714 * FUNCTION: AcpiEvAsynchEnableGpe
716 * PARAMETERS: Context (GpeEventInfo) - Info for this GPE
717 * Callback from AcpiOsExecute
721 * DESCRIPTION: Asynchronous clear/enable for GPE. This allows the GPE to
722 * complete (i.e., finish execution of Notify)
724 ******************************************************************************/
726 static void ACPI_SYSTEM_XFACE
727 AcpiEvAsynchEnableGpe (
730 ACPI_GPE_EVENT_INFO
*GpeEventInfo
= Context
;
731 ACPI_CPU_FLAGS Flags
;
734 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
735 (void) AcpiEvFinishGpe (GpeEventInfo
);
736 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
742 /*******************************************************************************
744 * FUNCTION: AcpiEvFinishGpe
746 * PARAMETERS: GpeEventInfo - Info for this GPE
750 * DESCRIPTION: Clear/Enable a GPE. Common code that is used after execution
751 * of a GPE method or a synchronous or asynchronous GPE handler.
753 ******************************************************************************/
757 ACPI_GPE_EVENT_INFO
*GpeEventInfo
)
762 if ((GpeEventInfo
->Flags
& ACPI_GPE_XRUPT_TYPE_MASK
) ==
763 ACPI_GPE_LEVEL_TRIGGERED
)
766 * GPE is level-triggered, we clear the GPE status bit after
767 * handling the event.
769 Status
= AcpiHwClearGpe (GpeEventInfo
);
770 if (ACPI_FAILURE (Status
))
777 * Enable this GPE, conditionally. This means that the GPE will
778 * only be physically enabled if the EnableMask bit is set
781 (void) AcpiHwLowSetGpe (GpeEventInfo
, ACPI_GPE_CONDITIONAL_ENABLE
);
782 GpeEventInfo
->DisableForDispatch
= FALSE
;
787 /*******************************************************************************
789 * FUNCTION: AcpiEvGpeDispatch
791 * PARAMETERS: GpeDevice - Device node. NULL for GPE0/GPE1
792 * GpeEventInfo - Info for this GPE
793 * GpeNumber - Number relative to the parent GPE block
795 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
797 * DESCRIPTION: Dispatch a General Purpose Event to either a function (e.g. EC)
798 * or method (e.g. _Lxx/_Exx) handler.
800 * This function executes at interrupt level.
802 ******************************************************************************/
806 ACPI_NAMESPACE_NODE
*GpeDevice
,
807 ACPI_GPE_EVENT_INFO
*GpeEventInfo
,
814 ACPI_FUNCTION_TRACE (EvGpeDispatch
);
818 * Always disable the GPE so that it does not keep firing before
819 * any asynchronous activity completes (either from the execution
820 * of a GPE method or an asynchronous GPE handler.)
822 * If there is no handler or method to run, just disable the
823 * GPE and leave it disabled permanently to prevent further such
824 * pointless events from firing.
826 Status
= AcpiHwLowSetGpe (GpeEventInfo
, ACPI_GPE_DISABLE
);
827 if (ACPI_FAILURE (Status
))
829 ACPI_EXCEPTION ((AE_INFO
, Status
,
830 "Unable to disable GPE %02X", GpeNumber
));
831 return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED
);
835 * If edge-triggered, clear the GPE status bit now. Note that
836 * level-triggered events are cleared after the GPE is serviced.
838 if ((GpeEventInfo
->Flags
& ACPI_GPE_XRUPT_TYPE_MASK
) ==
839 ACPI_GPE_EDGE_TRIGGERED
)
841 Status
= AcpiHwClearGpe (GpeEventInfo
);
842 if (ACPI_FAILURE (Status
))
844 ACPI_EXCEPTION ((AE_INFO
, Status
,
845 "Unable to clear GPE %02X", GpeNumber
));
846 (void) AcpiHwLowSetGpe (
847 GpeEventInfo
, ACPI_GPE_CONDITIONAL_ENABLE
);
848 return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED
);
852 GpeEventInfo
->DisableForDispatch
= TRUE
;
855 * Dispatch the GPE to either an installed handler or the control
856 * method associated with this GPE (_Lxx or _Exx). If a handler
857 * exists, we invoke it and do not attempt to run the method.
858 * If there is neither a handler nor a method, leave the GPE
861 switch (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo
->Flags
))
863 case ACPI_GPE_DISPATCH_HANDLER
:
865 /* Invoke the installed handler (at interrupt level) */
867 ReturnValue
= GpeEventInfo
->Dispatch
.Handler
->Address (
868 GpeDevice
, GpeNumber
,
869 GpeEventInfo
->Dispatch
.Handler
->Context
);
871 /* If requested, clear (if level-triggered) and reenable the GPE */
873 if (ReturnValue
& ACPI_REENABLE_GPE
)
875 (void) AcpiEvFinishGpe (GpeEventInfo
);
879 case ACPI_GPE_DISPATCH_METHOD
:
880 case ACPI_GPE_DISPATCH_NOTIFY
:
882 * Execute the method associated with the GPE
883 * NOTE: Level-triggered GPEs are cleared after the method completes.
885 Status
= AcpiOsExecute (OSL_GPE_HANDLER
,
886 AcpiEvAsynchExecuteGpeMethod
, GpeEventInfo
);
887 if (ACPI_FAILURE (Status
))
889 ACPI_EXCEPTION ((AE_INFO
, Status
,
890 "Unable to queue handler for GPE %02X - event disabled",
897 * No handler or method to run!
898 * 03/2010: This case should no longer be possible. We will not allow
899 * a GPE to be enabled if it has no handler or method.
901 ACPI_ERROR ((AE_INFO
,
902 "No handler or method for GPE %02X, disabling event",
907 return_UINT32 (ACPI_INTERRUPT_HANDLED
);
910 #endif /* !ACPI_REDUCED_HARDWARE */