Deleted Added
sdiff udiff text old ( 151937 ) new ( 167802 )
full compact
1/******************************************************************************
2 *
3 * Module Name: evgpe - General Purpose Event handling and dispatch
4 * $Revision: 1.53 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.

--- 123 unchanged lines hidden (view full) ---

144ACPI_STATUS
145AcpiEvSetGpeType (
146 ACPI_GPE_EVENT_INFO *GpeEventInfo,
147 UINT8 Type)
148{
149 ACPI_STATUS Status;
150
151
152 ACPI_FUNCTION_TRACE ("EvSetGpeType");
153
154
155 /* Validate type and update register enable masks */
156
157 switch (Type)
158 {
159 case ACPI_GPE_TYPE_WAKE:
160 case ACPI_GPE_TYPE_RUNTIME:

--- 34 unchanged lines hidden (view full) ---

195AcpiEvUpdateGpeEnableMasks (
196 ACPI_GPE_EVENT_INFO *GpeEventInfo,
197 UINT8 Type)
198{
199 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
200 UINT8 RegisterBit;
201
202
203 ACPI_FUNCTION_TRACE ("EvUpdateGpeEnableMasks");
204
205
206 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
207 if (!GpeRegisterInfo)
208 {
209 return_ACPI_STATUS (AE_NOT_EXIST);
210 }
211 RegisterBit = GpeEventInfo->RegisterBit;
212
213 /* 1) Disable case. Simply clear all enable bits */
214
215 if (Type == ACPI_GPE_DISABLE)
216 {
217 ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, RegisterBit);
218 ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForRun, RegisterBit);
219 return_ACPI_STATUS (AE_OK);

--- 43 unchanged lines hidden (view full) ---

263ACPI_STATUS
264AcpiEvEnableGpe (
265 ACPI_GPE_EVENT_INFO *GpeEventInfo,
266 BOOLEAN WriteToHardware)
267{
268 ACPI_STATUS Status;
269
270
271 ACPI_FUNCTION_TRACE ("EvEnableGpe");
272
273
274 /* Make sure HW enable masks are updated */
275
276 Status = AcpiEvUpdateGpeEnableMasks (GpeEventInfo, ACPI_GPE_ENABLE);
277 if (ACPI_FAILURE (Status))
278 {
279 return_ACPI_STATUS (Status);

--- 56 unchanged lines hidden (view full) ---

336
337ACPI_STATUS
338AcpiEvDisableGpe (
339 ACPI_GPE_EVENT_INFO *GpeEventInfo)
340{
341 ACPI_STATUS Status;
342
343
344 ACPI_FUNCTION_TRACE ("EvDisableGpe");
345
346
347 if (!(GpeEventInfo->Flags & ACPI_GPE_ENABLE_MASK))
348 {
349 return_ACPI_STATUS (AE_OK);
350 }
351
352 /* Make sure HW enable masks are updated */

--- 130 unchanged lines hidden (view full) ---

483{
484 ACPI_STATUS Status;
485 ACPI_GPE_BLOCK_INFO *GpeBlock;
486 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
487 UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED;
488 UINT8 EnabledStatusByte;
489 UINT32 StatusReg;
490 UINT32 EnableReg;
491 ACPI_NATIVE_UINT Flags;
492 ACPI_NATIVE_UINT i;
493 ACPI_NATIVE_UINT j;
494
495
496 ACPI_FUNCTION_NAME ("EvGpeDetect");
497
498 /* Check for the case where there are no GPEs */
499
500 if (!GpeXruptList)
501 {
502 return (IntStatus);
503 }
504
505 /* Examine all GPE blocks attached to this interrupt level */
506
507 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
508 GpeBlock = GpeXruptList->GpeBlockListHead;
509 while (GpeBlock)
510 {
511 /*
512 * Read all of the 8-bit GPE status and enable registers
513 * in this GPE block, saving all of them.
514 * Find all currently active GP events.
515 */

--- 36 unchanged lines hidden (view full) ---

552 }
553
554 /* Now look at the individual GPEs in this byte register */
555
556 for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
557 {
558 /* Examine one GPE bit */
559
560 if (EnabledStatusByte & AcpiGbl_DecodeTo8bit[j])
561 {
562 /*
563 * Found an active GPE. Dispatch the event to a handler
564 * or method.
565 */
566 IntStatus |= AcpiEvGpeDispatch (
567 &GpeBlock->EventInfo[(i * ACPI_GPE_REGISTER_WIDTH) + j],
568 (UINT32) j + GpeRegisterInfo->BaseGpeNumber);

--- 14 unchanged lines hidden (view full) ---

583/*******************************************************************************
584 *
585 * FUNCTION: AcpiEvAsynchExecuteGpeMethod
586 *
587 * PARAMETERS: Context (GpeEventInfo) - Info for this GPE
588 *
589 * RETURN: None
590 *
591 * DESCRIPTION: Perform the actual execution of a GPE control method. This
592 * function is called from an invocation of AcpiOsQueueForExecution
593 * (and therefore does NOT execute at interrupt level) so that
594 * the control method itself is not executed in the context of
595 * an interrupt handler.
596 *
597 ******************************************************************************/
598
599static void ACPI_SYSTEM_XFACE
600AcpiEvAsynchExecuteGpeMethod (
601 void *Context)
602{
603 ACPI_GPE_EVENT_INFO *GpeEventInfo = (void *) Context;
604 UINT32 GpeNumber = 0;
605 ACPI_STATUS Status;
606 ACPI_GPE_EVENT_INFO LocalGpeEventInfo;
607 ACPI_PARAMETER_INFO Info;
608
609
610 ACPI_FUNCTION_TRACE ("EvAsynchExecuteGpeMethod");
611
612
613 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
614 if (ACPI_FAILURE (Status))
615 {
616 return_VOID;
617 }
618

--- 24 unchanged lines hidden (view full) ---

643
644 /*
645 * Must check for control method type dispatch one more
646 * time to avoid race with EvGpeInstallHandler
647 */
648 if ((LocalGpeEventInfo.Flags & ACPI_GPE_DISPATCH_MASK) ==
649 ACPI_GPE_DISPATCH_METHOD)
650 {
651 /*
652 * Invoke the GPE Method (_Lxx, _Exx) i.e., evaluate the _Lxx/_Exx
653 * control method that corresponds to this GPE
654 */
655 Info.Node = LocalGpeEventInfo.Dispatch.MethodNode;
656 Info.Parameters = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT *, GpeEventInfo);
657 Info.ParameterType = ACPI_PARAM_GPE;
658
659 Status = AcpiNsEvaluateByHandle (&Info);
660 if (ACPI_FAILURE (Status))
661 {
662 ACPI_REPORT_ERROR ((
663 "%s while evaluating method [%4.4s] for GPE[%2X]\n",
664 AcpiFormatException (Status),
665 AcpiUtGetNodeName (LocalGpeEventInfo.Dispatch.MethodNode),
666 GpeNumber));
667 }
668 }
669
670 if ((LocalGpeEventInfo.Flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
671 ACPI_GPE_LEVEL_TRIGGERED)
672 {
673 /*
674 * GPE is level-triggered, we clear the GPE status bit after

--- 32 unchanged lines hidden (view full) ---

707UINT32
708AcpiEvGpeDispatch (
709 ACPI_GPE_EVENT_INFO *GpeEventInfo,
710 UINT32 GpeNumber)
711{
712 ACPI_STATUS Status;
713
714
715 ACPI_FUNCTION_TRACE ("EvGpeDispatch");
716
717
718 /*
719 * If edge-triggered, clear the GPE status bit now. Note that
720 * level-triggered events are cleared after the GPE is serviced.
721 */
722 if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
723 ACPI_GPE_EDGE_TRIGGERED)
724 {
725 Status = AcpiHwClearGpe (GpeEventInfo);
726 if (ACPI_FAILURE (Status))
727 {
728 ACPI_REPORT_ERROR ((
729 "AcpiEvGpeDispatch: %s, Unable to clear GPE[%2X]\n",
730 AcpiFormatException (Status), GpeNumber));
731 return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED);
732 }
733 }
734
735 /* Save current system state */
736
737 if (AcpiGbl_SystemAwakeAndRunning)
738 {
739 ACPI_SET_BIT (GpeEventInfo->Flags, ACPI_GPE_SYSTEM_RUNNING);
740 }
741 else
742 {
743 ACPI_CLEAR_BIT (GpeEventInfo->Flags, ACPI_GPE_SYSTEM_RUNNING);
744 }
745
746 /*
747 * Dispatch the GPE to either an installed handler, or the control
748 * method associated with this GPE (_Lxx or _Exx).
749 * If a handler exists, we invoke it and do not attempt to run the method.
750 * If there is neither a handler nor a method, we disable the level to
751 * prevent further events from coming in here.
752 */
753 switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
754 {
755 case ACPI_GPE_DISPATCH_HANDLER:
756
757 /*
758 * Invoke the installed handler (at interrupt level)
759 * Ignore return status for now. TBD: leave GPE disabled on error?

--- 4 unchanged lines hidden (view full) ---

764 /* It is now safe to clear level-triggered events. */
765
766 if ((GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK) ==
767 ACPI_GPE_LEVEL_TRIGGERED)
768 {
769 Status = AcpiHwClearGpe (GpeEventInfo);
770 if (ACPI_FAILURE (Status))
771 {
772 ACPI_REPORT_ERROR ((
773 "AcpiEvGpeDispatch: %s, Unable to clear GPE[%2X]\n",
774 AcpiFormatException (Status), GpeNumber));
775 return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED);
776 }
777 }
778 break;
779
780 case ACPI_GPE_DISPATCH_METHOD:
781
782 /*
783 * Disable GPE, so it doesn't keep firing before the method has a
784 * chance to run.
785 */
786 Status = AcpiEvDisableGpe (GpeEventInfo);
787 if (ACPI_FAILURE (Status))
788 {
789 ACPI_REPORT_ERROR ((
790 "AcpiEvGpeDispatch: %s, Unable to disable GPE[%2X]\n",
791 AcpiFormatException (Status), GpeNumber));
792 return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED);
793 }
794
795 /*
796 * Execute the method associated with the GPE
797 * NOTE: Level-triggered GPEs are cleared after the method completes.
798 */
799 Status = AcpiOsQueueForExecution (OSD_PRIORITY_GPE,
800 AcpiEvAsynchExecuteGpeMethod, GpeEventInfo);
801 if (ACPI_FAILURE (Status))
802 {
803 ACPI_REPORT_ERROR ((
804 "AcpiEvGpeDispatch: %s, Unable to queue handler for GPE[%2X] - event disabled\n",
805 AcpiFormatException (Status), GpeNumber));
806 }
807 break;
808
809 default:
810
811 /* No handler or method to run! */
812
813 ACPI_REPORT_ERROR ((
814 "AcpiEvGpeDispatch: No handler or method for GPE[%2X], disabling event\n",
815 GpeNumber));
816
817 /*
818 * Disable the GPE. The GPE will remain disabled until the ACPI
819 * Core Subsystem is restarted, or a handler is installed.
820 */
821 Status = AcpiEvDisableGpe (GpeEventInfo);
822 if (ACPI_FAILURE (Status))
823 {
824 ACPI_REPORT_ERROR ((
825 "AcpiEvGpeDispatch: %s, Unable to disable GPE[%2X]\n",
826 AcpiFormatException (Status), GpeNumber));
827 return_UINT32 (ACPI_INTERRUPT_NOT_HANDLED);
828 }
829 break;
830 }
831
832 return_UINT32 (ACPI_INTERRUPT_HANDLED);
833}
834
835
836#ifdef ACPI_GPE_NOTIFY_CHECK
837/*******************************************************************************
838 * TBD: NOT USED, PROTOTYPE ONLY AND WILL PROBABLY BE REMOVED
839 *
840 * FUNCTION: AcpiEvCheckForWakeOnlyGpe
841 *
842 * PARAMETERS: GpeEventInfo - info for this GPE
843 *
844 * RETURN: Status
845 *
846 * DESCRIPTION: Determine if a a GPE is "wake-only".
847 *
848 * Called from Notify() code in interpreter when a "DeviceWake"
849 * Notify comes in.
850 *
851 ******************************************************************************/
852
853ACPI_STATUS
854AcpiEvCheckForWakeOnlyGpe (
855 ACPI_GPE_EVENT_INFO *GpeEventInfo)
856{
857 ACPI_STATUS Status;
858
859
860 ACPI_FUNCTION_TRACE ("EvCheckForWakeOnlyGpe");
861
862
863 if ((GpeEventInfo) && /* Only >0 for _Lxx/_Exx */
864 ((GpeEventInfo->Flags & ACPI_GPE_SYSTEM_MASK) == ACPI_GPE_SYSTEM_RUNNING)) /* System state at GPE time */
865 {
866 /* This must be a wake-only GPE, disable it */
867
868 Status = AcpiEvDisableGpe (GpeEventInfo);
869
870 /* Set GPE to wake-only. Do not change wake disabled/enabled status */
871
872 AcpiEvSetGpeType (GpeEventInfo, ACPI_GPE_TYPE_WAKE);
873
874 ACPI_REPORT_INFO (("GPE %p was updated from wake/run to wake-only\n",
875 GpeEventInfo));
876
877 /* This was a wake-only GPE */
878
879 return_ACPI_STATUS (AE_WAKE_ONLY_GPE);
880 }
881
882 return_ACPI_STATUS (AE_OK);
883}
884#endif
885
886