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