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
27 #define WIN32_NO_STATUS
28 #define NONAMELESSUNION
29 #include "wine/winbase16.h"
30 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(int);
39 /* base KERNEL ordinal number for VxDs */
44 DOS_DEVICE_HEADER hdr
;
46 WORD reserved
; /* must be 0 */
47 BYTE drive
; /* drive letter (0=A:, 1=B:, ...) */
48 BYTE units
; /* number of supported units */
49 } CDROM_DEVICE_HEADER
;
53 CDROM_DEVICE_HEADER hdr
;
54 WORD cdrom_selector
; /* Protected mode selector for CDROM_HEAP */
57 static void do_int2f_16( CONTEXT
*context
);
58 static void MSCDEX_Handler( CONTEXT
*context
);
60 /**********************************************************************
63 * Handler for int 2fh (multiplex).
65 void WINAPI
DOSVM_Int2fHandler( CONTEXT
*context
)
67 TRACE("Subfunction 0x%X\n", AX_reg(context
));
69 switch(AH_reg(context
))
72 SET_AL( context
, 0xff ); /* share is installed */
75 case 0x11: /* Network Redirector / IFSFUNC */
76 switch (LOBYTE(context
->Eax
))
78 case 0x00: /* Install check */
81 case 0x80: /* Enhanced services - Install check */
85 INT_BARF( context
, 0x2f );
91 switch (LOBYTE(context
->Eax
))
93 case 0x2e: /* get or set DOS error table address */
94 switch (DL_reg(context
))
96 /* Four tables: even commands are 'get', odd are 'set' */
97 /* DOS 5.0+ ignores "set" commands */
104 /* Instead of having a message table in DOS-space, */
105 /* we can use a special case for MS-DOS to force */
106 /* the secondary interface. */
111 context
->SegEs
= 0x0001;
112 SET_DI( context
, 0x0000 );
115 FIXME("No real-mode handler for errors yet! (bye!)\n");
118 INT_BARF(context
, 0x2f);
122 INT_BARF(context
, 0x2f);
126 case 0x15: /* mscdex */
127 MSCDEX_Handler(context
);
131 do_int2f_16( context
);
134 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
135 /* Not supported yet, do nothing */
139 FIXME("check for XMS (not supported)\n");
140 SET_AL( context
, 0x42 ); /* != 0x80 */
144 switch (LOBYTE(context
->Eax
))
155 /* Microsoft Profiler - not installed */
158 INT_BARF( context
, 0x2f );
163 switch(LOBYTE(context
->Eax
))
165 case 0x10: /* smartdrv */
166 break; /* not installed */
167 case 0x11: /* dblspace */
168 break; /* not installed */
169 case 0x12: /* realtime compression interface */
170 break; /* not installed */
171 case 0x32: /* patch IO.SYS (???) */
172 break; /* we have no IO.SYS, so we can't patch it :-/ */
174 INT_BARF( context
, 0x2f );
178 switch(LOBYTE(context
->Eax
))
185 FIXME("Task Switcher - not implemented\n");
188 INT_BARF( context
, 0x2f );
191 case 0x56: /* INTERLNK */
192 switch(LOBYTE(context
->Eax
))
194 case 0x01: /* check if redirected drive */
195 SET_AL( context
, 0 ); /* not redirected */
198 INT_BARF( context
, 0x2f );
201 case 0x7a: /* NOVELL NetWare */
202 switch (LOBYTE(context
->Eax
))
204 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
205 SET_AL( context
, 0 );
207 case 0x20: /* Get VLM Call Address */
208 /* return nothing -> NetWare not installed */
211 INT_BARF( context
, 0x2f );
215 case 0xb7: /* append */
216 SET_AL( context
, 0 ); /* not installed */
218 case 0xb8: /* network */
219 switch (LOBYTE(context
->Eax
))
221 case 0x00: /* Install check */
225 INT_BARF( context
, 0x2f );
230 if (AL_reg(context
) == 0x00 && BX_reg(context
) == 0x3f3f) {
231 /* MVSOUND.SYS - Install check: not installed */
233 INT_BARF( context
, 0x2f );
236 case 0xbd: /* some Novell network install check ??? */
237 SET_AX( context
, 0xa5a5 ); /* pretend to have Novell IPX installed */
239 case 0xbf: /* REDIRIFS.EXE */
240 switch (LOBYTE(context
->Eax
))
242 case 0x00: /* Install check */
246 INT_BARF( context
, 0x2f );
251 switch(LOBYTE(context
->Eax
))
253 case 0x01: /* Quarterdeck RPCI - QEMM/QRAM - PCL-838.EXE functions */
254 if(BX_reg(context
) == 0x5145 && CX_reg(context
) == 0x4D4D
255 && DX_reg(context
) == 0x3432)
256 TRACE("Check for QEMM v5.0+ (not installed)\n");
259 INT_BARF( context
, 0x2f );
263 case 0xd7: /* Banyan Vines */
264 switch (LOBYTE(context
->Eax
))
266 case 0x01: /* Install check - Get Int Number */
270 INT_BARF( context
, 0x2f );
275 switch(LOBYTE(context
->Eax
))
277 case 0x01: /* Quarterdeck QDPMI.SYS - DESQview */
278 if(BX_reg(context
) == 0x4450 && CX_reg(context
) == 0x4d49
279 && DX_reg(context
) == 0x8f4f)
280 TRACE("Check for QDPMI.SYS (not installed)\n");
283 INT_BARF( context
, 0x2f );
287 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
290 INT_BARF( context
, 0x2f );
296 /**********************************************************************
299 static void do_int2f_16( CONTEXT
*context
)
303 switch(LOBYTE(context
->Eax
))
305 case 0x00: /* Windows enhanced mode installation check */
306 SET_AX( context
, LOWORD(GetVersion16()) );
309 case 0x0a: /* Get Windows version and type */
310 SET_AX( context
, 0 );
311 SET_BX( context
, (LOWORD(GetVersion16()) << 8) | (LOWORD(GetVersion16()) >> 8) );
312 SET_CX( context
, 3 );
315 case 0x0b: /* Identify Windows-aware TSRs */
316 /* we don't have any pre-Windows TSRs */
319 case 0x11: /* Get Shell Parameters - (SHELL= in CONFIG.SYS) */
320 /* We can mock this up. But not today... */
321 FIXME("Get Shell Parameters\n");
324 case 0x80: /* Release time-slice */
325 /* Linux sched_yield() still keeps burning CPU cycles
326 * if the current process is the only one in highest priority list
327 * (as Linux will immediately return to this process to waste
328 * more CPU cycles), so sched_yield() is essentially useless for us
329 * (poor API, if you ask me: its return code should indicate
330 * whether other processes did run in between, in order for us
331 * to be able to decide whether to do an additional Sleep() or not...)
332 * Thus we better unconditionally use a well-balanced Sleep()
333 * instead to really make sure the process calling int 0x2f/0x1680
334 * *doesn't* use 100% CPU...
336 Sleep(55); /* just wait 55ms (one "timer tick") for now. */
337 SET_AL( context
, 0 );
340 case 0x81: /* Begin critical section. */
344 case 0x82: /* End critical section. */
348 case 0x83: /* Return Current Virtual Machine ID */
349 /* Virtual Machines are usually created/destroyed when Windows runs
350 * DOS programs. Since we never do, we are always in the System VM.
351 * According to Ralf Brown's Interrupt List, never return 0. But it
352 * seems to work okay (returning 0), just to be sure we return 1.
354 SET_BX( context
, 1 ); /* VM 1 is probably the System VM */
357 case 0x84: /* Get device API entry point */
359 HMODULE16 mod
= GetModuleHandle16("kernel");
360 addr
= (DWORD
)GetProcAddress16( mod
, (LPCSTR
)(VXD_BASE
+ BX_reg(context
)) );
361 if (!addr
) /* not supported */
362 ERR("Accessing unknown VxD %04x - Expect a failure now.\n", BX_reg(context
) );
363 context
->SegEs
= SELECTOROF(addr
);
364 SET_DI( context
, OFFSETOF(addr
) );
368 case 0x86: /* DPMI detect mode */
369 SET_AX( context
, 0 ); /* Running under DPMI */
372 case 0x87: /* DPMI installation check */
376 SET_AX( context
, 0x0000 ); /* DPMI Installed */
377 SET_BX( context
, 0x0001 ); /* 32bits available */
378 SET_CL( context
, si
.wProcessorLevel
);
379 SET_DX( context
, 0x005a ); /* DPMI major/minor 0.90 */
380 SET_SI( context
, 0 ); /* # of para. of DOS extended private data */
381 context
->SegEs
= 0; /* no DPMI switch */
382 SET_DI( context
, 0 ); /* ES:DI is DPMI switch entry point */
385 case 0x8a: /* DPMI get vendor-specific API entry point. */
386 /* The 1.0 specs say this should work with all 0.9 hosts. */
390 INT_BARF( context
, 0x2f );
394 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
395 * must be <size> aligned
396 * <size> could be WORD, DWORD...
397 * in this case, we would need two macros, one for read, the other one for write
398 * Note: PTR_AT can be used as an l-value
400 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
402 #define CDFRAMES_PERSEC 75
403 #define CDFRAMES_PERMIN (CDFRAMES_PERSEC * 60)
404 #define FRAME_OF_ADDR(a) ((a)[1] * CDFRAMES_PERMIN + (a)[2] * CDFRAMES_PERSEC + (a)[3])
405 #define FRAME_OF_TOC(toc, idx) FRAME_OF_ADDR((toc).TrackData[idx - (toc).FirstTrack].Address)
406 #define CTRL_OF_TOC(toc, idx) (((toc).TrackData[idx - (toc).FirstTrack].Control << 4) | \
407 (toc).TrackData[idx - (toc).FirstTrack].Adr)
409 static void MSCDEX_StoreMSF(DWORD frame
, BYTE
* val
)
411 val
[3] = 0; /* zero */
412 val
[2] = frame
/ CDFRAMES_PERMIN
; /* minutes */
413 val
[1] = (frame
/ CDFRAMES_PERSEC
) % 60; /* seconds */
414 val
[0] = frame
% CDFRAMES_PERSEC
; /* frames */
417 static BOOL
is_cdrom(int drive
)
419 char root
[] = "A:\\";
421 return (GetDriveTypeA(root
) == DRIVE_CDROM
);
424 /***********************************************************************
427 * Initialize CDROM heap.
430 static void CDROM_FillHeap( CDROM_HEAP
*heap
)
434 /* Count the number of contiguous CDROM drives
436 for (drive
= count
= 0; drive
< 26; drive
++) {
437 if (is_cdrom(drive
)) {
438 while (is_cdrom(drive
+ count
)) count
++;
442 TRACE("Installation check: %d cdroms, starting at %d\n", count
, drive
);
443 heap
->hdr
.drive
= (drive
< 26) ? drive
: 0;
444 heap
->hdr
.units
= count
;
445 heap
->hdr
.reserved
= 0;
448 /**********************************************************************
451 * Get pointer for CDROM heap (CDROM_HEAP).
452 * Creates and initializes heap on first call.
454 static CDROM_HEAP
*CDROM_GetHeap( void )
456 static CDROM_HEAP
*heap_pointer
= NULL
;
460 WORD heap_selector
= GlobalAlloc16( GMEM_FIXED
| GMEM_ZEROINIT
, sizeof(CDROM_HEAP
) );
461 heap_pointer
= GlobalLock16( heap_selector
);
462 heap_pointer
->cdrom_selector
= heap_selector
;
463 CDROM_FillHeap( heap_pointer
);
469 static void MSCDEX_Request(BYTE
*driver_request
)
472 BYTE Error
= 255; /* No Error */
473 char devName
[] = "\\\\.\\@:";
476 CDROM_SUB_Q_DATA_FORMAT fmt
;
477 SUB_Q_CHANNEL_DATA data
;
482 * the following tests are wrong because lots of functions don't require the
483 * tray to be closed with a CD inside
485 TRACE("CDROM device driver -> command <%d>\n", driver_request
[2]);
487 /* set status to 0 */
488 PTR_AT(driver_request
, 3, WORD
) = 0;
489 devName
[4] = 'A' + CDROM_GetHeap()->hdr
.drive
+ driver_request
[1];
490 h
= CreateFileA(devName
, GENERIC_READ
, FILE_SHARE_READ
, NULL
, OPEN_EXISTING
, 0, 0);
491 if (h
== INVALID_HANDLE_VALUE
) {
492 WARN("Couldn't open cdrom handle\n");
493 driver_request
[4] |= 0x80;
494 driver_request
[3] = 1; /* unknown unit */
498 fmt
.Format
= IOCTL_CDROM_CURRENT_POSITION
;
499 if (!DeviceIoControl(h
, IOCTL_CDROM_READ_TOC
, NULL
, 0, &toc
, sizeof(toc
), &br
, NULL
) ||
500 !DeviceIoControl(h
, IOCTL_CDROM_READ_Q_CHANNEL
, &fmt
, sizeof(fmt
),
501 &data
, sizeof(data
), &br
, NULL
)) {
502 if (GetLastError() == STATUS_NO_MEDIA_IN_DEVICE
)
504 if (driver_request
[2] != 6 && driver_request
[2] != 15)
506 driver_request
[4] |= 0x80;
507 driver_request
[3] = 2; /* drive not ready */
515 driver_request
[4] |= 0x80;
516 driver_request
[3] = 1; /* unknown unit */
522 switch (driver_request
[2]) {
524 io_stru
= MapSL( MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
)));
526 TRACE(" --> IOCTL INPUT <%d>\n", io_stru
[0]);
527 switch (io_stru
[0]) {
529 case 0: /* Get device Header */
531 static LPSTR ptr
= 0;
533 ptr
= SEGPTR_ALLOC(22);
534 PTR_AT(ptr
, 0, DWORD
) = ~1; /* Next Device Driver */
535 PTR_AT(ptr
, 4, WORD
) = 0xC800; /* Device attributes */
536 PTR_AT(ptr
, 6, WORD
) = 0x1234; /* Pointer to device strategy routine: FIXME */
537 PTR_AT(ptr
, 8, WORD
) = 0x3142; /* Pointer to device interrupt routine: FIXME */
538 PTR_AT(ptr
, 10, char) = 'W'; /* 8-byte character device name field */
539 PTR_AT(ptr
, 11, char) = 'I';
540 PTR_AT(ptr
, 12, char) = 'N';
541 PTR_AT(ptr
, 13, char) = 'E';
542 PTR_AT(ptr
, 14, char) = '_';
543 PTR_AT(ptr
, 15, char) = 'C';
544 PTR_AT(ptr
, 16, char) = 'D';
545 PTR_AT(ptr
, 17, char) = '_';
546 PTR_AT(ptr
, 18, WORD
) = 0; /* Reserved (must be zero) */
547 PTR_AT(ptr
, 20, BYTE
) = 0; /* Drive letter (must be zero) */
548 PTR_AT(ptr
, 21, BYTE
) = 1; /* Number of units supported (one or more) FIXME*/
550 PTR_AT(io_stru
, DWORD
, 0) = SEGPTR_GET(ptr
);
555 case 1: /* location of head */
556 switch (io_stru
[1]) {
558 PTR_AT(io_stru
, 2, DWORD
) =
559 FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
);
562 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
),
566 ERR("CD-ROM driver: unsupported addressing mode !!\n");
569 TRACE(" ----> HEAD LOCATION <%d>\n", PTR_AT(io_stru
, 2, DWORD
));
572 case 4: /* Audio channel info */
581 TRACE(" ----> AUDIO CHANNEL INFO\n");
584 case 6: /* device status */
585 PTR_AT(io_stru
, 1, DWORD
) = 0x00000290;
587 * 1 Supports HSG and Red Book addressing modes
588 * 0 Supports audio channel manipulation
590 * 1 Supports prefetching requests
593 * 1 Data read and plays audio/video tracks
596 * 0 Supports only cooked reading
598 * 0 see below (Door closed/opened)
600 if (!present
) PTR_AT(io_stru
, 1, DWORD
) |= 1;
601 TRACE(" ----> DEVICE STATUS <0x%08x>\n", PTR_AT(io_stru
, 1, DWORD
));
604 case 8: /* Volume size */
605 PTR_AT(io_stru
, 1, DWORD
) = FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1) -
606 FRAME_OF_TOC(toc
, toc
.FirstTrack
) - 1;
607 TRACE(" ----> VOLUME SIZE <%d>\n", PTR_AT(io_stru
, 1, DWORD
));
610 case 9: /* media changed ? */
611 /* answers don't know... -1/1 for yes/no would be better */
612 io_stru
[1] = 0; /* FIXME? 1? */
613 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru
[1]);
616 case 10: /* audio disk info */
617 io_stru
[1] = toc
.FirstTrack
; /* starting track of the disc */
618 io_stru
[2] = toc
.LastTrack
; /* ending track */
619 MSCDEX_StoreMSF(FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1) -
620 FRAME_OF_TOC(toc
, toc
.FirstTrack
) - 1, io_stru
+ 3);
622 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08x>\n",
623 io_stru
[1], io_stru
[2], PTR_AT(io_stru
, 3, DWORD
));
626 case 11: /* audio track info */
627 if (io_stru
[1] >= toc
.FirstTrack
&& io_stru
[1] <= toc
.LastTrack
) {
628 MSCDEX_StoreMSF(FRAME_OF_TOC(toc
, io_stru
[1]), io_stru
+ 2);
629 /* starting point if the track */
630 io_stru
[6] = CTRL_OF_TOC(toc
, io_stru
[1]);
632 PTR_AT(io_stru
, 2, DWORD
) = 0;
635 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08x:%d]\n",
636 io_stru
[1], PTR_AT(io_stru
, 2, DWORD
), io_stru
[6]);
639 case 12: /* get Q-Channel info */
640 io_stru
[1] = CTRL_OF_TOC(toc
, data
.CurrentPosition
.TrackNumber
);
641 io_stru
[2] = data
.CurrentPosition
.TrackNumber
;
642 io_stru
[3] = 0; /* FIXME ?? */
644 /* why the heck did MS use another format for 0MSF information... sigh */
648 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.TrackRelativeAddress
), bTmp
);
649 io_stru
[ 4] = bTmp
[2];
650 io_stru
[ 5] = bTmp
[1];
651 io_stru
[ 6] = bTmp
[0];
654 MSCDEX_StoreMSF(FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
), bTmp
);
655 io_stru
[ 8] = bTmp
[2];
656 io_stru
[ 9] = bTmp
[1];
657 io_stru
[10] = bTmp
[0];
660 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08x, tp=%08x)\n",
661 io_stru
[ 1], io_stru
[ 2], io_stru
[ 3],
662 io_stru
[ 4], io_stru
[ 5], io_stru
[ 6],
663 io_stru
[ 8], io_stru
[ 9], io_stru
[10],
664 FRAME_OF_ADDR(data
.CurrentPosition
.AbsoluteAddress
),
665 FRAME_OF_TOC(toc
, data
.CurrentPosition
.TrackNumber
));
668 case 15: /* Audio status info */
669 /* !!!! FIXME FIXME FIXME !! */
670 PTR_AT(io_stru
, 1, WORD
) = 2 | ((data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_PAUSED
) ? 1 : 0);
672 PTR_AT(io_stru
, 3, DWORD
) = 0;
673 PTR_AT(io_stru
, 7, DWORD
) = 0;
675 PTR_AT(io_stru
, 3, DWORD
) = FRAME_OF_TOC(toc
, toc
.FirstTrack
);
676 PTR_AT(io_stru
, 7, DWORD
) = FRAME_OF_TOC(toc
, toc
.LastTrack
+ 1);
678 TRACE("Audio status info: status=%04x startLoc=%d endLoc=%d\n",
679 PTR_AT(io_stru
, 1, WORD
), PTR_AT(io_stru
, 3, DWORD
), PTR_AT(io_stru
, 7, DWORD
));
683 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru
[0]);
690 io_stru
= MapSL( MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
), PTR_AT(driver_request
, 14, WORD
)));
692 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru
[0]);
693 switch (io_stru
[0]) {
695 DeviceIoControl(h
, IOCTL_STORAGE_EJECT_MEDIA
, NULL
, 0, NULL
, 0, &br
, NULL
);
696 TRACE(" ----> EJECT\n");
698 case 2: /* reset drive */
699 DeviceIoControl(h
, IOCTL_STORAGE_RESET_DEVICE
, NULL
, 0, NULL
, 0, &br
, NULL
);
700 TRACE(" ----> RESET\n");
702 case 3: /* Audio Channel Control */
703 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
705 case 5: /* close tray */
706 DeviceIoControl(h
, IOCTL_STORAGE_LOAD_MEDIA
, NULL
, 0, NULL
, 0, &br
, NULL
);
707 TRACE(" ----> CLOSE TRAY\n");
710 FIXME(" IOCTL OUTPUT: Unimplemented <%d>!!\n", io_stru
[0]);
716 case 128: /* read long */
718 LPVOID dst
= MapSL(MAKESEGPTR(PTR_AT(driver_request
, 16, WORD
),
719 PTR_AT(driver_request
, 14, WORD
)));
720 DWORD at
= PTR_AT(driver_request
, 20, DWORD
);
721 WORD num
= PTR_AT(driver_request
, 18, WORD
);
724 switch (driver_request
[13]) {
725 case 1: /* Red book addressing mode = 0:m:s:f */
726 /* FIXME : frame <=> msf conversion routines could be shared
727 * between mscdex and mcicda
729 at
= LOBYTE(HIWORD(at
)) * CDFRAMES_PERMIN
+
730 HIBYTE(LOWORD(at
)) * CDFRAMES_PERSEC
+
733 case 0: /* HSG addressing mode */
734 switch (PTR_AT(driver_request
, 24, BYTE
))
737 ReadFile(h
, dst
, num
* 2048, &br
, NULL
);
740 /* FIXME: computation is wrong */
741 rri
.DiskOffset
.u
.HighPart
= 0;
742 rri
.DiskOffset
.u
.LowPart
= at
<< 11;
743 rri
.TrackMode
= YellowMode2
;
744 rri
.SectorCount
= num
;
745 DeviceIoControl(h
, IOCTL_CDROM_RAW_READ
, &rri
, sizeof(rri
),
746 dst
, num
* 2352, &br
, NULL
);
749 ERR("Unsupported read mode !!\n");
755 ERR("Unsupported address mode !!\n");
765 CDROM_SEEK_AUDIO_MSF seek
;
767 at
= PTR_AT(driver_request
, 20, DWORD
);
769 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%d]\n", driver_request
[13], at
);
771 switch (driver_request
[13]) {
772 case 1: /* Red book addressing mode = 0:m:s:f */
773 /* FIXME : frame <=> msf conversion routines could be shared
774 * between mscdex and mcicda
776 at
= LOBYTE(HIWORD(at
)) * CDFRAMES_PERMIN
+
777 HIBYTE(LOWORD(at
)) * CDFRAMES_PERSEC
+
780 case 0: /* HSG addressing mode */
781 seek
.M
= at
/ CDFRAMES_PERMIN
;
782 seek
.S
= (at
/ CDFRAMES_PERSEC
) % 60;
783 seek
.F
= at
% CDFRAMES_PERSEC
;
784 DeviceIoControl(h
, IOCTL_CDROM_SEEK_AUDIO_MSF
, &seek
, sizeof(seek
),
788 ERR("Unsupported address mode !!\n");
798 CDROM_PLAY_AUDIO_MSF play
;
800 beg
= end
= PTR_AT(driver_request
, 14, DWORD
);
801 end
+= PTR_AT(driver_request
, 18, DWORD
);
803 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%d-%d]\n", driver_request
[13], beg
, end
);
805 switch (driver_request
[13]) {
807 /* Red book addressing mode = 0:m:s:f */
808 /* FIXME : frame <=> msf conversion routines could be shared
809 * between mscdex and mcicda
811 beg
= LOBYTE(LOWORD(beg
)) * CDFRAMES_PERMIN
+
812 HIBYTE(LOWORD(beg
)) * CDFRAMES_PERSEC
+
814 end
= LOBYTE(LOWORD(end
)) * CDFRAMES_PERMIN
+
815 HIBYTE(LOWORD(end
)) * CDFRAMES_PERSEC
+
818 case 0: /* HSG addressing mode */
819 play
.StartingM
= beg
/ CDFRAMES_PERMIN
;
820 play
.StartingS
= (beg
/ CDFRAMES_PERSEC
) % 60;
821 play
.StartingF
= beg
% CDFRAMES_PERSEC
;
822 play
.EndingM
= end
/ CDFRAMES_PERMIN
;
823 play
.EndingS
= (end
/ CDFRAMES_PERSEC
) % 60;
824 play
.EndingF
= end
% CDFRAMES_PERSEC
;
825 DeviceIoControl(h
, IOCTL_CDROM_PLAY_AUDIO_MSF
, &play
, sizeof(play
),
829 ERR("Unsupported address mode !!\n");
837 if (data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_IN_PROGRESS
) {
838 DeviceIoControl(h
, IOCTL_CDROM_PAUSE_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
839 TRACE(" --> STOP AUDIO (Paused)\n");
841 DeviceIoControl(h
, IOCTL_CDROM_STOP_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
842 TRACE(" --> STOP AUDIO (Stopped)\n");
847 TRACE(" --> RESUME AUDIO\n");
848 DeviceIoControl(h
, IOCTL_CDROM_PAUSE_AUDIO
, NULL
, 0, NULL
, 0, &br
, NULL
);
852 FIXME(" ioctl unimplemented <%d>\n", driver_request
[2]);
856 /* setting error codes if any */
858 driver_request
[4] |= 0x80;
859 driver_request
[3] = Error
;
863 /* setting status bits
864 * 3 == playing && done
868 (data
.CurrentPosition
.Header
.AudioStatus
== AUDIO_STATUS_IN_PROGRESS
) ? 3 : 1;
871 static void MSCDEX_Handler(CONTEXT
* context
)
876 switch (LOBYTE(context
->Eax
)) {
877 case 0x00: /* Installation check */
878 /* Count the number of contiguous CDROM drives
880 for (drive
= count
= 0; drive
< 26; drive
++) {
881 if (is_cdrom(drive
)) {
882 while (is_cdrom(drive
+ count
)) count
++;
886 TRACE("Installation check: %d cdroms, starting at %d\n", count
, drive
);
887 SET_BX( context
, count
);
888 SET_CX( context
, (drive
< 26) ? drive
: 0 );
891 case 0x01: /* get drive device list */
893 CDROM_HEAP
* cdrom_heap
= CDROM_GetHeap();
894 CDROM_DEVICE_HEADER
* dev
= &cdrom_heap
->hdr
;
895 SEGPTR ptr_dev
= MAKESEGPTR( cdrom_heap
->cdrom_selector
, FIELD_OFFSET(CDROM_HEAP
, hdr
) );
897 p
= CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Ebx
);
898 for (drive
= 0; drive
< dev
->units
; drive
++) {
899 *p
= drive
; /* subunit */
901 *(DWORD
*)p
= ptr_dev
;
904 TRACE("Get drive device list\n");
908 case 0x0B: /* drive check */
909 SET_AX( context
, is_cdrom(CX_reg(context
)) );
910 SET_BX( context
, 0xADAD );
913 case 0x0C: /* get version */
914 SET_BX( context
, 0x020a );
915 TRACE("Version number => %04x\n", BX_reg(context
));
918 case 0x0D: /* get drive letters */
919 p
= CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Ebx
);
921 for (drive
= 0; drive
< 26; drive
++) {
922 if (is_cdrom(drive
)) *p
++ = drive
;
924 TRACE("Get drive letters\n");
927 case 0x10: /* direct driver access */
929 BYTE
* driver_request
;
930 CDROM_HEAP
* cdrom_heap
= CDROM_GetHeap();
932 if (!is_cdrom(CX_reg(context
))) {
933 WARN("Request made doesn't match a CD ROM drive (%d)\n", CX_reg(context
));
934 SET_CFLAG( context
);
935 SET_AX( context
, 0x000f ); /* invalid drive */
939 driver_request
= CTX_SEG_OFF_TO_LIN(context
, context
->SegEs
, context
->Ebx
);
941 if (!driver_request
) {
942 /* FIXME - to be deleted ?? */
943 ERR("ES:BX==0 ! SEGFAULT ?\n");
944 ERR("-->BX=0x%04x, ES=0x%04x, DS=0x%04x, CX=0x%04x\n",
945 BX_reg(context
), context
->SegEs
, context
->SegDs
, CX_reg(context
));
946 driver_request
[4] |= 0x80;
947 driver_request
[3] = 5; /* bad request length */
951 driver_request
[1] = CX_reg(context
) - cdrom_heap
->hdr
.drive
;
952 MSCDEX_Request(driver_request
);
956 FIXME("Unimplemented MSCDEX function 0x%02X.\n", LOBYTE(context
->Eax
));