Redesign of the server communication protocol to allow arbitrary sized
[wine] / include / miscemu.h
1 /*
2  * Misc. emulation definitions
3  *
4  * Copyright 1995 Alexandre Julliard
5  */
6
7 #ifndef __WINE_MISCEMU_H
8 #define __WINE_MISCEMU_H
9
10 #include "winnt.h"
11 #include "selectors.h"
12 #include "wine/windef16.h"
13
14 /* msdos/dosconf.c */
15 extern int DOSCONF_ReadConfig(void);
16
17 /* msdos/dosmem.c */
18 #include "pshpack1.h"
19
20 typedef struct
21 {
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 */
76 } BIOSDATA;
77
78 typedef struct
79 {
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: */
107
108 } VIDEOSTATE;
109
110 typedef struct
111 {
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: */
120
121 } VIDEOFUNCTIONALITY;
122
123 #include "poppack.h"
124
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();
130
131 extern DWORD DOSMEM_CollateTable;
132
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;
138
139 extern DWORD DOS_LOLSeg;
140 extern struct _DOS_LISTOFLISTS * DOSMEM_LOL();
141
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 */
154
155 /* memory/instr.c */
156 extern BOOL INSTR_EmulateInstruction( CONTEXT86 *context );
157
158 /* msdos/devices.c */
159 extern void DOSDEV_InstallDOSDevices(void);
160 extern DWORD DOSDEV_Console(void);
161 extern DWORD DOSDEV_FindCharDevice(char*name);
162 extern int DOSDEV_Peek(DWORD dev, BYTE*data);
163 extern int DOSDEV_Read(DWORD dev, DWORD buf, int buflen);
164 extern int DOSDEV_Write(DWORD dev, DWORD buf, int buflen, int verify);
165 extern int DOSDEV_IoctlRead(DWORD dev, DWORD buf, int buflen);
166 extern int DOSDEV_IoctlWrite(DWORD dev, DWORD buf, int buflen);
167
168 /* msdos/interrupts.c */
169 typedef void WINAPI (*INTPROC)(CONTEXT86*);
170 extern FARPROC16 INT_GetPMHandler( BYTE intnum );
171 extern void INT_SetPMHandler( BYTE intnum, FARPROC16 handler );
172 extern FARPROC16 INT_GetRMHandler( BYTE intnum );
173 extern void INT_SetRMHandler( BYTE intnum, FARPROC16 handler );
174 extern FARPROC16 INT_CtxGetHandler( CONTEXT86 *context, BYTE intnum );
175 extern void INT_CtxSetHandler( CONTEXT86 *context, BYTE intnum, FARPROC16 handler );
176 extern int INT_RealModeInterrupt( BYTE intnum, CONTEXT86 *context );
177 extern INTPROC INT_GetWineHandler( BYTE intnum );
178 extern void INT_SetWineHandler( BYTE intnum, INTPROC proc );
179
180 /* msdos/ioports.c */
181 extern DWORD IO_inport( int port, int count );
182 extern void IO_outport( int port, int count, DWORD value );
183
184 /* msdos/int09.c */
185 extern void WINAPI INT_Int09Handler(CONTEXT86*);
186 extern void WINAPI INT_Int09SendScan(BYTE scan,BYTE ascii);
187 extern BYTE WINAPI INT_Int09ReadScan(BYTE*ascii);
188
189 /* msdos/int10.c */
190 extern void WINAPI INT_Int10Handler(CONTEXT86*);
191
192 /* msdos/int11.c */
193 extern void WINAPI INT_Int11Handler(CONTEXT86*);
194
195 /* msdos/int12.c */
196 extern void WINAPI INT_Int12Handler(CONTEXT86*);
197
198 /* msdos/int13.c */
199 extern void WINAPI INT_Int13Handler(CONTEXT86*);
200
201 /* msdos/int15.c */
202 extern void WINAPI INT_Int15Handler(CONTEXT86*);
203
204 /* msdos/int16.c */
205 extern void WINAPI INT_Int16Handler(CONTEXT86*);
206 extern int WINAPI INT_Int16ReadChar(BYTE*ascii,BYTE*scan,BOOL peek);
207 extern int WINAPI INT_Int16AddChar(BYTE ascii,BYTE scan);
208
209 /* msdos/int17.c */
210 extern void WINAPI INT_Int17Handler(CONTEXT86*);
211
212 /* msdos/int19.c */
213 extern void WINAPI INT_Int19Handler(CONTEXT86*);
214
215 /* msdos/int1a.c */
216 extern DWORD INT1A_GetTicksSinceMidnight(void);
217 extern void WINAPI INT_Int1aHandler(CONTEXT86*);
218
219 /* msdos/int20.c */
220 extern void WINAPI INT_Int20Handler(CONTEXT86*);
221
222 /* msdos/int25.c */
223 extern void WINAPI INT_Int25Handler(CONTEXT86*);
224
225 /* msdos/int26.c */
226 extern void WINAPI INT_Int26Handler(CONTEXT86*);
227
228 /* msdos/int29.c */
229 extern void WINAPI INT_Int29Handler(CONTEXT86*);
230
231 /* msdos/int2a.c */
232 extern void WINAPI INT_Int2aHandler(CONTEXT86*);
233
234 /* msdos/int2f.c */
235 extern void WINAPI INT_Int2fHandler(CONTEXT86*);
236
237 /* msdos/int33.c */
238 extern void WINAPI INT_Int33Handler(CONTEXT86*);
239 extern void WINAPI INT_Int33Message(UINT,WPARAM,LPARAM);
240
241 /* msdos/dpmi.c */
242 typedef void WINAPI (*RMCBPROC)(CONTEXT86*);
243 extern void WINAPI INT_Int31Handler(CONTEXT86*);
244 extern BOOL DPMI_LoadDosSystem(void);
245 extern FARPROC16 WINAPI DPMI_AllocInternalRMCB(RMCBPROC);
246 extern void WINAPI DPMI_FreeInternalRMCB(FARPROC16);
247 extern int DPMI_CallRMProc(CONTEXT86*,LPWORD,int,int);
248
249 /* msdos/xms.c */
250 extern void WINAPI XMS_Handler(CONTEXT86*);
251
252 /* misc/aspi.c */
253 extern void ASPI_DOS_HandleInt(CONTEXT86 *context);
254
255 /* misc/ppdev.c */
256
257 extern BOOL IO_pp_outp(int port, DWORD* res);
258 extern int IO_pp_inp(int port, DWORD* res);
259 extern char IO_pp_init(void);
260
261 #define PTR_REAL_TO_LIN(seg,off) \
262    ((void*)(((unsigned int)(seg) << 4) + LOWORD(off)))
263
264 /* NOTE: Interrupts might get called from three modes: real mode, 16-bit, and 
265  *        (via DeviceIoControl) 32-bit. For automatic conversion of pointer 
266  *       parameters, interrupt handlers should use CTX_SEG_OFF_TO_LIN with
267  *       the contents of a segment register as second and the contents of
268  *       a *32-bit* general register as third parameter, e.g.
269  *          CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EDX_reg(context) )
270  *       This will generate a linear pointer in all three cases:
271  *         Real-Mode:   Seg*16 + LOWORD(Offset)
272  *         16-bit:      convert (Seg, LOWORD(Offset)) to linear
273  *         32-bit:      use Offset as linear address (DeviceIoControl!)
274  *
275  *       Real-mode is recognized by checking the V86 bit in the flags register,
276  *       32-bit mode is recognized by checking whether 'seg' is a system selector
277  *       (0 counts also as 32-bit segment).
278  */
279 #define CTX_SEG_OFF_TO_LIN(context,seg,off) \
280     (ISV86(context) ? PTR_REAL_TO_LIN((seg),(off)) : \
281      (!seg || IS_SELECTOR_SYSTEM(seg))? (void *)(off) : MapSL(MAKESEGPTR((seg),(off))))
282
283 #define INT_BARF(context,num) \
284     ERR( "int%x: unknown/not implemented parameters:\n" \
285                      "int%x: AX %04x, BX %04x, CX %04x, DX %04x, " \
286                      "SI %04x, DI %04x, DS %04x, ES %04x\n", \
287              (num), (num), LOWORD((context)->Eax), LOWORD((context)->Ebx), \
288              LOWORD((context)->Ecx), LOWORD((context)->Edx), LOWORD((context)->Esi), \
289              LOWORD((context)->Edi), (WORD)(context)->SegDs, (WORD)(context)->SegEs )
290
291 #endif /* __WINE_MISCEMU_H */