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 public specific functions. 00036 * Any application linking against us should only 00037 * include this header 00038 * 00039 ****************************************************************************/ 00040 /* $XFree86$ */ 00041 00042 #ifndef __X86EMU_X86EMU_H 00043 #define __X86EMU_X86EMU_H 00044 00045 #ifdef SCITECH 00046 #include "scitech.h" 00047 #define X86API _ASMAPI 00048 #define X86APIP _ASMAPIP 00049 typedef int X86EMU_pioAddr; 00050 #else 00051 #include "x86emu/types.h" 00052 #define X86API 00053 #define X86APIP * 00054 #endif 00055 #include "x86emu/regs.h" 00056 00057 /*---------------------- Macros and type definitions ----------------------*/ 00058 00059 #ifdef PACK 00060 # pragma PACK /* Don't pack structs with function pointers! */ 00061 #endif 00062 00063 /**************************************************************************** 00064 REMARKS: 00065 Data structure containing ponters to programmed I/O functions used by the 00066 emulator. This is used so that the user program can hook all programmed 00067 I/O for the emulator to handled as necessary by the user program. By 00068 default the emulator contains simple functions that do not do access the 00069 hardware in any way. To allow the emualtor access the hardware, you will 00070 need to override the programmed I/O functions using the X86EMU_setupPioFuncs 00071 function. 00072 00073 HEADER: 00074 x86emu.h 00075 00076 MEMBERS: 00077 inb - Function to read a byte from an I/O port 00078 inw - Function to read a word from an I/O port 00079 inl - Function to read a dword from an I/O port 00080 outb - Function to write a byte to an I/O port 00081 outw - Function to write a word to an I/O port 00082 outl - Function to write a dword to an I/O port 00083 ****************************************************************************/ 00084 typedef struct { 00085 u8 (X86APIP inb)(X86EMU_pioAddr addr); 00086 u16 (X86APIP inw)(X86EMU_pioAddr addr); 00087 u32 (X86APIP inl)(X86EMU_pioAddr addr); 00088 void (X86APIP outb)(X86EMU_pioAddr addr, u8 val); 00089 void (X86APIP outw)(X86EMU_pioAddr addr, u16 val); 00090 void (X86APIP outl)(X86EMU_pioAddr addr, u32 val); 00091 } X86EMU_pioFuncs; 00092 00093 /**************************************************************************** 00094 REMARKS: 00095 Data structure containing ponters to memory access functions used by the 00096 emulator. This is used so that the user program can hook all memory 00097 access functions as necessary for the emulator. By default the emulator 00098 contains simple functions that only access the internal memory of the 00099 emulator. If you need specialised functions to handle access to different 00100 types of memory (ie: hardware framebuffer accesses and BIOS memory access 00101 etc), you will need to override this using the X86EMU_setupMemFuncs 00102 function. 00103 00104 HEADER: 00105 x86emu.h 00106 00107 MEMBERS: 00108 rdb - Function to read a byte from an address 00109 rdw - Function to read a word from an address 00110 rdl - Function to read a dword from an address 00111 wrb - Function to write a byte to an address 00112 wrw - Function to write a word to an address 00113 wrl - Function to write a dword to an address 00114 ****************************************************************************/ 00115 typedef struct { 00116 u8 (X86APIP rdb)(u32 addr); 00117 u16 (X86APIP rdw)(u32 addr); 00118 u32 (X86APIP rdl)(u32 addr); 00119 void (X86APIP wrb)(u32 addr, u8 val); 00120 void (X86APIP wrw)(u32 addr, u16 val); 00121 void (X86APIP wrl)(u32 addr, u32 val); 00122 } X86EMU_memFuncs; 00123 00124 /**************************************************************************** 00125 Here are the default memory read and write 00126 function in case they are needed as fallbacks. 00127 ***************************************************************************/ 00128 extern u8 X86API rdb(u32 addr); 00129 extern u16 X86API rdw(u32 addr); 00130 extern u32 X86API rdl(u32 addr); 00131 extern void X86API wrb(u32 addr, u8 val); 00132 extern void X86API wrw(u32 addr, u16 val); 00133 extern void X86API wrl(u32 addr, u32 val); 00134 00135 #ifdef END_PACK 00136 # pragma END_PACK 00137 #endif 00138 00139 /*--------------------- type definitions -----------------------------------*/ 00140 00141 typedef void (X86APIP X86EMU_intrFuncs)(int num); 00142 extern X86EMU_intrFuncs _X86EMU_intrTab[256]; 00143 00144 /*-------------------------- Function Prototypes --------------------------*/ 00145 00146 #ifdef __cplusplus 00147 extern "C" { /* Use "C" linkage when in C++ mode */ 00148 #endif 00149 00150 void X86EMU_setupMemFuncs(X86EMU_memFuncs *funcs); 00151 void X86EMU_setupPioFuncs(X86EMU_pioFuncs *funcs); 00152 void X86EMU_setupIntrFuncs(X86EMU_intrFuncs funcs[]); 00153 void X86EMU_prepareForInt(int num); 00154 00155 /* decode.c */ 00156 00157 void X86EMU_exec(unsigned timeout); 00158 void X86EMU_halt_sys(void); 00159 00160 #ifdef DEBUG 00161 #define HALT_SYS() \ 00162 printk("halt_sys: file %s, line %d\n", __FILE__, __LINE__), \ 00163 X86EMU_halt_sys() 00164 #else 00165 #define HALT_SYS() X86EMU_halt_sys() 00166 #endif 00167 00168 /* Debug options */ 00169 00170 #define DEBUG_DECODE_F 0x000001 /* print decoded instruction */ 00171 #define DEBUG_TRACE_F 0x000002 /* dump regs before/after execution */ 00172 #define DEBUG_STEP_F 0x000004 00173 #define DEBUG_DISASSEMBLE_F 0x000008 00174 #define DEBUG_BREAK_F 0x000010 00175 #define DEBUG_SVC_F 0x000020 00176 #define DEBUG_SAVE_IP_CS_F 0x000040 00177 #define DEBUG_FS_F 0x000080 00178 #define DEBUG_PROC_F 0x000100 00179 #define DEBUG_SYSINT_F 0x000200 /* bios system interrupts. */ 00180 #define DEBUG_TRACECALL_F 0x000400 00181 #define DEBUG_INSTRUMENT_F 0x000800 00182 #define DEBUG_MEM_TRACE_F 0x001000 00183 #define DEBUG_IO_TRACE_F 0x002000 00184 #define DEBUG_TRACECALL_REGS_F 0x004000 00185 #define DEBUG_DECODE_NOPRINT_F 0x008000 00186 #define DEBUG_EXIT 0x010000 00187 #define DEBUG_SYS_F (DEBUG_SVC_F|DEBUG_FS_F|DEBUG_PROC_F) 00188 00189 void X86EMU_trace_regs(void); 00190 void X86EMU_trace_xregs(void); 00191 void X86EMU_dump_memory(u16 seg, u16 off, u32 amt); 00192 int X86EMU_trace_on(void); 00193 int X86EMU_trace_off(void); 00194 00195 #ifdef __cplusplus 00196 } /* End of "C" linkage for C++ */ 00197 #endif 00198 00199 #endif /* __X86EMU_X86EMU_H */