[ros-diffs] [ion] 23674: - Enable the code in KeInitializeInterrupt that copies the Interrupt Template to the KINTERRUPT object and modifies the template pointer to point to the KINTERRUPT. - Add the template code in trap.s.

ion at svn.reactos.org ion at svn.reactos.org
Wed Aug 23 21:02:00 CEST 2006


Author: ion
Date: Wed Aug 23 23:02:00 2006
New Revision: 23674

URL: http://svn.reactos.org/svn/reactos?rev=23674&view=rev
Log:
- Enable the code in KeInitializeInterrupt that copies the Interrupt Template to the KINTERRUPT object and modifies the template pointer to point to the KINTERRUPT.
- Add the template code in trap.s.

Modified:
    trunk/reactos/ntoskrnl/ke/i386/irq.c
    trunk/reactos/ntoskrnl/ke/i386/trap.s

Modified: trunk/reactos/ntoskrnl/ke/i386/irq.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/irq.c?rev=23674&r1=23673&r2=23674&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/irq.c (original)
+++ trunk/reactos/ntoskrnl/ke/i386/irq.c Wed Aug 23 23:02:00 2006
@@ -23,6 +23,9 @@
 
 #define NDEBUG
 #include <internal/debug.h>
+
+extern ULONG KiInterruptTemplate[KINTERRUPT_DISPATCH_CODES];
+extern PULONG KiInterruptTemplateObject;
 
 /* GLOBALS *****************************************************************/
 
@@ -245,7 +248,6 @@
     * At this point we have interrupts disabled, nothing has been done to
     * the PIC.
     */
-
    KeGetCurrentPrcb()->InterruptCount++;
 
    /*
@@ -302,9 +304,9 @@
    PISR_TABLE CurrentIsr;
    BOOLEAN Result;
 
-   DPRINT("KeConnectInterrupt()\n");
 
    Vector = InterruptObject->Vector;
+   DPRINT1("KeConnectInterrupt(): %lx\n", Vector);
 
    if (Vector < IRQ_BASE || Vector >= IRQ_BASE + NR_IRQS)
       return FALSE;
@@ -437,10 +439,13 @@
                       CHAR ProcessorNumber,
                       BOOLEAN FloatingSave)
 {
+    ULONG i;
+    PULONG DispatchCode = &Interrupt->DispatchCode[0], Patch = DispatchCode;
+
     /* Set the Interrupt Header */
     Interrupt->Type = InterruptObject;
     Interrupt->Size = sizeof(KINTERRUPT);
-    
+
     /* Check if we got a spinlock */
     if (SpinLock)
     {
@@ -452,7 +457,7 @@
         KeInitializeSpinLock(&Interrupt->SpinLock);
         Interrupt->ActualLock = &Interrupt->SpinLock;
     }
-    
+
     /* Set the other settings */
     Interrupt->ServiceRoutine = ServiceRoutine;
     Interrupt->ServiceContext = ServiceContext;
@@ -463,7 +468,22 @@
     Interrupt->ShareVector = ShareVector;
     Interrupt->Number = ProcessorNumber;
     Interrupt->FloatingSave = FloatingSave;
-    
+
+    /* Loop the template in memory */
+    for (i = 0; i < KINTERRUPT_DISPATCH_CODES; i++)
+    {
+        /* Copy the dispatch code */
+        *DispatchCode++ = KiInterruptTemplate[i];
+    }
+
+    /* Jump to the last 4 bytes */
+    Patch = (PULONG)((ULONG_PTR)Patch +
+                     ((ULONG_PTR)&KiInterruptTemplateObject -
+                      (ULONG_PTR)KiInterruptTemplate) - 4);
+
+    /* Apply the patch */
+    *Patch = PtrToUlong(Interrupt);
+
     /* Disconnect it at first */
     Interrupt->Connected = FALSE;
 }

Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?rev=23674&r1=23673&r2=23674&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/trap.s (original)
+++ trunk/reactos/ntoskrnl/ke/i386/trap.s Wed Aug 23 23:02:00 2006
@@ -56,6 +56,10 @@
 .globl _NtRaiseException at 12
 .globl _NtContinue at 8
 
+/* Interrupt template entrypoints                                           */
+.globl _KiInterruptTemplate
+.globl _KiInterruptTemplateObject
+
 /* We implement the following trap exit points:                             */
 .globl _KiServiceExit               /* Exit from syscall                    */
 .globl _KiServiceExit2              /* Exit from syscall with complete frame*/
@@ -1295,7 +1299,7 @@
     ret
 .endfunc
 
-/* INTERRUPT HANDLERS ********************************************************/
+/* UNEXPECTED INTERRUPT HANDLERS **********************************************/
 
 .globl _KiStartUnexpected
 _KiStartUnexpected:
@@ -1346,3 +1350,20 @@
     /* Bugcheck with invalid interrupt code */
     push 0x12
     call _KeBugCheck at 4
+
+/* INTERRUPT HANDLERS ********************************************************/
+
+.func KiInterruptTemplate
+_KiInterruptTemplate:
+
+    /* Enter interrupt trap */
+    INT_PROLOG kit, DoPushFakeErrorCode
+.endfunc
+
+_KiInterruptTemplate2ndDispatch:
+    /* Dummy code, will be replaced by the address of the KINTERRUPT */
+    mov edi, 0
+
+_KiInterruptTemplateObject:
+    /* Dummy jump, will be replaced by the actual jump */
+    jmp _KeSynchronizeExecution at 12




More information about the Ros-diffs mailing list