1 /* $Id: service.c,v 1.8 2004/01/08 18:54:12 jfilby Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/kd/service.c
6 * PURPOSE: Debug service dispatcher
7 * PROGRAMMER: Eric Kohl (ekohl@abo.rhein-zeitung.de)
12 #include <ddk/ntddk.h>
13 #include <internal/i386/segment.h>
14 #include <internal/kd.h>
16 /* FUNCTIONS ***************************************************************/
19 * Note: DON'T CHANGE THIS FUNCTION!!!
20 * DON'T CALL HalDisplayString OR SOMETING ELSE!!!
21 * You'll only break the serial/bochs debugging feature!!!
25 KdpServiceDispatcher (
34 case 1: /* DbgPrint */
35 Result
= KdpPrintString ((PANSI_STRING
)Context1
);
39 HalDisplayString ("Invalid debug service call!\n");
48 #define STR(x) _STR(x)
52 void interrupt_handler2d(void);
53 __asm__("\n\t.global _interrupt_handler2d\n\t"
54 "_interrupt_handler2d:\n\t"
56 /* Save the user context */
57 "pushl %ebp\n\t" /* Ebp */
59 "pushl %eax\n\t" /* Eax */
60 "pushl %ecx\n\t" /* Ecx */
61 "pushl %edx\n\t" /* Edx */
62 "pushl %ebx\n\t" /* Ebx */
63 "pushl %esi\n\t" /* Esi */
64 "pushl %edi\n\t" /* Edi */
66 "pushl %ds\n\t" /* SegDs */
67 "pushl %es\n\t" /* SegEs */
68 "pushl %fs\n\t" /* SegFs */
69 "pushl %gs\n\t" /* SegGs */
71 "subl $112,%esp\n\t" /* FloatSave */
73 "pushl $0\n\t" /* Dr7 */
74 "pushl $0\n\t" /* Dr6 */
75 "pushl $0\n\t" /* Dr3 */
76 "pushl $0\n\t" /* Dr2 */
77 "pushl $0\n\t" /* Dr1 */
78 "pushl $0\n\t" /* Dr0 */
80 "pushl $0\n\t" /* ContextFlags */
82 /* Set ES to kernel segment */
83 "movw $"STR(KERNEL_DS
)",%bx\n\t"
86 /* FIXME: check to see if SS is valid/inrange */
88 /* DS is now also kernel segment */
91 /* Call debug service dispatcher */
95 "call _KdpServiceDispatcher\n\t"
96 "addl $12,%esp\n\t" /* restore stack pointer */
98 /* Restore the user context */
99 "addl $4,%esp\n\t" /* UserContext */
100 "addl $24,%esp\n\t" /* Dr[0-3,6-7] */
101 "addl $112,%esp\n\t" /* FloatingSave */
102 "popl %gs\n\t" /* SegGs */
103 "popl %fs\n\t" /* SegFs */
104 "popl %es\n\t" /* SegEs */
105 "popl %ds\n\t" /* SegDs */
107 "popl %edi\n\t" /* Edi */
108 "popl %esi\n\t" /* Esi */
109 "popl %ebx\n\t" /* Ebx */
110 "popl %edx\n\t" /* Edx */
111 "popl %ecx\n\t" /* Ecx */
112 "addl $4,%esp\n\t" /* Eax (Not restored) */
114 "popl %ebp\n\t" /* Ebp */
118 #elif defined(_MSC_VER)
121 void interrupt_handler2d()
125 /* Save the user context */
139 sub esp
, 112 /* FloatSave */
142 mov eax
, dr7 __asm push eax
143 mov eax
, dr6 __asm push eax
144 mov eax
, dr3 __asm push eax
145 mov eax
, dr2 __asm push eax
146 mov eax
, dr1 __asm push eax
147 mov eax
, dr0 __asm push eax
150 push
0 /* ContextFlags */
152 /* Set ES to kernel segment */
156 /* FIXME: check to see if SS is valid/inrange */
158 mov ds
, bx
/* DS is now also kernel segment */
160 /* Call debug service dispatcher */
164 call KdpServiceDispatcher
165 add esp
, 12 /* restore stack pointer */
167 /* Restore the user context */
168 add esp
, 4 /* UserContext */
169 pop eax __asm mov dr0
, eax
170 pop eax __asm mov dr1
, eax
171 pop eax __asm mov dr2
, eax
172 pop eax __asm mov dr3
, eax
173 pop eax __asm mov dr6
, eax
174 pop eax __asm mov dr7
, eax
175 add esp
, 112 /* FloatingSave */
186 add esp
, 4 /* Eax Not restored */
195 #error Unknown compiler for inline assembler