- Fix inclusion of deleted file.
[reactos.git] / reactos / ntoskrnl / kdbg / i386 / kdb_help.S
1 #include <ndk/asm.h>
2
3 .text
4
5 .globl _KdbEnter
6 _KdbEnter:
7 /*
8 * Set up a trap frame
9 */
10 pushfl /* Eflags */
11 pushl %cs /* Cs */
12 pushl $0 /* ErrorCode */
13 pushl %ebp /* Ebp */
14 pushl %ebx /* Ebx */
15 movl 20(%esp), %ebp /* Eip */
16 movl 16(%esp), %ebx /* Eflags */
17 movl %ebx, 20(%esp)
18 movl 12(%esp), %ebx /* Cs */
19 movl %ebx, 16(%esp)
20 movl %ebp, 12(%esp)
21 pushl %esi /* Esi */
22 pushl %edi /* Edi */
23 pushl %fs /* Fs */
24 pushl $0 /* ExceptionList */
25 pushl $0 /* PreviousMode */
26 pushl %eax /* Eax */
27 pushl %ecx /* Ecx */
28 pushl %edx /* Edx */
29 pushl %ds /* Ds */
30 pushl %es /* Es */
31 pushl %gs /* Gs */
32 movl %dr7, %eax
33 pushl %eax /* Dr7 */
34 /* Clear all breakpoint enables in dr7. */
35 andl $0xFFFF0000, %eax
36 movl %eax, %dr7
37 movl %dr6, %eax
38 pushl %eax /* Dr6 */
39 movl %dr3, %eax
40 pushl %eax /* Dr3 */
41 movl %dr2, %eax
42 pushl %eax /* Dr2 */
43 movl %dr1, %eax
44 pushl %eax /* Dr1 */
45 movl %dr0, %eax
46 pushl %eax /* Dr0 */
47 leal 0x58(%esp), %eax
48 pushl %eax /* TempEsp */
49 pushl %ss /* TempSegSs */
50 pushl $0 /* DebugPointer */
51 pushl $3 /* DebugArgMark (Exception number) */
52 pushl 0x60(%esp) /* DebugEip */
53 pushl %ebp /* DebugEbp */
54
55 /*
56 * Call KDB
57 */
58 movl %esp, %eax
59 pushl $1 /* FirstChance */
60 pushl %eax /* Push a pointer to the trap frame */
61 pushl $0 /* Context */
62 pushl $0 /* PreviousMode (KernelMode) */
63 pushl $0 /* ExceptionRecord */
64 call _KdbEnterDebuggerException
65
66 /*
67 * Pop the arguments and unused portions of the trap frame:
68 * DebugEbp
69 * DebugEip
70 * DebugArgMark
71 * DebugPointer
72 * TempSegSs
73 * TempEsp
74 */
75 addl $(11*4), %esp
76
77 /*
78 * Restore/update debugging registers.
79 */
80 popl %eax /* Dr0 */
81 movl %eax, %dr0
82 popl %eax /* Dr1 */
83 movl %eax, %dr1
84 popl %eax /* Dr2 */
85 movl %eax, %dr2
86 popl %eax /* Dr3 */
87 movl %eax, %dr3
88 popl %eax /* Dr6 */
89 movl %eax, %dr6
90 popl %eax /* Dr7 */
91 movl %eax, %dr7
92
93 /*
94 * Restore registers including any that might have been changed
95 * inside the debugger.
96 */
97 popl %gs /* Gs */
98 popl %es /* Es */
99 popl %ds /* Ds */
100 popl %edx /* Edx */
101 popl %ecx /* Ecx */
102 popl %eax /* Eax */
103 addl $8, %esp /* PreviousMode, ExceptionList */
104 popl %fs /* Fs */
105 popl %edi /* Edi */
106 popl %esi /* Esi */
107 popl %ebx /* Ebx */
108 popl %ebp /* Ebp */
109 addl $4, %esp /* ErrorCode */
110
111 /*
112 * Return to the caller.
113 */
114 iret
115
116
117 .globl _KdbpStackSwitchAndCall@8
118 _KdbpStackSwitchAndCall@8:
119 pushl %ebp
120 movl %esp, %ebp
121
122 movl 0x8(%esp), %eax /* New stack */
123 movl 0xC(%esp), %ecx /* Function to call */
124 movl %esp, %edx /* Old stack */
125
126 /* Switch stack */
127 movl %eax, %esp
128 pushl %edx
129
130 /* Call function */
131 call *%ecx
132
133 /* Switch back to old stack */
134 popl %esp
135
136 /* Return */
137 popl %ebp
138 ret $8
139