Add exclusion defs & remaining funcs, remove internal types &
[wine/hacks.git] / msdos / int2f.c
blobed6fffbdd8e5eebbec281ca348be47336b4ed37d
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
2 /*
3 * DOS interrupt 2fh handler
5 * Cdrom - device driver emulation - Audio features.
6 * (c) 1998 Petr Tomasek <tomasek@etf.cuni.cz>
7 * (c) 1999 Eric Pouech
8 */
10 #include "config.h"
12 #include <string.h>
13 #include "wine/winbase16.h"
14 #include "miscemu.h"
15 #include "module.h"
16 /* #define DEBUG_INT */
17 #include "debugtools.h"
18 #include "cdrom.h"
20 DEFAULT_DEBUG_CHANNEL(int);
22 /* base WPROCS.DLL ordinal number for VxDs */
23 #define VXD_BASE 400
25 static void do_int2f_16( CONTEXT86 *context );
26 static void MSCDEX_Handler( CONTEXT86 *context );
28 /**********************************************************************
29 * INT_Int2fHandler (WPROCS.147)
31 * Handler for int 2fh (multiplex).
33 void WINAPI INT_Int2fHandler( CONTEXT86 *context )
35 TRACE("Subfunction 0x%X\n", AX_reg(context));
37 switch(AH_reg(context))
39 case 0x10:
40 AL_reg(context) = 0xff; /* share is installed */
41 break;
43 case 0x11: /* Network Redirector / IFSFUNC */
44 switch (LOBYTE(context->Eax))
46 case 0x00: /* Install check */
47 /* not installed */
48 break;
49 case 0x80: /* Enhanced services - Install check */
50 /* not installed */
51 break;
52 default:
53 INT_BARF( context, 0x2f );
54 break;
56 break;
58 case 0x12:
59 switch (LOBYTE(context->Eax))
61 case 0x2e: /* get or set DOS error table address */
62 switch (DL_reg(context))
64 /* Four tables: even commands are 'get', odd are 'set' */
65 /* DOS 5.0+ ignores "set" commands */
66 case 0x01:
67 case 0x03:
68 case 0x05:
69 case 0x07:
70 case 0x09:
71 break;
72 /* Instead of having a message table in DOS-space, */
73 /* we can use a special case for MS-DOS to force */
74 /* the secondary interface. */
75 case 0x00:
76 case 0x02:
77 case 0x04:
78 case 0x06:
79 context->SegEs = 0x0001;
80 DI_reg(context) = 0x0000;
81 break;
82 case 0x08:
83 FIXME("No real-mode handler for errors yet! (bye!)\n");
84 break;
85 default:
86 INT_BARF(context, 0x2f);
88 break;
89 default:
90 INT_BARF(context, 0x2f);
92 break;
94 case 0x15: /* mscdex */
95 MSCDEX_Handler(context);
96 break;
98 case 0x16:
99 do_int2f_16( context );
100 break;
102 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
103 /* Not supported yet, do nothing */
104 break;
106 case 0x43:
107 #if 1
108 switch (LOBYTE(context->Eax))
110 case 0x00: /* XMS v2+ installation check */
111 WARN("XMS is not fully implemented\n");
112 AL_reg(context) = 0x80;
113 break;
114 case 0x10: /* XMS v2+ get driver address */
116 context->SegEs = DOSMEM_xms_seg;
117 BX_reg(context) = 0;
118 break;
120 default:
121 INT_BARF( context, 0x2f );
123 #else
124 FIXME("check for XMS (not supported)\n");
125 AL_reg(context) = 0x42; /* != 0x80 */
126 #endif
127 break;
129 case 0x45:
130 switch (LOBYTE(context->Eax))
132 case 0x00:
133 case 0x01:
134 case 0x02:
135 case 0x03:
136 case 0x04:
137 case 0x05:
138 case 0x06:
139 case 0x07:
140 case 0x08:
141 /* Microsoft Profiler - not installed */
142 break;
143 default:
144 INT_BARF( context, 0x2f );
146 break;
148 case 0x4a:
149 switch(LOBYTE(context->Eax))
151 case 0x10: /* smartdrv */
152 break; /* not installed */
153 case 0x11: /* dblspace */
154 break; /* not installed */
155 case 0x12: /* realtime compression interface */
156 break; /* not installed */
157 case 0x32: /* patch IO.SYS (???) */
158 break; /* we have no IO.SYS, so we can't patch it :-/ */
159 default:
160 INT_BARF( context, 0x2f );
162 break;
163 case 0x4b:
164 switch(LOBYTE(context->Eax))
166 case 0x01:
167 case 0x02:
168 case 0x03:
169 case 0x04:
170 case 0x05:
171 FIXME("Task Switcher - not implemented\n");
172 break;
173 default:
174 INT_BARF( context, 0x2f );
176 break;
177 case 0x56: /* INTERLNK */
178 switch(LOBYTE(context->Eax))
180 case 0x01: /* check if redirected drive */
181 AL_reg(context) = 0; /* not redirected */
182 break;
183 default:
184 INT_BARF( context, 0x2f );
186 break;
187 case 0x7a: /* NOVELL NetWare */
188 switch (LOBYTE(context->Eax))
190 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
191 AL_reg(context) = 0;
192 break;
193 case 0x20: /* Get VLM Call Address */
194 /* return nothing -> NetWare not installed */
195 break;
196 default:
197 INT_BARF( context, 0x2f );
198 break;
200 break;
201 case 0xb7: /* append */
202 LOBYTE(context->Eax) = 0; /* not installed */
203 break;
204 case 0xb8: /* network */
205 switch (LOBYTE(context->Eax))
207 case 0x00: /* Install check */
208 /* not installed */
209 break;
210 default:
211 INT_BARF( context, 0x2f );
212 break;
214 break;
215 case 0xbd: /* some Novell network install check ??? */
216 AX_reg(context) = 0xa5a5; /* pretend to have Novell IPX installed */
217 break;
218 case 0xbf: /* REDIRIFS.EXE */
219 switch (LOBYTE(context->Eax))
221 case 0x00: /* Install check */
222 /* not installed */
223 break;
224 default:
225 INT_BARF( context, 0x2f );
226 break;
228 break;
229 case 0xd2:
230 switch(LOBYTE(context->Eax))
232 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
233 if(BX_reg(context) == 0x5145 && CX_reg(context) == 0x4D4D
234 && DX_reg(context) == 0x3432)
235 TRACE("Check for QEMM v5.0+ (not installed)\n");
236 break;
237 default:
238 INT_BARF( context, 0x2f );
239 break;
241 break;
242 case 0xd7: /* Banyan Vines */
243 switch (LOBYTE(context->Eax))
245 case 0x01: /* Install check - Get Int Number */
246 /* not installed */
247 break;
248 default:
249 INT_BARF( context, 0x2f );
250 break;
252 break;
253 case 0xde:
254 switch(LOBYTE(context->Eax))
256 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
257 if(BX_reg(context) == 0x4450 && CX_reg(context) == 0x4d49
258 && DX_reg(context) == 0x8f4f)
259 TRACE("Check for QDPMI.SYS (not installed)\n");
260 break;
261 default:
262 INT_BARF( context, 0x2f );
263 break;
265 break;
266 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
267 break;
268 default:
269 INT_BARF( context, 0x2f );
270 break;
275 /**********************************************************************
276 * do_int2f_16
278 static void do_int2f_16( CONTEXT86 *context )
280 DWORD addr;
282 switch(LOBYTE(context->Eax))
284 case 0x00: /* Windows enhanced mode installation check */
285 AX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ?
286 LOWORD(GetVersion16()) : 0;
287 break;
289 case 0x0a: /* Get Windows version and type */
290 AX_reg(context) = 0;
291 BX_reg(context) = (LOWORD(GetVersion16()) << 8) |
292 (LOWORD(GetVersion16()) >> 8);
293 CX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ? 3 : 2;
294 break;
296 case 0x0b: /* Identify Windows-aware TSRs */
297 /* we don't have any pre-Windows TSRs */
298 break;
300 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
301 /* We can mock this up. But not today... */
302 FIXME("Get Shell Parameters\n");
303 break;
305 case 0x80: /* Release time-slice */
306 AL_reg(context) = 0;
307 break;
309 case 0x81: /* Begin critical section. */
310 /* FIXME? */
311 break;
313 case 0x82: /* End critical section. */
314 /* FIXME? */
315 break;
317 case 0x83: /* Return Current Virtual Machine ID */
318 /* Virtual Machines are usually created/destroyed when Windows runs
319 * DOS programs. Since we never do, we are always in the System VM.
320 * According to Ralf Brown's Interrupt List, never return 0. But it
321 * seems to work okay (returning 0), just to be sure we return 1.
323 BX_reg(context) = 1; /* VM 1 is probably the System VM */
324 break;
326 case 0x84: /* Get device API entry point */
328 HMODULE16 mod = GetModuleHandle16("wprocs");
329 if (mod < 32) mod = LoadLibrary16( "wprocs" );
330 addr = (DWORD)GetProcAddress16( mod, (LPCSTR)(VXD_BASE + BX_reg(context)) );
331 if (!addr) /* not supported */
332 ERR("Accessing unknown VxD %04x - Expect a failure now.\n", BX_reg(context) );
333 context->SegEs = SELECTOROF(addr);
334 DI_reg(context) = OFFSETOF(addr);
336 break;
338 case 0x86: /* DPMI detect mode */
339 AX_reg(context) = 0; /* Running under DPMI */
340 break;
342 case 0x87: /* DPMI installation check */
343 #if 1 /* DPMI still breaks pkunzip */
344 if (ISV86(context)) break; /* so bail out for now if in v86 mode */
345 #endif
347 SYSTEM_INFO si;
348 GetSystemInfo(&si);
349 AX_reg(context) = 0x0000; /* DPMI Installed */
350 BX_reg(context) = 0x0001; /* 32bits available */
351 CL_reg(context) = si.wProcessorLevel;
352 DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
353 SI_reg(context) = 0; /* # of para. of DOS extended private data */
354 context->SegEs = DOSMEM_dpmi_seg;
355 DI_reg(context) = 0; /* ES:DI is DPMI switch entry point */
356 break;
358 case 0x8a: /* DPMI get vendor-specific API entry point. */
359 /* The 1.0 specs say this should work with all 0.9 hosts. */
360 break;
362 default:
363 INT_BARF( context, 0x2f );
367 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
368 * must be <size> aligned
369 * <size> could be WORD, DWORD...
370 * in this case, we would need two macros, one for read, the other one for write
371 * Note: PTR_AT can be used as an l-value
373 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
375 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
376 #if 0
377 /**********************************************************************
378 * MSCDEX_Dump [internal]
380 * Dumps mscdex requests to int debug channel.
382 static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode)
384 int i;
385 BYTE buf[2048];
386 BYTE* ptr;
387 BYTE* ios;
389 ptr = buf;
390 ptr += sprintf(ptr, "%s\tCommand => ", pfx);
391 for (i = 0; i < req[0]; i++) {
392 ptr += sprintf(ptr, "%02x ", req[i]);
395 switch (req[2]) {
396 case 3:
397 case 12:
398 ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => ");
399 ios = (dorealmode) ? PTR_REAL_TO_LIN( PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD)) :
400 MapSL(MAKESEGPTR(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD)));
402 for (i = 0; i < PTR_AT(req, 18, WORD); i++) {
403 ptr += sprintf(ptr, "%02x ", ios[i]);
404 if ((i & 0x1F) == 0x1F) {
405 *ptr++ = '\n';
406 *ptr = 0;
409 break;
411 TRACE("%s\n", buf);
413 #else
414 #define MSCDEX_Dump(pfx, req, drm)
415 #endif
417 static void MSCDEX_StoreMSF(DWORD frame, BYTE* val)
419 val[3] = 0; /* zero */
420 val[2] = frame / CDFRAMES_PERMIN; /* minutes */
421 val[1] = (frame - CDFRAMES_PERMIN * val[2]) / CDFRAMES_PERSEC; /* seconds */
422 val[0] = frame - CDFRAMES_PERMIN * val[2] - CDFRAMES_PERSEC * val[1]; /* frames */
425 static int is_cdrom( int drive)
427 char root[] = "A:\\";
428 root[0] += drive;
429 return (GetDriveTypeA(root) == DRIVE_CDROM);
432 static void MSCDEX_Handler(CONTEXT86* context)
434 int drive, count;
435 char* p;
437 switch(LOBYTE(context->Eax)) {
438 case 0x00: /* Installation check */
439 /* Count the number of contiguous CDROM drives
441 for (drive = count = 0; drive < 26; drive++) {
442 if (is_cdrom(drive)) {
443 while (is_cdrom(drive + count)) count++;
444 break;
447 TRACE("Installation check: %d cdroms, starting at %d\n", count, drive);
448 BX_reg(context) = count;
449 CX_reg(context) = (drive < 26) ? drive : 0;
450 break;
452 case 0x0B: /* drive check */
453 AX_reg(context) = is_cdrom(CX_reg(context));
454 BX_reg(context) = 0xADAD;
455 break;
457 case 0x0C: /* get version */
458 BX_reg(context) = 0x020a;
459 TRACE("Version number => %04x\n", BX_reg(context));
460 break;
462 case 0x0D: /* get drive letters */
463 p = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
464 memset(p, 0, 26);
465 for (drive = 0; drive < 26; drive++) {
466 if (is_cdrom(drive)) *p++ = drive;
468 TRACE("Get drive letters\n");
469 break;
471 case 0x10: /* direct driver access */
473 static WINE_CDAUDIO wcda;
474 int dev = -1;
475 BYTE* driver_request;
476 BYTE* io_stru;
477 BYTE Error = 255; /* No Error */
478 int dorealmode = ISV86(context);
480 driver_request = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
482 if (!driver_request) {
483 /* FIXME - to be deleted ?? */
484 ERR("ES:BX==0 ! SEGFAULT ?\n");
485 ERR("-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
486 BX_reg(context), context->SegEs, context->SegDs, CX_reg(context));
487 driver_request[4] |= 0x80;
488 driver_request[3] = 5; /* bad request length */
489 return;
491 /* FIXME
492 * - the current implementation only supports a single CD ROM
494 CDROM_Open(&wcda, -1);
495 dev = CDROM_OpenDev(&wcda);
496 TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]);
498 for (drive = 0; drive < 26; drive++) if (is_cdrom(drive)) break;
499 /* drive contains the first CD ROM */
500 if (CX_reg(context) != drive) {
501 WARN("Request made doesn't match a CD ROM drive (%d/%d)\n", CX_reg(context), drive);
502 driver_request[4] |= 0x80;
503 driver_request[3] = 1; /* unknown unit */
504 return;
507 MSCDEX_Dump("Beg", driver_request, dorealmode);
509 /* set status to 0 */
510 PTR_AT(driver_request, 3, WORD) = 0;
511 CDROM_Audio_GetCDStatus(&wcda, dev);
513 switch (driver_request[2]) {
514 case 3:
515 io_stru = (dorealmode) ?
516 PTR_REAL_TO_LIN( PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD) ) :
517 MapSL( MAKESEGPTR(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)));
519 TRACE(" --> IOCTL INPUT <%d>\n", io_stru[0]);
520 switch (io_stru[0]) {
521 #if 0
522 case 0: /* Get device Header */
524 static LPSTR ptr = 0;
525 if (ptr == 0) {
526 ptr = SEGPTR_ALLOC(22);
527 PTR_AT(ptr, 0, DWORD) = ~1; /* Next Device Driver */
528 PTR_AT(ptr, 4, WORD) = 0xC800; /* Device attributes */
529 PTR_AT(ptr, 6, WORD) = 0x1234; /* Pointer to device strategy routine: FIXME */
530 PTR_AT(ptr, 8, WORD) = 0x3142; /* Pointer to device interrupt routine: FIXME */
531 PTR_AT(ptr, 10, char) = 'W'; /* 8-byte character device name field */
532 PTR_AT(ptr, 11, char) = 'I';
533 PTR_AT(ptr, 12, char) = 'N';
534 PTR_AT(ptr, 13, char) = 'E';
535 PTR_AT(ptr, 14, char) = '_';
536 PTR_AT(ptr, 15, char) = 'C';
537 PTR_AT(ptr, 16, char) = 'D';
538 PTR_AT(ptr, 17, char) = '_';
539 PTR_AT(ptr, 18, WORD) = 0; /* Reserved (must be zero) */
540 PTR_AT(ptr, 20, BYTE) = 0; /* Drive letter (must be zero) */
541 PTR_AT(ptr, 21, BYTE) = 1; /* Number of units supported (one or more) FIXME*/
543 PTR_AT(io_stru, DWORD, 0) = SEGPTR_GET(ptr);
545 break;
546 #endif
548 case 1: /* location of head */
549 switch (io_stru[1]) {
550 case 0:
551 PTR_AT(io_stru, 2, DWORD) = wcda.dwCurFrame;
552 break;
553 case 1:
554 MSCDEX_StoreMSF(wcda.dwCurFrame, io_stru + 2);
555 break;
556 default:
557 ERR("CD-ROM driver: unsupported addressing mode !!\n");
558 Error = 0x0c;
560 TRACE(" ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru, 2, DWORD));
561 break;
563 case 4: /* Audio channel info */
564 io_stru[1] = 0;
565 io_stru[2] = 0xff;
566 io_stru[3] = 1;
567 io_stru[4] = 0xff;
568 io_stru[5] = 2;
569 io_stru[6] = 0;
570 io_stru[7] = 3;
571 io_stru[8] = 0;
572 TRACE(" ----> AUDIO CHANNEL INFO\n");
573 break;
575 case 6: /* device status */
576 PTR_AT(io_stru, 1, DWORD) = 0x00000290;
577 /* 290 =>
578 * 1 Supports HSG and Red Book addressing modes
579 * 0 Supports audio channel manipulation
581 * 1 Supports prefetching requests
582 * 0 Reserved
583 * 0 No interleaving
584 * 1 Data read and plays audio/video tracks
586 * 0 Read only
587 * 0 Supports only cooked reading
588 * 0 Door locked
589 * 0 see below (Door closed/opened)
591 if (wcda.cdaMode == WINE_CDA_OPEN)
592 io_stru[1] |= 1;
593 TRACE(" ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru, 1, DWORD));
594 break;
596 case 8: /* Volume size */
597 PTR_AT(io_stru, 1, DWORD) = wcda.dwLastFrame;
598 TRACE(" ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru, 1, DWORD));
599 break;
601 case 9: /* media changed ? */
602 /* answers don't know... -1/1 for yes/no would be better */
603 io_stru[1] = 0; /* FIXME? 1? */
604 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru[1]);
605 break;
607 case 10: /* audio disk info */
608 io_stru[1] = wcda.nFirstTrack; /* starting track of the disc */
609 io_stru[2] = wcda.nLastTrack; /* ending track */
610 MSCDEX_StoreMSF(wcda.dwLastFrame, io_stru + 3);
612 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
613 io_stru[1], io_stru[2], PTR_AT(io_stru, 3, DWORD));
614 break;
616 case 11: /* audio track info */
617 if (io_stru[1] >= wcda.nFirstTrack && io_stru[1] <= wcda.nLastTrack) {
618 int nt = io_stru[1] - wcda.nFirstTrack;
619 MSCDEX_StoreMSF(wcda.lpdwTrackPos[nt], io_stru + 2);
620 /* starting point if the track */
621 io_stru[6] = (wcda.lpbTrackFlags[nt] & 0xF0) >> 4;
622 } else {
623 PTR_AT(io_stru, 2, DWORD) = 0;
624 io_stru[6] = 0;
626 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
627 io_stru[1], PTR_AT(io_stru, 2, DWORD), io_stru[6]);
628 break;
630 case 12: /* get Q-Channel info */
631 io_stru[1] = wcda.lpbTrackFlags[wcda.nCurTrack - 1];
632 io_stru[2] = wcda.nCurTrack;
633 io_stru[3] = 0; /* FIXME ?? */
635 /* why the heck did MS use another format for 0MSF information... sigh */
637 BYTE bTmp[4];
639 MSCDEX_StoreMSF(wcda.dwCurFrame - wcda.lpdwTrackPos[wcda.nCurTrack - 1], bTmp);
640 io_stru[ 4] = bTmp[2];
641 io_stru[ 5] = bTmp[1];
642 io_stru[ 6] = bTmp[0];
643 io_stru[ 7] = 0;
645 MSCDEX_StoreMSF(wcda.dwCurFrame, bTmp);
646 io_stru[ 8] = bTmp[2];
647 io_stru[ 9] = bTmp[1];
648 io_stru[10] = bTmp[0];
649 io_stru[11] = 0;
651 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08lx, tp=%08lx)\n",
652 io_stru[ 1], io_stru[ 2], io_stru[ 3],
653 io_stru[ 4], io_stru[ 5], io_stru[ 6],
654 io_stru[ 8], io_stru[ 9], io_stru[10],
655 wcda.dwCurFrame, wcda.lpdwTrackPos[wcda.nCurTrack - 1]);
656 break;
658 case 15: /* Audio status info */
659 /* !!!! FIXME FIXME FIXME !! */
660 PTR_AT(io_stru, 1, WORD) = 2 | ((wcda.cdaMode == WINE_CDA_PAUSE) ? 1 : 0);
661 if (wcda.cdaMode == WINE_CDA_OPEN) {
662 PTR_AT(io_stru, 3, DWORD) = 0;
663 PTR_AT(io_stru, 7, DWORD) = 0;
664 } else {
665 PTR_AT(io_stru, 3, DWORD) = wcda.lpdwTrackPos[0];
666 PTR_AT(io_stru, 7, DWORD) = wcda.lpdwTrackPos[wcda.nTracks - 1];
668 TRACE("Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
669 PTR_AT(io_stru, 1, WORD), PTR_AT(io_stru, 3, DWORD), PTR_AT(io_stru, 7, DWORD));
670 break;
672 default:
673 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru[0]);
674 Error = 0x0c;
675 break;
677 break;
679 case 12:
680 io_stru = (dorealmode) ?
681 PTR_REAL_TO_LIN( PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)) :
682 MapSL( MAKESEGPTR(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)));
684 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru[0]);
685 switch (io_stru[0]) {
686 case 0: /* eject */
687 CDROM_SetDoor(&wcda, 1, dev);
688 TRACE(" ----> EJECT\n");
689 break;
690 case 2: /* reset drive */
691 CDROM_Reset(&wcda, dev);
692 TRACE(" ----> RESET\n");
693 break;
694 case 3: /* Audio Channel Control */
695 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
696 break;
697 case 5: /* close tray */
698 CDROM_SetDoor(&wcda, 0, dev);
699 TRACE(" ----> CLOSE TRAY\n");
700 break;
701 default:
702 FIXME(" IOCTL OUTPUT: Unimplemented <%d>!!\n", io_stru[0]);
703 Error = 0x0c;
704 break;
706 break;
708 case 131: /* seek */
710 DWORD at;
712 at = PTR_AT(driver_request, 20, DWORD);
714 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
715 (BYTE)driver_request[13], at);
717 switch (driver_request[13]) {
718 case 1: /* Red book addressing mode = 0:m:s:f */
719 /* FIXME : frame <=> msf conversion routines could be shared
720 * between mscdex and mcicda
722 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
723 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
724 LOBYTE(LOWORD(at));
725 /* fall through */
726 case 0: /* HSG addressing mode */
727 CDROM_Audio_Seek(&wcda, at, dev);
728 break;
729 default:
730 ERR("Unsupported address mode !!\n");
731 Error = 0x0c;
732 break;
735 break;
737 case 132: /* play */
739 DWORD beg, end;
741 beg = end = PTR_AT(driver_request, 14, DWORD);
742 end += PTR_AT(driver_request, 18, DWORD);
744 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
745 (BYTE)driver_request[13], beg, end);
747 switch (driver_request[13]) {
748 case 1: /* Red book addressing mode = 0:m:s:f */
749 /* FIXME : frame <=> msf conversion routines could be shared
750 * between mscdex and mcicda
752 beg = LOBYTE(HIWORD(beg)) * CDFRAMES_PERMIN +
753 HIBYTE(LOWORD(beg)) * CDFRAMES_PERSEC +
754 LOBYTE(LOWORD(beg));
755 end = LOBYTE(HIWORD(end)) * CDFRAMES_PERMIN +
756 HIBYTE(LOWORD(end)) * CDFRAMES_PERSEC +
757 LOBYTE(LOWORD(end));
758 /* fall through */
759 case 0: /* HSG addressing mode */
760 CDROM_Audio_Play(&wcda, beg, end, dev);
761 break;
762 default:
763 ERR("Unsupported address mode !!\n");
764 Error = 0x0c;
765 break;
768 break;
770 case 133:
771 if (wcda.cdaMode == WINE_CDA_PLAY) {
772 CDROM_Audio_Pause(&wcda, 1, dev);
773 TRACE(" --> STOP AUDIO (Paused)\n");
774 } else {
775 CDROM_Audio_Stop(&wcda, dev);
776 TRACE(" --> STOP AUDIO (Stopped)\n");
778 break;
780 case 136:
781 TRACE(" --> RESUME AUDIO\n");
782 CDROM_Audio_Pause(&wcda, 0, dev);
783 break;
785 default:
786 FIXME(" ioctl unimplemented <%d>\n", driver_request[2]);
787 Error = 0x0c;
790 /* setting error codes if any */
791 if (Error < 255) {
792 driver_request[4] |= 0x80;
793 driver_request[3] = Error;
796 CDROM_CloseDev(dev);
797 CDROM_Close(&wcda);
798 /* setting status bits
799 * 3 == playing && done
800 * 1 == done
802 driver_request[4] |= (wcda.cdaMode == WINE_CDA_PLAY) ? 3 : 1;
804 MSCDEX_Dump("End", driver_request, dorealmode);
806 break;
807 default:
808 FIXME("Unimplemented MSCDEX function 0x%02X.\n", LOBYTE(context->Eax));
809 break;