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
27 #include "wine/winbase16.h"
30 /* #define DEBUG_INT */
31 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(int);
39 /* base WPROCS.DLL ordinal number for VxDs */
42 static void do_int2f_16( CONTEXT86 *context );
43 static void MSCDEX_Handler( CONTEXT86 *context );
45 /**********************************************************************
46 * DOSVM_Int2fHandler (WINEDOS16.147)
48 * Handler for int 2fh (multiplex).
50 void WINAPI DOSVM_Int2fHandler( CONTEXT86 *context )
52 TRACE("Subfunction 0x%X\n", AX_reg(context));
54 switch(AH_reg(context))
57 SET_AL( context, 0xff ); /* share is installed */
60 case 0x11: /* Network Redirector / IFSFUNC */
61 switch (LOBYTE(context->Eax))
63 case 0x00: /* Install check */
66 case 0x80: /* Enhanced services - Install check */
70 INT_BARF( context, 0x2f );
76 switch (LOBYTE(context->Eax))
78 case 0x2e: /* get or set DOS error table address */
79 switch (DL_reg(context))
81 /* Four tables: even commands are 'get', odd are 'set' */
82 /* DOS 5.0+ ignores "set" commands */
89 /* Instead of having a message table in DOS-space, */
90 /* we can use a special case for MS-DOS to force */
91 /* the secondary interface. */
96 context->SegEs = 0x0001;
97 SET_DI( context, 0x0000 );
100 FIXME("No real-mode handler for errors yet! (bye!)\n");
103 INT_BARF(context, 0x2f);
107 INT_BARF(context, 0x2f);
111 case 0x15: /* mscdex */
112 MSCDEX_Handler(context);
116 do_int2f_16( context );
119 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
120 /* Not supported yet, do nothing */
125 switch (LOBYTE(context->Eax))
127 case 0x00: /* XMS v2+ installation check */
128 WARN("XMS is not fully implemented\n");
129 SET_AL( context, 0x80 );
131 case 0x10: /* XMS v2+ get driver address */
133 context->SegEs = DOSVM_dpmi_segments->xms_seg;
134 SET_BX( context, 0 );
138 INT_BARF( context, 0x2f );
141 FIXME("check for XMS (not supported)\n");
142 SET_AL( context, 0x42 ); /* != 0x80 */
147 switch (LOBYTE(context->Eax))
158 /* Microsoft Profiler - not installed */
161 INT_BARF( context, 0x2f );
166 switch(LOBYTE(context->Eax))
168 case 0x10: /* smartdrv */
169 break; /* not installed */
170 case 0x11: /* dblspace */
171 break; /* not installed */
172 case 0x12: /* realtime compression interface */
173 break; /* not installed */
174 case 0x32: /* patch IO.SYS (???) */
175 break; /* we have no IO.SYS, so we can't patch it :-/ */
177 INT_BARF( context, 0x2f );
181 switch(LOBYTE(context->Eax))
188 FIXME("Task Switcher - not implemented\n");
191 INT_BARF( context, 0x2f );
194 case 0x56: /* INTERLNK */
195 switch(LOBYTE(context->Eax))
197 case 0x01: /* check if redirected drive */
198 SET_AL( context, 0 ); /* not redirected */
201 INT_BARF( context, 0x2f );
204 case 0x7a: /* NOVELL NetWare */
205 switch (LOBYTE(context->Eax))
207 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
208 SET_AL( context, 0 );
210 case 0x20: /* Get VLM Call Address */
211 /* return nothing -> NetWare not installed */
214 INT_BARF( context, 0x2f );
218 case 0xb7: /* append */
219 SET_AL( context, 0 ); /* not installed */
221 case 0xb8: /* network */
222 switch (LOBYTE(context->Eax))
224 case 0x00: /* Install check */
228 INT_BARF( context, 0x2f );
232 case 0xbd: /* some Novell network install check ??? */
233 SET_AX( context, 0xa5a5 ); /* pretend to have Novell IPX installed */
235 case 0xbf: /* REDIRIFS.EXE */
236 switch (LOBYTE(context->Eax))
238 case 0x00: /* Install check */
242 INT_BARF( context, 0x2f );
247 switch(LOBYTE(context->Eax))
249 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
250 if(BX_reg(context) == 0x5145 && CX_reg(context) == 0x4D4D
251 && DX_reg(context) == 0x3432)
252 TRACE("Check for QEMM v5.0+ (not installed)\n");
255 INT_BARF( context, 0x2f );
259 case 0xd7: /* Banyan Vines */
260 switch (LOBYTE(context->Eax))
262 case 0x01: /* Install check - Get Int Number */
266 INT_BARF( context, 0x2f );
271 switch(LOBYTE(context->Eax))
273 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
274 if(BX_reg(context) == 0x4450 && CX_reg(context) == 0x4d49
275 && DX_reg(context) == 0x8f4f)
276 TRACE("Check for QDPMI.SYS (not installed)\n");
279 INT_BARF( context, 0x2f );
283 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
286 INT_BARF( context, 0x2f );
292 /**********************************************************************
295 static void do_int2f_16( CONTEXT86 *context )
299 switch(LOBYTE(context->Eax))
301 case 0x00: /* Windows enhanced mode installation check */
302 SET_AX( context, (GetWinFlags16() & WF_ENHANCED) ? LOWORD(GetVersion16()) : 0 );
305 case 0x0a: /* Get Windows version and type */
306 SET_AX( context, 0 );
307 SET_BX( context, (LOWORD(GetVersion16()) << 8) | (LOWORD(GetVersion16()) >> 8) );
308 SET_CX( context, (GetWinFlags16() & WF_ENHANCED) ? 3 : 2 );
311 case 0x0b: /* Identify Windows-aware TSRs */
312 /* we don't have any pre-Windows TSRs */
315 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
316 /* We can mock this up. But not today... */
317 FIXME("Get Shell Parameters\n");
320 case 0x80: /* Release time-slice */
321 /* Linux sched_yield() still keeps burning CPU cycles
322 * if the current process is the only one in highest priority list
323 * (as Linux will immediately return to this process to waste
324 * more CPU cycles), so sched_yield() is essentially useless for us
325 * (poor API, if you ask me: its return code should indicate
326 * whether other processes did run in between, in order for us
327 * to be able to decide whether to do an additional Sleep() or not...)
328 * Thus we better unconditionally use a well-balanced Sleep()
329 * instead to really make sure the process calling int 0x2f/0x1680
330 * *doesn't* use 100% CPU...
332 Sleep(55); /* just wait 55ms (one "timer tick") for now. */
333 SET_AL( context, 0 );
336 case 0x81: /* Begin critical section. */
340 case 0x82: /* End critical section. */
344 case 0x83: /* Return Current Virtual Machine ID */
345 /* Virtual Machines are usually created/destroyed when Windows runs
346 * DOS programs. Since we never do, we are always in the System VM.
347 * According to Ralf Brown's Interrupt List, never return 0. But it
348 * seems to work okay (returning 0), just to be sure we return 1.
350 SET_BX( context, 1 ); /* VM 1 is probably the System VM */
353 case 0x84: /* Get device API entry point */
355 HMODULE16 mod = GetModuleHandle16("wprocs");
356 if (mod < 32) mod = LoadLibrary16( "wprocs" );
357 addr = (DWORD)GetProcAddress16( mod, (LPCSTR)(VXD_BASE + BX_reg(context)) );
358 if (!addr) /* not supported */
359 ERR("Accessing unknown VxD %04x - Expect a failure now.\n", BX_reg(context) );
360 context->SegEs = SELECTOROF(addr);
361 SET_DI( context, OFFSETOF(addr) );
365 case 0x86: /* DPMI detect mode */
366 SET_AX( context, 0 ); /* Running under DPMI */
369 case 0x87: /* DPMI installation check */
373 SET_AX( context, 0x0000 ); /* DPMI Installed */
374 SET_BX( context, 0x0001 ); /* 32bits available */
375 SET_CL( context, si.wProcessorLevel );
376 SET_DX( context, 0x005a ); /* DPMI major/minor 0.90 */
377 SET_SI( context, 0 ); /* # of para. of DOS extended private data */
378 context->SegEs = DOSVM_dpmi_segments->dpmi_seg;
379 SET_DI( context, 0 ); /* ES:DI is DPMI switch entry point */
382 case 0x8a: /* DPMI get vendor-specific API entry point. */
383 /* The 1.0 specs say this should work with all 0.9 hosts. */
387 INT_BARF( context, 0x2f );
391 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
392 * must be <size> aligned
393 * <size> could be WORD, DWORD...
394 * in this case, we would need two macros, one for read, the other one for write
395 * Note: PTR_AT can be used as an l-value
397 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
399 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
401 /**********************************************************************
402 * MSCDEX_Dump [internal]
404 * Dumps mscdex requests to int debug channel.
406 static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode)
414 ptr += sprintf(ptr, "%s\tCommand => ", pfx);
415 for (i = 0; i < req[0]; i++) {
416 ptr += sprintf(ptr, "%02x ", req[i]);
422 ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => ");
423 ios = (dorealmode) ? PTR_REAL_TO_LIN( PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD)) :
424 MapSL(MAKESEGPTR(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD)));
426 for (i = 0; i < PTR_AT(req, 18, WORD); i++) {
427 ptr += sprintf(ptr, "%02x ", ios[i]);
428 if ((i & 0x1F) == 0x1F) {
438 #define MSCDEX_Dump(pfx, req, drm)
441 #define CDFRAMES_PERSEC 75
442 #define CDFRAMES_PERMIN (CDFRAMES_PERSEC * 60)
443 #define FRAME_OF_ADDR(a) ((a)[1] * CDFRAMES_PERMIN + (a)[2] * CDFRAMES_PERSEC + (a)[3])
444 #define FRAME_OF_TOC(toc, idx) FRAME_OF_ADDR((toc).TrackData[idx - (toc).FirstTrack].Address)
445 #define CTRL_OF_TOC(toc, idx) (((toc).TrackData[idx - (toc).FirstTrack].Control << 4) | \
446 (toc).TrackData[idx - (toc).FirstTrack].Adr)
448 static void MSCDEX_StoreMSF(DWORD frame, BYTE* val)
450 val[3] = 0; /* zero */
451 val[2] = frame / CDFRAMES_PERMIN; /* minutes */
452 val[1] = (frame / CDFRAMES_PERSEC) % 60; /* seconds */
453 val[0] = frame % CDFRAMES_PERSEC; /* frames */
456 static int is_cdrom( int drive)
458 char root[] = "A:\\";
460 return (GetDriveTypeA(root) == DRIVE_CDROM);
463 static void MSCDEX_Handler(CONTEXT86* context)
468 switch (LOBYTE(context->Eax)) {
469 case 0x00: /* Installation check */
470 /* Count the number of contiguous CDROM drives
472 for (drive = count = 0; drive < 26; drive++) {
473 if (is_cdrom(drive)) {
474 while (is_cdrom(drive + count)) count++;
478 TRACE("Installation check: %d cdroms, starting at %d\n", count, drive);
479 SET_BX( context, count );
480 SET_CX( context, (drive < 26) ? drive : 0 );
483 case 0x0B: /* drive check */
484 SET_AX( context, is_cdrom(CX_reg(context)) );
485 SET_BX( context, 0xADAD );
488 case 0x0C: /* get version */
489 SET_BX( context, 0x020a );
490 TRACE("Version number => %04x\n", BX_reg(context));
493 case 0x0D: /* get drive letters */
494 p = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
496 for (drive = 0; drive < 26; drive++) {
497 if (is_cdrom(drive)) *p++ = drive;
499 TRACE("Get drive letters\n");
502 case 0x10: /* direct driver access */
504 BYTE* driver_request;
506 BYTE Error = 255; /* No Error */
507 int dorealmode = ISV86(context);
508 char devName[] = "\\\\.\\@:";
511 CDROM_SUB_Q_DATA_FORMAT fmt;
512 SUB_Q_CHANNEL_DATA data;
514 DWORD present = TRUE;
516 driver_request = CTX_SEG_OFF_TO_LIN(context, context->SegEs, context->Ebx);
518 if (!driver_request) {
519 /* FIXME - to be deleted ?? */
520 ERR("ES:BX==0 ! SEGFAULT ?\n");
521 ERR("-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
522 BX_reg(context), context->SegEs, context->SegDs, CX_reg(context));
523 driver_request[4] |= 0x80;
524 driver_request[3] = 5; /* bad request length */
528 * the following tests are wrong because lots of functions don't require the
529 * tray to be closed with a CD inside
531 TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]);
533 if (!is_cdrom(CX_reg(context))) {
534 WARN("Request made doesn't match a CD ROM drive (%d)\n", CX_reg(context));
535 driver_request[4] |= 0x80;
536 driver_request[3] = 1; /* unknown unit */
540 MSCDEX_Dump("Beg", driver_request, dorealmode);
542 /* set status to 0 */
543 PTR_AT(driver_request, 3, WORD) = 0;
544 devName[4] = 'A' + CX_reg(context);
545 h = CreateFileA(devName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
547 WARN("Couldn't open cdrom handle\n");
548 driver_request[4] |= 0x80;
549 driver_request[3] = 1; /* unknown unit */
553 fmt.Format = IOCTL_CDROM_CURRENT_POSITION;
554 if (!DeviceIoControl(h, IOCTL_CDROM_READ_TOC, NULL, 0, &toc, sizeof(toc), &br, NULL) ||
555 !DeviceIoControl(h, IOCTL_CDROM_READ_Q_CHANNEL, &fmt, sizeof(fmt),
556 &data, sizeof(data), &br, NULL)) {
557 if (GetLastError() == STATUS_NO_MEDIA_IN_DEVICE)
559 if (driver_request[2] != 6 && driver_request[2] != 15)
561 driver_request[4] |= 0x80;
562 driver_request[3] = 2; /* drive not ready */
570 driver_request[4] |= 0x80;
571 driver_request[3] = 1; /* unknown unit */
577 switch (driver_request[2]) {
579 io_stru = (dorealmode) ?
580 PTR_REAL_TO_LIN( PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD) ) :
581 MapSL( MAKESEGPTR(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)));
583 TRACE(" --> IOCTL INPUT <%d>\n", io_stru[0]);
584 switch (io_stru[0]) {
586 case 0: /* Get device Header */
588 static LPSTR ptr = 0;
590 ptr = SEGPTR_ALLOC(22);
591 PTR_AT(ptr, 0, DWORD) = ~1; /* Next Device Driver */
592 PTR_AT(ptr, 4, WORD) = 0xC800; /* Device attributes */
593 PTR_AT(ptr, 6, WORD) = 0x1234; /* Pointer to device strategy routine: FIXME */
594 PTR_AT(ptr, 8, WORD) = 0x3142; /* Pointer to device interrupt routine: FIXME */
595 PTR_AT(ptr, 10, char) = 'W'; /* 8-byte character device name field */
596 PTR_AT(ptr, 11, char) = 'I';
597 PTR_AT(ptr, 12, char) = 'N';
598 PTR_AT(ptr, 13, char) = 'E';
599 PTR_AT(ptr, 14, char) = '_';
600 PTR_AT(ptr, 15, char) = 'C';
601 PTR_AT(ptr, 16, char) = 'D';
602 PTR_AT(ptr, 17, char) = '_';
603 PTR_AT(ptr, 18, WORD) = 0; /* Reserved (must be zero) */
604 PTR_AT(ptr, 20, BYTE) = 0; /* Drive letter (must be zero) */
605 PTR_AT(ptr, 21, BYTE) = 1; /* Number of units supported (one or more) FIXME*/
607 PTR_AT(io_stru, DWORD, 0) = SEGPTR_GET(ptr);
612 case 1: /* location of head */
613 switch (io_stru[1]) {
615 PTR_AT(io_stru, 2, DWORD) =
616 FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress);
619 MSCDEX_StoreMSF(FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress),
623 ERR("CD-ROM driver: unsupported addressing mode !!\n");
626 TRACE(" ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru, 2, DWORD));
629 case 4: /* Audio channel info */
638 TRACE(" ----> AUDIO CHANNEL INFO\n");
641 case 6: /* device status */
642 PTR_AT(io_stru, 1, DWORD) = 0x00000290;
644 * 1 Supports HSG and Red Book addressing modes
645 * 0 Supports audio channel manipulation
647 * 1 Supports prefetching requests
650 * 1 Data read and plays audio/video tracks
653 * 0 Supports only cooked reading
655 * 0 see below (Door closed/opened)
657 if (!present) PTR_AT(io_stru, 1, DWORD) |= 1;
658 TRACE(" ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru, 1, DWORD));
661 case 8: /* Volume size */
662 PTR_AT(io_stru, 1, DWORD) = FRAME_OF_TOC(toc, toc.LastTrack + 1) -
663 FRAME_OF_TOC(toc, toc.FirstTrack) - 1;
664 TRACE(" ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru, 1, DWORD));
667 case 9: /* media changed ? */
668 /* answers don't know... -1/1 for yes/no would be better */
669 io_stru[1] = 0; /* FIXME? 1? */
670 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru[1]);
673 case 10: /* audio disk info */
674 io_stru[1] = toc.FirstTrack; /* starting track of the disc */
675 io_stru[2] = toc.LastTrack; /* ending track */
676 MSCDEX_StoreMSF(FRAME_OF_TOC(toc, toc.LastTrack + 1) -
677 FRAME_OF_TOC(toc, toc.FirstTrack) - 1, io_stru + 3);
679 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
680 io_stru[1], io_stru[2], PTR_AT(io_stru, 3, DWORD));
683 case 11: /* audio track info */
684 if (io_stru[1] >= toc.FirstTrack && io_stru[1] <= toc.LastTrack) {
685 MSCDEX_StoreMSF(FRAME_OF_TOC(toc, io_stru[1]), io_stru + 2);
686 /* starting point if the track */
687 io_stru[6] = CTRL_OF_TOC(toc, io_stru[1]);
689 PTR_AT(io_stru, 2, DWORD) = 0;
692 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
693 io_stru[1], PTR_AT(io_stru, 2, DWORD), io_stru[6]);
696 case 12: /* get Q-Channel info */
697 io_stru[1] = CTRL_OF_TOC(toc, data.CurrentPosition.TrackNumber);
698 io_stru[2] = data.CurrentPosition.TrackNumber;
699 io_stru[3] = 0; /* FIXME ?? */
701 /* why the heck did MS use another format for 0MSF information... sigh */
705 MSCDEX_StoreMSF(FRAME_OF_ADDR(data.CurrentPosition.TrackRelativeAddress), bTmp);
706 io_stru[ 4] = bTmp[2];
707 io_stru[ 5] = bTmp[1];
708 io_stru[ 6] = bTmp[0];
711 MSCDEX_StoreMSF(FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress), bTmp);
712 io_stru[ 8] = bTmp[2];
713 io_stru[ 9] = bTmp[1];
714 io_stru[10] = bTmp[0];
717 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08x, tp=%08x)\n",
718 io_stru[ 1], io_stru[ 2], io_stru[ 3],
719 io_stru[ 4], io_stru[ 5], io_stru[ 6],
720 io_stru[ 8], io_stru[ 9], io_stru[10],
721 FRAME_OF_ADDR(data.CurrentPosition.AbsoluteAddress),
722 FRAME_OF_TOC(toc, data.CurrentPosition.TrackNumber));
725 case 15: /* Audio status info */
726 /* !!!! FIXME FIXME FIXME !! */
727 PTR_AT(io_stru, 1, WORD) = 2 | ((data.CurrentPosition.Header.AudioStatus == AUDIO_STATUS_PAUSED) ? 1 : 0);
729 PTR_AT(io_stru, 3, DWORD) = 0;
730 PTR_AT(io_stru, 7, DWORD) = 0;
732 PTR_AT(io_stru, 3, DWORD) = FRAME_OF_TOC(toc, toc.FirstTrack);
733 PTR_AT(io_stru, 7, DWORD) = FRAME_OF_TOC(toc, toc.LastTrack + 1);
735 TRACE("Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
736 PTR_AT(io_stru, 1, WORD), PTR_AT(io_stru, 3, DWORD), PTR_AT(io_stru, 7, DWORD));
740 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru[0]);
747 io_stru = (dorealmode) ?
748 PTR_REAL_TO_LIN( PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)) :
749 MapSL( MAKESEGPTR(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD)));
751 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru[0]);
752 switch (io_stru[0]) {
754 DeviceIoControl(h, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &br, NULL);
755 TRACE(" ----> EJECT\n");
757 case 2: /* reset drive */
758 DeviceIoControl(h, IOCTL_STORAGE_RESET_DEVICE, NULL, 0, NULL, 0, &br, NULL);
759 TRACE(" ----> RESET\n");
761 case 3: /* Audio Channel Control */
762 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
764 case 5: /* close tray */
765 DeviceIoControl(h, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0, &br, NULL);
766 TRACE(" ----> CLOSE TRAY\n");
769 FIXME(" IOCTL OUTPUT: Unimplemented <%d>!!\n", io_stru[0]);
775 case 128: /* read long */
777 LPVOID dst = MapSL(MAKESEGPTR(PTR_AT(driver_request, 16, WORD),
778 PTR_AT(driver_request, 14, WORD)));
779 DWORD at = PTR_AT(driver_request, 20, DWORD);
780 WORD num = PTR_AT(driver_request, 18, WORD);
783 switch (driver_request[13]) {
784 case 1: /* Red book addressing mode = 0:m:s:f */
785 /* FIXME : frame <=> msf conversion routines could be shared
786 * between mscdex and mcicda
788 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
789 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
792 case 0: /* HSG addressing mode */
793 switch (PTR_AT(driver_request, 24, BYTE))
796 ReadFile(h, dst, num * 2048, &br, NULL);
799 /* FIXME: computation is wrong */
800 rri.DiskOffset.s.HighPart = 0;
801 rri.DiskOffset.s.LowPart = at << 11;
802 rri.TrackMode = YellowMode2;
803 rri.SectorCount = num;
804 DeviceIoControl(h, IOCTL_CDROM_RAW_READ, &rri, sizeof(rri),
805 dst, num * 2352, &br, NULL);
808 ERR("Unsupported read mode !!\n");
814 ERR("Unsupported address mode !!\n");
824 CDROM_SEEK_AUDIO_MSF seek;
826 at = PTR_AT(driver_request, 20, DWORD);
828 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
829 (BYTE)driver_request[13], at);
831 switch (driver_request[13]) {
832 case 1: /* Red book addressing mode = 0:m:s:f */
833 /* FIXME : frame <=> msf conversion routines could be shared
834 * between mscdex and mcicda
836 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
837 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
840 case 0: /* HSG addressing mode */
841 seek.M = at / CDFRAMES_PERMIN;
842 seek.S = (at / CDFRAMES_PERSEC) % 60;
843 seek.F = at % CDFRAMES_PERSEC;
844 DeviceIoControl(h, IOCTL_CDROM_SEEK_AUDIO_MSF, &seek, sizeof(seek),
848 ERR("Unsupported address mode !!\n");
858 CDROM_PLAY_AUDIO_MSF play;
860 beg = end = PTR_AT(driver_request, 14, DWORD);
861 end += PTR_AT(driver_request, 18, DWORD);
863 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
864 (BYTE)driver_request[13], beg, end);
866 switch (driver_request[13]) {
868 /* Red book addressing mode = 0:m:s:f */
869 /* FIXME : frame <=> msf conversion routines could be shared
870 * between mscdex and mcicda
872 beg = LOBYTE(LOWORD(beg)) * CDFRAMES_PERMIN +
873 HIBYTE(LOWORD(beg)) * CDFRAMES_PERSEC +
875 end = LOBYTE(LOWORD(end)) * CDFRAMES_PERMIN +
876 HIBYTE(LOWORD(end)) * CDFRAMES_PERSEC +
879 case 0: /* HSG addressing mode */
880 play.StartingM = beg / CDFRAMES_PERMIN;
881 play.StartingS = (beg / CDFRAMES_PERSEC) % 60;
882 play.StartingF = beg % CDFRAMES_PERSEC;
883 play.EndingM = end / CDFRAMES_PERMIN;
884 play.EndingS = (end / CDFRAMES_PERSEC) % 60;
885 play.EndingF = end % CDFRAMES_PERSEC;
886 DeviceIoControl(h, IOCTL_CDROM_PLAY_AUDIO_MSF, &play, sizeof(play),
890 ERR("Unsupported address mode !!\n");
898 if (data.CurrentPosition.Header.AudioStatus == AUDIO_STATUS_IN_PROGRESS) {
899 DeviceIoControl(h, IOCTL_CDROM_PAUSE_AUDIO, NULL, 0, NULL, 0, &br, NULL);
900 TRACE(" --> STOP AUDIO (Paused)\n");
902 DeviceIoControl(h, IOCTL_CDROM_STOP_AUDIO, NULL, 0, NULL, 0, &br, NULL);
903 TRACE(" --> STOP AUDIO (Stopped)\n");
908 TRACE(" --> RESUME AUDIO\n");
909 DeviceIoControl(h, IOCTL_CDROM_PAUSE_AUDIO, NULL, 0, NULL, 0, &br, NULL);
913 FIXME(" ioctl unimplemented <%d>\n", driver_request[2]);
917 /* setting error codes if any */
919 driver_request[4] |= 0x80;
920 driver_request[3] = Error;
924 /* setting status bits
925 * 3 == playing && done
929 (data.CurrentPosition.Header.AudioStatus == AUDIO_STATUS_IN_PROGRESS) ? 3 : 1;
931 MSCDEX_Dump("End", driver_request, dorealmode);
935 FIXME("Unimplemented MSCDEX function 0x%02X.\n", LOBYTE(context->Eax));