Release 960606
[wine.git] / miscemu / int2f.c
blobfdfd3a52094fc0ae4136ef80ca8929cfd9040836
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <unistd.h>
5 #include "registers.h"
6 #include "ldt.h"
7 #include "wine.h"
8 #include "drive.h"
9 #include "msdos.h"
10 #include "miscemu.h"
11 #include "module.h"
12 #include "options.h"
13 #include "stddebug.h"
14 /* #define DEBUG_INT */
15 #include "debug.h"
17 /* base WPROCS.DLL ordinal number for VxDs */
18 #define VXD_BASE 400
20 static void do_int2f_16(struct sigcontext_struct *context);
21 void do_mscdex(struct sigcontext_struct *context);
23 /**********************************************************************
24 * INT_Int2fHandler
26 * Handler for int 2fh (multiplex).
28 void INT_Int2fHandler( struct sigcontext_struct context )
30 switch(AH_reg(&context))
32 case 0x10:
33 AL_reg(&context) = 0xff; /* share is installed */
34 break;
36 case 0x15: /* mscdex */
37 do_mscdex(&context);
38 break;
40 case 0x16:
41 do_int2f_16( &context );
42 break;
44 case 0x4a:
45 switch(AL_reg(&context))
47 case 0x10: /* smartdrv */
48 break; /* not installed */
49 case 0x11: /* dblspace */
50 break; /* not installed */
51 case 0x12: /* realtime compression interface */
52 break; /* not installed */
53 default:
54 INT_BARF( &context, 0x2f );
56 break;
57 case 0xb7: /* append */
58 AL_reg(&context) = 0; /* not installed */
59 break;
60 default:
61 INT_BARF( &context, 0x2f );
62 break;
67 /**********************************************************************
68 * do_int2f_16
70 static void do_int2f_16(struct sigcontext_struct *context)
72 DWORD addr;
74 switch(AL_reg(context))
76 case 0x00: /* Windows enhanced mode installation check */
77 AX_reg(context) = (Options.mode == MODE_ENHANCED) ? WINVERSION : 0;
78 break;
80 case 0x0a: /* Get Windows version and type */
81 AX_reg(context) = 0;
82 BX_reg(context) = (WINVERSION >> 8) | ((WINVERSION << 8) & 0xff00);
83 CX_reg(context) = (Options.mode == MODE_ENHANCED) ? 3 : 2;
84 break;
86 case 0x80: /* Release time-slice */
87 AL_reg(context) = 0;
88 /* FIXME: We need to do something that lets some other process run
89 here. */
90 sleep(0);
91 break;
93 case 0x83: /* Return Current Virtual Machine ID */
94 /* Virtual Machines are usually created/destroyed when Windows runs
95 * DOS programs. Since we never do, we are always in the System VM.
96 * According to Ralf Brown's Interrupt List, never return 0. But it
97 * seems to work okay (returning 0), just to be sure we return 1.
99 BX_reg(context) = 1; /* VM 1 is probably the System VM */
100 break;
102 case 0x84: /* Get device API entry point */
103 addr = MODULE_GetEntryPoint( GetModuleHandle("WPROCS"),
104 VXD_BASE + BX_reg(context) );
105 if (!addr) /* not supported */
107 fprintf( stderr,"Application attempted to access VxD %04x\n",
108 BX_reg(context) );
109 fprintf( stderr,"This device is not known to Wine.");
110 fprintf( stderr,"Expect a failure now\n");
112 ES_reg(context) = SELECTOROF(addr);
113 DI_reg(context) = OFFSETOF(addr);
114 break;
116 case 0x86: /* DPMI detect mode */
117 AX_reg(context) = 0; /* Running under DPMI */
118 break;
120 /* FIXME: is this right? Specs say that this should only be callable
121 in real (v86) mode which we never enter. */
122 case 0x87: /* DPMI installation check */
123 AX_reg(context) = 0x0000; /* DPMI Installed */
124 BX_reg(context) = 0x0001; /* 32bits available */
125 CL_reg(context) = runtime_cpu();
126 DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
127 SI_reg(context) = 0; /* # of para. of DOS extended private data */
128 ES_reg(context) = 0; /* ES:DI is DPMI switch entry point */
129 DI_reg(context) = 0;
130 break;
132 case 0x8a: /* DPMI get vendor-specific API entry point. */
133 /* The 1.0 specs say this should work with all 0.9 hosts. */
134 break;
136 default:
137 INT_BARF( context, 0x2f );
141 void do_mscdex(struct sigcontext_struct *context)
143 int drive, count;
144 char *p;
146 switch(AL_reg(context))
148 case 0x00: /* Installation check */
149 /* Count the number of contiguous CDROM drives
151 for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++)
153 if (DRIVE_GetType(drive) == TYPE_CDROM)
155 while (DRIVE_GetType(drive + count) == TYPE_CDROM) count++;
156 break;
160 BX_reg(context) = count;
161 CX_reg(context) = (drive < MAX_DOS_DRIVES) ? drive : 0;
162 break;
164 case 0x0B: /* drive check */
165 AX_reg(context) = (DRIVE_GetType(CX_reg(context)) == TYPE_CDROM);
166 BX_reg(context) = 0xADAD;
167 break;
169 case 0x0C: /* get version */
170 BX_reg(context) = 0x020a;
171 break;
173 case 0x0D: /* get drive letters */
174 p = PTR_SEG_OFF_TO_LIN(ES_reg(context), BX_reg(context));
175 memset( p, 0, MAX_DOS_DRIVES );
176 for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
178 if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive;
180 break;
182 default:
183 fprintf(stderr, "Unimplemented MSCDEX function 0x%02.2X.\n", AL_reg(context));
184 break;