2 * Misc. emulation definitions
4 * Copyright 1995 Alexandre Julliard
7 #ifndef __WINE_MISCEMU_H
8 #define __WINE_MISCEMU_H
11 #include "selectors.h"
12 #include "wine/windef16.h"
15 extern int DOSCONF_ReadConfig(void);
22 WORD Com1Addr; /* 00: COM1 I/O address */
23 WORD Com2Addr; /* 02: COM2 I/O address */
24 WORD Com3Addr; /* 04: COM3 I/O address */
25 WORD Com4Addr; /* 06: COM4 I/O address */
26 WORD Lpt1Addr; /* 08: LPT1 I/O address */
27 WORD Lpt2Addr; /* 0a: LPT2 I/O address */
28 WORD Lpt3Addr; /* 0c: LPT3 I/O address */
29 WORD Lpt4Addr; /* 0e: LPT4 I/O address */
30 WORD InstalledHardware; /* 10: Installed hardware flags */
31 BYTE POSTstatus; /* 12: Power-On Self Test status */
32 WORD MemSize WINE_PACKED; /* 13: Base memory size in Kb */
33 WORD unused1 WINE_PACKED; /* 15: Manufacturing test scratch pad */
34 BYTE KbdFlags1; /* 17: Keyboard flags 1 */
35 BYTE KbdFlags2; /* 18: Keyboard flags 2 */
36 BYTE unused2; /* 19: Keyboard driver workspace */
37 WORD NextKbdCharPtr; /* 1a: Next character in kbd buffer */
38 WORD FirstKbdCharPtr; /* 1c: First character in kbd buffer */
39 WORD KbdBuffer[16]; /* 1e: Keyboard buffer */
40 BYTE DisketteStatus1; /* 3e: Diskette recalibrate status */
41 BYTE DisketteStatus2; /* 3f: Diskette motor status */
42 BYTE DisketteStatus3; /* 40: Diskette motor timeout */
43 BYTE DisketteStatus4; /* 41: Diskette last operation status */
44 BYTE DiskStatus[7]; /* 42: Disk status/command bytes */
45 BYTE VideoMode; /* 49: Video mode */
46 WORD VideoColumns; /* 4a: Number of columns */
47 WORD VideoPageSize; /* 4c: Video page size in bytes */
48 WORD VideoPageStartAddr; /* 4e: Video page start address */
49 BYTE VideoCursorPos[16]; /* 50: Cursor position for 8 pages */
50 WORD VideoCursorType; /* 60: Video cursor type */
51 BYTE VideoCurPage; /* 62: Video current page */
52 WORD VideoCtrlAddr WINE_PACKED; /* 63: Video controller address */
53 BYTE VideoReg1; /* 65: Video mode select register */
54 BYTE VideoReg2; /* 66: Video CGA palette register */
55 DWORD ResetEntry WINE_PACKED; /* 67: Warm reset entry point */
56 BYTE LastIRQ; /* 6b: Last unexpected interrupt */
57 DWORD Ticks; /* 6c: Ticks since midnight */
58 BYTE TicksOverflow; /* 70: Timer overflow if past midnight */
59 BYTE CtrlBreakFlag; /* 71: Ctrl-Break flag */
60 WORD ResetFlag; /* 72: POST Reset flag */
61 BYTE DiskOpStatus; /* 74: Last hard-disk operation status */
62 BYTE NbHardDisks; /* 75: Number of hard disks */
63 BYTE DiskCtrlByte; /* 76: Disk control byte */
64 BYTE DiskIOPort; /* 77: Disk I/O port offset */
65 BYTE LptTimeout[4]; /* 78: Timeouts for parallel ports */
66 BYTE ComTimeout[4]; /* 7c: Timeouts for serial ports */
67 WORD KbdBufferStart; /* 80: Keyboard buffer start */
68 WORD KbdBufferEnd; /* 82: Keyboard buffer end */
69 BYTE RowsOnScreenMinus1; /* 84: EGA only */
70 WORD BytesPerChar WINE_PACKED; /* 85: EGA only */
71 BYTE ModeOptions; /* 87: EGA only */
72 BYTE FeatureBitsSwitches; /* 88: EGA only */
73 BYTE VGASettings; /* 89: VGA misc settings */
74 BYTE DisplayCombination; /* 8A: VGA display combinations */
75 BYTE DiskDataRate; /* 8B: Last disk data rate selected */
80 DWORD StaticFuncTable; /* 00: static functionality table */
81 BYTE VideoMode; /* 04: video mode in effect */
82 WORD NumberColumns; /* 05: number of columns */
83 WORD RegenBufLen; /* 07: length of regen buffer in bytes */
84 WORD RegenBufAddr; /* 09: starting address of regen buffer */
85 WORD CursorPos[8]; /* 0B: cursor position for page 0..7 */
86 WORD CursorType; /* 1B: cursor "type" (start/stop scan lines) */
87 BYTE ActivePage; /* 1D: active display page */
88 WORD CRTCPort; /* 1E: CRTC port address */
89 BYTE Port3x8; /* 20: current setting of PORT 03x8h */
90 BYTE Port3x9; /* 21: current setting of PORT 03x9h */
91 BYTE NumberRows; /* 22: number of rows - 1 */
92 WORD BytesPerChar; /* 23: bytes/character */
93 BYTE DCCActive; /* 25: display combination code of active display */
94 BYTE DCCAlternate; /* 26: DCC of alternate display */
95 WORD NumberColors; /* 27: number of colors supported in current mode (0000h = mono) */
96 BYTE NumberPages; /* 29: number of pages supported in current mode */
97 BYTE NumberScanlines; /* 2A: number of scan lines active */
98 BYTE CharBlockPrimary; /* 2B: primary character block */
99 BYTE CharBlockSecondary; /* 2C: secondary character block */
100 BYTE MiscFlags; /* 2D: miscellaneous flags */
101 BYTE NonVGASupport; /* 2E: non-VGA mode support */
102 BYTE _reserved1[2]; /* 2F: */
103 BYTE VideoMem; /* 31: video memory available */
104 BYTE SavePointerState; /* 32: save pointer state flags */
105 BYTE DisplayStatus; /* 33: display information and status */
106 BYTE _reserved2[12]; /* 34: */
112 BYTE ModeSupport[7]; /* 00: modes supported 1..7 */
113 BYTE ScanlineSupport; /* 07: scan lines supported */
114 BYTE NumberCharBlocks; /* 08: total number of character blocks */
115 BYTE ActiveCharBlocks; /* 09: max. number of active character blocks */
116 WORD MiscFlags; /* 0A: miscellaneous function support flags */
117 WORD _reserved1; /* 0C: */
118 BYTE SavePointerFlags; /* 0E: save pointer function flags */
119 BYTE _reserved2; /* OF: */
121 } VIDEOFUNCTIONALITY;
125 extern WORD DOSMEM_0000H;
126 extern WORD DOSMEM_BiosDataSeg;
127 extern WORD DOSMEM_BiosSysSeg;
128 extern BIOSDATA * DOSMEM_BiosData();
129 extern BYTE * DOSMEM_BiosSys();
131 extern DWORD DOSMEM_CollateTable;
133 /* various real-mode code stubs */
134 extern WORD DOSMEM_wrap_seg;
135 extern WORD DOSMEM_xms_seg;
136 extern WORD DOSMEM_dpmi_seg;
137 extern WORD DOSMEM_dpmi_sel;
139 extern DWORD DOS_LOLSeg;
140 extern struct _DOS_LISTOFLISTS * DOSMEM_LOL();
142 extern BOOL DOSMEM_Init(BOOL);
143 extern void DOSMEM_Tick(WORD timer);
144 extern WORD DOSMEM_AllocSelector(WORD);
145 extern char * DOSMEM_MemoryBase(void);
146 extern char * DOSMEM_SystemBase(void);
147 extern LPVOID DOSMEM_GetBlock(UINT size, WORD* p);
148 extern BOOL DOSMEM_FreeBlock(void* ptr);
149 extern LPVOID DOSMEM_ResizeBlock(void* ptr, UINT size, WORD* p);
150 extern UINT DOSMEM_Available(void);
151 extern LPVOID DOSMEM_MapRealToLinear(DWORD); /* real-mode to linear */
152 extern LPVOID DOSMEM_MapDosToLinear(UINT); /* linear DOS to Wine */
153 extern UINT DOSMEM_MapLinearToDos(LPVOID); /* linear Wine to DOS */
156 extern BOOL INSTR_EmulateInstruction( CONTEXT86 *context );
158 /* msdos/interrupts.c */
159 typedef void (WINAPI *INTPROC)(CONTEXT86*);
160 extern FARPROC16 INT_GetPMHandler( BYTE intnum );
161 extern void INT_SetPMHandler( BYTE intnum, FARPROC16 handler );
163 /* msdos/ioports.c */
164 extern DWORD IO_inport( int port, int count );
165 extern void IO_outport( int port, int count, DWORD value );
168 extern void WINAPI INT_Int11Handler(CONTEXT86*);
171 extern void WINAPI INT_Int12Handler(CONTEXT86*);
174 extern void WINAPI INT_Int13Handler(CONTEXT86*);
177 extern void WINAPI INT_Int15Handler(CONTEXT86*);
180 extern DWORD INT1A_GetTicksSinceMidnight(void);
181 extern void WINAPI INT_Int1aHandler(CONTEXT86*);
184 extern void WINAPI INT_Int20Handler(CONTEXT86*);
187 extern void WINAPI INT_Int25Handler(CONTEXT86*);
190 extern void WINAPI INT_Int26Handler(CONTEXT86*);
193 extern void WINAPI INT_Int2aHandler(CONTEXT86*);
196 extern void WINAPI INT_Int2fHandler(CONTEXT86*);
199 typedef void (WINAPI *RMCBPROC)(CONTEXT86*);
200 extern void WINAPI INT_Int31Handler(CONTEXT86*);
201 extern BOOL DPMI_LoadDosSystem(void);
202 extern FARPROC16 WINAPI DPMI_AllocInternalRMCB(RMCBPROC);
203 extern void WINAPI DPMI_FreeInternalRMCB(FARPROC16);
204 extern int DPMI_CallRMProc(CONTEXT86*,LPWORD,int,int);
208 extern BOOL IO_pp_outp(int port, DWORD* res);
209 extern int IO_pp_inp(int port, DWORD* res);
210 extern char IO_pp_init(void);
212 #define PTR_REAL_TO_LIN(seg,off) \
213 ((void*)(((unsigned int)(seg) << 4) + LOWORD(off)))
215 /* NOTE: Interrupts might get called from three modes: real mode, 16-bit, and
216 * (via DeviceIoControl) 32-bit. For automatic conversion of pointer
217 * parameters, interrupt handlers should use CTX_SEG_OFF_TO_LIN with
218 * the contents of a segment register as second and the contents of
219 * a *32-bit* general register as third parameter, e.g.
220 * CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EDX_reg(context) )
221 * This will generate a linear pointer in all three cases:
222 * Real-Mode: Seg*16 + LOWORD(Offset)
223 * 16-bit: convert (Seg, LOWORD(Offset)) to linear
224 * 32-bit: use Offset as linear address (DeviceIoControl!)
226 * Real-mode is recognized by checking the V86 bit in the flags register,
227 * 32-bit mode is recognized by checking whether 'seg' is a system selector
228 * (0 counts also as 32-bit segment).
230 #define CTX_SEG_OFF_TO_LIN(context,seg,off) \
231 (ISV86(context) ? PTR_REAL_TO_LIN((seg),(off)) : \
232 (!seg || IS_SELECTOR_SYSTEM(seg))? (void *)(off) : MapSL(MAKESEGPTR((seg),(off))))
234 #define INT_BARF(context,num) \
235 ERR( "int%x: unknown/not implemented parameters:\n" \
236 "int%x: AX %04x, BX %04x, CX %04x, DX %04x, " \
237 "SI %04x, DI %04x, DS %04x, ES %04x\n", \
238 (num), (num), LOWORD((context)->Eax), LOWORD((context)->Ebx), \
239 LOWORD((context)->Ecx), LOWORD((context)->Edx), LOWORD((context)->Esi), \
240 LOWORD((context)->Edi), (WORD)(context)->SegDs, (WORD)(context)->SegEs )
242 #endif /* __WINE_MISCEMU_H */