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"
36 WINE_DEFAULT_DEBUG_CHANNEL(int);
38 /* base WPROCS.DLL ordinal number for VxDs */
41 static void do_int2f_16( CONTEXT86
*context
);
42 static void MSCDEX_Handler( CONTEXT86
*context
);
44 /**********************************************************************
45 * INT_Int2fHandler (WPROCS.147)
47 * Handler for int 2fh (multiplex).
49 void WINAPI
INT_Int2fHandler( CONTEXT86
*context
)
51 TRACE("Subfunction 0x%X\n", AX_reg(context
));
53 switch(AH_reg(context
))
56 AL_reg(context
) = 0xff; /* share is installed */
59 case 0x11: /* Network Redirector / IFSFUNC */
60 switch (LOBYTE(context
->Eax
))
62 case 0x00: /* Install check */
65 case 0x80: /* Enhanced services - Install check */
69 INT_BARF( context
, 0x2f );
75 switch (LOBYTE(context
->Eax
))
77 case 0x2e: /* get or set DOS error table address */
78 switch (DL_reg(context
))
80 /* Four tables: even commands are 'get', odd are 'set' */
81 /* DOS 5.0+ ignores "set" commands */
88 /* Instead of having a message table in DOS-space, */
89 /* we can use a special case for MS-DOS to force */
90 /* the secondary interface. */
95 context
->SegEs
= 0x0001;
96 DI_reg(context
) = 0x0000;
99 FIXME("No real-mode handler for errors yet! (bye!)\n");
102 INT_BARF(context
, 0x2f);
106 INT_BARF(context
, 0x2f);
110 case 0x15: /* mscdex */
111 MSCDEX_Handler(context
);
115 do_int2f_16( context
);
118 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
119 /* Not supported yet, do nothing */
124 switch (LOBYTE(context
->Eax
))
126 case 0x00: /* XMS v2+ installation check */
127 WARN("XMS is not fully implemented\n");
128 AL_reg(context
) = 0x80;
130 case 0x10: /* XMS v2+ get driver address */
132 context
->SegEs
= DOSMEM_xms_seg
;
137 INT_BARF( context
, 0x2f );
140 FIXME("check for XMS (not supported)\n");
141 AL_reg(context
) = 0x42; /* != 0x80 */
146 switch (LOBYTE(context
->Eax
))
157 /* Microsoft Profiler - not installed */
160 INT_BARF( context
, 0x2f );
165 switch(LOBYTE(context
->Eax
))
167 case 0x10: /* smartdrv */
168 break; /* not installed */
169 case 0x11: /* dblspace */
170 break; /* not installed */
171 case 0x12: /* realtime compression interface */
172 break; /* not installed */
173 case 0x32: /* patch IO.SYS (???) */
174 break; /* we have no IO.SYS, so we can't patch it :-/ */
176 INT_BARF( context
, 0x2f );
180 switch(LOBYTE(context
->Eax
))
187 FIXME("Task Switcher - not implemented\n");
190 INT_BARF( context
, 0x2f );
193 case 0x56: /* INTERLNK */
194 switch(LOBYTE(context
->Eax
))
196 case 0x01: /* check if redirected drive */
197 AL_reg(context
) = 0; /* not redirected */
200 INT_BARF( context
, 0x2f );
203 case 0x7a: /* NOVELL NetWare */
204 switch (LOBYTE(context
->Eax
))
206 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
209 case 0x20: /* Get VLM Call Address */
210 /* return nothing -> NetWare not installed */
213 INT_BARF( context
, 0x2f );
217 case 0xb7: /* append */
218 LOBYTE(context
->Eax
) = 0; /* not installed */
220 case 0xb8: /* network */
221 switch (LOBYTE(context
->Eax
))
223 case 0x00: /* Install check */
227 INT_BARF( context
, 0x2f );
231 case 0xbd: /* some Novell network install check ??? */
232 AX_reg(context
) = 0xa5a5; /* pretend to have Novell IPX installed */
234 case 0xbf: /* REDIRIFS.EXE */
235 switch (LOBYTE(context
->Eax
))
237 case 0x00: /* Install check */
241 INT_BARF( context
, 0x2f );
246 switch(LOBYTE(context
->Eax
))
248 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
249 if(BX_reg(context
) == 0x5145 && CX_reg(context
) == 0x4D4D
250 && DX_reg(context
) == 0x3432)
251 TRACE("Check for QEMM v5.0+ (not installed)\n");
254 INT_BARF( context
, 0x2f );
258 case 0xd7: /* Banyan Vines */
259 switch (LOBYTE(context
->Eax
))
261 case 0x01: /* Install check - Get Int Number */
265 INT_BARF( context
, 0x2f );
270 switch(LOBYTE(context
->Eax
))
272 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
273 if(BX_reg(context
) == 0x4450 && CX_reg(context
) == 0x4d49
274 && DX_reg(context
) == 0x8f4f)
275 TRACE("Check for QDPMI.SYS (not installed)\n");
278 INT_BARF( context
, 0x2f );
282 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
285 INT_BARF( context
, 0x2f );
291 /**********************************************************************
294 static void do_int2f_16( CONTEXT86
*context
)
298 switch(LOBYTE(context
->Eax
))
300 case 0x00: /* Windows enhanced mode installation check */
301 AX_reg(context
) = (GetWinFlags16() & WF_ENHANCED
) ?
302 LOWORD(GetVersion16()) : 0;
305 case 0x0a: /* Get Windows version and type */
307 BX_reg(context
) = (LOWORD(GetVersion16()) << 8) |
308 (LOWORD(GetVersion16()) >> 8);
309 CX_reg(context
) = (GetWinFlags16() & WF_ENHANCED
) ? 3 : 2;
312 case 0x0b: /* Identify Windows-aware TSRs */
313 /* we don't have any pre-Windows TSRs */
316 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
317 /* We can mock this up. But not today... */
318 FIXME("Get Shell Parameters\n");
321 case 0x80: /* Release time-slice */
325 case 0x81: /* Begin critical section. */
329 case 0x82: /* End critical section. */
333 case 0x83: /* Return Current Virtual Machine ID */
334 /* Virtual Machines are usually created/destroyed when Windows runs
335 * DOS programs. Since we never do, we are always in the System VM.
336 * According to Ralf Brown's Interrupt List, never return 0. But it
337 * seems to work okay (returning 0), just to be sure we return 1.
339 BX_reg(context
) = 1; /* VM 1 is probably the System VM */
342 case 0x84: /* Get device API entry point */
344 HMODULE16 mod
= GetModuleHandle16("wprocs");
345 if (mod
< 32) mod
= LoadLibrary16( "wprocs" );
346 addr
= (DWORD
)GetProcAddress16( mod
, (LPCSTR
)(VXD_BASE
+ BX_reg(context
)) );
347 if (!addr
) /* not supported */
348 ERR("Accessing unknown VxD %04x - Expect a failure now.\n", BX_reg(context
) );
349 context
->SegEs
= SELECTOROF(addr
);
350 DI_reg(context
) = OFFSETOF(addr
);
354 case 0x86: /* DPMI detect mode */
355 AX_reg(context
) = 0; /* Running under DPMI */
358 case 0x87: /* DPMI installation check */
359 #if 1 /* DPMI still breaks pkunzip */
360 if (ISV86(context
)) break; /* so bail out for now if in v86 mode */
365 AX_reg(context
) = 0x0000; /* DPMI Installed */
366 BX_reg(context
) = 0x0001; /* 32bits available */
367 CL_reg(context
) = si
.wProcessorLevel
;
368 DX_reg(context
) = 0x005a; /* DPMI major/minor 0.90 */
369 SI_reg(context
) = 0; /* # of para. of DOS extended private data */
370 context
->SegEs
= DOSMEM_dpmi_seg
;
371 DI_reg(context
) = 0; /* ES:DI is DPMI switch entry point */
374 case 0x8a: /* DPMI get vendor-specific API entry point. */
375 /* The 1.0 specs say this should work with all 0.9 hosts. */
379 INT_BARF( context
, 0x2f );
383 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
384 * must be <size> aligned
385 * <size> could be WORD, DWORD...
386 * in this case, we would need two macros, one for read, the other one for write
387 * Note: PTR_AT can be used as an l-value
389 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
391 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
393 /**********************************************************************
394 * MSCDEX_Dump [internal]
396 * Dumps mscdex requests to int debug channel.
398 static void MSCDEX_Dump(char* pfx
, BYTE
* req
, int dorealmode
)
406 ptr
+= sprintf(ptr
, "%s\tCommand => ", pfx
);
407 for (i
= 0; i
< req
[0]; i
++) {
408 ptr
+= sprintf(ptr
, "%02x ", req
[i
]);
414 ptr
+= sprintf(ptr
, "\n\t\t\t\tIO_struct => ");
415 ios
= (dorealmode
) ? PTR_REAL_TO_LIN( PTR_AT(req
, 16, WORD
), PTR_AT(req
, 14, WORD
)) :
416 MapSL(MAKESEGPTR(PTR_AT(req
, 16, WORD
), PTR_AT(req
, 14, WORD
)));
418 for (i
= 0; i
< PTR_AT(req
, 18, WORD
); i
++) {
419 ptr
+= sprintf(ptr
, "%02x ", ios
[i
]);
420 if ((i
& 0x1F) == 0x1F) {
430 #define MSCDEX_Dump(pfx, req, drm)
433 #define CDFRAMES_PERSEC 75
434 #define CDFRAMES_PERMIN (CDFRAMES_PERSEC * 60)
435 #define FRAME_OF_ADDR(a) ((a)[1] * CDFRAMES_PERMIN + (a)[2] * CDFRAMES_PERSEC + (a)[3])
436 #define FRAME_OF_TOC(toc, idx) FRAME_OF_ADDR((toc).TrackData[idx - (toc).FirstTrack].Address)
437 #define CTRL_OF_TOC(toc, idx) (((toc).TrackData[idx - (toc).FirstTrack].Control << 4) | \
438 (toc).TrackData[idx - (toc).FirstTrack].Adr)
440 static void MSCDEX_StoreMSF(DWORD frame
, BYTE
* val
)
442 val
[3] = 0; /* zero */
443 val
[2] = frame
/ CDFRAMES_PERMIN
; /* minutes */
444 val
[1] = (frame
/ CDFRAMES_PERSEC
) % 60; /* seconds */
445 val
[0] = frame
% CDFRAMES_PERSEC
; /* frames */
448 static int is_cdrom( int drive
)
450 char root
[] = "A:\\";
452 return (GetDriveTypeA(root
) == DRIVE_CDROM
);
455 static void MSCDEX_Handler(CONTEXT86
* context
)
460 switch (LOBYTE(context
->Eax
)) {
461 case 0x00: /* Installation check */
462 /* Count the number of contiguous CDROM drives
464 for (drive
= count
= 0; drive
< 26; drive
++) {
465 if (is_cdrom(drive
)) {
466 while (is_cdrom(drive
+ count
)) count
++;
470 TRACE("Installation check: %d cdroms, starting at %d\n", count
, drive
);
471 BX_reg(context
) = count
;
472 CX_reg(context
) = (drive
< 26) ? drive
: 0;
475 case 0x0B: /* drive check */
476 AX_reg(context
) = is_cdrom(CX_reg(context
));
477 BX_reg(context
) = 0xADAD;
480 case 0x0C: /* get version */
481 BX_reg(context
) = 0x020a;
482 TRACE("Version number => %04x\n", BX_reg(context
));
485 case 0x0D: /* get drive letters */
486 p
= CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Ebx
);
488 for (drive
= 0; drive
< 26; drive
++) {
489 if (is_cdrom(drive
)) *p
++ = drive
;
491 TRACE("Get drive letters\n");
494 case 0x10: /* direct driver access */
496 BYTE
* driver_request
;
498 BYTE Error
= 255; /* No Error */
499 int dorealmode
= ISV86(context
);
500 char devName
[] = "\\\\.\\@:";
503 CDROM_SUB_Q_DATA_FORMAT fmt
;
504 SUB_Q_CHANNEL_DATA data
;
506 DWORD present
= TRUE
;
508 driver_request
= CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Ebx
);
510 if (!driver_request
) {
511 /* FIXME - to be deleted ?? */
512 ERR("ES:BX==0 ! SEGFAULT ?\n");
513 ERR("-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
514 BX_reg(context
), context
->SegEs
, context
->SegDs
, CX_reg(context
));
515 driver_request
[4] |= 0x80;
516 driver_request
[3] = 5; /* bad request length */
520 * the following tests are wrong because lots of functions don't require the
521 * tray to be closed with a CD inside
523 TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request
[2]);
525 if (!is_cdrom(CX_reg(context
))) {
526 WARN("Request made doesn't match a CD ROM drive (%d)\n", CX_reg(context
));
527 driver_request
[4] |= 0x80;
528 driver_request
[3] = 1; /* unknown unit */
532 MSCDEX_Dump("Beg", driver_request
, dorealmode
);
534 /* set status to 0 */
535 PTR_AT(driver_request
, 3, WORD
) = 0;
536 devName
[4] = 'A' + CX_reg(context
);
537 h
= CreateFileA(devName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, 0);
539 WARN("Couldn't open cdrom handle\n");
540 driver_request
[4] |= 0x80;
541 driver_request
[3] = 1; /* unknown unit */
545 fmt
.Format
= IOCTL_CDROM_CURRENT_POSITION
;
546 if (!DeviceIoControl(h
, IOCTL_CDROM_READ_TOC
, NULL
, 0, &toc
, sizeof(toc
), &br
, NULL
) ||
547 !DeviceIoControl(h
, IOCTL_CDROM_READ_Q_CHANNEL
, &fmt
, sizeof(fmt
),
548 &data
, sizeof(data
), &br
, NULL
)) {
549 if (GetLastError() == STATUS_NO_MEDIA_IN_DEVICE
)
551 if (driver_request
[2] != 6 && driver_request
[2] != 15)
553 driver_request
[4] |= 0x80;
554 driver_request
[3] = 2; /* drive not ready */
562 driver_request
[4] |= 0x80;
563 driver_request
[3] = 1; /* unknown unit */
569 switch (driver_request
[2]) {
571 io_stru
= (dorealmode
) ?
572 PTR_REAL_TO_LIN( PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
) ) :
573 MapSL( MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
)));
575 TRACE(" --> IOCTL INPUT <%d>\n", io_stru
[0]);
576 switch (io_stru
[0]) {
578 case 0: /* Get device Header */
580 static LPSTR ptr
= 0;
582 ptr
= SEGPTR_ALLOC(22);
583 PTR_AT(ptr
, 0, DWORD
) = ~1; /* Next Device Driver */
584 PTR_AT(ptr
, 4, WORD
) = 0xC800; /* Device attributes */
585 PTR_AT(ptr
, 6, WORD
) = 0x1234; /* Pointer to device strategy routine: FIXME */
586 PTR_AT(ptr
, 8, WORD
) = 0x3142; /* Pointer to device interrupt routine: FIXME */
587 PTR_AT(ptr
, 10, char) = 'W'; /* 8-byte character device name field */
588 PTR_AT(ptr
, 11, char) = 'I';
589 PTR_AT(ptr
, 12, char) = 'N';
590 PTR_AT(ptr
, 13, char) = 'E';
591 PTR_AT(ptr
, 14, char) = '_';
592 PTR_AT(ptr
, 15, char) = 'C';
593 PTR_AT(ptr
, 16, char) = 'D';
594 PTR_AT(ptr
, 17, char) = '_';
595 PTR_AT(ptr
, 18, WORD
) = 0; /* Reserved (must be zero) */
596 PTR_AT(ptr
, 20, BYTE
) = 0; /* Drive letter (must be zero) */
597 PTR_AT(ptr
, 21, BYTE
) = 1; /* Number of units supported (one or more) FIXME*/
599 PTR_AT(io_stru
, DWORD
, 0) = SEGPTR_GET(ptr
);
604 case 1: /* location of head */
605 switch (io_stru
[1]) {
607 PTR_AT(io_stru
, 2, DWORD
) =
608 FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
);
611 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
),
615 ERR("CD-ROM driver: unsupported addressing mode !!\n");
618 TRACE(" ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru
, 2, DWORD
));
621 case 4: /* Audio channel info */
630 TRACE(" ----> AUDIO CHANNEL INFO\n");
633 case 6: /* device status */
634 PTR_AT(io_stru
, 1, DWORD
) = 0x00000290;
636 * 1 Supports HSG and Red Book addressing modes
637 * 0 Supports audio channel manipulation
639 * 1 Supports prefetching requests
642 * 1 Data read and plays audio/video tracks
645 * 0 Supports only cooked reading
647 * 0 see below (Door closed/opened)
649 if (!present
) PTR_AT(io_stru
, 1, DWORD
) |= 1;
650 TRACE(" ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru
, 1, DWORD
));
653 case 8: /* Volume size */
654 PTR_AT(io_stru
, 1, DWORD
) = FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1) -
655 FRAME_OF_TOC(toc
, toc
.FirstTrack
) - 1;
656 TRACE(" ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru
, 1, DWORD
));
659 case 9: /* media changed ? */
660 /* answers don't know... -1/1 for yes/no would be better */
661 io_stru
[1] = 0; /* FIXME? 1? */
662 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru
[1]);
665 case 10: /* audio disk info */
666 io_stru
[1] = toc
.FirstTrack
; /* starting track of the disc */
667 io_stru
[2] = toc
.LastTrack
; /* ending track */
668 MSCDEX_StoreMSF(FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1) -
669 FRAME_OF_TOC(toc
, toc
.FirstTrack
) - 1, io_stru
+ 3);
671 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
672 io_stru
[1], io_stru
[2], PTR_AT(io_stru
, 3, DWORD
));
675 case 11: /* audio track info */
676 if (io_stru
[1] >= toc
.FirstTrack
&& io_stru
[1] <= toc
.LastTrack
) {
677 MSCDEX_StoreMSF(FRAME_OF_TOC(toc
, io_stru
[1]), io_stru
+ 2);
678 /* starting point if the track */
679 io_stru
[6] = CTRL_OF_TOC(toc
, io_stru
[1]);
681 PTR_AT(io_stru
, 2, DWORD
) = 0;
684 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
685 io_stru
[1], PTR_AT(io_stru
, 2, DWORD
), io_stru
[6]);
688 case 12: /* get Q-Channel info */
689 io_stru
[1] = CTRL_OF_TOC(toc
, data
.CurrentPosition
.TrackNumber
);
690 io_stru
[2] = data
.CurrentPosition
.TrackNumber
;
691 io_stru
[3] = 0; /* FIXME ?? */
693 /* why the heck did MS use another format for 0MSF information... sigh */
697 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.TrackRelativeAddress
), bTmp
);
698 io_stru
[ 4] = bTmp
[2];
699 io_stru
[ 5] = bTmp
[1];
700 io_stru
[ 6] = bTmp
[0];
703 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
), bTmp
);
704 io_stru
[ 8] = bTmp
[2];
705 io_stru
[ 9] = bTmp
[1];
706 io_stru
[10] = bTmp
[0];
709 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08x, tp=%08x)\n",
710 io_stru
[ 1], io_stru
[ 2], io_stru
[ 3],
711 io_stru
[ 4], io_stru
[ 5], io_stru
[ 6],
712 io_stru
[ 8], io_stru
[ 9], io_stru
[10],
713 FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
),
714 FRAME_OF_TOC(toc
, data
.CurrentPosition
.TrackNumber
));
717 case 15: /* Audio status info */
718 /* !!!! FIXME FIXME FIXME !! */
719 PTR_AT(io_stru
, 1, WORD
) = 2 | ((data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_PAUSED
) ? 1 : 0);
721 PTR_AT(io_stru
, 3, DWORD
) = 0;
722 PTR_AT(io_stru
, 7, DWORD
) = 0;
724 PTR_AT(io_stru
, 3, DWORD
) = FRAME_OF_TOC(toc
, toc
.FirstTrack
);
725 PTR_AT(io_stru
, 7, DWORD
) = FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1);
727 TRACE("Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
728 PTR_AT(io_stru
, 1, WORD
), PTR_AT(io_stru
, 3, DWORD
), PTR_AT(io_stru
, 7, DWORD
));
732 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru
[0]);
739 io_stru
= (dorealmode
) ?
740 PTR_REAL_TO_LIN( PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
)) :
741 MapSL( MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
)));
743 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru
[0]);
744 switch (io_stru
[0]) {
746 DeviceIoControl(h
, IOCTL_STORAGE_EJECT_MEDIA
, NULL
, 0, NULL
, 0, &br
, NULL
);
747 TRACE(" ----> EJECT\n");
749 case 2: /* reset drive */
750 DeviceIoControl(h
, IOCTL_STORAGE_RESET_DEVICE
, NULL
, 0, NULL
, 0, &br
, NULL
);
751 TRACE(" ----> RESET\n");
753 case 3: /* Audio Channel Control */
754 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
756 case 5: /* close tray */
757 DeviceIoControl(h
, IOCTL_STORAGE_LOAD_MEDIA
, NULL
, 0, NULL
, 0, &br
, NULL
);
758 TRACE(" ----> CLOSE TRAY\n");
761 FIXME(" IOCTL OUTPUT: Unimplemented <%d>!!\n", io_stru
[0]);
767 case 128: /* read long */
769 LPVOID dst
= MapSL(MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
),
770 PTR_AT(driver_request
, 14, WORD
)));
771 DWORD at
= PTR_AT(driver_request
, 20, DWORD
);
772 WORD num
= PTR_AT(driver_request
, 18, WORD
);
775 switch (driver_request
[13]) {
776 case 1: /* Red book addressing mode = 0:m:s:f */
777 /* FIXME : frame <=> msf conversion routines could be shared
778 * between mscdex and mcicda
780 at
= LOBYTE(HIWORD(at
)) * CDFRAMES_PERMIN
+
781 HIBYTE(LOWORD(at
)) * CDFRAMES_PERSEC
+
784 case 0: /* HSG addressing mode */
785 switch (PTR_AT(driver_request
, 24, BYTE
))
788 ReadFile(h
, dst
, num
* 2048, &br
, NULL
);
791 /* FIXME: computation is wrong */
792 rri
.DiskOffset
.s
.HighPart
= 0;
793 rri
.DiskOffset
.s
.LowPart
= at
<< 11;
794 rri
.TrackMode
= YellowMode2
;
795 rri
.SectorCount
= num
;
796 DeviceIoControl(h
, IOCTL_CDROM_RAW_READ
, &rri
, sizeof(rri
),
797 dst
, num
* 2352, &br
, NULL
);
800 ERR("Unsupported read mode !!\n");
806 ERR("Unsupported address mode !!\n");
816 CDROM_SEEK_AUDIO_MSF seek
;
818 at
= PTR_AT(driver_request
, 20, DWORD
);
820 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
821 (BYTE
)driver_request
[13], at
);
823 switch (driver_request
[13]) {
824 case 1: /* Red book addressing mode = 0:m:s:f */
825 /* FIXME : frame <=> msf conversion routines could be shared
826 * between mscdex and mcicda
828 at
= LOBYTE(HIWORD(at
)) * CDFRAMES_PERMIN
+
829 HIBYTE(LOWORD(at
)) * CDFRAMES_PERSEC
+
832 case 0: /* HSG addressing mode */
833 seek
.M
= at
/ CDFRAMES_PERMIN
;
834 seek
.S
= (at
/ CDFRAMES_PERSEC
) % 60;
835 seek
.F
= at
% CDFRAMES_PERSEC
;
836 DeviceIoControl(h
, IOCTL_CDROM_SEEK_AUDIO_MSF
, &seek
, sizeof(seek
),
840 ERR("Unsupported address mode !!\n");
850 CDROM_PLAY_AUDIO_MSF play
;
852 beg
= end
= PTR_AT(driver_request
, 14, DWORD
);
853 end
+= PTR_AT(driver_request
, 18, DWORD
);
855 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
856 (BYTE
)driver_request
[13], beg
, end
);
858 switch (driver_request
[13]) {
860 /* Red book addressing mode = 0:m:s:f */
861 /* FIXME : frame <=> msf conversion routines could be shared
862 * between mscdex and mcicda
864 beg
= LOBYTE(LOWORD(beg
)) * CDFRAMES_PERMIN
+
865 HIBYTE(LOWORD(beg
)) * CDFRAMES_PERSEC
+
867 end
= LOBYTE(LOWORD(end
)) * CDFRAMES_PERMIN
+
868 HIBYTE(LOWORD(end
)) * CDFRAMES_PERSEC
+
871 case 0: /* HSG addressing mode */
872 play
.StartingM
= beg
/ CDFRAMES_PERMIN
;
873 play
.StartingS
= (beg
/ CDFRAMES_PERSEC
) % 60;
874 play
.StartingF
= beg
% CDFRAMES_PERSEC
;
875 play
.EndingM
= end
/ CDFRAMES_PERMIN
;
876 play
.EndingS
= (end
/ CDFRAMES_PERSEC
) % 60;
877 play
.EndingF
= end
% CDFRAMES_PERSEC
;
878 DeviceIoControl(h
, IOCTL_CDROM_PLAY_AUDIO_MSF
, &play
, sizeof(play
),
882 ERR("Unsupported address mode !!\n");
890 if (data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_IN_PROGRESS
) {
891 DeviceIoControl(h
, IOCTL_CDROM_PAUSE_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
892 TRACE(" --> STOP AUDIO (Paused)\n");
894 DeviceIoControl(h
, IOCTL_CDROM_STOP_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
895 TRACE(" --> STOP AUDIO (Stopped)\n");
900 TRACE(" --> RESUME AUDIO\n");
901 DeviceIoControl(h
, IOCTL_CDROM_PAUSE_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
905 FIXME(" ioctl unimplemented <%d>\n", driver_request
[2]);
909 /* setting error codes if any */
911 driver_request
[4] |= 0x80;
912 driver_request
[3] = Error
;
916 /* setting status bits
917 * 3 == playing && done
921 (data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_IN_PROGRESS
) ? 3 : 1;
923 MSCDEX_Dump("End", driver_request
, dorealmode
);
927 FIXME("Unimplemented MSCDEX function 0x%02X.\n", LOBYTE(context
->Eax
));