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"
32 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(int);
41 /* base WPROCS.DLL ordinal number for VxDs */
44 static void do_int2f_16( CONTEXT86 *context );
45 static void MSCDEX_Handler( CONTEXT86 *context );
47 /**********************************************************************
48 * DOSVM_Int2fHandler (WINEDOS16.147)
50 * Handler for int 2fh (multiplex).
52 void WINAPI DOSVM_Int2fHandler( CONTEXT86 *context )
54 TRACE("Subfunction 0x%X\n", AX_reg(context));
56 switch(AH_reg(context))
59 SET_AL( context, 0xff ); /* share is installed */
62 case 0x11: /* Network Redirector / IFSFUNC */
63 switch (LOBYTE(context->Eax))
65 case 0x00: /* Install check */
68 case 0x80: /* Enhanced services - Install check */
72 INT_BARF( context, 0x2f );
78 switch (LOBYTE(context->Eax))
80 case 0x2e: /* get or set DOS error table address */
81 switch (DL_reg(context))
83 /* Four tables: even commands are 'get', odd are 'set' */
84 /* DOS 5.0+ ignores "set" commands */
91 /* Instead of having a message table in DOS-space, */
92 /* we can use a special case for MS-DOS to force */
93 /* the secondary interface. */
98 context->SegEs = 0x0001;
99 SET_DI( context, 0x0000 );
102 FIXME("No real-mode handler for errors yet! (bye!)\n");
105 INT_BARF(context, 0x2f);
109 INT_BARF(context, 0x2f);
113 case 0x15: /* mscdex */
114 MSCDEX_Handler(context);
118 do_int2f_16( context );
121 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
122 /* Not supported yet, do nothing */
127 switch (LOBYTE(context->Eax))
129 case 0x00: /* XMS v2+ installation check */
130 WARN("XMS is not fully implemented\n");
131 SET_AL( context, 0x80 );
133 case 0x10: /* XMS v2+ get driver address */
135 context->SegEs = DOSVM_dpmi_segments->xms_seg;
136 SET_BX( context, 0 );
140 INT_BARF( context, 0x2f );
143 FIXME("check for XMS (not supported)\n");
144 SET_AL( context, 0x42 ); /* != 0x80 */
149 switch (LOBYTE(context->Eax))
160 /* Microsoft Profiler - not installed */
163 INT_BARF( context, 0x2f );
168 switch(LOBYTE(context->Eax))
170 case 0x10: /* smartdrv */
171 break; /* not installed */
172 case 0x11: /* dblspace */
173 break; /* not installed */
174 case 0x12: /* realtime compression interface */
175 break; /* not installed */
176 case 0x32: /* patch IO.SYS (???) */
177 break; /* we have no IO.SYS, so we can't patch it :-/ */
179 INT_BARF( context, 0x2f );
183 switch(LOBYTE(context->Eax))
190 FIXME("Task Switcher - not implemented\n");
193 INT_BARF( context, 0x2f );
196 case 0x56: /* INTERLNK */
197 switch(LOBYTE(context->Eax))
199 case 0x01: /* check if redirected drive */
200 SET_AL( context, 0 ); /* not redirected */
203 INT_BARF( context, 0x2f );
206 case 0x7a: /* NOVELL NetWare */
207 switch (LOBYTE(context->Eax))
209 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
210 SET_AL( context, 0 );
212 case 0x20: /* Get VLM Call Address */
213 /* return nothing -> NetWare not installed */
216 INT_BARF( context, 0x2f );
220 case 0xb7: /* append */
221 SET_AL( context, 0 ); /* not installed */
223 case 0xb8: /* network */
224 switch (LOBYTE(context->Eax))
226 case 0x00: /* Install check */
230 INT_BARF( context, 0x2f );
234 case 0xbd: /* some Novell network install check ??? */
235 SET_AX( context, 0xa5a5 ); /* pretend to have Novell IPX installed */
237 case 0xbf: /* REDIRIFS.EXE */
238 switch (LOBYTE(context->Eax))
240 case 0x00: /* Install check */
244 INT_BARF( context, 0x2f );
249 switch(LOBYTE(context->Eax))
251 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
252 if(BX_reg(context) == 0x5145 && CX_reg(context) == 0x4D4D
253 && DX_reg(context) == 0x3432)
254 TRACE("Check for QEMM v5.0+ (not installed)\n");
257 INT_BARF( context, 0x2f );
261 case 0xd7: /* Banyan Vines */
262 switch (LOBYTE(context->Eax))
264 case 0x01: /* Install check - Get Int Number */
268 INT_BARF( context, 0x2f );
273 switch(LOBYTE(context->Eax))
275 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
276 if(BX_reg(context) == 0x4450 && CX_reg(context) == 0x4d49
277 && DX_reg(context) == 0x8f4f)
278 TRACE("Check for QDPMI.SYS (not installed)\n");
281 INT_BARF( context, 0x2f );
285 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
288 INT_BARF( context, 0x2f );
294 /**********************************************************************
297 static void do_int2f_16( CONTEXT86 *context )
301 switch(LOBYTE(context->Eax))
303 case 0x00: /* Windows enhanced mode installation check */
304 SET_AX( context, (GetWinFlags16() & WF_ENHANCED) ? LOWORD(GetVersion16()) : 0 );
307 case 0x0a: /* Get Windows version and type */
308 SET_AX( context, 0 );
309 SET_BX( context, (LOWORD(GetVersion16()) << 8) | (LOWORD(GetVersion16()) >> 8) );
310 SET_CX( context, (GetWinFlags16() & WF_ENHANCED) ? 3 : 2 );
313 case 0x0b: /* Identify Windows-aware TSRs */
314 /* we don't have any pre-Windows TSRs */
317 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
318 /* We can mock this up. But not today... */
319 FIXME("Get Shell Parameters\n");
322 case 0x80: /* Release time-slice */
323 /* Linux sched_yield() still keeps burning CPU cycles
324 * if the current process is the only one in highest priority list
325 * (as Linux will immediately return to this process to waste
326 * more CPU cycles), so sched_yield() is essentially useless for us
327 * (poor API, if you ask me: its return code should indicate
328 * whether other processes did run in between, in order for us
329 * to be able to decide whether to do an additional Sleep() or not...)
330 * Thus we better unconditionally use a well-balanced Sleep()
331 * instead to really make sure the process calling int 0x2f/0x1680
332 * *doesn't* use 100% CPU...
334 Sleep(55); /* just wait 55ms (one "timer tick") for now. */
335 SET_AL( context, 0 );
338 case 0x81: /* Begin critical section. */
342 case 0x82: /* End critical section. */
346 case 0x83: /* Return Current Virtual Machine ID */
347 /* Virtual Machines are usually created/destroyed when Windows runs
348 * DOS programs. Since we never do, we are always in the System VM.
349 * According to Ralf Brown's Interrupt List, never return 0. But it
350 * seems to work okay (returning 0), just to be sure we return 1.
352 SET_BX( context, 1 ); /* VM 1 is probably the System VM */
355 case 0x84: /* Get device API entry point */
357 HMODULE16 mod = GetModuleHandle16("wprocs");
358 if (mod < 32) mod = LoadLibrary16( "wprocs" );
359 addr = (DWORD)GetProcAddress16( mod, (LPCSTR)(VXD_BASE + BX_reg(context)) );
360 if (!addr) /* not supported */
361 ERR("Accessing unknown VxD %04x - Expect a failure now.\n", BX_reg(context) );
362 context->SegEs = SELECTOROF(addr);
363 SET_DI( context, OFFSETOF(addr) );
367 case 0x86: /* DPMI detect mode */
368 SET_AX( context, 0 ); /* Running under DPMI */
371 case 0x87: /* DPMI installation check */
375 SET_AX( context, 0x0000 ); /* DPMI Installed */
376 SET_BX( context, 0x0001 ); /* 32bits available */
377 SET_CL( context, si.wProcessorLevel );
378 SET_DX( context, 0x005a ); /* DPMI major/minor 0.90 */
379 SET_SI( context, 0 ); /* # of para. of DOS extended private data */
380 context->SegEs = DOSVM_dpmi_segments->dpmi_seg;
381 SET_DI( context, 0 ); /* ES:DI is DPMI switch entry point */
384 case 0x8a: /* DPMI get vendor-specific API entry point. */
385 /* The 1.0 specs say this should work with all 0.9 hosts. */
389 INT_BARF( context, 0x2f );
393 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
394 * must be <size> aligned
395 * <size> could be WORD, DWORD...
396 * in this case, we would need two macros, one for read, the other one for write
397 * Note: PTR_AT can be used as an l-value
399 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
401 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
403 /**********************************************************************
404 * MSCDEX_Dump [internal]
406 * Dumps mscdex requests to int debug channel.
408 static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode)
416 ptr += sprintf(ptr, "%s\tCommand => ", pfx);
417 for (i = 0; i < req[0]; i++) {
418 ptr += sprintf(ptr, "%02x ", req[i]);
424 ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => ");
425 ios = (dorealmode) ? PTR_REAL_TO_LIN( PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD)) :
426 MapSL(MAKESEGPTR(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD)));
428 for (i = 0; i < PTR_AT(req, 18, WORD); i++) {
429 ptr += sprintf(ptr, "%02x ", ios[i]);
430 if ((i & 0x1F) == 0x1F) {
440 #define MSCDEX_Dump(pfx, req, drm)
443 #define CDFRAMES_PERSEC 75
444 #define CDFRAMES_PERMIN (CDFRAMES_PERSEC * 60)
445 #define FRAME_OF_ADDR(a) ((a)[1] * CDFRAMES_PERMIN + (a)[2] * CDFRAMES_PERSEC + (a)[3])
446 #define FRAME_OF_TOC(toc, idx) FRAME_OF_ADDR((toc).TrackData[idx - (toc).FirstTrack].Address)
447 #define CTRL_OF_TOC(toc, idx) (((toc).TrackData[idx - (toc).FirstTrack].Control << 4) | \
448 (toc).TrackData[idx - (toc).FirstTrack].Adr)
450 static void MSCDEX_StoreMSF(DWORD frame, BYTE* val)
452 val[3] = 0; /* zero */
453 val[2] = frame / CDFRAMES_PERMIN; /* minutes */
454 val[1] = (frame / CDFRAMES_PERSEC) % 60; /* seconds */
455 val[0] = frame % CDFRAMES_PERSEC; /* frames */
458 static int is_cdrom( int drive)
460 char root[] = "A:\\";
462 return (GetDriveTypeA(root) == DRIVE_CDROM);
465 static void MSCDEX_Handler(CONTEXT86* context)
470 switch (LOBYTE(context->Eax)) {
471 case 0x00: /* Installation check */
472 /* Count the number of contiguous CDROM drives
474 for (drive = count = 0; drive < 26; drive++) {
475 if (is_cdrom(drive)) {
476 while (is_cdrom(drive + count)) count++;
480 TRACE("Installation check: %d cdroms, starting at %d\n", count, drive);
481 SET_BX( context, count );
482 SET_CX( context, (drive < 26) ? drive : 0 );
485 case 0x0B: /* drive check */
486 SET_AX( context, is_cdrom(CX_reg(context)) );
487 SET_BX( context, 0xADAD );
490 case 0x0C: /* get version */
491 SET_BX( context, 0x020a );
492 TRACE("Version number => %04x\n", BX_reg(context));
495 case 0x0D: /* get drive letters */
496 p = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
498 for (drive = 0; drive < 26; drive++) {
499 if (is_cdrom(drive)) *p++ = drive;
501 TRACE("Get drive letters\n");
504 case 0x10: /* direct driver access */
506 BYTE* driver_request;
508 BYTE Error = 255; /* No Error */
509 int dorealmode = ISV86(context);
510 char devName[] = "\\\\.\\@:";
513 CDROM_SUB_Q_DATA_FORMAT fmt;
514 SUB_Q_CHANNEL_DATA data;
516 DWORD present = TRUE;
518 driver_request = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
520 if (!driver_request) {
521 /* FIXME - to be deleted ?? */
522 ERR("ES:BX==0 ! SEGFAULT ?\n");
523 ERR("-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
524 BX_reg(context), context->SegEs, context->SegDs, CX_reg(context));
525 driver_request[4] |= 0x80;
526 driver_request[3] = 5; /* bad request length */
530 * the following tests are wrong because lots of functions don't require the
531 * tray to be closed with a CD inside
533 TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]);
535 if (!is_cdrom(CX_reg(context))) {
536 WARN("Request made doesn't match a CD ROM drive (%d)\n", CX_reg(context));
537 driver_request[4] |= 0x80;
538 driver_request[3] = 1; /* unknown unit */
542 MSCDEX_Dump("Beg", driver_request, dorealmode);
544 /* set status to 0 */
545 PTR_AT(driver_request, 3, WORD) = 0;
546 devName[4] = 'A' + CX_reg(context);
547 h = CreateFileA(devName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
549 WARN("Couldn't open cdrom handle\n");
550 driver_request[4] |= 0x80;
551 driver_request[3] = 1; /* unknown unit */
555 fmt.Format = IOCTL_CDROM_CURRENT_POSITION;
556 if (!DeviceIoControl(h, IOCTL_CDROM_READ_TOC, NULL, 0, &toc, sizeof(toc), &br, NULL) ||
557 !DeviceIoControl(h, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
558 &data, sizeof(data), &br, NULL)) {
559 if (GetLastError() == STATUS_NO_MEDIA_IN_DEVICE)
561 if (driver_request[2] != 6 && driver_request[2] != 15)
563 driver_request[4] |= 0x80;
564 driver_request[3] = 2; /* drive not ready */
572 driver_request[4] |= 0x80;
573 driver_request[3] = 1; /* unknown unit */
579 switch (driver_request[2]) {
581 io_stru = (dorealmode) ?
582 PTR_REAL_TO_LIN( PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD) ) :
583 MapSL( MAKESEGPTR(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)));
585 TRACE(" --> IOCTL INPUT <%d>\n", io_stru[0]);
586 switch (io_stru[0]) {
588 case 0: /* Get device Header */
590 static LPSTR ptr = 0;
592 ptr = SEGPTR_ALLOC(22);
593 PTR_AT(ptr, 0, DWORD) = ~1; /* Next Device Driver */
594 PTR_AT(ptr, 4, WORD) = 0xC800; /* Device attributes */
595 PTR_AT(ptr, 6, WORD) = 0x1234; /* Pointer to device strategy routine: FIXME */
596 PTR_AT(ptr, 8, WORD) = 0x3142; /* Pointer to device interrupt routine: FIXME */
597 PTR_AT(ptr, 10, char) = 'W'; /* 8-byte character device name field */
598 PTR_AT(ptr, 11, char) = 'I';
599 PTR_AT(ptr, 12, char) = 'N';
600 PTR_AT(ptr, 13, char) = 'E';
601 PTR_AT(ptr, 14, char) = '_';
602 PTR_AT(ptr, 15, char) = 'C';
603 PTR_AT(ptr, 16, char) = 'D';
604 PTR_AT(ptr, 17, char) = '_';
605 PTR_AT(ptr, 18, WORD) = 0; /* Reserved (must be zero) */
606 PTR_AT(ptr, 20, BYTE) = 0; /* Drive letter (must be zero) */
607 PTR_AT(ptr, 21, BYTE) = 1; /* Number of units supported (one or more) FIXME*/
609 PTR_AT(io_stru, DWORD, 0) = SEGPTR_GET(ptr);
614 case 1: /* location of head */
615 switch (io_stru[1]) {
617 PTR_AT(io_stru, 2, DWORD) =
618 FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress);
621 MSCDEX_StoreMSF(FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress),
625 ERR("CD-ROM driver: unsupported addressing mode !!\n");
628 TRACE(" ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru, 2, DWORD));
631 case 4: /* Audio channel info */
640 TRACE(" ----> AUDIO CHANNEL INFO\n");
643 case 6: /* device status */
644 PTR_AT(io_stru, 1, DWORD) = 0x00000290;
646 * 1 Supports HSG and Red Book addressing modes
647 * 0 Supports audio channel manipulation
649 * 1 Supports prefetching requests
652 * 1 Data read and plays audio/video tracks
655 * 0 Supports only cooked reading
657 * 0 see below (Door closed/opened)
659 if (!present) PTR_AT(io_stru, 1, DWORD) |= 1;
660 TRACE(" ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru, 1, DWORD));
663 case 8: /* Volume size */
664 PTR_AT(io_stru, 1, DWORD) = FRAME_OF_TOC(toc, toc.LastTrack + 1) -
665 FRAME_OF_TOC(toc, toc.FirstTrack) - 1;
666 TRACE(" ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru, 1, DWORD));
669 case 9: /* media changed ? */
670 /* answers don't know... -1/1 for yes/no would be better */
671 io_stru[1] = 0; /* FIXME? 1? */
672 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru[1]);
675 case 10: /* audio disk info */
676 io_stru[1] = toc.FirstTrack; /* starting track of the disc */
677 io_stru[2] = toc.LastTrack; /* ending track */
678 MSCDEX_StoreMSF(FRAME_OF_TOC(toc, toc.LastTrack + 1) -
679 FRAME_OF_TOC(toc, toc.FirstTrack) - 1, io_stru + 3);
681 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
682 io_stru[1], io_stru[2], PTR_AT(io_stru, 3, DWORD));
685 case 11: /* audio track info */
686 if (io_stru[1] >= toc.FirstTrack && io_stru[1] <= toc.LastTrack) {
687 MSCDEX_StoreMSF(FRAME_OF_TOC(toc, io_stru[1]), io_stru + 2);
688 /* starting point if the track */
689 io_stru[6] = CTRL_OF_TOC(toc, io_stru[1]);
691 PTR_AT(io_stru, 2, DWORD) = 0;
694 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
695 io_stru[1], PTR_AT(io_stru, 2, DWORD), io_stru[6]);
698 case 12: /* get Q-Channel info */
699 io_stru[1] = CTRL_OF_TOC(toc, data.CurrentPosition.TrackNumber);
700 io_stru[2] = data.CurrentPosition.TrackNumber;
701 io_stru[3] = 0; /* FIXME ?? */
703 /* why the heck did MS use another format for 0MSF information... sigh */
707 MSCDEX_StoreMSF(FRAME_OF_ADDR(data.CurrentPosition.TrackRelativeAddress), bTmp);
708 io_stru[ 4] = bTmp[2];
709 io_stru[ 5] = bTmp[1];
710 io_stru[ 6] = bTmp[0];
713 MSCDEX_StoreMSF(FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress), bTmp);
714 io_stru[ 8] = bTmp[2];
715 io_stru[ 9] = bTmp[1];
716 io_stru[10] = bTmp[0];
719 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08x, tp=%08x)\n",
720 io_stru[ 1], io_stru[ 2], io_stru[ 3],
721 io_stru[ 4], io_stru[ 5], io_stru[ 6],
722 io_stru[ 8], io_stru[ 9], io_stru[10],
723 FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress),
724 FRAME_OF_TOC(toc, data.CurrentPosition.TrackNumber));
727 case 15: /* Audio status info */
728 /* !!!! FIXME FIXME FIXME !! */
729 PTR_AT(io_stru, 1, WORD) = 2 | ((data.CurrentPosition.Header.AudioStatus == AUDIO_STATUS_PAUSED) ? 1 : 0);
731 PTR_AT(io_stru, 3, DWORD) = 0;
732 PTR_AT(io_stru, 7, DWORD) = 0;
734 PTR_AT(io_stru, 3, DWORD) = FRAME_OF_TOC(toc, toc.FirstTrack);
735 PTR_AT(io_stru, 7, DWORD) = FRAME_OF_TOC(toc, toc.LastTrack + 1);
737 TRACE("Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
738 PTR_AT(io_stru, 1, WORD), PTR_AT(io_stru, 3, DWORD), PTR_AT(io_stru, 7, DWORD));
742 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru[0]);
749 io_stru = (dorealmode) ?
750 PTR_REAL_TO_LIN( PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)) :
751 MapSL( MAKESEGPTR(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)));
753 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru[0]);
754 switch (io_stru[0]) {
756 DeviceIoControl(h, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &br, NULL);
757 TRACE(" ----> EJECT\n");
759 case 2: /* reset drive */
760 DeviceIoControl(h, IOCTL_STORAGE_RESET_DEVICE, NULL, 0, NULL, 0, &br, NULL);
761 TRACE(" ----> RESET\n");
763 case 3: /* Audio Channel Control */
764 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
766 case 5: /* close tray */
767 DeviceIoControl(h, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0, &br, NULL);
768 TRACE(" ----> CLOSE TRAY\n");
771 FIXME(" IOCTL OUTPUT: Unimplemented <%d>!!\n", io_stru[0]);
777 case 128: /* read long */
779 LPVOID dst = MapSL(MAKESEGPTR(PTR_AT(driver_request, 16, WORD),
780 PTR_AT(driver_request, 14, WORD)));
781 DWORD at = PTR_AT(driver_request, 20, DWORD);
782 WORD num = PTR_AT(driver_request, 18, WORD);
785 switch (driver_request[13]) {
786 case 1: /* Red book addressing mode = 0:m:s:f */
787 /* FIXME : frame <=> msf conversion routines could be shared
788 * between mscdex and mcicda
790 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
791 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
794 case 0: /* HSG addressing mode */
795 switch (PTR_AT(driver_request, 24, BYTE))
798 ReadFile(h, dst, num * 2048, &br, NULL);
801 /* FIXME: computation is wrong */
802 rri.DiskOffset.s.HighPart = 0;
803 rri.DiskOffset.s.LowPart = at << 11;
804 rri.TrackMode = YellowMode2;
805 rri.SectorCount = num;
806 DeviceIoControl(h, IOCTL_CDROM_RAW_READ, &rri, sizeof(rri),
807 dst, num * 2352, &br, NULL);
810 ERR("Unsupported read mode !!\n");
816 ERR("Unsupported address mode !!\n");
826 CDROM_SEEK_AUDIO_MSF seek;
828 at = PTR_AT(driver_request, 20, DWORD);
830 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
831 (BYTE)driver_request[13], at);
833 switch (driver_request[13]) {
834 case 1: /* Red book addressing mode = 0:m:s:f */
835 /* FIXME : frame <=> msf conversion routines could be shared
836 * between mscdex and mcicda
838 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
839 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
842 case 0: /* HSG addressing mode */
843 seek.M = at / CDFRAMES_PERMIN;
844 seek.S = (at / CDFRAMES_PERSEC) % 60;
845 seek.F = at % CDFRAMES_PERSEC;
846 DeviceIoControl(h, IOCTL_CDROM_SEEK_AUDIO_MSF, &seek, sizeof(seek),
850 ERR("Unsupported address mode !!\n");
860 CDROM_PLAY_AUDIO_MSF play;
862 beg = end = PTR_AT(driver_request, 14, DWORD);
863 end += PTR_AT(driver_request, 18, DWORD);
865 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
866 (BYTE)driver_request[13], beg, end);
868 switch (driver_request[13]) {
870 /* Red book addressing mode = 0:m:s:f */
871 /* FIXME : frame <=> msf conversion routines could be shared
872 * between mscdex and mcicda
874 beg = LOBYTE(LOWORD(beg)) * CDFRAMES_PERMIN +
875 HIBYTE(LOWORD(beg)) * CDFRAMES_PERSEC +
877 end = LOBYTE(LOWORD(end)) * CDFRAMES_PERMIN +
878 HIBYTE(LOWORD(end)) * CDFRAMES_PERSEC +
881 case 0: /* HSG addressing mode */
882 play.StartingM = beg / CDFRAMES_PERMIN;
883 play.StartingS = (beg / CDFRAMES_PERSEC) % 60;
884 play.StartingF = beg % CDFRAMES_PERSEC;
885 play.EndingM = end / CDFRAMES_PERMIN;
886 play.EndingS = (end / CDFRAMES_PERSEC) % 60;
887 play.EndingF = end % CDFRAMES_PERSEC;
888 DeviceIoControl(h, IOCTL_CDROM_PLAY_AUDIO_MSF, &play, sizeof(play),
892 ERR("Unsupported address mode !!\n");
900 if (data.CurrentPosition.Header.AudioStatus == AUDIO_STATUS_IN_PROGRESS) {
901 DeviceIoControl(h, IOCTL_CDROM_PAUSE_AUDIO, NULL, 0, NULL, 0, &br, NULL);
902 TRACE(" --> STOP AUDIO (Paused)\n");
904 DeviceIoControl(h, IOCTL_CDROM_STOP_AUDIO, NULL, 0, NULL, 0, &br, NULL);
905 TRACE(" --> STOP AUDIO (Stopped)\n");
910 TRACE(" --> RESUME AUDIO\n");
911 DeviceIoControl(h, IOCTL_CDROM_PAUSE_AUDIO, NULL, 0, NULL, 0, &br, NULL);
915 FIXME(" ioctl unimplemented <%d>\n", driver_request[2]);
919 /* setting error codes if any */
921 driver_request[4] |= 0x80;
922 driver_request[3] = Error;
926 /* setting status bits
927 * 3 == playing && done
931 (data.CurrentPosition.Header.AudioStatus == AUDIO_STATUS_IN_PROGRESS) ? 3 : 1;
933 MSCDEX_Dump("End", driver_request, dorealmode);
937 FIXME("Unimplemented MSCDEX function 0x%02X.\n", LOBYTE(context->Eax));