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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #define WIN32_NO_STATUS
30 #define NONAMELESSUNION
31 #include "wine/winbase16.h"
32 #include "wine/debug.h"
39 WINE_DEFAULT_DEBUG_CHANNEL(int);
41 /* base KERNEL ordinal number for VxDs */
46 DOS_DEVICE_HEADER hdr
;
48 WORD reserved
; /* must be 0 */
49 BYTE drive
; /* drive letter (0=A:, 1=B:, ...) */
50 BYTE units
; /* number of supported units */
51 } CDROM_DEVICE_HEADER
;
55 CDROM_DEVICE_HEADER hdr
;
56 WORD cdrom_selector
; /* Protected mode selector for CDROM_HEAP */
59 static void do_int2f_16( CONTEXT
*context
);
60 static void MSCDEX_Handler( CONTEXT
*context
);
62 /**********************************************************************
65 * Handler for int 2fh (multiplex).
67 void WINAPI
DOSVM_Int2fHandler( CONTEXT
*context
)
69 TRACE("Subfunction 0x%X\n", AX_reg(context
));
71 switch(AH_reg(context
))
74 SET_AL( context
, 0xff ); /* share is installed */
77 case 0x11: /* Network Redirector / IFSFUNC */
78 switch (LOBYTE(context
->Eax
))
80 case 0x00: /* Install check */
83 case 0x80: /* Enhanced services - Install check */
87 INT_BARF( context
, 0x2f );
93 switch (LOBYTE(context
->Eax
))
95 case 0x2e: /* get or set DOS error table address */
96 switch (DL_reg(context
))
98 /* Four tables: even commands are 'get', odd are 'set' */
99 /* DOS 5.0+ ignores "set" commands */
106 /* Instead of having a message table in DOS-space, */
107 /* we can use a special case for MS-DOS to force */
108 /* the secondary interface. */
113 context
->SegEs
= 0x0001;
114 SET_DI( context
, 0x0000 );
117 FIXME("No real-mode handler for errors yet! (bye!)\n");
120 INT_BARF(context
, 0x2f);
124 INT_BARF(context
, 0x2f);
128 case 0x15: /* mscdex */
129 MSCDEX_Handler(context
);
133 do_int2f_16( context
);
136 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
137 /* Not supported yet, do nothing */
141 FIXME("check for XMS (not supported)\n");
142 SET_AL( 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 SET_AL( 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.*/
207 SET_AL( context
, 0 );
209 case 0x20: /* Get VLM Call Address */
210 /* return nothing -> NetWare not installed */
213 INT_BARF( context
, 0x2f );
217 case 0xb7: /* append */
218 SET_AL( context
, 0 ); /* not installed */
220 case 0xb8: /* network */
221 switch (LOBYTE(context
->Eax
))
223 case 0x00: /* Install check */
227 INT_BARF( context
, 0x2f );
232 if (AL_reg(context
) == 0x00 && BX_reg(context
) == 0x3f3f) {
233 /* MVSOUND.SYS - Install check: not installed */
235 INT_BARF( context
, 0x2f );
238 case 0xbd: /* some Novell network install check ??? */
239 SET_AX( context
, 0xa5a5 ); /* pretend to have Novell IPX installed */
241 case 0xbf: /* REDIRIFS.EXE */
242 switch (LOBYTE(context
->Eax
))
244 case 0x00: /* Install check */
248 INT_BARF( context
, 0x2f );
253 switch(LOBYTE(context
->Eax
))
255 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
256 if(BX_reg(context
) == 0x5145 && CX_reg(context
) == 0x4D4D
257 && DX_reg(context
) == 0x3432)
258 TRACE("Check for QEMM v5.0+ (not installed)\n");
261 INT_BARF( context
, 0x2f );
265 case 0xd7: /* Banyan Vines */
266 switch (LOBYTE(context
->Eax
))
268 case 0x01: /* Install check - Get Int Number */
272 INT_BARF( context
, 0x2f );
277 switch(LOBYTE(context
->Eax
))
279 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
280 if(BX_reg(context
) == 0x4450 && CX_reg(context
) == 0x4d49
281 && DX_reg(context
) == 0x8f4f)
282 TRACE("Check for QDPMI.SYS (not installed)\n");
285 INT_BARF( context
, 0x2f );
289 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
292 INT_BARF( context
, 0x2f );
298 /**********************************************************************
301 static void do_int2f_16( CONTEXT
*context
)
305 switch(LOBYTE(context
->Eax
))
307 case 0x00: /* Windows enhanced mode installation check */
308 SET_AX( context
, LOWORD(GetVersion16()) );
311 case 0x0a: /* Get Windows version and type */
312 SET_AX( context
, 0 );
313 SET_BX( context
, (LOWORD(GetVersion16()) << 8) | (LOWORD(GetVersion16()) >> 8) );
314 SET_CX( context
, 3 );
317 case 0x0b: /* Identify Windows-aware TSRs */
318 /* we don't have any pre-Windows TSRs */
321 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
322 /* We can mock this up. But not today... */
323 FIXME("Get Shell Parameters\n");
326 case 0x80: /* Release time-slice */
327 /* Linux sched_yield() still keeps burning CPU cycles
328 * if the current process is the only one in highest priority list
329 * (as Linux will immediately return to this process to waste
330 * more CPU cycles), so sched_yield() is essentially useless for us
331 * (poor API, if you ask me: its return code should indicate
332 * whether other processes did run in between, in order for us
333 * to be able to decide whether to do an additional Sleep() or not...)
334 * Thus we better unconditionally use a well-balanced Sleep()
335 * instead to really make sure the process calling int 0x2f/0x1680
336 * *doesn't* use 100% CPU...
338 Sleep(55); /* just wait 55ms (one "timer tick") for now. */
339 SET_AL( context
, 0 );
342 case 0x81: /* Begin critical section. */
346 case 0x82: /* End critical section. */
350 case 0x83: /* Return Current Virtual Machine ID */
351 /* Virtual Machines are usually created/destroyed when Windows runs
352 * DOS programs. Since we never do, we are always in the System VM.
353 * According to Ralf Brown's Interrupt List, never return 0. But it
354 * seems to work okay (returning 0), just to be sure we return 1.
356 SET_BX( context
, 1 ); /* VM 1 is probably the System VM */
359 case 0x84: /* Get device API entry point */
361 HMODULE16 mod
= GetModuleHandle16("kernel");
362 addr
= (DWORD
)GetProcAddress16( mod
, (LPCSTR
)(VXD_BASE
+ BX_reg(context
)) );
363 if (!addr
) /* not supported */
364 ERR("Accessing unknown VxD %04x - Expect a failure now.\n", BX_reg(context
) );
365 context
->SegEs
= SELECTOROF(addr
);
366 SET_DI( context
, OFFSETOF(addr
) );
370 case 0x86: /* DPMI detect mode */
371 SET_AX( context
, 0 ); /* Running under DPMI */
374 case 0x87: /* DPMI installation check */
378 SET_AX( context
, 0x0000 ); /* DPMI Installed */
379 SET_BX( context
, 0x0001 ); /* 32bits available */
380 SET_CL( context
, si
.wProcessorLevel
);
381 SET_DX( context
, 0x005a ); /* DPMI major/minor 0.90 */
382 SET_SI( context
, 0 ); /* # of para. of DOS extended private data */
383 context
->SegEs
= 0; /* no DPMI switch */
384 SET_DI( context
, 0 ); /* ES:DI is DPMI switch entry point */
387 case 0x8a: /* DPMI get vendor-specific API entry point. */
388 /* The 1.0 specs say this should work with all 0.9 hosts. */
392 INT_BARF( context
, 0x2f );
396 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
397 * must be <size> aligned
398 * <size> could be WORD, DWORD...
399 * in this case, we would need two macros, one for read, the other one for write
400 * Note: PTR_AT can be used as an l-value
402 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
404 #define CDFRAMES_PERSEC 75
405 #define CDFRAMES_PERMIN (CDFRAMES_PERSEC * 60)
406 #define FRAME_OF_ADDR(a) ((a)[1] * CDFRAMES_PERMIN + (a)[2] * CDFRAMES_PERSEC + (a)[3])
407 #define FRAME_OF_TOC(toc, idx) FRAME_OF_ADDR((toc).TrackData[idx - (toc).FirstTrack].Address)
408 #define CTRL_OF_TOC(toc, idx) (((toc).TrackData[idx - (toc).FirstTrack].Control << 4) | \
409 (toc).TrackData[idx - (toc).FirstTrack].Adr)
411 static void MSCDEX_StoreMSF(DWORD frame
, BYTE
* val
)
413 val
[3] = 0; /* zero */
414 val
[2] = frame
/ CDFRAMES_PERMIN
; /* minutes */
415 val
[1] = (frame
/ CDFRAMES_PERSEC
) % 60; /* seconds */
416 val
[0] = frame
% CDFRAMES_PERSEC
; /* frames */
419 static BOOL
is_cdrom(int drive
)
421 char root
[] = "A:\\";
423 return (GetDriveTypeA(root
) == DRIVE_CDROM
);
426 /***********************************************************************
429 * Initialize CDROM heap.
432 static void CDROM_FillHeap( CDROM_HEAP
*heap
)
436 /* Count the number of contiguous CDROM drives
438 for (drive
= count
= 0; drive
< 26; drive
++) {
439 if (is_cdrom(drive
)) {
440 while (is_cdrom(drive
+ count
)) count
++;
444 TRACE("Installation check: %d cdroms, starting at %d\n", count
, drive
);
445 heap
->hdr
.drive
= (drive
< 26) ? drive
: 0;
446 heap
->hdr
.units
= count
;
447 heap
->hdr
.reserved
= 0;
450 /**********************************************************************
453 * Get pointer for CDROM heap (CDROM_HEAP).
454 * Creates and initializes heap on first call.
456 static CDROM_HEAP
*CDROM_GetHeap( void )
458 static CDROM_HEAP
*heap_pointer
= NULL
;
464 /* allocate a new DOS data segment */
465 heap_pointer
= DOSVM_AllocDataUMB( sizeof(CDROM_HEAP
), &heap_selector
);
466 heap_pointer
->cdrom_selector
= heap_selector
;
467 CDROM_FillHeap( heap_pointer
);
473 static void MSCDEX_Request(BYTE
*driver_request
)
476 BYTE Error
= 255; /* No Error */
477 char devName
[] = "\\\\.\\@:";
480 CDROM_SUB_Q_DATA_FORMAT fmt
;
481 SUB_Q_CHANNEL_DATA data
;
486 * the following tests are wrong because lots of functions don't require the
487 * tray to be closed with a CD inside
489 TRACE("CDROM device driver -> command <%d>\n", driver_request
[2]);
491 /* set status to 0 */
492 PTR_AT(driver_request
, 3, WORD
) = 0;
493 devName
[4] = 'A' + CDROM_GetHeap()->hdr
.drive
+ driver_request
[1];
494 h
= CreateFileA(devName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, 0);
495 if (h
== INVALID_HANDLE_VALUE
) {
496 WARN("Couldn't open cdrom handle\n");
497 driver_request
[4] |= 0x80;
498 driver_request
[3] = 1; /* unknown unit */
502 fmt
.Format
= IOCTL_CDROM_CURRENT_POSITION
;
503 if (!DeviceIoControl(h
, IOCTL_CDROM_READ_TOC
, NULL
, 0, &toc
, sizeof(toc
), &br
, NULL
) ||
504 !DeviceIoControl(h
, IOCTL_CDROM_READ_Q_CHANNEL
, &fmt
, sizeof(fmt
),
505 &data
, sizeof(data
), &br
, NULL
)) {
506 if (GetLastError() == STATUS_NO_MEDIA_IN_DEVICE
)
508 if (driver_request
[2] != 6 && driver_request
[2] != 15)
510 driver_request
[4] |= 0x80;
511 driver_request
[3] = 2; /* drive not ready */
519 driver_request
[4] |= 0x80;
520 driver_request
[3] = 1; /* unknown unit */
526 switch (driver_request
[2]) {
528 io_stru
= MapSL( MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
)));
530 TRACE(" --> IOCTL INPUT <%d>\n", io_stru
[0]);
531 switch (io_stru
[0]) {
533 case 0: /* Get device Header */
535 static LPSTR ptr
= 0;
537 ptr
= SEGPTR_ALLOC(22);
538 PTR_AT(ptr
, 0, DWORD
) = ~1; /* Next Device Driver */
539 PTR_AT(ptr
, 4, WORD
) = 0xC800; /* Device attributes */
540 PTR_AT(ptr
, 6, WORD
) = 0x1234; /* Pointer to device strategy routine: FIXME */
541 PTR_AT(ptr
, 8, WORD
) = 0x3142; /* Pointer to device interrupt routine: FIXME */
542 PTR_AT(ptr
, 10, char) = 'W'; /* 8-byte character device name field */
543 PTR_AT(ptr
, 11, char) = 'I';
544 PTR_AT(ptr
, 12, char) = 'N';
545 PTR_AT(ptr
, 13, char) = 'E';
546 PTR_AT(ptr
, 14, char) = '_';
547 PTR_AT(ptr
, 15, char) = 'C';
548 PTR_AT(ptr
, 16, char) = 'D';
549 PTR_AT(ptr
, 17, char) = '_';
550 PTR_AT(ptr
, 18, WORD
) = 0; /* Reserved (must be zero) */
551 PTR_AT(ptr
, 20, BYTE
) = 0; /* Drive letter (must be zero) */
552 PTR_AT(ptr
, 21, BYTE
) = 1; /* Number of units supported (one or more) FIXME*/
554 PTR_AT(io_stru
, DWORD
, 0) = SEGPTR_GET(ptr
);
559 case 1: /* location of head */
560 switch (io_stru
[1]) {
562 PTR_AT(io_stru
, 2, DWORD
) =
563 FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
);
566 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
),
570 ERR("CD-ROM driver: unsupported addressing mode !!\n");
573 TRACE(" ----> HEAD LOCATION <%d>\n", PTR_AT(io_stru
, 2, DWORD
));
576 case 4: /* Audio channel info */
585 TRACE(" ----> AUDIO CHANNEL INFO\n");
588 case 6: /* device status */
589 PTR_AT(io_stru
, 1, DWORD
) = 0x00000290;
591 * 1 Supports HSG and Red Book addressing modes
592 * 0 Supports audio channel manipulation
594 * 1 Supports prefetching requests
597 * 1 Data read and plays audio/video tracks
600 * 0 Supports only cooked reading
602 * 0 see below (Door closed/opened)
604 if (!present
) PTR_AT(io_stru
, 1, DWORD
) |= 1;
605 TRACE(" ----> DEVICE STATUS <0x%08x>\n", PTR_AT(io_stru
, 1, DWORD
));
608 case 8: /* Volume size */
609 PTR_AT(io_stru
, 1, DWORD
) = FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1) -
610 FRAME_OF_TOC(toc
, toc
.FirstTrack
) - 1;
611 TRACE(" ----> VOLUME SIZE <%d>\n", PTR_AT(io_stru
, 1, DWORD
));
614 case 9: /* media changed ? */
615 /* answers don't know... -1/1 for yes/no would be better */
616 io_stru
[1] = 0; /* FIXME? 1? */
617 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru
[1]);
620 case 10: /* audio disk info */
621 io_stru
[1] = toc
.FirstTrack
; /* starting track of the disc */
622 io_stru
[2] = toc
.LastTrack
; /* ending track */
623 MSCDEX_StoreMSF(FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1) -
624 FRAME_OF_TOC(toc
, toc
.FirstTrack
) - 1, io_stru
+ 3);
626 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08x>\n",
627 io_stru
[1], io_stru
[2], PTR_AT(io_stru
, 3, DWORD
));
630 case 11: /* audio track info */
631 if (io_stru
[1] >= toc
.FirstTrack
&& io_stru
[1] <= toc
.LastTrack
) {
632 MSCDEX_StoreMSF(FRAME_OF_TOC(toc
, io_stru
[1]), io_stru
+ 2);
633 /* starting point if the track */
634 io_stru
[6] = CTRL_OF_TOC(toc
, io_stru
[1]);
636 PTR_AT(io_stru
, 2, DWORD
) = 0;
639 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08x:%d]\n",
640 io_stru
[1], PTR_AT(io_stru
, 2, DWORD
), io_stru
[6]);
643 case 12: /* get Q-Channel info */
644 io_stru
[1] = CTRL_OF_TOC(toc
, data
.CurrentPosition
.TrackNumber
);
645 io_stru
[2] = data
.CurrentPosition
.TrackNumber
;
646 io_stru
[3] = 0; /* FIXME ?? */
648 /* why the heck did MS use another format for 0MSF information... sigh */
652 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.TrackRelativeAddress
), bTmp
);
653 io_stru
[ 4] = bTmp
[2];
654 io_stru
[ 5] = bTmp
[1];
655 io_stru
[ 6] = bTmp
[0];
658 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
), bTmp
);
659 io_stru
[ 8] = bTmp
[2];
660 io_stru
[ 9] = bTmp
[1];
661 io_stru
[10] = bTmp
[0];
664 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08x, tp=%08x)\n",
665 io_stru
[ 1], io_stru
[ 2], io_stru
[ 3],
666 io_stru
[ 4], io_stru
[ 5], io_stru
[ 6],
667 io_stru
[ 8], io_stru
[ 9], io_stru
[10],
668 FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
),
669 FRAME_OF_TOC(toc
, data
.CurrentPosition
.TrackNumber
));
672 case 15: /* Audio status info */
673 /* !!!! FIXME FIXME FIXME !! */
674 PTR_AT(io_stru
, 1, WORD
) = 2 | ((data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_PAUSED
) ? 1 : 0);
676 PTR_AT(io_stru
, 3, DWORD
) = 0;
677 PTR_AT(io_stru
, 7, DWORD
) = 0;
679 PTR_AT(io_stru
, 3, DWORD
) = FRAME_OF_TOC(toc
, toc
.FirstTrack
);
680 PTR_AT(io_stru
, 7, DWORD
) = FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1);
682 TRACE("Audio status info: status=%04x startLoc=%d endLoc=%d\n",
683 PTR_AT(io_stru
, 1, WORD
), PTR_AT(io_stru
, 3, DWORD
), PTR_AT(io_stru
, 7, DWORD
));
687 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru
[0]);
694 io_stru
= MapSL( MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
)));
696 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru
[0]);
697 switch (io_stru
[0]) {
699 DeviceIoControl(h
, IOCTL_STORAGE_EJECT_MEDIA
, NULL
, 0, NULL
, 0, &br
, NULL
);
700 TRACE(" ----> EJECT\n");
702 case 2: /* reset drive */
703 DeviceIoControl(h
, IOCTL_STORAGE_RESET_DEVICE
, NULL
, 0, NULL
, 0, &br
, NULL
);
704 TRACE(" ----> RESET\n");
706 case 3: /* Audio Channel Control */
707 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
709 case 5: /* close tray */
710 DeviceIoControl(h
, IOCTL_STORAGE_LOAD_MEDIA
, NULL
, 0, NULL
, 0, &br
, NULL
);
711 TRACE(" ----> CLOSE TRAY\n");
714 FIXME(" IOCTL OUTPUT: Unimplemented <%d>!!\n", io_stru
[0]);
720 case 128: /* read long */
722 LPVOID dst
= MapSL(MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
),
723 PTR_AT(driver_request
, 14, WORD
)));
724 DWORD at
= PTR_AT(driver_request
, 20, DWORD
);
725 WORD num
= PTR_AT(driver_request
, 18, WORD
);
728 switch (driver_request
[13]) {
729 case 1: /* Red book addressing mode = 0:m:s:f */
730 /* FIXME : frame <=> msf conversion routines could be shared
731 * between mscdex and mcicda
733 at
= LOBYTE(HIWORD(at
)) * CDFRAMES_PERMIN
+
734 HIBYTE(LOWORD(at
)) * CDFRAMES_PERSEC
+
737 case 0: /* HSG addressing mode */
738 switch (PTR_AT(driver_request
, 24, BYTE
))
741 ReadFile(h
, dst
, num
* 2048, &br
, NULL
);
744 /* FIXME: computation is wrong */
745 rri
.DiskOffset
.u
.HighPart
= 0;
746 rri
.DiskOffset
.u
.LowPart
= at
<< 11;
747 rri
.TrackMode
= YellowMode2
;
748 rri
.SectorCount
= num
;
749 DeviceIoControl(h
, IOCTL_CDROM_RAW_READ
, &rri
, sizeof(rri
),
750 dst
, num
* 2352, &br
, NULL
);
753 ERR("Unsupported read mode !!\n");
759 ERR("Unsupported address mode !!\n");
769 CDROM_SEEK_AUDIO_MSF seek
;
771 at
= PTR_AT(driver_request
, 20, DWORD
);
773 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%d]\n", driver_request
[13], at
);
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 seek
.M
= at
/ CDFRAMES_PERMIN
;
786 seek
.S
= (at
/ CDFRAMES_PERSEC
) % 60;
787 seek
.F
= at
% CDFRAMES_PERSEC
;
788 DeviceIoControl(h
, IOCTL_CDROM_SEEK_AUDIO_MSF
, &seek
, sizeof(seek
),
792 ERR("Unsupported address mode !!\n");
802 CDROM_PLAY_AUDIO_MSF play
;
804 beg
= end
= PTR_AT(driver_request
, 14, DWORD
);
805 end
+= PTR_AT(driver_request
, 18, DWORD
);
807 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%d-%d]\n", driver_request
[13], beg
, end
);
809 switch (driver_request
[13]) {
811 /* Red book addressing mode = 0:m:s:f */
812 /* FIXME : frame <=> msf conversion routines could be shared
813 * between mscdex and mcicda
815 beg
= LOBYTE(LOWORD(beg
)) * CDFRAMES_PERMIN
+
816 HIBYTE(LOWORD(beg
)) * CDFRAMES_PERSEC
+
818 end
= LOBYTE(LOWORD(end
)) * CDFRAMES_PERMIN
+
819 HIBYTE(LOWORD(end
)) * CDFRAMES_PERSEC
+
822 case 0: /* HSG addressing mode */
823 play
.StartingM
= beg
/ CDFRAMES_PERMIN
;
824 play
.StartingS
= (beg
/ CDFRAMES_PERSEC
) % 60;
825 play
.StartingF
= beg
% CDFRAMES_PERSEC
;
826 play
.EndingM
= end
/ CDFRAMES_PERMIN
;
827 play
.EndingS
= (end
/ CDFRAMES_PERSEC
) % 60;
828 play
.EndingF
= end
% CDFRAMES_PERSEC
;
829 DeviceIoControl(h
, IOCTL_CDROM_PLAY_AUDIO_MSF
, &play
, sizeof(play
),
833 ERR("Unsupported address mode !!\n");
841 if (data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_IN_PROGRESS
) {
842 DeviceIoControl(h
, IOCTL_CDROM_PAUSE_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
843 TRACE(" --> STOP AUDIO (Paused)\n");
845 DeviceIoControl(h
, IOCTL_CDROM_STOP_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
846 TRACE(" --> STOP AUDIO (Stopped)\n");
851 TRACE(" --> RESUME AUDIO\n");
852 DeviceIoControl(h
, IOCTL_CDROM_PAUSE_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
856 FIXME(" ioctl unimplemented <%d>\n", driver_request
[2]);
860 /* setting error codes if any */
862 driver_request
[4] |= 0x80;
863 driver_request
[3] = Error
;
867 /* setting status bits
868 * 3 == playing && done
872 (data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_IN_PROGRESS
) ? 3 : 1;
875 static void MSCDEX_Handler(CONTEXT
* context
)
880 switch (LOBYTE(context
->Eax
)) {
881 case 0x00: /* Installation check */
882 /* Count the number of contiguous CDROM drives
884 for (drive
= count
= 0; drive
< 26; drive
++) {
885 if (is_cdrom(drive
)) {
886 while (is_cdrom(drive
+ count
)) count
++;
890 TRACE("Installation check: %d cdroms, starting at %d\n", count
, drive
);
891 SET_BX( context
, count
);
892 SET_CX( context
, (drive
< 26) ? drive
: 0 );
895 case 0x01: /* get drive device list */
897 CDROM_HEAP
* cdrom_heap
= CDROM_GetHeap();
898 CDROM_DEVICE_HEADER
* dev
= &cdrom_heap
->hdr
;
899 SEGPTR ptr_dev
= MAKESEGPTR( cdrom_heap
->cdrom_selector
, FIELD_OFFSET(CDROM_HEAP
, hdr
) );
901 p
= CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Ebx
);
902 for (drive
= 0; drive
< dev
->units
; drive
++) {
903 *p
= drive
; /* subunit */
905 *(DWORD
*)p
= ptr_dev
;
908 TRACE("Get drive device list\n");
912 case 0x0B: /* drive check */
913 SET_AX( context
, is_cdrom(CX_reg(context
)) );
914 SET_BX( context
, 0xADAD );
917 case 0x0C: /* get version */
918 SET_BX( context
, 0x020a );
919 TRACE("Version number => %04x\n", BX_reg(context
));
922 case 0x0D: /* get drive letters */
923 p
= CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Ebx
);
925 for (drive
= 0; drive
< 26; drive
++) {
926 if (is_cdrom(drive
)) *p
++ = drive
;
928 TRACE("Get drive letters\n");
931 case 0x10: /* direct driver access */
933 BYTE
* driver_request
;
934 CDROM_HEAP
* cdrom_heap
= CDROM_GetHeap();
936 if (!is_cdrom(CX_reg(context
))) {
937 WARN("Request made doesn't match a CD ROM drive (%d)\n", CX_reg(context
));
938 SET_CFLAG( context
);
939 SET_AX( context
, 0x000f ); /* invalid drive */
943 driver_request
= CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Ebx
);
945 if (!driver_request
) {
946 /* FIXME - to be deleted ?? */
947 ERR("ES:BX==0 ! SEGFAULT ?\n");
948 ERR("-->BX=0x%04x, ES=0x%04x, DS=0x%04x, CX=0x%04x\n",
949 BX_reg(context
), context
->SegEs
, context
->SegDs
, CX_reg(context
));
950 driver_request
[4] |= 0x80;
951 driver_request
[3] = 5; /* bad request length */
955 driver_request
[1] = CX_reg(context
) - cdrom_heap
->hdr
.drive
;
956 MSCDEX_Request(driver_request
);
960 FIXME("Unimplemented MSCDEX function 0x%02X.\n", LOBYTE(context
->Eax
));