Release 980601
[wine/multimedia.git] / msdos / int2f.c
blob40878f10095f08919a882ffeedee07c57ca7735f
1 /*
2 * DOS interrupt 2fh handler
3 */
5 #include <stdlib.h>
6 #include <string.h>
7 #include <unistd.h>
8 #include "ldt.h"
9 #include "drive.h"
10 #include "msdos.h"
11 #include "miscemu.h"
12 #include "module.h"
13 /* #define DEBUG_INT */
14 #include "debug.h"
16 /* base WPROCS.DLL ordinal number for VxDs */
17 #define VXD_BASE 400
19 static void do_int2f_16( CONTEXT *context );
21 /**********************************************************************
22 * INT_Int2fHandler
24 * Handler for int 2fh (multiplex).
26 void WINAPI INT_Int2fHandler( CONTEXT *context )
28 switch(AH_reg(context))
30 case 0x10:
31 AL_reg(context) = 0xff; /* share is installed */
32 break;
34 case 0x15: /* mscdex */
35 do_mscdex(context);
36 break;
38 case 0x16:
39 do_int2f_16( context );
40 break;
42 case 0x45:
43 switch (AL_reg(context))
45 case 0x00:
46 case 0x01:
47 case 0x02:
48 case 0x03:
49 case 0x04:
50 case 0x05:
51 case 0x06:
52 case 0x07:
53 case 0x08:
54 /* Microsoft Profiler - not installed */
55 break;
56 default:
57 INT_BARF( context, 0x2f );
59 break;
61 case 0x4a:
62 switch(AL_reg(context))
64 case 0x10: /* smartdrv */
65 break; /* not installed */
66 case 0x11: /* dblspace */
67 break; /* not installed */
68 case 0x12: /* realtime compression interface */
69 break; /* not installed */
70 default:
71 INT_BARF( context, 0x2f );
73 break;
74 case 0x56: /* INTERLNK */
75 switch(AL_reg(context))
77 case 0x01: /* check if redirected drive */
78 AL_reg(context) = 0; /* not redirected */
79 break;
80 default:
81 INT_BARF( context, 0x2f );
83 break;
84 case 0xb7: /* append */
85 AL_reg(context) = 0; /* not installed */
86 break;
87 case 0xbd: /* some Novell network install check ??? */
88 AX_reg(context) = 0xa5a5; /* pretend to have Novell IPX installed */
89 break;
90 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
91 break;
92 default:
93 INT_BARF( context, 0x2f );
94 break;
99 /**********************************************************************
100 * do_int2f_16
102 static void do_int2f_16( CONTEXT *context )
104 DWORD addr;
106 switch(AL_reg(context))
108 case 0x00: /* Windows enhanced mode installation check */
109 AX_reg(context) = (GetWinFlags() & WF_ENHANCED) ?
110 LOWORD(GetVersion16()) : 0;
111 break;
113 case 0x0a: /* Get Windows version and type */
114 AX_reg(context) = 0;
115 BX_reg(context) = (LOWORD(GetVersion16()) << 8) |
116 (LOWORD(GetVersion16()) >> 8);
117 CX_reg(context) = (GetWinFlags() & WF_ENHANCED) ? 3 : 2;
118 break;
120 case 0x80: /* Release time-slice */
121 AL_reg(context) = 0;
122 /* FIXME: We need to do something that lets some other process run
123 here. */
124 sleep(0);
125 break;
127 case 0x81: /* Begin critical section. */
128 /* FIXME? */
129 break;
131 case 0x82: /* End critical section. */
132 /* FIXME? */
133 break;
135 case 0x83: /* Return Current Virtual Machine ID */
136 /* Virtual Machines are usually created/destroyed when Windows runs
137 * DOS programs. Since we never do, we are always in the System VM.
138 * According to Ralf Brown's Interrupt List, never return 0. But it
139 * seems to work okay (returning 0), just to be sure we return 1.
141 BX_reg(context) = 1; /* VM 1 is probably the System VM */
142 break;
144 case 0x84: /* Get device API entry point */
145 addr = (DWORD)NE_GetEntryPoint( GetModuleHandle16("WPROCS"),
146 VXD_BASE + BX_reg(context) );
147 if (!addr) /* not supported */
149 WARN(int,"Application attempted to access VxD %04x\n",
150 BX_reg(context) );
151 WARN(int,"This device is not known to Wine.");
152 WARN(int,"Expect a failure now\n");
154 ES_reg(context) = SELECTOROF(addr);
155 DI_reg(context) = OFFSETOF(addr);
156 break;
158 case 0x86: /* DPMI detect mode */
159 AX_reg(context) = 0; /* Running under DPMI */
160 break;
162 /* FIXME: is this right? Specs say that this should only be callable
163 in real (v86) mode which we never enter. */
164 case 0x87: /* DPMI installation check */
166 SYSTEM_INFO si;
168 GetSystemInfo(&si);
169 AX_reg(context) = 0x0000; /* DPMI Installed */
170 BX_reg(context) = 0x0001; /* 32bits available */
171 CL_reg(context) = si.wProcessorLevel;
172 DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
173 SI_reg(context) = 0; /* # of para. of DOS extended private data */
174 ES_reg(context) = 0; /* ES:DI is DPMI switch entry point */
175 DI_reg(context) = 0;
176 break;
178 case 0x8a: /* DPMI get vendor-specific API entry point. */
179 /* The 1.0 specs say this should work with all 0.9 hosts. */
180 break;
182 default:
183 INT_BARF( context, 0x2f );
187 void do_mscdex( CONTEXT *context )
189 int drive, count;
190 char *p;
192 switch(AL_reg(context))
194 case 0x00: /* Installation check */
195 /* Count the number of contiguous CDROM drives
197 for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++)
199 if (DRIVE_GetType(drive) == TYPE_CDROM)
201 while (DRIVE_GetType(drive + count) == TYPE_CDROM) count++;
202 break;
206 BX_reg(context) = count;
207 CX_reg(context) = (drive < MAX_DOS_DRIVES) ? drive : 0;
208 break;
210 case 0x0B: /* drive check */
211 AX_reg(context) = (DRIVE_GetType(CX_reg(context)) == TYPE_CDROM);
212 BX_reg(context) = 0xADAD;
213 break;
215 case 0x0C: /* get version */
216 BX_reg(context) = 0x020a;
217 break;
219 case 0x0D: /* get drive letters */
220 p = PTR_SEG_OFF_TO_LIN(ES_reg(context), BX_reg(context));
221 memset( p, 0, MAX_DOS_DRIVES );
222 for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
224 if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive;
226 break;
228 default:
229 FIXME(int, "Unimplemented MSCDEX function 0x%02X.\n", AL_reg(context));
230 break;