kernel32: Update Italian translation.
[wine/testsucceed.git] / dlls / krnl386.exe16 / dosexe.h
blobfa73207e6122e35322536ac4125b59adc67642d9
1 /*
2 * DOS EXE loader
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __WINE_DOSEXE_H
22 #define __WINE_DOSEXE_H
24 #include <stdarg.h>
25 #include <sys/types.h>
27 #include "windef.h"
28 #include "wine/library.h"
29 #include "wine/windef16.h"
30 #include "winbase.h"
31 #include "winnt.h" /* for PCONTEXT */
32 #include "wincon.h" /* for MOUSE_EVENT_RECORD */
34 #define MAX_DOS_DRIVES 26
36 struct _DOSEVENT;
38 typedef struct {
39 PAPCFUNC proc;
40 ULONG_PTR arg;
41 } DOS_SPC;
43 extern pid_t dosvm_pid;
45 /* amount of space reserved for relay stack */
46 #define DOSVM_RELAY_DATA_SIZE 4096
48 /* various real-mode code stubs */
49 struct DPMI_segments
51 WORD wrap_seg;
52 WORD xms_seg;
53 WORD dpmi_seg;
54 WORD dpmi_sel;
55 WORD int48_sel;
56 WORD int16_sel;
57 WORD relay_code_sel;
58 WORD relay_data_sel;
61 /* 48-bit segmented pointers for DOS DPMI32 */
62 typedef struct {
63 WORD selector;
64 DWORD offset;
65 } SEGPTR48, FARPROC48;
67 #define DOSCONF_MEM_HIGH 0x0001
68 #define DOSCONF_MEM_UMB 0x0002
69 #define DOSCONF_NUMLOCK 0x0004
70 #define DOSCONF_KEYB_CONV 0x0008
72 typedef struct {
73 char lastdrive;
74 int brk_flag;
75 int files;
76 int stacks_nr;
77 int stacks_sz;
78 int buf;
79 int buf2;
80 int fcbs;
81 int flags;
82 char *shell;
83 char *country;
84 } DOSCONF;
86 typedef void (*DOSRELAY)(CONTEXT86*,void*);
87 typedef void (WINAPI *RMCBPROC)(CONTEXT86*);
88 typedef void (WINAPI *INTPROC)(CONTEXT86*);
90 #define DOS_PRIORITY_REALTIME 0 /* IRQ0 */
91 #define DOS_PRIORITY_KEYBOARD 1 /* IRQ1 */
92 #define DOS_PRIORITY_VGA 2 /* IRQ9 */
93 #define DOS_PRIORITY_MOUSE 5 /* IRQ12 */
94 #define DOS_PRIORITY_SERIAL 10 /* IRQ4 */
96 extern WORD DOSVM_psp; /* psp of current DOS task */
97 extern WORD DOSVM_retval; /* return value of previous DOS task */
98 extern struct DPMI_segments *DOSVM_dpmi_segments;
100 #if defined(linux) && defined(__i386__) && defined(HAVE_SYS_VM86_H)
101 # define MZ_SUPPORTED
102 #endif /* linux-i386 */
105 * Declare some CONTEXT86.EFlags bits.
106 * IF_MASK is only pushed into real mode stack.
108 #define V86_FLAG 0x00020000
109 #define TF_MASK 0x00000100
110 #define IF_MASK 0x00000200
111 #define VIF_MASK 0x00080000
112 #define VIP_MASK 0x00100000
114 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
116 #define PTR_REAL_TO_LIN(seg,off) ((void*)(((unsigned int)(seg) << 4) + LOWORD(off)))
118 /* NOTE: Interrupts might get called from four modes: real mode, 16-bit,
119 * 32-bit segmented (DPMI32) and 32-bit linear (via DeviceIoControl).
120 * For automatic conversion of pointer
121 * parameters, interrupt handlers should use CTX_SEG_OFF_TO_LIN with
122 * the contents of a segment register as second and the contents of
123 * a *32-bit* general register as third parameter, e.g.
124 * CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EDX_reg(context) )
125 * This will generate a linear pointer in all three cases:
126 * Real-Mode: Seg*16 + LOWORD(Offset)
127 * 16-bit: convert (Seg, LOWORD(Offset)) to linear
128 * 32-bit segmented: convert (Seg, Offset) to linear
129 * 32-bit linear: use Offset as linear address (DeviceIoControl!)
131 * Real-mode is recognized by checking the V86 bit in the flags register,
132 * 32-bit linear mode is recognized by checking whether 'seg' is
133 * a system selector (0 counts also as 32-bit segment) and 32-bit
134 * segmented mode is recognized by checking whether 'seg' is 32-bit
135 * selector which is neither system selector nor zero.
137 #define CTX_SEG_OFF_TO_LIN(context,seg,off) \
138 (ISV86(context) ? PTR_REAL_TO_LIN((seg),(off)) : wine_ldt_get_ptr((seg),(off)))
140 #define INT_BARF(context,num) \
141 ERR( "int%x: unknown/not implemented parameters:\n" \
142 "int%x: AX %04x, BX %04x, CX %04x, DX %04x, " \
143 "SI %04x, DI %04x, DS %04x, ES %04x\n", \
144 (num), (num), LOWORD((context)->Eax), LOWORD((context)->Ebx), \
145 LOWORD((context)->Ecx), LOWORD((context)->Edx), LOWORD((context)->Esi), \
146 LOWORD((context)->Edi), (WORD)(context)->SegDs, (WORD)(context)->SegEs )
148 /* pushing on stack in 16 bit needs segment wrap around */
149 #define PUSH_WORD16(context,val) \
150 *((WORD*)CTX_SEG_OFF_TO_LIN((context), \
151 (context)->SegSs, ADD_LOWORD( context->Esp, -2 ) )) = (val)
153 /* Macros for easier access to i386 context registers */
155 #define AX_reg(context) ((WORD)(context)->Eax)
156 #define BX_reg(context) ((WORD)(context)->Ebx)
157 #define CX_reg(context) ((WORD)(context)->Ecx)
158 #define DX_reg(context) ((WORD)(context)->Edx)
159 #define SI_reg(context) ((WORD)(context)->Esi)
160 #define DI_reg(context) ((WORD)(context)->Edi)
162 #define AL_reg(context) ((BYTE)(context)->Eax)
163 #define AH_reg(context) ((BYTE)((context)->Eax >> 8))
164 #define BL_reg(context) ((BYTE)(context)->Ebx)
165 #define BH_reg(context) ((BYTE)((context)->Ebx >> 8))
166 #define CL_reg(context) ((BYTE)(context)->Ecx)
167 #define CH_reg(context) ((BYTE)((context)->Ecx >> 8))
168 #define DL_reg(context) ((BYTE)(context)->Edx)
169 #define DH_reg(context) ((BYTE)((context)->Edx >> 8))
171 #define SET_CFLAG(context) ((context)->EFlags |= 0x0001)
172 #define RESET_CFLAG(context) ((context)->EFlags &= ~0x0001)
173 #define SET_ZFLAG(context) ((context)->EFlags |= 0x0040)
174 #define RESET_ZFLAG(context) ((context)->EFlags &= ~0x0040)
175 #define ISV86(context) ((context)->EFlags & 0x00020000)
177 #define SET_AX(context,val) ((void)((context)->Eax = ((context)->Eax & ~0xffff) | (WORD)(val)))
178 #define SET_BX(context,val) ((void)((context)->Ebx = ((context)->Ebx & ~0xffff) | (WORD)(val)))
179 #define SET_CX(context,val) ((void)((context)->Ecx = ((context)->Ecx & ~0xffff) | (WORD)(val)))
180 #define SET_DX(context,val) ((void)((context)->Edx = ((context)->Edx & ~0xffff) | (WORD)(val)))
181 #define SET_SI(context,val) ((void)((context)->Esi = ((context)->Esi & ~0xffff) | (WORD)(val)))
182 #define SET_DI(context,val) ((void)((context)->Edi = ((context)->Edi & ~0xffff) | (WORD)(val)))
184 #define SET_AL(context,val) ((void)((context)->Eax = ((context)->Eax & ~0xff) | (BYTE)(val)))
185 #define SET_BL(context,val) ((void)((context)->Ebx = ((context)->Ebx & ~0xff) | (BYTE)(val)))
186 #define SET_CL(context,val) ((void)((context)->Ecx = ((context)->Ecx & ~0xff) | (BYTE)(val)))
187 #define SET_DL(context,val) ((void)((context)->Edx = ((context)->Edx & ~0xff) | (BYTE)(val)))
189 #define SET_AH(context,val) ((void)((context)->Eax = ((context)->Eax & ~0xff00) | (((BYTE)(val)) << 8)))
190 #define SET_BH(context,val) ((void)((context)->Ebx = ((context)->Ebx & ~0xff00) | (((BYTE)(val)) << 8)))
191 #define SET_CH(context,val) ((void)((context)->Ecx = ((context)->Ecx & ~0xff00) | (((BYTE)(val)) << 8)))
192 #define SET_DH(context,val) ((void)((context)->Edx = ((context)->Edx & ~0xff00) | (((BYTE)(val)) << 8)))
194 #include <pshpack1.h>
196 typedef struct
198 WORD Com1Addr; /* 00: COM1 I/O address */
199 WORD Com2Addr; /* 02: COM2 I/O address */
200 WORD Com3Addr; /* 04: COM3 I/O address */
201 WORD Com4Addr; /* 06: COM4 I/O address */
202 WORD Lpt1Addr; /* 08: LPT1 I/O address */
203 WORD Lpt2Addr; /* 0a: LPT2 I/O address */
204 WORD Lpt3Addr; /* 0c: LPT3 I/O address */
205 WORD Lpt4Addr; /* 0e: LPT4 I/O address */
206 WORD InstalledHardware; /* 10: Installed hardware flags */
207 BYTE POSTstatus; /* 12: Power-On Self Test status */
208 WORD MemSize; /* 13: Base memory size in Kb */
209 WORD unused1; /* 15: Manufacturing test scratch pad */
210 BYTE KbdFlags1; /* 17: Keyboard flags 1 */
211 BYTE KbdFlags2; /* 18: Keyboard flags 2 */
212 BYTE unused2; /* 19: Keyboard driver workspace */
213 WORD NextKbdCharPtr; /* 1a: Next character in kbd buffer */
214 WORD FirstKbdCharPtr; /* 1c: First character in kbd buffer */
215 WORD KbdBuffer[16]; /* 1e: Keyboard buffer */
216 BYTE DisketteStatus1; /* 3e: Diskette recalibrate status */
217 BYTE DisketteStatus2; /* 3f: Diskette motor status */
218 BYTE DisketteStatus3; /* 40: Diskette motor timeout */
219 BYTE DisketteStatus4; /* 41: Diskette last operation status */
220 BYTE DiskStatus[7]; /* 42: Disk status/command bytes */
221 BYTE VideoMode; /* 49: Video mode */
222 WORD VideoColumns; /* 4a: Number of columns */
223 WORD VideoPageSize; /* 4c: Video page size in bytes */
224 WORD VideoPageStartAddr; /* 4e: Video page start address */
225 BYTE VideoCursorPos[16]; /* 50: Cursor position for 8 pages, column/row order */
226 WORD VideoCursorType; /* 60: Video cursor type */
227 BYTE VideoCurPage; /* 62: Video current page */
228 WORD VideoCtrlAddr; /* 63: Video controller address */
229 BYTE VideoReg1; /* 65: Video mode select register */
230 BYTE VideoReg2; /* 66: Video CGA palette register */
231 DWORD ResetEntry; /* 67: Warm reset entry point */
232 BYTE LastIRQ; /* 6b: Last unexpected interrupt */
233 DWORD Ticks; /* 6c: Ticks since midnight */
234 BYTE TicksOverflow; /* 70: Timer overflow if past midnight */
235 BYTE CtrlBreakFlag; /* 71: Ctrl-Break flag */
236 WORD ResetFlag; /* 72: POST Reset flag */
237 BYTE DiskOpStatus; /* 74: Last hard-disk operation status */
238 BYTE NbHardDisks; /* 75: Number of hard disks */
239 BYTE DiskCtrlByte; /* 76: Disk control byte */
240 BYTE DiskIOPort; /* 77: Disk I/O port offset */
241 BYTE LptTimeout[4]; /* 78: Timeouts for parallel ports */
242 BYTE ComTimeout[4]; /* 7c: Timeouts for serial ports */
243 WORD KbdBufferStart; /* 80: Keyboard buffer start */
244 WORD KbdBufferEnd; /* 82: Keyboard buffer end */
245 BYTE RowsOnScreenMinus1; /* 84: EGA only */
246 WORD BytesPerChar; /* 85: EGA only */
247 BYTE ModeOptions; /* 87: EGA only */
248 BYTE FeatureBitsSwitches; /* 88: EGA only */
249 BYTE VGASettings; /* 89: VGA misc settings */
250 BYTE DisplayCombination; /* 8A: VGA display combinations */
251 BYTE DiskDataRate; /* 8B: Last disk data rate selected */
252 } BIOSDATA;
254 #include <poppack.h>
256 /* Device driver header */
258 #define NONEXT ((DWORD)-1)
260 #define ATTR_STDIN 0x0001
261 #define ATTR_STDOUT 0x0002
262 #define ATTR_NUL 0x0004
263 #define ATTR_CLOCK 0x0008
264 #define ATTR_FASTCON 0x0010
265 #define ATTR_RAW 0x0020
266 #define ATTR_NOTEOF 0x0040
267 #define ATTR_DEVICE 0x0080
268 #define ATTR_REMOVABLE 0x0800
269 #define ATTR_NONIBM 0x2000 /* block devices */
270 #define ATTR_UNTILBUSY 0x2000 /* char devices */
271 #define ATTR_IOCTL 0x4000
272 #define ATTR_CHAR 0x8000
274 #include <pshpack1.h>
276 typedef struct
278 DWORD next_dev;
279 WORD attr;
280 WORD strategy;
281 WORD interrupt;
282 char name[8];
283 } DOS_DEVICE_HEADER;
285 #include <poppack.h>
287 /* DOS Device requests */
289 #define CMD_INIT 0
290 #define CMD_MEDIACHECK 1 /* block devices */
291 #define CMD_BUILDBPB 2 /* block devices */
292 #define CMD_INIOCTL 3
293 #define CMD_INPUT 4 /* read data */
294 #define CMD_SAFEINPUT 5 /* "non-destructive input no wait", char devices */
295 #define CMD_INSTATUS 6 /* char devices */
296 #define CMD_INFLUSH 7 /* char devices */
297 #define CMD_OUTPUT 8 /* write data */
298 #define CMD_SAFEOUTPUT 9 /* write data with verify */
299 #define CMD_OUTSTATUS 10 /* char devices */
300 #define CMD_OUTFLUSH 11 /* char devices */
301 #define CMD_OUTIOCTL 12
302 #define CMD_DEVOPEN 13
303 #define CMD_DEVCLOSE 14
304 #define CMD_REMOVABLE 15 /* block devices */
305 #define CMD_UNTILBUSY 16 /* output until busy */
307 #define STAT_MASK 0x00FF
308 #define STAT_DONE 0x0100
309 #define STAT_BUSY 0x0200
310 #define STAT_ERROR 0x8000
312 #include <pshpack1.h>
314 typedef struct {
315 BYTE size; /* length of header + data */
316 BYTE unit; /* unit (block devices only) */
317 BYTE command;
318 WORD status;
319 BYTE reserved[8];
320 } REQUEST_HEADER;
322 typedef struct {
323 REQUEST_HEADER hdr;
324 BYTE media; /* media descriptor from BPB */
325 SEGPTR buffer;
326 WORD count; /* byte/sector count */
327 WORD sector; /* starting sector (block devices) */
328 DWORD volume; /* volume ID (block devices) */
329 } REQ_IO;
331 typedef struct {
332 REQUEST_HEADER hdr;
333 BYTE data;
334 } REQ_SAFEINPUT;
336 /* WINE device driver thunk from RM */
337 typedef struct {
338 BYTE ljmp1;
339 FARPROC16 strategy;
340 BYTE ljmp2;
341 FARPROC16 interrupt;
342 } WINEDEV_THUNK;
344 #include <poppack.h>
346 /* Device driver info (used for initialization) */
347 typedef struct
349 char name[8];
350 WORD attr;
351 RMCBPROC strategy;
352 RMCBPROC interrupt;
353 } WINEDEV;
355 /* dosexe.c */
356 extern BOOL MZ_Exec( CONTEXT86 *context, LPCSTR filename, BYTE func, LPVOID paramblk );
357 extern void MZ_Exit( CONTEXT86 *context, BOOL cs_psp, WORD retval );
358 extern BOOL MZ_Current( void );
359 extern void MZ_AllocDPMITask( void );
360 extern void MZ_RunInThread( PAPCFUNC proc, ULONG_PTR arg );
361 extern BOOL DOSVM_IsWin16(void);
362 extern void DOSVM_Exit( WORD retval );
364 /* dosvm.c */
365 extern void DOSVM_SendQueuedEvents( CONTEXT86 * );
366 extern void WINAPI DOSVM_AcknowledgeIRQ( CONTEXT86 * );
367 extern INT DOSVM_Enter( CONTEXT86 *context );
368 extern void DOSVM_Wait( CONTEXT86 * );
369 extern DWORD DOSVM_Loop( HANDLE hThread );
370 extern void DOSVM_QueueEvent( INT irq, INT priority, DOSRELAY relay, LPVOID data );
371 extern void DOSVM_PIC_ioport_out( WORD port, BYTE val );
372 extern void DOSVM_SetTimer( UINT ticks );
373 extern LPVOID DOSVM_AllocDataUMB(DWORD, WORD *, WORD *);
374 extern void DOSVM_InitSegments(void);
376 /* devices.c */
377 extern void DOSDEV_InstallDOSDevices(void);
378 extern void DOSDEV_SetupDevice(const WINEDEV * devinfo,
379 WORD seg, WORD off_dev, WORD off_thunk);
380 extern void DOSDEV_SetSharingRetry(WORD delay, WORD count);
381 extern SEGPTR DOSDEV_GetLOL(BOOL v86);
383 /* dma.c */
384 extern int DMA_Transfer(int channel,int reqlength,void* buffer);
385 extern void DMA_ioport_out( WORD port, BYTE val );
386 extern BYTE DMA_ioport_in( WORD port );
388 /* dosaspi.c */
389 extern void DOSVM_ASPIHandler(CONTEXT86*);
391 /* dosconf.c */
392 extern DOSCONF *DOSCONF_GetConfig( void );
394 /* dosmem.c */
395 extern BIOSDATA *DOSVM_BiosData( void );
396 extern void DOSVM_start_bios_timer(void);
398 /* fpu.c */
399 extern void WINAPI DOSVM_Int34Handler(CONTEXT86*);
400 extern void WINAPI DOSVM_Int35Handler(CONTEXT86*);
401 extern void WINAPI DOSVM_Int36Handler(CONTEXT86*);
402 extern void WINAPI DOSVM_Int37Handler(CONTEXT86*);
403 extern void WINAPI DOSVM_Int38Handler(CONTEXT86*);
404 extern void WINAPI DOSVM_Int39Handler(CONTEXT86*);
405 extern void WINAPI DOSVM_Int3aHandler(CONTEXT86*);
406 extern void WINAPI DOSVM_Int3bHandler(CONTEXT86*);
407 extern void WINAPI DOSVM_Int3cHandler(CONTEXT86*);
408 extern void WINAPI DOSVM_Int3dHandler(CONTEXT86*);
409 extern void WINAPI DOSVM_Int3eHandler(CONTEXT86*);
411 /* int09.c */
412 extern void WINAPI DOSVM_Int09Handler(CONTEXT86*);
413 extern void DOSVM_Int09SendScan(BYTE scan,BYTE ascii);
414 extern BYTE DOSVM_Int09ReadScan(BYTE*ascii);
416 /* int10.c */
417 extern void WINAPI DOSVM_Int10Handler(CONTEXT86*);
418 extern void DOSVM_PutChar(BYTE ascii);
420 /* int13.c */
421 extern void WINAPI DOSVM_Int13Handler(CONTEXT86*);
423 /* int15.c */
424 extern void WINAPI DOSVM_Int15Handler(CONTEXT86*);
426 /* int16.c */
427 extern void WINAPI DOSVM_Int16Handler(CONTEXT86*);
428 extern BOOL DOSVM_Int16ReadChar( BYTE *, BYTE *, CONTEXT86 * );
429 extern int DOSVM_Int16AddChar(BYTE ascii,BYTE scan);
431 /* int21.c */
432 extern void WINAPI DOSVM_Int21Handler(CONTEXT86*);
434 /* int25.c */
435 BOOL DOSVM_RawRead( BYTE, DWORD, DWORD, BYTE *, BOOL );
436 void WINAPI DOSVM_Int25Handler( CONTEXT86 * );
438 /* int26.c */
439 BOOL DOSVM_RawWrite( BYTE, DWORD, DWORD, BYTE *, BOOL );
440 void WINAPI DOSVM_Int26Handler( CONTEXT86 * );
442 /* int2f.c */
443 extern void WINAPI DOSVM_Int2fHandler(CONTEXT86*);
444 extern void MSCDEX_InstallCDROM(void);
446 /* int31.c */
447 extern void WINAPI DOSVM_Int31Handler(CONTEXT86*);
448 extern void WINAPI DOSVM_RawModeSwitchHandler(CONTEXT86*);
449 extern BOOL DOSVM_IsDos32(void);
450 extern FARPROC16 DPMI_AllocInternalRMCB(RMCBPROC);
451 extern int DPMI_CallRMProc(CONTEXT86*,LPWORD,int,int);
452 extern BOOL DOSVM_CheckWrappers(CONTEXT86*);
454 /* int33.c */
455 extern void WINAPI DOSVM_Int33Handler(CONTEXT86*);
456 extern void DOSVM_Int33Message(UINT,WPARAM,LPARAM);
457 extern void DOSVM_Int33Console(MOUSE_EVENT_RECORD*);
459 /* int67.c */
460 extern void WINAPI DOSVM_Int67Handler(CONTEXT86*);
461 extern void EMS_Ioctl_Handler(CONTEXT86*);
463 /* interrupts.c */
464 extern void __wine_call_int_handler( CONTEXT86 *, BYTE );
465 extern void DOSVM_CallBuiltinHandler( CONTEXT86 *, BYTE );
466 extern BOOL DOSVM_EmulateInterruptPM( CONTEXT86 *, BYTE );
467 extern BOOL DOSVM_EmulateInterruptRM( CONTEXT86 *, BYTE );
468 extern FARPROC16 DOSVM_GetPMHandler16( BYTE );
469 extern FARPROC48 DOSVM_GetPMHandler48( BYTE );
470 extern FARPROC16 DOSVM_GetRMHandler( BYTE );
471 extern void DOSVM_HardwareInterruptPM( CONTEXT86 *, BYTE );
472 extern void DOSVM_HardwareInterruptRM( CONTEXT86 *, BYTE );
473 extern void DOSVM_SetPMHandler16( BYTE, FARPROC16 );
474 extern void DOSVM_SetPMHandler48( BYTE, FARPROC48 );
475 extern void DOSVM_SetRMHandler( BYTE, FARPROC16 );
477 /* ioports.c */
478 extern DWORD DOSVM_inport( int port, int size );
479 extern void DOSVM_outport( int port, int size, DWORD value );
481 /* relay.c */
482 void DOSVM_RelayHandler( CONTEXT86 * );
483 void DOSVM_BuildCallFrame( CONTEXT86 *, DOSRELAY, LPVOID );
485 /* soundblaster.c */
486 extern void SB_ioport_out( WORD port, BYTE val );
487 extern BYTE SB_ioport_in( WORD port );
489 /* timer.c */
490 extern void WINAPI DOSVM_Int08Handler(CONTEXT86*);
492 #endif /* __WINE_DOSEXE_H */