]> git.ipfire.org Git - ipfire-2.x.git/blob - src/hwinfo/src/x86emu/include/x86emu.h
Kleiner netter neuer Versuch.
[ipfire-2.x.git] / src / hwinfo / src / x86emu / include / x86emu.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 public specific functions.
36 * Any application linking against us should only
37 * include this header
38 *
39 ****************************************************************************/
40 /* $XFree86$ */
41
42 #ifndef __X86EMU_X86EMU_H
43 #define __X86EMU_X86EMU_H
44
45 #ifdef SCITECH
46 #include "scitech.h"
47 #define X86API _ASMAPI
48 #define X86APIP _ASMAPIP
49 typedef int X86EMU_pioAddr;
50 #else
51 #include "x86emu/types.h"
52 #define X86API
53 #define X86APIP *
54 #endif
55 #include "x86emu/regs.h"
56
57 /*---------------------- Macros and type definitions ----------------------*/
58
59 #ifdef PACK
60 # pragma PACK /* Don't pack structs with function pointers! */
61 #endif
62
63 /****************************************************************************
64 REMARKS:
65 Data structure containing ponters to programmed I/O functions used by the
66 emulator. This is used so that the user program can hook all programmed
67 I/O for the emulator to handled as necessary by the user program. By
68 default the emulator contains simple functions that do not do access the
69 hardware in any way. To allow the emualtor access the hardware, you will
70 need to override the programmed I/O functions using the X86EMU_setupPioFuncs
71 function.
72
73 HEADER:
74 x86emu.h
75
76 MEMBERS:
77 inb - Function to read a byte from an I/O port
78 inw - Function to read a word from an I/O port
79 inl - Function to read a dword from an I/O port
80 outb - Function to write a byte to an I/O port
81 outw - Function to write a word to an I/O port
82 outl - Function to write a dword to an I/O port
83 ****************************************************************************/
84 typedef struct {
85 u8 (X86APIP inb)(X86EMU_pioAddr addr);
86 u16 (X86APIP inw)(X86EMU_pioAddr addr);
87 u32 (X86APIP inl)(X86EMU_pioAddr addr);
88 void (X86APIP outb)(X86EMU_pioAddr addr, u8 val);
89 void (X86APIP outw)(X86EMU_pioAddr addr, u16 val);
90 void (X86APIP outl)(X86EMU_pioAddr addr, u32 val);
91 } X86EMU_pioFuncs;
92
93 /****************************************************************************
94 REMARKS:
95 Data structure containing ponters to memory access functions used by the
96 emulator. This is used so that the user program can hook all memory
97 access functions as necessary for the emulator. By default the emulator
98 contains simple functions that only access the internal memory of the
99 emulator. If you need specialised functions to handle access to different
100 types of memory (ie: hardware framebuffer accesses and BIOS memory access
101 etc), you will need to override this using the X86EMU_setupMemFuncs
102 function.
103
104 HEADER:
105 x86emu.h
106
107 MEMBERS:
108 rdb - Function to read a byte from an address
109 rdw - Function to read a word from an address
110 rdl - Function to read a dword from an address
111 wrb - Function to write a byte to an address
112 wrw - Function to write a word to an address
113 wrl - Function to write a dword to an address
114 ****************************************************************************/
115 typedef struct {
116 u8 (X86APIP rdb)(u32 addr);
117 u16 (X86APIP rdw)(u32 addr);
118 u32 (X86APIP rdl)(u32 addr);
119 void (X86APIP wrb)(u32 addr, u8 val);
120 void (X86APIP wrw)(u32 addr, u16 val);
121 void (X86APIP wrl)(u32 addr, u32 val);
122 } X86EMU_memFuncs;
123
124 /****************************************************************************
125 Here are the default memory read and write
126 function in case they are needed as fallbacks.
127 ***************************************************************************/
128 extern u8 X86API rdb(u32 addr);
129 extern u16 X86API rdw(u32 addr);
130 extern u32 X86API rdl(u32 addr);
131 extern void X86API wrb(u32 addr, u8 val);
132 extern void X86API wrw(u32 addr, u16 val);
133 extern void X86API wrl(u32 addr, u32 val);
134
135 #ifdef END_PACK
136 # pragma END_PACK
137 #endif
138
139 /*--------------------- type definitions -----------------------------------*/
140
141 typedef void (X86APIP X86EMU_intrFuncs)(int num);
142 extern X86EMU_intrFuncs _X86EMU_intrTab[256];
143
144 /*-------------------------- Function Prototypes --------------------------*/
145
146 #ifdef __cplusplus
147 extern "C" { /* Use "C" linkage when in C++ mode */
148 #endif
149
150 void X86EMU_setupMemFuncs(X86EMU_memFuncs *funcs);
151 void X86EMU_setupPioFuncs(X86EMU_pioFuncs *funcs);
152 void X86EMU_setupIntrFuncs(X86EMU_intrFuncs funcs[]);
153 void X86EMU_prepareForInt(int num);
154
155 /* decode.c */
156
157 void X86EMU_exec(unsigned timeout);
158 void X86EMU_halt_sys(void);
159
160 #ifdef DEBUG
161 #define HALT_SYS() \
162 printk("halt_sys: file %s, line %d\n", __FILE__, __LINE__), \
163 X86EMU_halt_sys()
164 #else
165 #define HALT_SYS() X86EMU_halt_sys()
166 #endif
167
168 /* Debug options */
169
170 #define DEBUG_DECODE_F 0x000001 /* print decoded instruction */
171 #define DEBUG_TRACE_F 0x000002 /* dump regs before/after execution */
172 #define DEBUG_STEP_F 0x000004
173 #define DEBUG_DISASSEMBLE_F 0x000008
174 #define DEBUG_BREAK_F 0x000010
175 #define DEBUG_SVC_F 0x000020
176 #define DEBUG_SAVE_IP_CS_F 0x000040
177 #define DEBUG_FS_F 0x000080
178 #define DEBUG_PROC_F 0x000100
179 #define DEBUG_SYSINT_F 0x000200 /* bios system interrupts. */
180 #define DEBUG_TRACECALL_F 0x000400
181 #define DEBUG_INSTRUMENT_F 0x000800
182 #define DEBUG_MEM_TRACE_F 0x001000
183 #define DEBUG_IO_TRACE_F 0x002000
184 #define DEBUG_TRACECALL_REGS_F 0x004000
185 #define DEBUG_DECODE_NOPRINT_F 0x008000
186 #define DEBUG_EXIT 0x010000
187 #define DEBUG_SYS_F (DEBUG_SVC_F|DEBUG_FS_F|DEBUG_PROC_F)
188
189 void X86EMU_trace_regs(void);
190 void X86EMU_trace_xregs(void);
191 void X86EMU_dump_memory(u16 seg, u16 off, u32 amt);
192 int X86EMU_trace_on(void);
193 int X86EMU_trace_off(void);
194
195 #ifdef __cplusplus
196 } /* End of "C" linkage for C++ */
197 #endif
198
199 #endif /* __X86EMU_X86EMU_H */