Added KiDebugService. Will optimize soon to use common Exit code
Modified: trunk/reactos/ntoskrnl/Makefile
Deleted: trunk/reactos/ntoskrnl/kd/service.c
Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
Modified: trunk/reactos/ntoskrnl/ke/i386/syscall.S

Modified: trunk/reactos/ntoskrnl/Makefile
--- trunk/reactos/ntoskrnl/Makefile	2005-04-25 14:44:48 UTC (rev 14799)
+++ trunk/reactos/ntoskrnl/Makefile	2005-04-25 15:02:11 UTC (rev 14800)
@@ -332,7 +332,6 @@
 	kd/kdinit.o \
 	kd/kdmain.o \
 	kd/kdio.o \
-	kd/service.o \
 	kd/wrappers/gdbstub.o \
 	kd/wrappers/bochs.o
 

Deleted: trunk/reactos/ntoskrnl/kd/service.c
--- trunk/reactos/ntoskrnl/kd/service.c	2005-04-25 14:44:48 UTC (rev 14799)
+++ trunk/reactos/ntoskrnl/kd/service.c	2005-04-25 15:02:11 UTC (rev 14800)
@@ -1,170 +0,0 @@
-/*
- * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/kd/service.c
- * PURPOSE:         Debug service dispatcher
- * 
- * PROGRAMMERS:     Eric Kohl (ekohl@abo.rhein-zeitung.de)
- */
-
-#include <ntoskrnl.h>
-
-
-/* FUNCTIONS ***************************************************************/
-
-#define _STR(x) #x
-#define STR(x) _STR(x)
-
-#if defined(__GNUC__)
-
-void interrupt_handler2d(void);
-   __asm__("\n\t.global _interrupt_handler2d\n\t"
-	   "_interrupt_handler2d:\n\t"
-	   
-	   /* Save the user context */
-	   "pushl %ebp\n\t"       /* Ebp */
-	   
-	   "pushl %eax\n\t"       /* Eax */
-	   "pushl %ecx\n\t"       /* Ecx */
-	   "pushl %edx\n\t"       /* Edx */
-	   "pushl %ebx\n\t"       /* Ebx */
-	   "pushl %esi\n\t"       /* Esi */
-	   "pushl %edi\n\t"       /* Edi */
-	   
-	   "pushl %ds\n\t"        /* SegDs */
-	   "pushl %es\n\t"        /* SegEs */
-	   "pushl %fs\n\t"        /* SegFs */
-	   "pushl %gs\n\t"        /* SegGs */
-	   
-	   "subl $112,%esp\n\t"   /* FloatSave */
-	   
-	   "pushl $0\n\t"         /* Dr7 */
-	   "pushl $0\n\t"         /* Dr6 */
-	   "pushl $0\n\t"         /* Dr3 */
-	   "pushl $0\n\t"         /* Dr2 */
-	   "pushl $0\n\t"         /* Dr1 */
-	   "pushl $0\n\t"         /* Dr0 */
-	   
-	   "pushl $0\n\t"         /* ContextFlags */
-	   
-	   /*  Set ES to kernel segment  */
-	   "movw  $"STR(KERNEL_DS)",%bx\n\t"
-	   "movw %bx,%es\n\t"
-	   
-           /* FIXME: check to see if SS is valid/inrange */
-           
-           /*  DS and GS are now also kernel segments */
-           "movw %bx,%ds\n\t"
-	   "movw %bx,%gs\n\t"
-
-           /* Set FS to the PCR */
-	   "movw  $"STR(PCR_SELECTOR)",%bx\n\t"
-	   "movw  %bx,%fs\n\t"
-           
-           /* Call debug service dispatcher */
-           "pushl %edx\n\t"
-           "pushl %ecx\n\t"
-           "pushl %eax\n\t"
-	   "call _KdpServiceDispatcher@12\n\t"
-
-	   /*  Restore the user context  */
-	   "addl $4,%esp\n\t"    /* UserContext */
-	   "addl $24,%esp\n\t"   /* Dr[0-3,6-7] */
-	   "addl $112,%esp\n\t"  /* FloatingSave */
-	   "popl %gs\n\t"        /* SegGs */
-	   "popl %fs\n\t"        /* SegFs */
-	   "popl %es\n\t"        /* SegEs */
-	   "popl %ds\n\t"        /* SegDs */
-	   
-	   "popl %edi\n\t"       /* Edi */
-	   "popl %esi\n\t"       /* Esi */
-	   "popl %ebx\n\t"       /* Ebx */
-	   "popl %edx\n\t"       /* Edx */
-	   "popl %ecx\n\t"       /* Ecx */
-	   "addl $4,%esp\n\t"    /* Eax (Not restored) */
-	   
-	   "popl %ebp\n\t"       /* Ebp */
-	   
-	   "iret\n\t");
-
-#elif defined(_MSC_VER)
-
-__declspec(naked)
-void interrupt_handler2d()
-{
-	__asm
-	{
-		/* Save the user context */
-		push ebp
-		push eax
-		push ecx
-		push edx
-		push ebx
-		push esi
-		push edi
-
-		push ds
-		push es
-		push fs
-		push gs
-
-		sub esp, 112  /* FloatSave */
-
-		mov ebx, eax
-		mov eax, dr7 __asm push eax
-		mov eax, dr6 __asm push eax
-		mov eax, dr3 __asm push eax
-		mov eax, dr2 __asm push eax
-		mov eax, dr1 __asm push eax
-		mov eax, dr0 __asm push eax
-		mov eax, ebx
-
-		push 0		/* ContextFlags */
-
-		/*  Set ES to kernel segment  */
-		mov bx, KERNEL_DS
-		mov es, bx
-
-		/* FIXME: check to see if SS is valid/inrange */
-
-		mov ds, bx	/*  DS is now also kernel segment */
-
-			/* Call debug service dispatcher */
-		push edx
-		push ecx
-		push eax
-		call KdpServiceDispatcher
-		add esp, 12		/* restore stack pointer */
-
-		/*  Restore the user context  */
-		add esp, 4			/* UserContext */
-		pop eax __asm mov dr0, eax
-		pop eax __asm mov dr1, eax
-		pop eax __asm mov dr2, eax
-		pop eax __asm mov dr3, eax
-		pop eax __asm mov dr6, eax
-		pop eax __asm mov dr7, eax
-		add esp, 112		/* FloatingSave */
-		pop gs
-		pop fs
-		pop es
-		pop ds
-
-		pop edi
-		pop esi
-		pop ebx
-		pop edx
-		pop ecx
-		add esp, 4		/* Eax Not restored */
-
-		pop ebp
-
-		iretd
-	}
-}
-
-#else
-#error Unknown compiler for inline assembler
-#endif
-
-/* EOF */

Modified: trunk/reactos/ntoskrnl/ke/i386/exp.c
--- trunk/reactos/ntoskrnl/ke/i386/exp.c	2005-04-25 14:44:48 UTC (rev 14799)
+++ trunk/reactos/ntoskrnl/ke/i386/exp.c	2005-04-25 15:02:11 UTC (rev 14800)
@@ -27,7 +27,7 @@
 #endif
 
 extern void KiSystemService(void);
-extern void interrupt_handler2d(void);
+extern void KiDebugService(void);
 
 extern VOID KiTrap0(VOID);
 extern VOID KiTrap1(VOID);
@@ -928,7 +928,7 @@
         set_trap_gate(i,(int)KiTrapUnknown, 0);
      }
 
-   set_system_call_gate(0x2d,(int)interrupt_handler2d);
+   set_system_call_gate(0x2d,(int)KiDebugService);
    set_system_call_gate(0x2e,(int)KiSystemService);
 }
 

Modified: trunk/reactos/ntoskrnl/ke/i386/syscall.S
--- trunk/reactos/ntoskrnl/ke/i386/syscall.S	2005-04-25 14:44:48 UTC (rev 14799)
+++ trunk/reactos/ntoskrnl/ke/i386/syscall.S	2005-04-25 15:02:11 UTC (rev 14800)
@@ -25,6 +25,7 @@
 .globl _KiServiceExit2
 .globl _KiFastCallEntry
 .globl _KiSystemService
+.globl _KiDebugService
 
 _KiFastCallEntry:
     
@@ -397,3 +398,79 @@
 
    /* Return to user-mode */
     iret
+    
+.intel_syntax noprefix
+_KiDebugService:
+    /* Save the user context */
+    push ebp
+    push eax
+    push ecx
+    push edx
+    push ebx
+    push esi
+    push edi
+    push ds
+    push es
+    push fs
+    push gs
+    sub esp, 112  /* FloatSave */
+
+    mov ebx, eax
+    mov eax, dr7 
+    push eax
+    mov eax, dr6 
+    push eax
+    mov eax, dr3 
+    push eax
+    mov eax, dr2 
+    push eax
+    mov eax, dr1 
+    push eax
+    mov eax, dr0 
+    push eax
+    mov eax, ebx
+
+    push 0 /* ContextFlags */
+
+    /*  Set ES to kernel segment  */
+    mov bx, KERNEL_DS
+    mov es, bx
+
+    /* FIXME: check to see if SS is valid/inrange */
+
+    mov ds, bx	/*  DS is now also kernel segment */
+
+    /* Call debug service dispatcher */
+    push edx
+    push ecx
+    push eax
+    call _KdpServiceDispatcher@12
+    
+    /*  Restore the user context  */
+    add esp, 4	/* UserContext */
+    pop eax 
+    mov dr0, eax
+    pop eax 
+    mov dr1, eax
+    pop eax 
+    mov dr2, eax
+    pop eax 
+    mov dr3, eax
+    pop eax 
+    mov dr6, eax
+    pop eax 
+    mov dr7, eax
+    add esp, 112  /* FloatingSave */
+    pop gs
+    pop fs
+    pop es
+    pop ds
+    pop edi
+    pop esi
+    pop ebx
+    pop edx
+    pop ecx
+    add esp, 4   /* Eax Not restored */
+    pop ebp
+
+    iretd