[ros-diffs] [ion] 23676: - Implement Chained and Normal generic interrupt handlers. - Make generated handlers have a proper .func symbol for symbol data. - Make IDT writable, the page shouldn't be read-only. - Change some symbol names.

ion at svn.reactos.org ion at svn.reactos.org
Thu Aug 24 03:53:54 CEST 2006


Author: ion
Date: Thu Aug 24 05:53:54 2006
New Revision: 23676

URL: http://svn.reactos.org/svn/reactos?rev=23676&view=rev
Log:
- Implement Chained and Normal generic interrupt handlers.
- Make generated handlers have a proper .func symbol for symbol data.
- Make IDT writable, the page shouldn't be read-only.
- Change some symbol names.

Modified:
    trunk/reactos/hal/halx86/generic/systimer.S
    trunk/reactos/include/ndk/asm.h
    trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S
    trunk/reactos/ntoskrnl/ke/i386/kernel.c
    trunk/reactos/ntoskrnl/ke/i386/trap.s

Modified: trunk/reactos/hal/halx86/generic/systimer.S
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/systimer.S?rev=23676&r1=23675&r2=23676&view=diff
==============================================================================
--- trunk/reactos/hal/halx86/generic/systimer.S (original)
+++ trunk/reactos/hal/halx86/generic/systimer.S Thu Aug 24 05:53:54 2006
@@ -23,3 +23,4 @@
 
     jmp $
 .endfunc
+

Modified: trunk/reactos/include/ndk/asm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/asm.h?rev=23676&r1=23675&r2=23676&view=diff
==============================================================================
--- trunk/reactos/include/ndk/asm.h (original)
+++ trunk/reactos/include/ndk/asm.h Thu Aug 24 05:53:54 2006
@@ -154,6 +154,16 @@
 #define KPCR_PRCB_INTERRUPT_COUNT               0x644
 #define KPCR_SYSTEM_CALLS                       0x6B8
 #define KPCR_PRCB_DPC_ROUTINE_ACTIVE            0x994
+
+//
+// KINTERRUPT Offsets
+//
+#define KINTERRUPT_SERVICE_ROUTINE              0x0C
+#define KINTERRUPT_SERVICE_CONTEXT              0x10
+#define KINTERRUPT_ACTUAL_LOCK                  0x1C
+#define KINTERRUPT_IRQL                         0x20
+#define KINTERRUPT_VECTOR                       0x24
+#define KINTERRUPT_SYNCHRONIZE_IRQL             0x29
 
 //
 // KGDTENTRY Offsets

Modified: trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S?rev=23676&r1=23675&r2=23676&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/asmmacro.S Thu Aug 24 05:53:54 2006
@@ -125,9 +125,11 @@
 // @remark None.
 //
 .macro GENERATE_INT_HANDLER Number
+.func KiUnexpectedInterrupt&Number
 _KiUnexpectedInterrupt&Number:
     push PRIMARY_VECTOR_BASE + Number
-    jmp _KiEndUnexpected
+    jmp _KiEndUnexpectedRange at 0
+.endfunc
 .endm
 
 //

Modified: trunk/reactos/ntoskrnl/ke/i386/kernel.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/kernel.c?rev=23676&r1=23675&r2=23676&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/kernel.c (original)
+++ trunk/reactos/ntoskrnl/ke/i386/kernel.c Thu Aug 24 05:53:54 2006
@@ -489,6 +489,7 @@
 NTAPI
 KeInit2(VOID)
 {
+   ULONG Protect;
    PKIPCR Pcr = (PKIPCR)KeGetCurrentKPCR();
 
    KiInitializeBugCheck();
@@ -548,6 +549,10 @@
    {
       DPRINT("Ke386L2CacheSize: %dkB\n", Pcr->SecondLevelCacheSize);
    }
+
+   /* Set IDT to writable */
+   Protect = MmGetPageProtect(NULL, (PVOID)KiIdt);
+   MmSetPageProtect(NULL, (PVOID)KiIdt, Protect | PAGE_IS_WRITABLE);
 }
 
 VOID INIT_FUNCTION

Modified: trunk/reactos/ntoskrnl/ke/i386/trap.s
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/trap.s?rev=23676&r1=23675&r2=23676&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/ke/i386/trap.s (original)
+++ trunk/reactos/ntoskrnl/ke/i386/trap.s Thu Aug 24 05:53:54 2006
@@ -59,6 +59,12 @@
 /* Interrupt template entrypoints                                           */
 .globl _KiInterruptTemplate
 .globl _KiInterruptTemplateObject
+.globl _KiInterruptTemplateDispatch
+
+/* Chained and Normal generic interrupt handlers for 1st and 2nd level entry*/
+.globl _KiChainedDispatch2ndLvl at 0
+.globl _KiInterruptDispatch3 at 0
+.globl _KiChainedDispatch at 0
 
 /* We implement the following trap exit points:                             */
 .globl _KiServiceExit               /* Exit from syscall                    */
@@ -70,6 +76,10 @@
 _KiIdtDescriptor:
     .short 0x800
     .long _KiIdt
+
+.globl _KiUnexpectedEntrySize
+_KiUnexpectedEntrySize:
+    .long _KiUnexpectedInterrupt1 - _KiUnexpectedInterrupt0
 
 /* SOFTWARE INTERRUPT SERVICES ***********************************************/
 
@@ -1301,12 +1311,13 @@
 
 /* UNEXPECTED INTERRUPT HANDLERS **********************************************/
 
-.globl _KiStartUnexpected
-_KiStartUnexpected:
+.globl _KiStartUnexpectedRange at 0
+_KiStartUnexpectedRange at 0:
 
 GENERATE_INT_HANDLERS
 
-_KiEndUnexpected:
+.globl _KiEndUnexpectedRange at 0
+_KiEndUnexpectedRange at 0:
     jmp _KiUnexpectedInterruptTail
 
 .func KiUnexpectedInterruptTail
@@ -1367,3 +1378,113 @@
 _KiInterruptTemplateObject:
     /* Dummy jump, will be replaced by the actual jump */
     jmp _KeSynchronizeExecution at 12
+
+_KiInterruptTemplateDispatch:
+    /* Marks the end of the template so that the jump above can be edited */
+
+.func KiChainedDispatch2ndLvl at 0
+_KiChainedDispatch2ndLvl at 0:
+
+    /* Not yet supported */
+    int 3
+.endfunc
+
+.func KiChainedDispatch at 0
+_KiChainedDispatch at 0:
+
+    /* Increase interrupt count */
+    inc dword ptr [fs:KPCR_PRCB_INTERRUPT_COUNT]
+
+    /* Save trap frame */
+    mov ebp, esp
+
+    /* Save vector and IRQL */
+    mov eax, [edi+KINTERRUPT_VECTOR]
+    mov ecx, [edi+KINTERRUPT_IRQL]
+
+    /* Save old irql */
+    push eax
+    sub esp, 4
+
+    /* Begin interrupt */
+    push eax
+    push ecx
+    call _HalBeginSystemInterrupt at 12
+
+    /* Check if it was handled */
+    or eax, eax
+    jz SpuriousInt
+    sub esp, 12
+
+    /* Call the 2nd-level handler */
+    call _KiChainedDispatch2ndLvl at 0
+
+    /* Exit the interrupt */
+    mov esi, $
+    cli
+    call _HalEndSystemInterrupt at 8
+    jmp _Kei386EoiHelper at 0
+.endfunc
+
+.func KiInterruptDispatch3 at 0
+_KiInterruptDispatch3 at 0:
+
+    /* Increase interrupt count */
+    inc dword ptr [fs:KPCR_PRCB_INTERRUPT_COUNT]
+
+    /* Save trap frame */
+    mov ebp, esp
+
+    /* Save vector and IRQL */
+    mov eax, [edi+KINTERRUPT_VECTOR]
+    mov ecx, [edi+KINTERRUPT_SYNCHRONIZE_IRQL]
+
+    /* Save old irql */
+    push eax
+    sub esp, 4
+    push esp
+
+    /* Begin interrupt */
+    push eax
+    push ecx
+    call _HalBeginSystemInterrupt at 12
+
+    /* Check if it was handled */
+    or eax, eax
+    jz SpuriousInt
+    sub esp, 12
+
+    /* Acquire the lock */
+GetIntLock:
+    mov esi, [edi+KINTERRUPT_ACTUAL_LOCK]
+    ACQUIRE_SPINLOCK(esi, IntSpin)
+
+    /* Call the ISR */
+    mov eax, [edi+KINTERRUPT_SERVICE_CONTEXT]
+    push eax
+    push edi
+    call [edi+KINTERRUPT_SERVICE_ROUTINE]
+
+    /* Release the lock */
+    RELEASE_SPINLOCK(esi)
+
+    /* Clean up the stack */
+    add esp, 12
+
+    /* Exit the interrupt */
+    mov esi, $
+    cli
+    call _HalEndSystemInterrupt at 8
+    jmp _Kei386EoiHelper at 0
+
+SpuriousInt:
+    /* Exit the interrupt */
+    add esp, 8
+    mov esi, $
+    jmp _Kei386EoiHelper at 0
+
+#ifdef CONFIG_SMP
+IntSpin:
+    SPIN_ON_LOCK esi, GetIntLock
+#endif
+.endfunc




More information about the Ros-diffs mailing list