4 * Copyright 1998 Ove Kåven
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __WINE_DOSEXE_H
22 #define __WINE_DOSEXE_H
24 #include "wine/windef16.h"
25 #include "winbase.h" /* for LPSTARTUPINFO32A */
26 #include "winnt.h" /* for PCONTEXT */
27 #include "wincon.h" /* for MOUSE_EVENT_RECORD */
33 /* amount of space reserved for relay stack */
34 #define DOSVM_RELAY_DATA_SIZE 4096
36 /* various real-mode code stubs */
49 /* 48-bit segmented pointers for DOS DPMI32 */
53 } SEGPTR48, FARPROC48;
55 #define DOSCONF_MEM_HIGH 0x0001
56 #define DOSCONF_MEM_UMB 0x0002
57 #define DOSCONF_NUMLOCK 0x0004
58 #define DOSCONF_KEYB_CONV 0x0008
74 typedef void (*DOSRELAY)(CONTEXT86*,void*);
75 typedef void (WINAPI *RMCBPROC)(CONTEXT86*);
76 typedef void (WINAPI *INTPROC)(CONTEXT86*);
78 #define DOS_PRIORITY_REALTIME 1 /* IRQ0 - FIXME: should be 0 */
79 #define DOS_PRIORITY_KEYBOARD 0 /* IRQ1 - FIXME: should be 1 */
80 #define DOS_PRIORITY_VGA 2 /* IRQ9 */
81 #define DOS_PRIORITY_MOUSE 5 /* IRQ12 */
82 #define DOS_PRIORITY_SERIAL 10 /* IRQ4 */
84 extern WORD DOSVM_psp; /* psp of current DOS task */
85 extern WORD DOSVM_retval; /* return value of previous DOS task */
86 extern struct DPMI_segments *DOSVM_dpmi_segments;
88 #if defined(linux) && defined(__i386__) && defined(HAVE_SYS_VM86_H)
90 #endif /* linux-i386 */
92 #define V86_FLAG 0x00020000
94 #define BIOS_DATA ((void *)0x400)
96 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
99 extern void WINAPI MZ_LoadImage( LPCSTR filename, HANDLE hFile );
100 extern BOOL WINAPI MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk );
101 extern void WINAPI MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval );
102 extern BOOL WINAPI MZ_Current( void );
103 extern void WINAPI MZ_AllocDPMITask( void );
104 extern void WINAPI MZ_RunInThread( PAPCFUNC proc, ULONG_PTR arg );
105 extern BOOL DOSVM_IsWin16(void);
108 extern INT WINAPI DOSVM_Enter( CONTEXT86 *context );
109 extern void WINAPI DOSVM_Wait( CONTEXT86 * );
110 extern DWORD WINAPI DOSVM_Loop( HANDLE hThread );
111 extern void WINAPI DOSVM_QueueEvent( INT irq, INT priority, DOSRELAY relay, LPVOID data );
112 extern void WINAPI DOSVM_PIC_ioport_out( WORD port, BYTE val );
113 extern void WINAPI DOSVM_SetTimer( UINT ticks );
114 extern UINT WINAPI DOSVM_GetTimer( void );
117 extern void DOSDEV_InstallDOSDevices(void);
118 extern DWORD DOSDEV_Console(void);
119 extern DWORD DOSDEV_FindCharDevice(char*name);
120 extern int DOSDEV_Peek(DWORD dev, BYTE*data);
121 extern int DOSDEV_Read(DWORD dev, DWORD buf, int buflen);
122 extern int DOSDEV_Write(DWORD dev, DWORD buf, int buflen, int verify);
123 extern int DOSDEV_IoctlRead(DWORD dev, DWORD buf, int buflen);
124 extern int DOSDEV_IoctlWrite(DWORD dev, DWORD buf, int buflen);
125 extern struct _DOS_LISTOFLISTS * DOSMEM_LOL();
128 extern int DMA_Transfer(int channel,int reqlength,void* buffer);
129 extern void DMA_ioport_out( WORD port, BYTE val );
130 extern BYTE DMA_ioport_in( WORD port );
133 void WINAPI DOSVM_ASPIHandler(CONTEXT86*);
136 DOSCONF *DOSCONF_GetConfig( void );
139 extern void WINAPI DOSVM_Int34Handler(CONTEXT86*);
140 extern void WINAPI DOSVM_Int35Handler(CONTEXT86*);
141 extern void WINAPI DOSVM_Int36Handler(CONTEXT86*);
142 extern void WINAPI DOSVM_Int37Handler(CONTEXT86*);
143 extern void WINAPI DOSVM_Int38Handler(CONTEXT86*);
144 extern void WINAPI DOSVM_Int39Handler(CONTEXT86*);
145 extern void WINAPI DOSVM_Int3aHandler(CONTEXT86*);
146 extern void WINAPI DOSVM_Int3bHandler(CONTEXT86*);
147 extern void WINAPI DOSVM_Int3cHandler(CONTEXT86*);
148 extern void WINAPI DOSVM_Int3dHandler(CONTEXT86*);
149 extern void WINAPI DOSVM_Int3eHandler(CONTEXT86*);
152 extern void DOSVM_InitSegments(void);
153 extern LPVOID DOSVM_AllocUMB(DWORD);
154 extern LPVOID DOSVM_AllocCodeUMB(DWORD, WORD *, WORD *);
155 extern LPVOID DOSVM_AllocDataUMB(DWORD, WORD *, WORD *);
158 extern void WINAPI DOSVM_Int09Handler(CONTEXT86*);
159 extern void WINAPI DOSVM_Int09SendScan(BYTE scan,BYTE ascii);
160 extern BYTE WINAPI DOSVM_Int09ReadScan(BYTE*ascii);
163 extern void WINAPI DOSVM_Int10Handler(CONTEXT86*);
164 extern void WINAPI DOSVM_PutChar(BYTE ascii);
167 extern void WINAPI DOSVM_Int11Handler(CONTEXT86*);
170 extern void WINAPI DOSVM_Int12Handler(CONTEXT86*);
173 extern void WINAPI DOSVM_Int13Handler(CONTEXT86*);
176 extern void WINAPI DOSVM_Int15Handler(CONTEXT86*);
179 extern void WINAPI DOSVM_Int1aHandler(CONTEXT86*);
182 extern void WINAPI DOSVM_Int16Handler(CONTEXT86*);
183 extern BOOL WINAPI DOSVM_Int16ReadChar( BYTE *, BYTE *, CONTEXT86 * );
184 extern int WINAPI DOSVM_Int16AddChar(BYTE ascii,BYTE scan);
187 extern void WINAPI DOSVM_Int17Handler(CONTEXT86*);
190 extern void WINAPI DOSVM_Int19Handler(CONTEXT86*);
193 extern void WINAPI DOSVM_Int20Handler(CONTEXT86*);
196 extern void WINAPI DOSVM_Int21Handler(CONTEXT86*);
199 BOOL DOSVM_RawRead( BYTE, DWORD, DWORD, BYTE *, BOOL );
200 void WINAPI DOSVM_Int25Handler( CONTEXT86 * );
203 BOOL DOSVM_RawWrite( BYTE, DWORD, DWORD, BYTE *, BOOL );
204 void WINAPI DOSVM_Int26Handler( CONTEXT86 * );
207 extern void WINAPI DOSVM_Int29Handler(CONTEXT86*);
210 extern void WINAPI DOSVM_Int2aHandler(CONTEXT86*);
213 extern void WINAPI DOSVM_Int2fHandler(CONTEXT86*);
216 extern void WINAPI DOSVM_Int31Handler(CONTEXT86*);
217 extern void WINAPI DOSVM_RawModeSwitchHandler(CONTEXT86*);
218 extern BOOL DOSVM_IsDos32(void);
219 extern FARPROC16 WINAPI DPMI_AllocInternalRMCB(RMCBPROC);
220 extern void WINAPI DPMI_FreeInternalRMCB(FARPROC16);
221 extern int DPMI_CallRMProc(CONTEXT86*,LPWORD,int,int);
222 extern BOOL DOSVM_CheckWrappers(CONTEXT86*);
225 extern void WINAPI DOSVM_Int33Handler(CONTEXT86*);
226 extern void WINAPI DOSVM_Int33Message(UINT,WPARAM,LPARAM);
227 extern void WINAPI DOSVM_Int33Console(MOUSE_EVENT_RECORD*);
230 extern void WINAPI DOSVM_Int41Handler(CONTEXT86*);
233 extern void WINAPI DOSVM_Int4bHandler(CONTEXT86*);
236 extern void WINAPI DOSVM_Int5cHandler(CONTEXT86*);
239 extern void WINAPI DOSVM_Int67Handler(CONTEXT86*);
240 extern void WINAPI EMS_Ioctl_Handler(CONTEXT86*);
243 extern void WINAPI DOSVM_CallBuiltinHandler( CONTEXT86 *, BYTE );
244 extern void WINAPI DOSVM_EmulateInterruptPM( CONTEXT86 *, BYTE );
245 extern BOOL WINAPI DOSVM_EmulateInterruptRM( CONTEXT86 *, BYTE );
246 extern FARPROC16 DOSVM_GetPMHandler16( BYTE );
247 extern FARPROC48 DOSVM_GetPMHandler48( BYTE );
248 extern FARPROC16 DOSVM_GetRMHandler( BYTE );
249 extern void DOSVM_HardwareInterruptPM( CONTEXT86 *, BYTE );
250 extern void DOSVM_HardwareInterruptRM( CONTEXT86 *, BYTE );
251 extern void DOSVM_SetPMHandler16( BYTE, FARPROC16 );
252 extern void DOSVM_SetPMHandler48( BYTE, FARPROC48 );
253 extern void DOSVM_SetRMHandler( BYTE, FARPROC16 );
256 void DOSVM_RelayHandler( CONTEXT86 * );
257 void DOSVM_SaveCallFrame( CONTEXT86 *, struct _STACK16FRAME * );
258 void DOSVM_RestoreCallFrame( CONTEXT86 *, struct _STACK16FRAME * );
259 void DOSVM_BuildCallFrame( CONTEXT86 *, DOSRELAY, LPVOID );
262 extern void SB_ioport_out( WORD port, BYTE val );
263 extern BYTE SB_ioport_in( WORD port );
266 extern void WINAPI XMS_Handler(CONTEXT86*);
268 #endif /* __WINE_DOSEXE_H */