]> git.ipfire.org Git - ipfire-2.x.git/blob - src/hwinfo/src/x86emu/x86emu/debug.h
Zwischencommit Installer...
[ipfire-2.x.git] / src / hwinfo / src / x86emu / x86emu / debug.h
1 /****************************************************************************
2 *
3 * Realmode X86 Emulator Library
4 *
5 * Copyright (C) 1996-1999 SciTech Software, Inc.
6 * Copyright (C) David Mosberger-Tang
7 * Copyright (C) 1999 Egbert Eich
8 *
9 * ========================================================================
10 *
11 * Permission to use, copy, modify, distribute, and sell this software and
12 * its documentation for any purpose is hereby granted without fee,
13 * provided that the above copyright notice appear in all copies and that
14 * both that copyright notice and this permission notice appear in
15 * supporting documentation, and that the name of the authors not be used
16 * in advertising or publicity pertaining to distribution of the software
17 * without specific, written prior permission. The authors makes no
18 * representations about the suitability of this software for any purpose.
19 * It is provided "as is" without express or implied warranty.
20 *
21 * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
22 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
23 * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
24 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
25 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27 * PERFORMANCE OF THIS SOFTWARE.
28 *
29 * ========================================================================
30 *
31 * Language: ANSI C
32 * Environment: Any
33 * Developer: Kendall Bennett
34 *
35 * Description: Header file for debug definitions.
36 *
37 ****************************************************************************/
38 /* $XFree86: xc/extras/x86emu/src/x86emu/x86emu/debug.h,v 1.3 2000/04/19 15:48:15 tsi Exp $ */
39
40 #ifndef __X86EMU_DEBUG_H
41 #define __X86EMU_DEBUG_H
42
43 /*---------------------- Macros and type definitions ----------------------*/
44
45 /* checks to be enabled for "runtime" */
46
47 #define CHECK_IP_FETCH_F 0x1
48 #define CHECK_SP_ACCESS_F 0x2
49 #define CHECK_MEM_ACCESS_F 0x4 /*using regular linear pointer */
50 #define CHECK_DATA_ACCESS_F 0x8 /*using segment:offset*/
51
52 #ifdef DEBUG
53 # define CHECK_IP_FETCH() (M.x86.check & CHECK_IP_FETCH_F)
54 # define CHECK_SP_ACCESS() (M.x86.check & CHECK_SP_ACCESS_F)
55 # define CHECK_MEM_ACCESS() (M.x86.check & CHECK_MEM_ACCESS_F)
56 # define CHECK_DATA_ACCESS() (M.x86.check & CHECK_DATA_ACCESS_F)
57 #else
58 # define CHECK_IP_FETCH()
59 # define CHECK_SP_ACCESS()
60 # define CHECK_MEM_ACCESS()
61 # define CHECK_DATA_ACCESS()
62 #endif
63
64 #ifdef DEBUG
65 # define DEBUG_INSTRUMENT() (M.x86.debug & DEBUG_INSTRUMENT_F)
66 # define DEBUG_DECODE() (M.x86.debug & DEBUG_DECODE_F)
67 # define DEBUG_TRACE() (M.x86.debug & DEBUG_TRACE_F)
68 # define DEBUG_STEP() (M.x86.debug & DEBUG_STEP_F)
69 # define DEBUG_DISASSEMBLE() (M.x86.debug & DEBUG_DISASSEMBLE_F)
70 # define DEBUG_BREAK() (M.x86.debug & DEBUG_BREAK_F)
71 # define DEBUG_SVC() (M.x86.debug & DEBUG_SVC_F)
72 # define DEBUG_SAVE_IP_CS() (M.x86.debug & DEBUG_SAVE_IP_CS_F)
73
74 # define DEBUG_FS() (M.x86.debug & DEBUG_FS_F)
75 # define DEBUG_PROC() (M.x86.debug & DEBUG_PROC_F)
76 # define DEBUG_SYSINT() (M.x86.debug & DEBUG_SYSINT_F)
77 # define DEBUG_TRACECALL() (M.x86.debug & DEBUG_TRACECALL_F)
78 # define DEBUG_TRACECALLREGS() (M.x86.debug & DEBUG_TRACECALL_REGS_F)
79 # define DEBUG_SYS() (M.x86.debug & DEBUG_SYS_F)
80 # define DEBUG_MEM_TRACE() (M.x86.debug & DEBUG_MEM_TRACE_F)
81 # define DEBUG_IO_TRACE() (M.x86.debug & DEBUG_IO_TRACE_F)
82 # define DEBUG_DECODE_NOPRINT() (M.x86.debug & DEBUG_DECODE_NOPRINT_F)
83 #else
84 # define DEBUG_INSTRUMENT() 0
85 # define DEBUG_DECODE() 0
86 # define DEBUG_TRACE() 0
87 # define DEBUG_STEP() 0
88 # define DEBUG_DISASSEMBLE() 0
89 # define DEBUG_BREAK() 0
90 # define DEBUG_SVC() 0
91 # define DEBUG_SAVE_IP_CS() 0
92 # define DEBUG_FS() 0
93 # define DEBUG_PROC() 0
94 # define DEBUG_SYSINT() 0
95 # define DEBUG_TRACECALL() 0
96 # define DEBUG_TRACECALLREGS() 0
97 # define DEBUG_SYS() 0
98 # define DEBUG_MEM_TRACE() 0
99 # define DEBUG_IO_TRACE() 0
100 # define DEBUG_DECODE_NOPRINT() 0
101 #endif
102
103 #ifdef DEBUG
104
105 # define DECODE_PRINTF(x) if (DEBUG_DECODE()) \
106 x86emu_decode_printf(x)
107 # define DECODE_PRINTF2(x,y) if (DEBUG_DECODE()) \
108 x86emu_decode_printf2(x,y)
109
110 /*
111 * The following allow us to look at the bytes of an instruction. The
112 * first INCR_INSTRN_LEN, is called everytime bytes are consumed in
113 * the decoding process. The SAVE_IP_CS is called initially when the
114 * major opcode of the instruction is accessed.
115 */
116 #define INC_DECODED_INST_LEN(x) \
117 if (DEBUG_DECODE()) \
118 x86emu_inc_decoded_inst_len(x)
119
120 #define SAVE_IP_CS(x,y) \
121 if (DEBUG_DECODE() | DEBUG_TRACECALL() | DEBUG_BREAK() \
122 | DEBUG_IO_TRACE() | DEBUG_SAVE_IP_CS()) { \
123 M.x86.saved_cs = x; \
124 M.x86.saved_ip = y; \
125 }
126 #else
127 # define INC_DECODED_INST_LEN(x)
128 # define DECODE_PRINTF(x)
129 # define DECODE_PRINTF2(x,y)
130 # define SAVE_IP_CS(x,y)
131 #endif
132
133 #ifdef DEBUG
134 #define TRACE_REGS() \
135 if (DEBUG_DISASSEMBLE()) { \
136 x86emu_just_disassemble(); \
137 goto EndOfTheInstructionProcedure; \
138 } \
139 if (DEBUG_TRACE() || DEBUG_DECODE()) X86EMU_trace_regs()
140 #else
141 # define TRACE_REGS()
142 #endif
143
144 #ifdef DEBUG
145 # define SINGLE_STEP() if (DEBUG_STEP()) x86emu_single_step()
146 #else
147 # define SINGLE_STEP()
148 #endif
149
150 #define TRACE_AND_STEP() \
151 TRACE_REGS(); \
152 SINGLE_STEP()
153
154 #ifdef DEBUG
155 # define START_OF_INSTR()
156 # define END_OF_INSTR() EndOfTheInstructionProcedure: x86emu_end_instr();
157 # define END_OF_INSTR_NO_TRACE() x86emu_end_instr();
158 #else
159 # define START_OF_INSTR()
160 # define END_OF_INSTR()
161 # define END_OF_INSTR_NO_TRACE()
162 #endif
163
164 #ifdef DEBUG
165 # define CALL_TRACE(u,v,w,x,s) \
166 if (DEBUG_TRACECALLREGS()) \
167 x86emu_dump_regs(); \
168 if (DEBUG_TRACECALL()) \
169 printk("%04x:%04x: CALL %s%04x:%04x\n", u , v, s, w, x);
170 # define RETURN_TRACE(n,u,v) \
171 if (DEBUG_TRACECALLREGS()) \
172 x86emu_dump_regs(); \
173 if (DEBUG_TRACECALL()) \
174 printk("%04x:%04x: %s\n",u,v,n);
175 #else
176 # define CALL_TRACE(u,v,w,x,s)
177 # define RETURN_TRACE(n,u,v)
178 #endif
179
180 #ifdef DEBUG
181 #define DB(x) x
182 #else
183 #define DB(x)
184 #endif
185
186 /*-------------------------- Function Prototypes --------------------------*/
187
188 #ifdef __cplusplus
189 extern "C" { /* Use "C" linkage when in C++ mode */
190 #endif
191
192 extern void x86emu_inc_decoded_inst_len (int x);
193 extern void x86emu_decode_printf (char *x);
194 extern void x86emu_decode_printf2 (char *x, int y);
195 extern void x86emu_just_disassemble (void);
196 extern void x86emu_single_step (void);
197 extern void x86emu_end_instr (void);
198 extern void x86emu_dump_regs (void);
199 extern void x86emu_dump_xregs (void);
200 extern void x86emu_print_int_vect (u16 iv);
201 extern void x86emu_instrument_instruction (void);
202 extern void x86emu_check_ip_access (void);
203 extern void x86emu_check_sp_access (void);
204 extern void x86emu_check_mem_access (u32 p);
205 extern void x86emu_check_data_access (uint s, uint o);
206
207 #ifdef __cplusplus
208 } /* End of "C" linkage for C++ */
209 #endif
210
211 #endif /* __X86EMU_DEBUG_H */