Commit | Line | Data |
---|---|---|
c906108c SS |
1 | #include <dfs.h> |
2 | #include <stdio.h> | |
3 | #include <string.h> | |
4 | #include <stdlib.h> | |
5 | #include <ctype.h> | |
6 | #include <time.h> | |
7 | #include <conio.h> | |
8 | #include <advanced.h> | |
9 | #include <debugapi.h> | |
10 | #include <process.h> | |
11 | #include <errno.h> | |
12 | #include "i386.h" | |
13 | ||
14 | extern char *mem2hex (void *mem, char *buf, int count, int may_fault); | |
15 | extern char *hex2mem (char *buf, void *mem, int count, int may_fault); | |
16 | extern int computeSignal (int exceptionVector); | |
17 | ||
18 | void | |
fba45db2 | 19 | flush_i_cache (void) |
c906108c SS |
20 | { |
21 | } | |
22 | ||
23 | /* Get the registers out of the frame information. */ | |
24 | ||
25 | void | |
fba45db2 | 26 | frame_to_registers (struct StackFrame *frame, char *regs) |
c906108c SS |
27 | { |
28 | /* Copy EAX -> EDI */ | |
29 | mem2hex (&frame->ExceptionEAX, ®s[0 * 4 * 2], 4 * 8, 0); | |
30 | ||
31 | /* Copy EIP & PS */ | |
32 | mem2hex (&frame->ExceptionPC, ®s[8 * 4 * 2], 4 * 2, 0); | |
33 | ||
34 | /* Copy CS, SS, DS */ | |
35 | mem2hex (&frame->ExceptionCS, ®s[10 * 4 * 2], 4 * 3, 0); | |
36 | ||
37 | /* Copy ES */ | |
38 | mem2hex (&frame->ExceptionES, ®s[13 * 4 * 2], 4 * 1, 0); | |
39 | ||
40 | /* Copy FS & GS */ | |
41 | mem2hex (&frame->ExceptionFS, ®s[14 * 4 * 2], 4 * 2, 0); | |
42 | } | |
43 | ||
44 | /* Put the registers back into the frame information. */ | |
45 | ||
46 | void | |
fba45db2 | 47 | registers_to_frame (char *regs, struct StackFrame *frame) |
c906108c SS |
48 | { |
49 | /* Copy EAX -> EDI */ | |
50 | hex2mem (®s[0 * 4 * 2], &frame->ExceptionEAX, 4 * 8, 0); | |
51 | ||
52 | /* Copy EIP & PS */ | |
53 | hex2mem (®s[8 * 4 * 2], &frame->ExceptionPC, 4 * 2, 0); | |
54 | ||
55 | /* Copy CS, SS, DS */ | |
56 | hex2mem (®s[10 * 4 * 2], &frame->ExceptionCS, 4 * 3, 0); | |
57 | ||
58 | /* Copy ES */ | |
59 | hex2mem (®s[13 * 4 * 2], &frame->ExceptionES, 4 * 1, 0); | |
60 | ||
61 | /* Copy FS & GS */ | |
62 | hex2mem (®s[14 * 4 * 2], &frame->ExceptionFS, 4 * 2, 0); | |
63 | } | |
64 | ||
65 | void | |
fba45db2 | 66 | set_step_traps (struct StackFrame *frame) |
c906108c SS |
67 | { |
68 | frame->ExceptionSystemFlags |= 0x100; | |
69 | } | |
70 | ||
71 | void | |
fba45db2 | 72 | clear_step_traps (struct StackFrame *frame) |
c906108c SS |
73 | { |
74 | frame->ExceptionSystemFlags &= ~0x100; | |
75 | } | |
76 | ||
77 | void | |
fba45db2 | 78 | do_status (char *ptr, struct StackFrame *frame) |
c906108c SS |
79 | { |
80 | int sigval; | |
81 | ||
82 | sigval = computeSignal (frame->ExceptionNumber); | |
83 | ||
84 | sprintf (ptr, "T%02x", sigval); | |
85 | ptr += 3; | |
86 | ||
87 | sprintf (ptr, "%02x:", PC_REGNUM); | |
88 | ptr = mem2hex (&frame->ExceptionPC, ptr + 3, 4, 0); | |
89 | *ptr++ = ';'; | |
90 | ||
91 | sprintf (ptr, "%02x:", SP_REGNUM); | |
92 | ptr = mem2hex (&frame->ExceptionESP, ptr + 3, 4, 0); | |
93 | *ptr++ = ';'; | |
94 | ||
0ba6dca9 | 95 | sprintf (ptr, "%02x:", DEPRECATED_FP_REGNUM); |
c906108c SS |
96 | ptr = mem2hex (&frame->ExceptionEBP, ptr + 3, 4, 0); |
97 | *ptr++ = ';'; | |
98 | ||
99 | *ptr = '\000'; | |
100 | } |