1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
3 * DOS interrupt 2fh handler
5 * Cdrom - device driver emulation - Audio features.
6 * Copyright (c) 1998 Petr Tomasek <tomasek@etf.cuni.cz>
7 * Copyright (c) 1999,2002 Eric Pouech
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #define NONAMELESSUNION
29 #define NONAMELESSSTRUCT
30 #include "wine/winbase16.h"
31 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(int);
40 /* base WPROCS.DLL ordinal number for VxDs */
43 static void do_int2f_16( CONTEXT86 *context );
44 static void MSCDEX_Handler( CONTEXT86 *context );
46 /**********************************************************************
47 * DOSVM_Int2fHandler (WINEDOS16.147)
49 * Handler for int 2fh (multiplex).
51 void WINAPI DOSVM_Int2fHandler( CONTEXT86 *context )
53 TRACE("Subfunction 0x%X\n", AX_reg(context));
55 switch(AH_reg(context))
58 SET_AL( context, 0xff ); /* share is installed */
61 case 0x11: /* Network Redirector / IFSFUNC */
62 switch (LOBYTE(context->Eax))
64 case 0x00: /* Install check */
67 case 0x80: /* Enhanced services - Install check */
71 INT_BARF( context, 0x2f );
77 switch (LOBYTE(context->Eax))
79 case 0x2e: /* get or set DOS error table address */
80 switch (DL_reg(context))
82 /* Four tables: even commands are 'get', odd are 'set' */
83 /* DOS 5.0+ ignores "set" commands */
90 /* Instead of having a message table in DOS-space, */
91 /* we can use a special case for MS-DOS to force */
92 /* the secondary interface. */
97 context->SegEs = 0x0001;
98 SET_DI( context, 0x0000 );
101 FIXME("No real-mode handler for errors yet! (bye!)\n");
104 INT_BARF(context, 0x2f);
108 INT_BARF(context, 0x2f);
112 case 0x15: /* mscdex */
113 MSCDEX_Handler(context);
117 do_int2f_16( context );
120 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
121 /* Not supported yet, do nothing */
126 switch (LOBYTE(context->Eax))
128 case 0x00: /* XMS v2+ installation check */
129 WARN("XMS is not fully implemented\n");
130 SET_AL( context, 0x80 );
132 case 0x10: /* XMS v2+ get driver address */
134 context->SegEs = DOSVM_dpmi_segments->xms_seg;
135 SET_BX( context, 0 );
139 INT_BARF( context, 0x2f );
142 FIXME("check for XMS (not supported)\n");
143 SET_AL( context, 0x42 ); /* != 0x80 */
148 switch (LOBYTE(context->Eax))
159 /* Microsoft Profiler - not installed */
162 INT_BARF( context, 0x2f );
167 switch(LOBYTE(context->Eax))
169 case 0x10: /* smartdrv */
170 break; /* not installed */
171 case 0x11: /* dblspace */
172 break; /* not installed */
173 case 0x12: /* realtime compression interface */
174 break; /* not installed */
175 case 0x32: /* patch IO.SYS (???) */
176 break; /* we have no IO.SYS, so we can't patch it :-/ */
178 INT_BARF( context, 0x2f );
182 switch(LOBYTE(context->Eax))
189 FIXME("Task Switcher - not implemented\n");
192 INT_BARF( context, 0x2f );
195 case 0x56: /* INTERLNK */
196 switch(LOBYTE(context->Eax))
198 case 0x01: /* check if redirected drive */
199 SET_AL( context, 0 ); /* not redirected */
202 INT_BARF( context, 0x2f );
205 case 0x7a: /* NOVELL NetWare */
206 switch (LOBYTE(context->Eax))
208 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
209 SET_AL( context, 0 );
211 case 0x20: /* Get VLM Call Address */
212 /* return nothing -> NetWare not installed */
215 INT_BARF( context, 0x2f );
219 case 0xb7: /* append */
220 SET_AL( context, 0 ); /* not installed */
222 case 0xb8: /* network */
223 switch (LOBYTE(context->Eax))
225 case 0x00: /* Install check */
229 INT_BARF( context, 0x2f );
234 if (AL_reg(context) == 0x00 && BX_reg(context) == 0x3f3f) {
235 /* MVSOUND.SYS - Install check: not installed */
237 INT_BARF( context, 0x2f );
240 case 0xbd: /* some Novell network install check ??? */
241 SET_AX( context, 0xa5a5 ); /* pretend to have Novell IPX installed */
243 case 0xbf: /* REDIRIFS.EXE */
244 switch (LOBYTE(context->Eax))
246 case 0x00: /* Install check */
250 INT_BARF( context, 0x2f );
255 switch(LOBYTE(context->Eax))
257 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
258 if(BX_reg(context) == 0x5145 && CX_reg(context) == 0x4D4D
259 && DX_reg(context) == 0x3432)
260 TRACE("Check for QEMM v5.0+ (not installed)\n");
263 INT_BARF( context, 0x2f );
267 case 0xd7: /* Banyan Vines */
268 switch (LOBYTE(context->Eax))
270 case 0x01: /* Install check - Get Int Number */
274 INT_BARF( context, 0x2f );
279 switch(LOBYTE(context->Eax))
281 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
282 if(BX_reg(context) == 0x4450 && CX_reg(context) == 0x4d49
283 && DX_reg(context) == 0x8f4f)
284 TRACE("Check for QDPMI.SYS (not installed)\n");
287 INT_BARF( context, 0x2f );
291 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
294 INT_BARF( context, 0x2f );
300 /**********************************************************************
303 static void do_int2f_16( CONTEXT86 *context )
307 switch(LOBYTE(context->Eax))
309 case 0x00: /* Windows enhanced mode installation check */
310 SET_AX( context, (GetWinFlags16() & WF_ENHANCED) ? LOWORD(GetVersion16()) : 0 );
313 case 0x0a: /* Get Windows version and type */
314 SET_AX( context, 0 );
315 SET_BX( context, (LOWORD(GetVersion16()) << 8) | (LOWORD(GetVersion16()) >> 8) );
316 SET_CX( context, (GetWinFlags16() & WF_ENHANCED) ? 3 : 2 );
319 case 0x0b: /* Identify Windows-aware TSRs */
320 /* we don't have any pre-Windows TSRs */
323 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
324 /* We can mock this up. But not today... */
325 FIXME("Get Shell Parameters\n");
328 case 0x80: /* Release time-slice */
329 /* Linux sched_yield() still keeps burning CPU cycles
330 * if the current process is the only one in highest priority list
331 * (as Linux will immediately return to this process to waste
332 * more CPU cycles), so sched_yield() is essentially useless for us
333 * (poor API, if you ask me: its return code should indicate
334 * whether other processes did run in between, in order for us
335 * to be able to decide whether to do an additional Sleep() or not...)
336 * Thus we better unconditionally use a well-balanced Sleep()
337 * instead to really make sure the process calling int 0x2f/0x1680
338 * *doesn't* use 100% CPU...
340 Sleep(55); /* just wait 55ms (one "timer tick") for now. */
341 SET_AL( context, 0 );
344 case 0x81: /* Begin critical section. */
348 case 0x82: /* End critical section. */
352 case 0x83: /* Return Current Virtual Machine ID */
353 /* Virtual Machines are usually created/destroyed when Windows runs
354 * DOS programs. Since we never do, we are always in the System VM.
355 * According to Ralf Brown's Interrupt List, never return 0. But it
356 * seems to work okay (returning 0), just to be sure we return 1.
358 SET_BX( context, 1 ); /* VM 1 is probably the System VM */
361 case 0x84: /* Get device API entry point */
363 HMODULE16 mod = GetModuleHandle16("wprocs");
364 if (mod < 32) mod = LoadLibrary16( "wprocs" );
365 addr = (DWORD)GetProcAddress16( mod, (LPCSTR)(VXD_BASE + BX_reg(context)) );
366 if (!addr) /* not supported */
367 ERR("Accessing unknown VxD %04x - Expect a failure now.\n", BX_reg(context) );
368 context->SegEs = SELECTOROF(addr);
369 SET_DI( context, OFFSETOF(addr) );
373 case 0x86: /* DPMI detect mode */
374 SET_AX( context, 0 ); /* Running under DPMI */
377 case 0x87: /* DPMI installation check */
381 SET_AX( context, 0x0000 ); /* DPMI Installed */
382 SET_BX( context, 0x0001 ); /* 32bits available */
383 SET_CL( context, si.wProcessorLevel );
384 SET_DX( context, 0x005a ); /* DPMI major/minor 0.90 */
385 SET_SI( context, 0 ); /* # of para. of DOS extended private data */
386 context->SegEs = DOSVM_dpmi_segments->dpmi_seg;
387 SET_DI( context, 0 ); /* ES:DI is DPMI switch entry point */
390 case 0x8a: /* DPMI get vendor-specific API entry point. */
391 /* The 1.0 specs say this should work with all 0.9 hosts. */
395 INT_BARF( context, 0x2f );
399 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
400 * must be <size> aligned
401 * <size> could be WORD, DWORD...
402 * in this case, we would need two macros, one for read, the other one for write
403 * Note: PTR_AT can be used as an l-value
405 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
407 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
409 /**********************************************************************
410 * MSCDEX_Dump [internal]
412 * Dumps mscdex requests to int debug channel.
414 static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode)
422 ptr += sprintf(ptr, "%s\tCommand => ", pfx);
423 for (i = 0; i < req[0]; i++) {
424 ptr += sprintf(ptr, "%02x ", req[i]);
430 ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => ");
431 ios = (dorealmode) ? PTR_REAL_TO_LIN( PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD)) :
432 MapSL(MAKESEGPTR(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD)));
434 for (i = 0; i < PTR_AT(req, 18, WORD); i++) {
435 ptr += sprintf(ptr, "%02x ", ios[i]);
436 if ((i & 0x1F) == 0x1F) {
446 #define MSCDEX_Dump(pfx, req, drm)
449 #define CDFRAMES_PERSEC 75
450 #define CDFRAMES_PERMIN (CDFRAMES_PERSEC * 60)
451 #define FRAME_OF_ADDR(a) ((a)[1] * CDFRAMES_PERMIN + (a)[2] * CDFRAMES_PERSEC + (a)[3])
452 #define FRAME_OF_TOC(toc, idx) FRAME_OF_ADDR((toc).TrackData[idx - (toc).FirstTrack].Address)
453 #define CTRL_OF_TOC(toc, idx) (((toc).TrackData[idx - (toc).FirstTrack].Control << 4) | \
454 (toc).TrackData[idx - (toc).FirstTrack].Adr)
456 static void MSCDEX_StoreMSF(DWORD frame, BYTE* val)
458 val[3] = 0; /* zero */
459 val[2] = frame / CDFRAMES_PERMIN; /* minutes */
460 val[1] = (frame / CDFRAMES_PERSEC) % 60; /* seconds */
461 val[0] = frame % CDFRAMES_PERSEC; /* frames */
464 static int is_cdrom( int drive)
466 char root[] = "A:\\";
468 return (GetDriveTypeA(root) == DRIVE_CDROM);
471 static void MSCDEX_Handler(CONTEXT86* context)
476 switch (LOBYTE(context->Eax)) {
477 case 0x00: /* Installation check */
478 /* Count the number of contiguous CDROM drives
480 for (drive = count = 0; drive < 26; drive++) {
481 if (is_cdrom(drive)) {
482 while (is_cdrom(drive + count)) count++;
486 TRACE("Installation check: %d cdroms, starting at %d\n", count, drive);
487 SET_BX( context, count );
488 SET_CX( context, (drive < 26) ? drive : 0 );
491 case 0x0B: /* drive check */
492 SET_AX( context, is_cdrom(CX_reg(context)) );
493 SET_BX( context, 0xADAD );
496 case 0x0C: /* get version */
497 SET_BX( context, 0x020a );
498 TRACE("Version number => %04x\n", BX_reg(context));
501 case 0x0D: /* get drive letters */
502 p = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
504 for (drive = 0; drive < 26; drive++) {
505 if (is_cdrom(drive)) *p++ = drive;
507 TRACE("Get drive letters\n");
510 case 0x10: /* direct driver access */
512 BYTE* driver_request;
514 BYTE Error = 255; /* No Error */
515 int dorealmode = ISV86(context);
516 char devName[] = "\\\\.\\@:";
519 CDROM_SUB_Q_DATA_FORMAT fmt;
520 SUB_Q_CHANNEL_DATA data;
522 DWORD present = TRUE;
524 driver_request = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
526 if (!driver_request) {
527 /* FIXME - to be deleted ?? */
528 ERR("ES:BX==0 ! SEGFAULT ?\n");
529 ERR("-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
530 BX_reg(context), context->SegEs, context->SegDs, CX_reg(context));
531 driver_request[4] |= 0x80;
532 driver_request[3] = 5; /* bad request length */
536 * the following tests are wrong because lots of functions don't require the
537 * tray to be closed with a CD inside
539 TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]);
541 if (!is_cdrom(CX_reg(context))) {
542 WARN("Request made doesn't match a CD ROM drive (%d)\n", CX_reg(context));
543 driver_request[4] |= 0x80;
544 driver_request[3] = 1; /* unknown unit */
548 MSCDEX_Dump("Beg", driver_request, dorealmode);
550 /* set status to 0 */
551 PTR_AT(driver_request, 3, WORD) = 0;
552 devName[4] = 'A' + CX_reg(context);
553 h = CreateFileA(devName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
555 WARN("Couldn't open cdrom handle\n");
556 driver_request[4] |= 0x80;
557 driver_request[3] = 1; /* unknown unit */
561 fmt.Format = IOCTL_CDROM_CURRENT_POSITION;
562 if (!DeviceIoControl(h, IOCTL_CDROM_READ_TOC, NULL, 0, &toc, sizeof(toc), &br, NULL) ||
563 !DeviceIoControl(h, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
564 &data, sizeof(data), &br, NULL)) {
565 if (GetLastError() == STATUS_NO_MEDIA_IN_DEVICE)
567 if (driver_request[2] != 6 && driver_request[2] != 15)
569 driver_request[4] |= 0x80;
570 driver_request[3] = 2; /* drive not ready */
578 driver_request[4] |= 0x80;
579 driver_request[3] = 1; /* unknown unit */
585 switch (driver_request[2]) {
587 io_stru = (dorealmode) ?
588 PTR_REAL_TO_LIN( PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD) ) :
589 MapSL( MAKESEGPTR(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)));
591 TRACE(" --> IOCTL INPUT <%d>\n", io_stru[0]);
592 switch (io_stru[0]) {
594 case 0: /* Get device Header */
596 static LPSTR ptr = 0;
598 ptr = SEGPTR_ALLOC(22);
599 PTR_AT(ptr, 0, DWORD) = ~1; /* Next Device Driver */
600 PTR_AT(ptr, 4, WORD) = 0xC800; /* Device attributes */
601 PTR_AT(ptr, 6, WORD) = 0x1234; /* Pointer to device strategy routine: FIXME */
602 PTR_AT(ptr, 8, WORD) = 0x3142; /* Pointer to device interrupt routine: FIXME */
603 PTR_AT(ptr, 10, char) = 'W'; /* 8-byte character device name field */
604 PTR_AT(ptr, 11, char) = 'I';
605 PTR_AT(ptr, 12, char) = 'N';
606 PTR_AT(ptr, 13, char) = 'E';
607 PTR_AT(ptr, 14, char) = '_';
608 PTR_AT(ptr, 15, char) = 'C';
609 PTR_AT(ptr, 16, char) = 'D';
610 PTR_AT(ptr, 17, char) = '_';
611 PTR_AT(ptr, 18, WORD) = 0; /* Reserved (must be zero) */
612 PTR_AT(ptr, 20, BYTE) = 0; /* Drive letter (must be zero) */
613 PTR_AT(ptr, 21, BYTE) = 1; /* Number of units supported (one or more) FIXME*/
615 PTR_AT(io_stru, DWORD, 0) = SEGPTR_GET(ptr);
620 case 1: /* location of head */
621 switch (io_stru[1]) {
623 PTR_AT(io_stru, 2, DWORD) =
624 FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress);
627 MSCDEX_StoreMSF(FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress),
631 ERR("CD-ROM driver: unsupported addressing mode !!\n");
634 TRACE(" ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru, 2, DWORD));
637 case 4: /* Audio channel info */
646 TRACE(" ----> AUDIO CHANNEL INFO\n");
649 case 6: /* device status */
650 PTR_AT(io_stru, 1, DWORD) = 0x00000290;
652 * 1 Supports HSG and Red Book addressing modes
653 * 0 Supports audio channel manipulation
655 * 1 Supports prefetching requests
658 * 1 Data read and plays audio/video tracks
661 * 0 Supports only cooked reading
663 * 0 see below (Door closed/opened)
665 if (!present) PTR_AT(io_stru, 1, DWORD) |= 1;
666 TRACE(" ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru, 1, DWORD));
669 case 8: /* Volume size */
670 PTR_AT(io_stru, 1, DWORD) = FRAME_OF_TOC(toc, toc.LastTrack + 1) -
671 FRAME_OF_TOC(toc, toc.FirstTrack) - 1;
672 TRACE(" ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru, 1, DWORD));
675 case 9: /* media changed ? */
676 /* answers don't know... -1/1 for yes/no would be better */
677 io_stru[1] = 0; /* FIXME? 1? */
678 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru[1]);
681 case 10: /* audio disk info */
682 io_stru[1] = toc.FirstTrack; /* starting track of the disc */
683 io_stru[2] = toc.LastTrack; /* ending track */
684 MSCDEX_StoreMSF(FRAME_OF_TOC(toc, toc.LastTrack + 1) -
685 FRAME_OF_TOC(toc, toc.FirstTrack) - 1, io_stru + 3);
687 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
688 io_stru[1], io_stru[2], PTR_AT(io_stru, 3, DWORD));
691 case 11: /* audio track info */
692 if (io_stru[1] >= toc.FirstTrack && io_stru[1] <= toc.LastTrack) {
693 MSCDEX_StoreMSF(FRAME_OF_TOC(toc, io_stru[1]), io_stru + 2);
694 /* starting point if the track */
695 io_stru[6] = CTRL_OF_TOC(toc, io_stru[1]);
697 PTR_AT(io_stru, 2, DWORD) = 0;
700 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
701 io_stru[1], PTR_AT(io_stru, 2, DWORD), io_stru[6]);
704 case 12: /* get Q-Channel info */
705 io_stru[1] = CTRL_OF_TOC(toc, data.CurrentPosition.TrackNumber);
706 io_stru[2] = data.CurrentPosition.TrackNumber;
707 io_stru[3] = 0; /* FIXME ?? */
709 /* why the heck did MS use another format for 0MSF information... sigh */
713 MSCDEX_StoreMSF(FRAME_OF_ADDR(data.CurrentPosition.TrackRelativeAddress), bTmp);
714 io_stru[ 4] = bTmp[2];
715 io_stru[ 5] = bTmp[1];
716 io_stru[ 6] = bTmp[0];
719 MSCDEX_StoreMSF(FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress), bTmp);
720 io_stru[ 8] = bTmp[2];
721 io_stru[ 9] = bTmp[1];
722 io_stru[10] = bTmp[0];
725 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08x, tp=%08x)\n",
726 io_stru[ 1], io_stru[ 2], io_stru[ 3],
727 io_stru[ 4], io_stru[ 5], io_stru[ 6],
728 io_stru[ 8], io_stru[ 9], io_stru[10],
729 FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress),
730 FRAME_OF_TOC(toc, data.CurrentPosition.TrackNumber));
733 case 15: /* Audio status info */
734 /* !!!! FIXME FIXME FIXME !! */
735 PTR_AT(io_stru, 1, WORD) = 2 | ((data.CurrentPosition.Header.AudioStatus == AUDIO_STATUS_PAUSED) ? 1 : 0);
737 PTR_AT(io_stru, 3, DWORD) = 0;
738 PTR_AT(io_stru, 7, DWORD) = 0;
740 PTR_AT(io_stru, 3, DWORD) = FRAME_OF_TOC(toc, toc.FirstTrack);
741 PTR_AT(io_stru, 7, DWORD) = FRAME_OF_TOC(toc, toc.LastTrack + 1);
743 TRACE("Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
744 PTR_AT(io_stru, 1, WORD), PTR_AT(io_stru, 3, DWORD), PTR_AT(io_stru, 7, DWORD));
748 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru[0]);
755 io_stru = (dorealmode) ?
756 PTR_REAL_TO_LIN( PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)) :
757 MapSL( MAKESEGPTR(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)));
759 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru[0]);
760 switch (io_stru[0]) {
762 DeviceIoControl(h, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &br, NULL);
763 TRACE(" ----> EJECT\n");
765 case 2: /* reset drive */
766 DeviceIoControl(h, IOCTL_STORAGE_RESET_DEVICE, NULL, 0, NULL, 0, &br, NULL);
767 TRACE(" ----> RESET\n");
769 case 3: /* Audio Channel Control */
770 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
772 case 5: /* close tray */
773 DeviceIoControl(h, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0, &br, NULL);
774 TRACE(" ----> CLOSE TRAY\n");
777 FIXME(" IOCTL OUTPUT: Unimplemented <%d>!!\n", io_stru[0]);
783 case 128: /* read long */
785 LPVOID dst = MapSL(MAKESEGPTR(PTR_AT(driver_request, 16, WORD),
786 PTR_AT(driver_request, 14, WORD)));
787 DWORD at = PTR_AT(driver_request, 20, DWORD);
788 WORD num = PTR_AT(driver_request, 18, WORD);
791 switch (driver_request[13]) {
792 case 1: /* Red book addressing mode = 0:m:s:f */
793 /* FIXME : frame <=> msf conversion routines could be shared
794 * between mscdex and mcicda
796 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
797 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
800 case 0: /* HSG addressing mode */
801 switch (PTR_AT(driver_request, 24, BYTE))
804 ReadFile(h, dst, num * 2048, &br, NULL);
807 /* FIXME: computation is wrong */
808 rri.DiskOffset.u.HighPart = 0;
809 rri.DiskOffset.u.LowPart = at << 11;
810 rri.TrackMode = YellowMode2;
811 rri.SectorCount = num;
812 DeviceIoControl(h, IOCTL_CDROM_RAW_READ, &rri, sizeof(rri),
813 dst, num * 2352, &br, NULL);
816 ERR("Unsupported read mode !!\n");
822 ERR("Unsupported address mode !!\n");
832 CDROM_SEEK_AUDIO_MSF seek;
834 at = PTR_AT(driver_request, 20, DWORD);
836 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
837 (BYTE)driver_request[13], at);
839 switch (driver_request[13]) {
840 case 1: /* Red book addressing mode = 0:m:s:f */
841 /* FIXME : frame <=> msf conversion routines could be shared
842 * between mscdex and mcicda
844 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
845 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
848 case 0: /* HSG addressing mode */
849 seek.M = at / CDFRAMES_PERMIN;
850 seek.S = (at / CDFRAMES_PERSEC) % 60;
851 seek.F = at % CDFRAMES_PERSEC;
852 DeviceIoControl(h, IOCTL_CDROM_SEEK_AUDIO_MSF, &seek, sizeof(seek),
856 ERR("Unsupported address mode !!\n");
866 CDROM_PLAY_AUDIO_MSF play;
868 beg = end = PTR_AT(driver_request, 14, DWORD);
869 end += PTR_AT(driver_request, 18, DWORD);
871 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
872 (BYTE)driver_request[13], beg, end);
874 switch (driver_request[13]) {
876 /* Red book addressing mode = 0:m:s:f */
877 /* FIXME : frame <=> msf conversion routines could be shared
878 * between mscdex and mcicda
880 beg = LOBYTE(LOWORD(beg)) * CDFRAMES_PERMIN +
881 HIBYTE(LOWORD(beg)) * CDFRAMES_PERSEC +
883 end = LOBYTE(LOWORD(end)) * CDFRAMES_PERMIN +
884 HIBYTE(LOWORD(end)) * CDFRAMES_PERSEC +
887 case 0: /* HSG addressing mode */
888 play.StartingM = beg / CDFRAMES_PERMIN;
889 play.StartingS = (beg / CDFRAMES_PERSEC) % 60;
890 play.StartingF = beg % CDFRAMES_PERSEC;
891 play.EndingM = end / CDFRAMES_PERMIN;
892 play.EndingS = (end / CDFRAMES_PERSEC) % 60;
893 play.EndingF = end % CDFRAMES_PERSEC;
894 DeviceIoControl(h, IOCTL_CDROM_PLAY_AUDIO_MSF, &play, sizeof(play),
898 ERR("Unsupported address mode !!\n");
906 if (data.CurrentPosition.Header.AudioStatus == AUDIO_STATUS_IN_PROGRESS) {
907 DeviceIoControl(h, IOCTL_CDROM_PAUSE_AUDIO, NULL, 0, NULL, 0, &br, NULL);
908 TRACE(" --> STOP AUDIO (Paused)\n");
910 DeviceIoControl(h, IOCTL_CDROM_STOP_AUDIO, NULL, 0, NULL, 0, &br, NULL);
911 TRACE(" --> STOP AUDIO (Stopped)\n");
916 TRACE(" --> RESUME AUDIO\n");
917 DeviceIoControl(h, IOCTL_CDROM_PAUSE_AUDIO, NULL, 0, NULL, 0, &br, NULL);
921 FIXME(" ioctl unimplemented <%d>\n", driver_request[2]);
925 /* setting error codes if any */
927 driver_request[4] |= 0x80;
928 driver_request[3] = Error;
932 /* setting status bits
933 * 3 == playing && done
937 (data.CurrentPosition.Header.AudioStatus == AUDIO_STATUS_IN_PROGRESS) ? 3 : 1;
939 MSCDEX_Dump("End", driver_request, dorealmode);
943 FIXME("Unimplemented MSCDEX function 0x%02X.\n", LOBYTE(context->Eax));