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)
15 /* FUNCTIONS ***************************************************************/
18 * Note: DON'T CHANGE THIS FUNCTION!!!
19 * DON'T CALL HalDisplayString OR SOMETING ELSE!!!
20 * You'll only break the serial/bochs debugging feature!!!
24 KdpServiceDispatcher (
33 case 1: /* DbgPrint */
34 Result
= KdpPrintString ((PANSI_STRING
)Context1
);
38 HalDisplayString ("Invalid debug service call!\n");
47 #define STR(x) _STR(x)
51 void interrupt_handler2d(void);
52 __asm__("\n\t.global _interrupt_handler2d\n\t"
53 "_interrupt_handler2d:\n\t"
55 /* Save the user context */
56 "pushl %ebp\n\t" /* Ebp */
58 "pushl %eax\n\t" /* Eax */
59 "pushl %ecx\n\t" /* Ecx */
60 "pushl %edx\n\t" /* Edx */
61 "pushl %ebx\n\t" /* Ebx */
62 "pushl %esi\n\t" /* Esi */
63 "pushl %edi\n\t" /* Edi */
65 "pushl %ds\n\t" /* SegDs */
66 "pushl %es\n\t" /* SegEs */
67 "pushl %fs\n\t" /* SegFs */
68 "pushl %gs\n\t" /* SegGs */
70 "subl $112,%esp\n\t" /* FloatSave */
72 "pushl $0\n\t" /* Dr7 */
73 "pushl $0\n\t" /* Dr6 */
74 "pushl $0\n\t" /* Dr3 */
75 "pushl $0\n\t" /* Dr2 */
76 "pushl $0\n\t" /* Dr1 */
77 "pushl $0\n\t" /* Dr0 */
79 "pushl $0\n\t" /* ContextFlags */
81 /* Set ES to kernel segment */
82 "movw $"STR(KERNEL_DS
)",%bx\n\t"
85 /* FIXME: check to see if SS is valid/inrange */
87 /* DS and GS are now also kernel segments */
91 /* Set FS to the PCR */
92 "movw $"STR(PCR_SELECTOR
)",%bx\n\t"
95 /* Call debug service dispatcher */
99 "call _KdpServiceDispatcher\n\t"
100 "addl $12,%esp\n\t" /* restore stack pointer */
102 /* Restore the user context */
103 "addl $4,%esp\n\t" /* UserContext */
104 "addl $24,%esp\n\t" /* Dr[0-3,6-7] */
105 "addl $112,%esp\n\t" /* FloatingSave */
106 "popl %gs\n\t" /* SegGs */
107 "popl %fs\n\t" /* SegFs */
108 "popl %es\n\t" /* SegEs */
109 "popl %ds\n\t" /* SegDs */
111 "popl %edi\n\t" /* Edi */
112 "popl %esi\n\t" /* Esi */
113 "popl %ebx\n\t" /* Ebx */
114 "popl %edx\n\t" /* Edx */
115 "popl %ecx\n\t" /* Ecx */
116 "addl $4,%esp\n\t" /* Eax (Not restored) */
118 "popl %ebp\n\t" /* Ebp */
122 #elif defined(_MSC_VER)
125 void interrupt_handler2d()
129 /* Save the user context */
143 sub esp
, 112 /* FloatSave */
146 mov eax
, dr7 __asm push eax
147 mov eax
, dr6 __asm push eax
148 mov eax
, dr3 __asm push eax
149 mov eax
, dr2 __asm push eax
150 mov eax
, dr1 __asm push eax
151 mov eax
, dr0 __asm push eax
154 push
0 /* ContextFlags */
156 /* Set ES to kernel segment */
160 /* FIXME: check to see if SS is valid/inrange */
162 mov ds
, bx
/* DS is now also kernel segment */
164 /* Call debug service dispatcher */
168 call KdpServiceDispatcher
169 add esp
, 12 /* restore stack pointer */
171 /* Restore the user context */
172 add esp
, 4 /* UserContext */
173 pop eax __asm mov dr0
, eax
174 pop eax __asm mov dr1
, eax
175 pop eax __asm mov dr2
, eax
176 pop eax __asm mov dr3
, eax
177 pop eax __asm mov dr6
, eax
178 pop eax __asm mov dr7
, eax
179 add esp
, 112 /* FloatingSave */
190 add esp
, 4 /* Eax Not restored */
199 #error Unknown compiler for inline assembler