[ros-diffs] [sir_richard] 45310: [NTOS]: Implement chained interrupt dispatch. For level interrupts, the first interrupt handler should process the interrupt and no other handlers are called. Edge interrupts are another matter, but since they aren't yet supported, I haven't implemented that code path (it wasn't implemented previously). I seriously hope we don't have edge/chained interrupts because the HAL/NTOS could never handle this!

sir_richard at svn.reactos.org sir_richard at svn.reactos.org
Fri Jan 29 02:37:25 CET 2010


Author: sir_richard
Date: Fri Jan 29 02:37:25 2010
New Revision: 45310

URL: http://svn.reactos.org/svn/reactos?rev=45310&view=rev
Log:
[NTOS]: Implement chained interrupt dispatch. For level interrupts, the first interrupt handler should process the interrupt and no other handlers are called. Edge interrupts are another matter, but since they aren't yet supported, I haven't implemented that code path (it wasn't implemented previously). I seriously hope we don't have edge/chained interrupts because the HAL/NTOS could never handle this!

Modified:
    trunk/reactos/ntoskrnl/ke/i386/irqobj.c

Modified: trunk/reactos/ntoskrnl/ke/i386/irqobj.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/irqobj.c?rev=45310&r1=45309&r2=45310&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/irqobj.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/i386/irqobj.c [iso-8859-1] Fri Jan 29 02:37:25 2010
@@ -233,11 +233,79 @@
 KiChainedDispatch(IN PKTRAP_FRAME TrapFrame,
                   IN PKINTERRUPT Interrupt)
 {   
+    KIRQL OldIrql;
+    BOOLEAN Handled;
+    PLIST_ENTRY NextEntry, ListHead;
+    
     /* Increase interrupt count */
     KeGetCurrentPrcb()->InterruptCount++;
-    UNIMPLEMENTED;
-    while (TRUE);
-}
+
+    /* Begin the interrupt, making sure it's not spurious */
+    if (HalBeginSystemInterrupt(Interrupt->Irql,
+                                Interrupt->Vector,
+                                &OldIrql))
+    {
+        /* Get list pointers */
+        ListHead = &Interrupt->InterruptListEntry;
+        NextEntry = ListHead; /* The head is an entry! */
+        while (TRUE)
+        {            
+            /* Check if this interrupt's IRQL is higher than the current one */
+            if (Interrupt->SynchronizeIrql > Interrupt->Irql)
+            {
+                /* Raise to higher IRQL */
+                OldIrql = KfRaiseIrql(Interrupt->Irql);
+            }
+        
+            /* Acquire interrupt lock */
+            KxAcquireSpinLock(Interrupt->ActualLock);
+
+            /* Call the ISR */
+            Handled = Interrupt->ServiceRoutine(Interrupt,
+                                                Interrupt->ServiceContext);
+
+            /* Release interrupt lock */
+            KxReleaseSpinLock(Interrupt->ActualLock);
+        
+            /* Check if this interrupt's IRQL is higher than the current one */
+            if (Interrupt->SynchronizeIrql > Interrupt->Irql)
+            {
+                /* Lower the IRQL back */
+                KfLowerIrql(OldIrql);
+            }
+        
+            /* Check if the interrupt got handled */
+            if (Handled)
+            {
+                /* Edge shared interrupts are not handled (they never were) */
+                ASSERT(Interrupt->Mode == LevelSensitive);
+                break;
+            }
+            else
+            {
+                /* This code path was never tested, and shouldn't be reached */
+                DPRINT1("Edge shared interrupt. ReactOS cannot handle these\n");
+                
+                /* What's next? */
+                NextEntry = NextEntry->Flink;
+                
+                /* Is this the last one? */
+                if (NextEntry == ListHead) break;
+                
+                /* Get the actual interrupt object */
+                Interrupt = CONTAINING_RECORD(NextEntry, KINTERRUPT, InterruptListEntry);
+            }
+        }
+
+        /* Now call the epilogue code */
+        KiExitInterrupt(TrapFrame, OldIrql, FALSE);
+    }
+    else
+    {
+        /* Now call the epilogue code */
+        KiExitInterrupt(TrapFrame, OldIrql, TRUE);
+    }
+ }
 
 VOID
 FASTCALL




More information about the Ros-diffs mailing list