libhd 5.0
|
00001 /**************************************************************************** 00002 * 00003 * Realmode X86 Emulator Library 00004 * 00005 * Copyright (C) 1996-1999 SciTech Software, Inc. 00006 * Copyright (C) David Mosberger-Tang 00007 * Copyright (C) 1999 Egbert Eich 00008 * 00009 * ======================================================================== 00010 * 00011 * Permission to use, copy, modify, distribute, and sell this software and 00012 * its documentation for any purpose is hereby granted without fee, 00013 * provided that the above copyright notice appear in all copies and that 00014 * both that copyright notice and this permission notice appear in 00015 * supporting documentation, and that the name of the authors not be used 00016 * in advertising or publicity pertaining to distribution of the software 00017 * without specific, written prior permission. The authors makes no 00018 * representations about the suitability of this software for any purpose. 00019 * It is provided "as is" without express or implied warranty. 00020 * 00021 * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 00022 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 00023 * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 00024 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 00025 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00026 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00027 * PERFORMANCE OF THIS SOFTWARE. 00028 * 00029 * ======================================================================== 00030 * 00031 * Language: ANSI C 00032 * Environment: Any 00033 * Developer: Kendall Bennett 00034 * 00035 * Description: Header file for debug definitions. 00036 * 00037 ****************************************************************************/ 00038 /* $XFree86: xc/extras/x86emu/src/x86emu/x86emu/debug.h,v 1.3 2000/04/19 15:48:15 tsi Exp $ */ 00039 00040 #ifndef __X86EMU_DEBUG_H 00041 #define __X86EMU_DEBUG_H 00042 00043 /*---------------------- Macros and type definitions ----------------------*/ 00044 00045 /* checks to be enabled for "runtime" */ 00046 00047 #define CHECK_IP_FETCH_F 0x1 00048 #define CHECK_SP_ACCESS_F 0x2 00049 #define CHECK_MEM_ACCESS_F 0x4 /*using regular linear pointer */ 00050 #define CHECK_DATA_ACCESS_F 0x8 /*using segment:offset*/ 00051 00052 #ifdef DEBUG 00053 # define CHECK_IP_FETCH() (M.x86.check & CHECK_IP_FETCH_F) 00054 # define CHECK_SP_ACCESS() (M.x86.check & CHECK_SP_ACCESS_F) 00055 # define CHECK_MEM_ACCESS() (M.x86.check & CHECK_MEM_ACCESS_F) 00056 # define CHECK_DATA_ACCESS() (M.x86.check & CHECK_DATA_ACCESS_F) 00057 #else 00058 # define CHECK_IP_FETCH() 00059 # define CHECK_SP_ACCESS() 00060 # define CHECK_MEM_ACCESS() 00061 # define CHECK_DATA_ACCESS() 00062 #endif 00063 00064 #ifdef DEBUG 00065 # define DEBUG_INSTRUMENT() (M.x86.debug & DEBUG_INSTRUMENT_F) 00066 # define DEBUG_DECODE() (M.x86.debug & DEBUG_DECODE_F) 00067 # define DEBUG_TRACE() (M.x86.debug & DEBUG_TRACE_F) 00068 # define DEBUG_STEP() (M.x86.debug & DEBUG_STEP_F) 00069 # define DEBUG_DISASSEMBLE() (M.x86.debug & DEBUG_DISASSEMBLE_F) 00070 # define DEBUG_BREAK() (M.x86.debug & DEBUG_BREAK_F) 00071 # define DEBUG_SVC() (M.x86.debug & DEBUG_SVC_F) 00072 # define DEBUG_SAVE_IP_CS() (M.x86.debug & DEBUG_SAVE_IP_CS_F) 00073 00074 # define DEBUG_FS() (M.x86.debug & DEBUG_FS_F) 00075 # define DEBUG_PROC() (M.x86.debug & DEBUG_PROC_F) 00076 # define DEBUG_SYSINT() (M.x86.debug & DEBUG_SYSINT_F) 00077 # define DEBUG_TRACECALL() (M.x86.debug & DEBUG_TRACECALL_F) 00078 # define DEBUG_TRACECALLREGS() (M.x86.debug & DEBUG_TRACECALL_REGS_F) 00079 # define DEBUG_SYS() (M.x86.debug & DEBUG_SYS_F) 00080 # define DEBUG_MEM_TRACE() (M.x86.debug & DEBUG_MEM_TRACE_F) 00081 # define DEBUG_IO_TRACE() (M.x86.debug & DEBUG_IO_TRACE_F) 00082 # define DEBUG_DECODE_NOPRINT() (M.x86.debug & DEBUG_DECODE_NOPRINT_F) 00083 #else 00084 # define DEBUG_INSTRUMENT() 0 00085 # define DEBUG_DECODE() 0 00086 # define DEBUG_TRACE() 0 00087 # define DEBUG_STEP() 0 00088 # define DEBUG_DISASSEMBLE() 0 00089 # define DEBUG_BREAK() 0 00090 # define DEBUG_SVC() 0 00091 # define DEBUG_SAVE_IP_CS() 0 00092 # define DEBUG_FS() 0 00093 # define DEBUG_PROC() 0 00094 # define DEBUG_SYSINT() 0 00095 # define DEBUG_TRACECALL() 0 00096 # define DEBUG_TRACECALLREGS() 0 00097 # define DEBUG_SYS() 0 00098 # define DEBUG_MEM_TRACE() 0 00099 # define DEBUG_IO_TRACE() 0 00100 # define DEBUG_DECODE_NOPRINT() 0 00101 #endif 00102 00103 #ifdef DEBUG 00104 00105 # define DECODE_PRINTF(x) if (DEBUG_DECODE()) \ 00106 x86emu_decode_printf(x) 00107 # define DECODE_PRINTF2(x,y) if (DEBUG_DECODE()) \ 00108 x86emu_decode_printf2(x,y) 00109 00110 /* 00111 * The following allow us to look at the bytes of an instruction. The 00112 * first INCR_INSTRN_LEN, is called everytime bytes are consumed in 00113 * the decoding process. The SAVE_IP_CS is called initially when the 00114 * major opcode of the instruction is accessed. 00115 */ 00116 #define INC_DECODED_INST_LEN(x) \ 00117 if (DEBUG_DECODE()) \ 00118 x86emu_inc_decoded_inst_len(x) 00119 00120 #define SAVE_IP_CS(x,y) \ 00121 if (DEBUG_DECODE() | DEBUG_TRACECALL() | DEBUG_BREAK() \ 00122 | DEBUG_IO_TRACE() | DEBUG_SAVE_IP_CS()) { \ 00123 M.x86.saved_cs = x; \ 00124 M.x86.saved_ip = y; \ 00125 } 00126 #else 00127 # define INC_DECODED_INST_LEN(x) 00128 # define DECODE_PRINTF(x) 00129 # define DECODE_PRINTF2(x,y) 00130 # define SAVE_IP_CS(x,y) 00131 #endif 00132 00133 #ifdef DEBUG 00134 #define TRACE_REGS() \ 00135 if (DEBUG_DISASSEMBLE()) { \ 00136 x86emu_just_disassemble(); \ 00137 goto EndOfTheInstructionProcedure; \ 00138 } \ 00139 if (DEBUG_TRACE() || DEBUG_DECODE()) X86EMU_trace_regs() 00140 #else 00141 # define TRACE_REGS() 00142 #endif 00143 00144 #ifdef DEBUG 00145 # define SINGLE_STEP() if (DEBUG_STEP()) x86emu_single_step() 00146 #else 00147 # define SINGLE_STEP() 00148 #endif 00149 00150 #define TRACE_AND_STEP() \ 00151 TRACE_REGS(); \ 00152 SINGLE_STEP() 00153 00154 #ifdef DEBUG 00155 # define START_OF_INSTR() 00156 # define END_OF_INSTR() EndOfTheInstructionProcedure: x86emu_end_instr(); 00157 # define END_OF_INSTR_NO_TRACE() x86emu_end_instr(); 00158 #else 00159 # define START_OF_INSTR() 00160 # define END_OF_INSTR() 00161 # define END_OF_INSTR_NO_TRACE() 00162 #endif 00163 00164 #ifdef DEBUG 00165 # define CALL_TRACE(u,v,w,x,s) \ 00166 if (DEBUG_TRACECALLREGS()) \ 00167 x86emu_dump_regs(); \ 00168 if (DEBUG_TRACECALL()) \ 00169 printk("%04x:%04x: CALL %s%04x:%04x\n", u , v, s, w, x); 00170 # define RETURN_TRACE(n,u,v) \ 00171 if (DEBUG_TRACECALLREGS()) \ 00172 x86emu_dump_regs(); \ 00173 if (DEBUG_TRACECALL()) \ 00174 printk("%04x:%04x: %s\n",u,v,n); 00175 #else 00176 # define CALL_TRACE(u,v,w,x,s) 00177 # define RETURN_TRACE(n,u,v) 00178 #endif 00179 00180 #ifdef DEBUG 00181 #define DB(x) x 00182 #else 00183 #define DB(x) 00184 #endif 00185 00186 /*-------------------------- Function Prototypes --------------------------*/ 00187 00188 #ifdef __cplusplus 00189 extern "C" { /* Use "C" linkage when in C++ mode */ 00190 #endif 00191 00192 extern void x86emu_inc_decoded_inst_len (int x); 00193 extern void x86emu_decode_printf (char *x); 00194 extern void x86emu_decode_printf2 (char *x, int y); 00195 extern void x86emu_just_disassemble (void); 00196 extern void x86emu_single_step (void); 00197 extern void x86emu_end_instr (void); 00198 extern void x86emu_dump_regs (void); 00199 extern void x86emu_dump_xregs (void); 00200 extern void x86emu_print_int_vect (u16 iv); 00201 extern void x86emu_instrument_instruction (void); 00202 extern void x86emu_check_ip_access (void); 00203 extern void x86emu_check_sp_access (void); 00204 extern void x86emu_check_mem_access (u32 p); 00205 extern void x86emu_check_data_access (uint s, uint o); 00206 00207 #ifdef __cplusplus 00208 } /* End of "C" linkage for C++ */ 00209 #endif 00210 00211 #endif /* __X86EMU_DEBUG_H */