ntdll: Use a separate memory allocation for the kernel stack.
[wine.git] / dlls / krnl386.exe16 / dosexe.h
blob1e4d15c75e59d3c25ec1dd81bc18204d1ea8d737
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/windef16.h"
29 #include "winbase.h"
30 #include "winnt.h" /* for PCONTEXT */
31 #include "kernel16_private.h"
33 #define MAX_DOS_DRIVES 26
35 /* amount of space reserved for relay stack */
36 #define DOSVM_RELAY_DATA_SIZE 4096
38 typedef void (*DOSRELAY)(CONTEXT*,void*);
39 typedef void (WINAPI *INTPROC)(CONTEXT*);
41 extern WORD DOSVM_psp DECLSPEC_HIDDEN; /* psp of current DOS task */
42 extern WORD int16_sel DECLSPEC_HIDDEN;
44 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
46 /* NOTE: Interrupts might get called from four modes: real mode, 16-bit,
47 * 32-bit segmented (DPMI32) and 32-bit linear (via DeviceIoControl).
48 * For automatic conversion of pointer
49 * parameters, interrupt handlers should use CTX_SEG_OFF_TO_LIN with
50 * the contents of a segment register as second and the contents of
51 * a *32-bit* general register as third parameter, e.g.
52 * CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EDX_reg(context) )
53 * This will generate a linear pointer in all three cases:
54 * Real-Mode: Seg*16 + LOWORD(Offset)
55 * 16-bit: convert (Seg, LOWORD(Offset)) to linear
56 * 32-bit segmented: convert (Seg, Offset) to linear
57 * 32-bit linear: use Offset as linear address (DeviceIoControl!)
59 * Real-mode is recognized by checking the V86 bit in the flags register,
60 * 32-bit linear mode is recognized by checking whether 'seg' is
61 * a system selector (0 counts also as 32-bit segment) and 32-bit
62 * segmented mode is recognized by checking whether 'seg' is 32-bit
63 * selector which is neither system selector nor zero.
65 #define CTX_SEG_OFF_TO_LIN(context,seg,off) (ldt_get_ptr((seg),(off)))
67 #define INT_BARF(context,num) \
68 ERR( "int%x: unknown/not implemented parameters:\n" \
69 "int%x: AX %04x, BX %04x, CX %04x, DX %04x, " \
70 "SI %04x, DI %04x, DS %04x, ES %04x\n", \
71 (num), (num), LOWORD((context)->Eax), LOWORD((context)->Ebx), \
72 LOWORD((context)->Ecx), LOWORD((context)->Edx), LOWORD((context)->Esi), \
73 LOWORD((context)->Edi), (WORD)(context)->SegDs, (WORD)(context)->SegEs )
75 /* pushing on stack in 16 bit needs segment wrap around */
76 #define PUSH_WORD16(context,val) \
77 *((WORD*)CTX_SEG_OFF_TO_LIN((context), \
78 (context)->SegSs, ADD_LOWORD( context->Esp, -2 ) )) = (val)
80 /* Macros for easier access to i386 context registers */
82 #define AX_reg(context) ((WORD)(context)->Eax)
83 #define BX_reg(context) ((WORD)(context)->Ebx)
84 #define CX_reg(context) ((WORD)(context)->Ecx)
85 #define DX_reg(context) ((WORD)(context)->Edx)
86 #define SI_reg(context) ((WORD)(context)->Esi)
87 #define DI_reg(context) ((WORD)(context)->Edi)
89 #define AL_reg(context) ((BYTE)(context)->Eax)
90 #define AH_reg(context) ((BYTE)((context)->Eax >> 8))
91 #define BL_reg(context) ((BYTE)(context)->Ebx)
92 #define BH_reg(context) ((BYTE)((context)->Ebx >> 8))
93 #define CL_reg(context) ((BYTE)(context)->Ecx)
94 #define CH_reg(context) ((BYTE)((context)->Ecx >> 8))
95 #define DL_reg(context) ((BYTE)(context)->Edx)
96 #define DH_reg(context) ((BYTE)((context)->Edx >> 8))
98 #define SET_CFLAG(context) ((context)->EFlags |= 0x0001)
99 #define RESET_CFLAG(context) ((context)->EFlags &= ~0x0001)
100 #define SET_ZFLAG(context) ((context)->EFlags |= 0x0040)
101 #define RESET_ZFLAG(context) ((context)->EFlags &= ~0x0040)
103 #define SET_AX(context,val) ((void)((context)->Eax = ((context)->Eax & ~0xffff) | (WORD)(val)))
104 #define SET_BX(context,val) ((void)((context)->Ebx = ((context)->Ebx & ~0xffff) | (WORD)(val)))
105 #define SET_CX(context,val) ((void)((context)->Ecx = ((context)->Ecx & ~0xffff) | (WORD)(val)))
106 #define SET_DX(context,val) ((void)((context)->Edx = ((context)->Edx & ~0xffff) | (WORD)(val)))
107 #define SET_SI(context,val) ((void)((context)->Esi = ((context)->Esi & ~0xffff) | (WORD)(val)))
108 #define SET_DI(context,val) ((void)((context)->Edi = ((context)->Edi & ~0xffff) | (WORD)(val)))
110 #define SET_AL(context,val) ((void)((context)->Eax = ((context)->Eax & ~0xff) | (BYTE)(val)))
111 #define SET_BL(context,val) ((void)((context)->Ebx = ((context)->Ebx & ~0xff) | (BYTE)(val)))
112 #define SET_CL(context,val) ((void)((context)->Ecx = ((context)->Ecx & ~0xff) | (BYTE)(val)))
113 #define SET_DL(context,val) ((void)((context)->Edx = ((context)->Edx & ~0xff) | (BYTE)(val)))
115 #define SET_AH(context,val) ((void)((context)->Eax = ((context)->Eax & ~0xff00) | (((BYTE)(val)) << 8)))
116 #define SET_BH(context,val) ((void)((context)->Ebx = ((context)->Ebx & ~0xff00) | (((BYTE)(val)) << 8)))
117 #define SET_CH(context,val) ((void)((context)->Ecx = ((context)->Ecx & ~0xff00) | (((BYTE)(val)) << 8)))
118 #define SET_DH(context,val) ((void)((context)->Edx = ((context)->Edx & ~0xff00) | (((BYTE)(val)) << 8)))
120 #include <pshpack1.h>
122 typedef struct
124 WORD Com1Addr; /* 00: COM1 I/O address */
125 WORD Com2Addr; /* 02: COM2 I/O address */
126 WORD Com3Addr; /* 04: COM3 I/O address */
127 WORD Com4Addr; /* 06: COM4 I/O address */
128 WORD Lpt1Addr; /* 08: LPT1 I/O address */
129 WORD Lpt2Addr; /* 0a: LPT2 I/O address */
130 WORD Lpt3Addr; /* 0c: LPT3 I/O address */
131 WORD Lpt4Addr; /* 0e: LPT4 I/O address */
132 WORD InstalledHardware; /* 10: Installed hardware flags */
133 BYTE POSTstatus; /* 12: Power-On Self Test status */
134 WORD MemSize; /* 13: Base memory size in Kb */
135 WORD unused1; /* 15: Manufacturing test scratch pad */
136 BYTE KbdFlags1; /* 17: Keyboard flags 1 */
137 BYTE KbdFlags2; /* 18: Keyboard flags 2 */
138 BYTE unused2; /* 19: Keyboard driver workspace */
139 WORD NextKbdCharPtr; /* 1a: Next character in kbd buffer */
140 WORD FirstKbdCharPtr; /* 1c: First character in kbd buffer */
141 WORD KbdBuffer[16]; /* 1e: Keyboard buffer */
142 BYTE DisketteStatus1; /* 3e: Diskette recalibrate status */
143 BYTE DisketteStatus2; /* 3f: Diskette motor status */
144 BYTE DisketteStatus3; /* 40: Diskette motor timeout */
145 BYTE DisketteStatus4; /* 41: Diskette last operation status */
146 BYTE DiskStatus[7]; /* 42: Disk status/command bytes */
147 BYTE VideoMode; /* 49: Video mode */
148 WORD VideoColumns; /* 4a: Number of columns */
149 WORD VideoPageSize; /* 4c: Video page size in bytes */
150 WORD VideoPageStartAddr; /* 4e: Video page start address */
151 BYTE VideoCursorPos[16]; /* 50: Cursor position for 8 pages, column/row order */
152 WORD VideoCursorType; /* 60: Video cursor type */
153 BYTE VideoCurPage; /* 62: Video current page */
154 WORD VideoCtrlAddr; /* 63: Video controller address */
155 BYTE VideoReg1; /* 65: Video mode select register */
156 BYTE VideoReg2; /* 66: Video CGA palette register */
157 DWORD ResetEntry; /* 67: Warm reset entry point */
158 BYTE LastIRQ; /* 6b: Last unexpected interrupt */
159 DWORD Ticks; /* 6c: Ticks since midnight */
160 BYTE TicksOverflow; /* 70: Timer overflow if past midnight */
161 BYTE CtrlBreakFlag; /* 71: Ctrl-Break flag */
162 WORD ResetFlag; /* 72: POST Reset flag */
163 BYTE DiskOpStatus; /* 74: Last hard-disk operation status */
164 BYTE NbHardDisks; /* 75: Number of hard disks */
165 BYTE DiskCtrlByte; /* 76: Disk control byte */
166 BYTE DiskIOPort; /* 77: Disk I/O port offset */
167 BYTE LptTimeout[4]; /* 78: Timeouts for parallel ports */
168 BYTE ComTimeout[4]; /* 7c: Timeouts for serial ports */
169 WORD KbdBufferStart; /* 80: Keyboard buffer start */
170 WORD KbdBufferEnd; /* 82: Keyboard buffer end */
171 BYTE RowsOnScreenMinus1; /* 84: EGA only */
172 WORD BytesPerChar; /* 85: EGA only */
173 BYTE ModeOptions; /* 87: EGA only */
174 BYTE FeatureBitsSwitches; /* 88: EGA only */
175 BYTE VGASettings; /* 89: VGA misc settings */
176 BYTE DisplayCombination; /* 8A: VGA display combinations */
177 BYTE DiskDataRate; /* 8B: Last disk data rate selected */
178 } BIOSDATA;
180 #include <poppack.h>
182 /* Device driver header */
184 #include <pshpack1.h>
186 typedef struct
188 DWORD next_dev;
189 WORD attr;
190 WORD strategy;
191 WORD interrupt;
192 char name[8];
193 } DOS_DEVICE_HEADER;
195 #include <poppack.h>
197 /* dosvm.c */
198 extern void DOSVM_Exit( WORD retval ) DECLSPEC_HIDDEN;
200 /* dosmem.c */
201 extern BIOSDATA *DOSVM_BiosData( void ) DECLSPEC_HIDDEN;
202 extern void DOSVM_start_bios_timer(void) DECLSPEC_HIDDEN;
204 /* fpu.c */
205 extern void WINAPI DOSVM_Int34Handler(CONTEXT*) DECLSPEC_HIDDEN;
206 extern void WINAPI DOSVM_Int35Handler(CONTEXT*) DECLSPEC_HIDDEN;
207 extern void WINAPI DOSVM_Int36Handler(CONTEXT*) DECLSPEC_HIDDEN;
208 extern void WINAPI DOSVM_Int37Handler(CONTEXT*) DECLSPEC_HIDDEN;
209 extern void WINAPI DOSVM_Int38Handler(CONTEXT*) DECLSPEC_HIDDEN;
210 extern void WINAPI DOSVM_Int39Handler(CONTEXT*) DECLSPEC_HIDDEN;
211 extern void WINAPI DOSVM_Int3aHandler(CONTEXT*) DECLSPEC_HIDDEN;
212 extern void WINAPI DOSVM_Int3bHandler(CONTEXT*) DECLSPEC_HIDDEN;
213 extern void WINAPI DOSVM_Int3cHandler(CONTEXT*) DECLSPEC_HIDDEN;
214 extern void WINAPI DOSVM_Int3dHandler(CONTEXT*) DECLSPEC_HIDDEN;
215 extern void WINAPI DOSVM_Int3eHandler(CONTEXT*) DECLSPEC_HIDDEN;
217 /* int15.c */
218 extern void WINAPI DOSVM_Int15Handler(CONTEXT*) DECLSPEC_HIDDEN;
220 /* int21.c */
221 extern void WINAPI DOSVM_Int21Handler(CONTEXT*) DECLSPEC_HIDDEN;
223 /* int25.c */
224 BOOL DOSVM_RawRead( BYTE, DWORD, DWORD, BYTE *, BOOL ) DECLSPEC_HIDDEN;
225 void WINAPI DOSVM_Int25Handler( CONTEXT * ) DECLSPEC_HIDDEN;
227 /* int26.c */
228 BOOL DOSVM_RawWrite( BYTE, DWORD, DWORD, BYTE *, BOOL ) DECLSPEC_HIDDEN;
229 void WINAPI DOSVM_Int26Handler( CONTEXT * ) DECLSPEC_HIDDEN;
231 /* int2f.c */
232 extern void WINAPI DOSVM_Int2fHandler(CONTEXT*) DECLSPEC_HIDDEN;
234 /* int31.c */
235 extern void WINAPI DOSVM_Int31Handler(CONTEXT*) DECLSPEC_HIDDEN;
237 /* interrupts.c */
238 extern void WINAPI __wine_call_int_handler16( BYTE, CONTEXT * ) DECLSPEC_HIDDEN;
239 extern BOOL DOSVM_EmulateInterruptPM( CONTEXT *, BYTE ) DECLSPEC_HIDDEN;
240 extern FARPROC16 DOSVM_GetPMHandler16( BYTE ) DECLSPEC_HIDDEN;
241 extern void DOSVM_SetPMHandler16( BYTE, FARPROC16 ) DECLSPEC_HIDDEN;
243 /* ioports.c */
244 extern DWORD DOSVM_inport( int port, int size ) DECLSPEC_HIDDEN;
245 extern void DOSVM_outport( int port, int size, DWORD value ) DECLSPEC_HIDDEN;
247 #endif /* __WINE_DOSEXE_H */