Removed obsolete files no longer in use.
[wine/dcerpc.git] / msdos / int2f.c
blob2b77bf9b23dbe032d27b796b63bbdf9601bb8559
1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */
2 /*
3 * DOS interrupt 2fh handler
5 * Cdrom - device driver emulation - Audio features.
6 * (c) 1998 Petr Tomasek <tomasek@etf.cuni.cz>
7 * (c) 1999 Eric Pouech
8 */
10 #include <stdlib.h>
11 #include <string.h>
12 #include <unistd.h>
14 #include "wine/winbase16.h"
15 #include "ldt.h"
16 #include "drive.h"
17 #include "msdos.h"
18 #include "miscemu.h"
19 #include "module.h"
20 #include "task.h"
21 #include "dosexe.h"
22 #include "heap.h"
23 /* #define DEBUG_INT */
24 #include "debugtools.h"
25 #include "cdrom.h"
27 DEFAULT_DEBUG_CHANNEL(int)
29 /* base WPROCS.DLL ordinal number for VxDs */
30 #define VXD_BASE 400
32 static void do_int2f_16( CONTEXT86 *context );
33 static void MSCDEX_Handler( CONTEXT86 *context );
35 /**********************************************************************
36 * INT_Int2fHandler
38 * Handler for int 2fh (multiplex).
40 void WINAPI INT_Int2fHandler( CONTEXT86 *context )
42 TRACE("Subfunction 0x%X\n", AX_reg(context));
44 switch(AH_reg(context))
46 case 0x10:
47 AL_reg(context) = 0xff; /* share is installed */
48 break;
50 case 0x11: /* Network Redirector / IFSFUNC */
51 switch (AL_reg(context))
53 case 0x00: /* Install check */
54 /* not installed */
55 break;
56 case 0x80: /* Enhanced services - Install check */
57 /* not installed */
58 break;
59 default:
60 INT_BARF( context, 0x2f );
61 break;
63 break;
65 case 0x12:
66 switch (AL_reg(context))
68 case 0x2e: /* get or set DOS error table address */
69 switch (DL_reg(context))
71 /* Four tables: even commands are 'get', odd are 'set' */
72 /* DOS 5.0+ ignores "set" commands */
73 case 0x01:
74 case 0x03:
75 case 0x05:
76 case 0x07:
77 case 0x09:
78 break;
79 /* Instead of having a message table in DOS-space, */
80 /* we can use a special case for MS-DOS to force */
81 /* the secondary interface. */
82 case 0x00:
83 case 0x02:
84 case 0x04:
85 case 0x06:
86 ES_reg(context) = 0x0001;
87 DI_reg(context) = 0x0000;
88 break;
89 case 0x08:
90 FIXME("No real-mode handler for errors yet! (bye!)");
91 break;
92 default:
93 INT_BARF(context, 0x2f);
95 break;
96 default:
97 INT_BARF(context, 0x2f);
99 break;
101 case 0x15: /* mscdex */
102 MSCDEX_Handler(context);
103 break;
105 case 0x16:
106 do_int2f_16( context );
107 break;
109 case 0x1a: /* ANSI.SYS / AVATAR.SYS Install Check */
110 /* Not supported yet, do nothing */
111 break;
113 case 0x43:
114 #if 1
115 switch (AL_reg(context))
117 case 0x00: /* XMS v2+ installation check */
118 WARN("XMS is not fully implemented\n");
119 AL_reg(context) = 0x80;
120 break;
121 case 0x10: /* XMS v2+ get driver address */
123 #ifdef MZ_SUPPORTED
124 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
125 NE_MODULE *pModule = pTask ? NE_GetPtr( pTask->hModule ) : NULL;
126 GlobalUnlock16( GetCurrentTask() );
128 if (pModule && pModule->lpDosTask)
129 ES_reg(context) = pModule->lpDosTask->xms_seg;
130 else
131 #endif
132 ES_reg(context) = 0;
133 BX_reg(context) = 0;
134 break;
136 default:
137 INT_BARF( context, 0x2f );
139 #else
140 FIXME("check for XMS (not supported)\n");
141 AL_reg(context) = 0x42; /* != 0x80 */
142 #endif
143 break;
145 case 0x45:
146 switch (AL_reg(context))
148 case 0x00:
149 case 0x01:
150 case 0x02:
151 case 0x03:
152 case 0x04:
153 case 0x05:
154 case 0x06:
155 case 0x07:
156 case 0x08:
157 /* Microsoft Profiler - not installed */
158 break;
159 default:
160 INT_BARF( context, 0x2f );
162 break;
164 case 0x4a:
165 switch(AL_reg(context))
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 :-/ */
175 default:
176 INT_BARF( context, 0x2f );
178 break;
179 case 0x4b:
180 switch(AL_reg(context))
182 case 0x01:
183 case 0x02:
184 case 0x03:
185 case 0x04:
186 case 0x05:
187 FIXME("Task Switcher - not implemented\n");
188 break;
189 default:
190 INT_BARF( context, 0x2f );
192 break;
193 case 0x56: /* INTERLNK */
194 switch(AL_reg(context))
196 case 0x01: /* check if redirected drive */
197 AL_reg(context) = 0; /* not redirected */
198 break;
199 default:
200 INT_BARF( context, 0x2f );
202 break;
203 case 0x7a: /* NOVELL NetWare */
204 switch (AL_reg(context))
206 case 0x0: /* Low-level Netware installation check AL=0 not installed.*/
207 AL_reg(context) = 0;
208 break;
209 case 0x20: /* Get VLM Call Address */
210 /* return nothing -> NetWare not installed */
211 break;
212 default:
213 INT_BARF( context, 0x2f );
214 break;
216 break;
217 case 0xb7: /* append */
218 AL_reg(context) = 0; /* not installed */
219 break;
220 case 0xb8: /* network */
221 switch (AL_reg(context))
223 case 0x00: /* Install check */
224 /* not installed */
225 break;
226 default:
227 INT_BARF( context, 0x2f );
228 break;
230 break;
231 case 0xbd: /* some Novell network install check ??? */
232 AX_reg(context) = 0xa5a5; /* pretend to have Novell IPX installed */
233 break;
234 case 0xbf: /* REDIRIFS.EXE */
235 switch (AL_reg(context))
237 case 0x00: /* Install check */
238 /* not installed */
239 break;
240 default:
241 INT_BARF( context, 0x2f );
242 break;
244 break;
245 case 0xd2:
246 switch(AL_reg(context))
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");
252 break;
253 default:
254 INT_BARF( context, 0x2f );
255 break;
257 break;
258 case 0xd7: /* Banyan Vines */
259 switch (AL_reg(context))
261 case 0x01: /* Install check - Get Int Number */
262 /* not installed */
263 break;
264 default:
265 INT_BARF( context, 0x2f );
266 break;
268 break;
269 case 0xde:
270 switch(AL_reg(context))
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");
276 break;
277 default:
278 INT_BARF( context, 0x2f );
279 break;
281 break;
282 case 0xfa: /* Watcom debugger check, returns 0x666 if installed */
283 break;
284 default:
285 INT_BARF( context, 0x2f );
286 break;
291 /**********************************************************************
292 * do_int2f_16
294 static void do_int2f_16( CONTEXT86 *context )
296 DWORD addr;
298 switch(AL_reg(context))
300 case 0x00: /* Windows enhanced mode installation check */
301 AX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ?
302 LOWORD(GetVersion16()) : 0;
303 break;
305 case 0x0a: /* Get Windows version and type */
306 AX_reg(context) = 0;
307 BX_reg(context) = (LOWORD(GetVersion16()) << 8) |
308 (LOWORD(GetVersion16()) >> 8);
309 CX_reg(context) = (GetWinFlags16() & WF_ENHANCED) ? 3 : 2;
310 break;
312 case 0x0b: /* Identify Windows-aware TSRs */
313 /* we don't have any pre-Windows TSRs */
314 break;
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");
319 break;
321 case 0x80: /* Release time-slice */
322 AL_reg(context) = 0;
323 break;
325 case 0x81: /* Begin critical section. */
326 /* FIXME? */
327 break;
329 case 0x82: /* End critical section. */
330 /* FIXME? */
331 break;
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 */
340 break;
342 case 0x84: /* Get device API entry point */
343 addr = (DWORD)NE_GetEntryPoint( GetModuleHandle16("WPROCS"),
344 VXD_BASE + BX_reg(context) );
345 if (!addr) /* not supported */
347 ERR("Accessing unknown VxD %04x - Expect a failure now.\n",
348 BX_reg(context) );
350 ES_reg(context) = SELECTOROF(addr);
351 DI_reg(context) = OFFSETOF(addr);
352 break;
354 case 0x86: /* DPMI detect mode */
355 AX_reg(context) = 0; /* Running under DPMI */
356 break;
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 */
361 #endif
363 SYSTEM_INFO si;
364 #ifdef MZ_SUPPORTED
365 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
366 NE_MODULE *pModule = pTask ? NE_GetPtr( pTask->hModule ) : NULL;
368 GlobalUnlock16( GetCurrentTask() );
369 #endif
371 GetSystemInfo(&si);
372 AX_reg(context) = 0x0000; /* DPMI Installed */
373 BX_reg(context) = 0x0001; /* 32bits available */
374 CL_reg(context) = si.wProcessorLevel;
375 DX_reg(context) = 0x005a; /* DPMI major/minor 0.90 */
376 SI_reg(context) = 0; /* # of para. of DOS extended private data */
377 #ifdef MZ_SUPPORTED /* ES:DI is DPMI switch entry point */
378 if (pModule && pModule->lpDosTask)
379 ES_reg(context) = pModule->lpDosTask->dpmi_seg;
380 else
381 #endif
382 ES_reg(context) = 0;
383 DI_reg(context) = 0;
384 break;
386 case 0x8a: /* DPMI get vendor-specific API entry point. */
387 /* The 1.0 specs say this should work with all 0.9 hosts. */
388 break;
390 default:
391 INT_BARF( context, 0x2f );
395 /* FIXME: this macro may have to be changed on architectures where <size> reads/writes
396 * must be <size> aligned
397 * <size> could be WORD, DWORD...
398 * in this case, we would need two macros, one for read, the other one for write
399 * Note: PTR_AT can be used as an l-value
401 #define PTR_AT(_ptr, _ofs, _typ) (*((_typ*)(((char*)_ptr)+(_ofs))))
403 /* Use #if 1 if you want full int 2f debug... normal users can leave it at 0 */
404 #if 0
405 /**********************************************************************
406 * MSCDEX_Dump [internal]
408 * Dumps mscdex requests to int debug channel.
410 static void MSCDEX_Dump(char* pfx, BYTE* req, int dorealmode)
412 int i;
413 BYTE buf[2048];
414 BYTE* ptr;
415 BYTE* ios;
417 ptr = buf;
418 ptr += sprintf(ptr, "%s\tCommand => ", pfx);
419 for (i = 0; i < req[0]; i++) {
420 ptr += sprintf(ptr, "%02x ", req[i]);
423 switch (req[2]) {
424 case 3:
425 case 12:
426 ptr += sprintf(ptr, "\n\t\t\t\tIO_struct => ");
427 ios = (dorealmode) ?
428 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(req, 14, WORD), PTR_AT(req, 16, WORD))) :
429 PTR_SEG_OFF_TO_LIN(PTR_AT(req, 16, WORD), PTR_AT(req, 14, WORD));
431 for (i = 0; i < PTR_AT(req, 18, WORD); i++) {
432 ptr += sprintf(ptr, "%02x ", ios[i]);
433 if ((i & 0x1F) == 0x1F) {
434 *ptr++ = '\n';
435 *ptr = 0;
438 break;
440 TRACE("%s\n", buf);
442 #else
443 #define MSCDEX_Dump(pfx, req, drm)
444 #endif
446 static void MSCDEX_StoreMSF(DWORD frame, BYTE* val)
448 val[3] = 0; /* zero */
449 val[2] = frame / CDFRAMES_PERMIN; /* minutes */
450 val[1] = (frame - CDFRAMES_PERMIN * val[2]) / CDFRAMES_PERSEC; /* seconds */
451 val[0] = frame - CDFRAMES_PERMIN * val[2] - CDFRAMES_PERSEC * val[1]; /* frames */
454 static void MSCDEX_Handler(CONTEXT86* context)
456 int drive, count;
457 char* p;
459 switch(AL_reg(context)) {
460 case 0x00: /* Installation check */
461 /* Count the number of contiguous CDROM drives
463 for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++) {
464 if (DRIVE_GetType(drive) == TYPE_CDROM) {
465 while (DRIVE_GetType(drive + count) == TYPE_CDROM) count++;
466 break;
469 TRACE("Installation check: %d cdroms, starting at %d\n", count, drive);
470 BX_reg(context) = count;
471 CX_reg(context) = (drive < MAX_DOS_DRIVES) ? drive : 0;
472 break;
474 case 0x0B: /* drive check */
475 AX_reg(context) = (DRIVE_GetType(CX_reg(context)) == TYPE_CDROM);
476 BX_reg(context) = 0xADAD;
477 break;
479 case 0x0C: /* get version */
480 BX_reg(context) = 0x020a;
481 TRACE("Version number => %04x\n", BX_reg(context));
482 break;
484 case 0x0D: /* get drive letters */
485 p = CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EBX_reg(context));
486 memset(p, 0, MAX_DOS_DRIVES);
487 for (drive = 0; drive < MAX_DOS_DRIVES; drive++) {
488 if (DRIVE_GetType(drive) == TYPE_CDROM) *p++ = drive;
490 TRACE("Get drive letters\n");
491 break;
493 case 0x10: /* direct driver acces */
495 static WINE_CDAUDIO wcda;
496 BYTE* driver_request;
497 BYTE* io_stru;
498 BYTE Error = 255; /* No Error */
499 int dorealmode = ISV86(context);
501 driver_request = (dorealmode) ?
502 DOSMEM_MapRealToLinear(MAKELONG(BX_reg(context), ES_reg(context))) :
503 PTR_SEG_OFF_TO_LIN(ES_reg(context), BX_reg(context));
505 if (!driver_request) {
506 /* FIXME - to be deleted ?? */
507 ERR("ES:BX==0 ! SEGFAULT ?\n");
508 ERR("-->BX=0x%04x, ES=0x%04lx, DS=0x%04lx, CX=0x%04x\n",
509 BX_reg(context), ES_reg(context), DS_reg(context), CX_reg(context));
510 driver_request[4] |= 0x80;
511 driver_request[3] = 5; /* bad request length */
512 return;
514 /* FIXME - would be better to open the device at the begining of the wine session...
515 * - the device is also never closed...
516 * - the current implementation only supports a single CD ROM
518 if (wcda.unixdev <= 0)
519 CDAUDIO_Open(&wcda);
520 TRACE("CDROM device driver -> command <%d>\n", (unsigned char)driver_request[2]);
522 for (drive = 0;
523 drive < MAX_DOS_DRIVES && DRIVE_GetType(drive) != TYPE_CDROM;
524 drive++);
525 /* drive contains the first CD ROM */
526 if (CX_reg(context) != drive) {
527 WARN("Request made doesn't match a CD ROM drive (%d/%d)\n", CX_reg(context), drive);
528 driver_request[4] |= 0x80;
529 driver_request[3] = 1; /* unknown unit */
530 return;
533 MSCDEX_Dump("Beg", driver_request, dorealmode);
535 /* set status to 0 */
536 PTR_AT(driver_request, 3, WORD) = 0;
537 CDAUDIO_GetCDStatus(&wcda);
539 switch (driver_request[2]) {
540 case 3:
541 io_stru = (dorealmode) ?
542 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) :
543 PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
545 TRACE(" --> IOCTL INPUT <%d>\n", io_stru[0]);
546 switch (io_stru[0]) {
547 #if 0
548 case 0: /* Get device Header */
550 static LPSTR ptr = 0;
551 if (ptr == 0) {
552 ptr = SEGPTR_ALLOC(22);
553 PTR_AT(ptr, 0, DWORD) = ~1; /* Next Device Driver */
554 PTR_AT(ptr, 4, WORD) = 0xC800; /* Device attributes */
555 PTR_AT(ptr, 6, WORD) = 0x1234; /* Pointer to device strategy routine: FIXME */
556 PTR_AT(ptr, 8, WORD) = 0x3142; /* Pointer to device interrupt routine: FIXME */
557 PTR_AT(ptr, 10, char) = 'W'; /* 8-byte character device name field */
558 PTR_AT(ptr, 11, char) = 'I';
559 PTR_AT(ptr, 12, char) = 'N';
560 PTR_AT(ptr, 13, char) = 'E';
561 PTR_AT(ptr, 14, char) = '_';
562 PTR_AT(ptr, 15, char) = 'C';
563 PTR_AT(ptr, 16, char) = 'D';
564 PTR_AT(ptr, 17, char) = '_';
565 PTR_AT(ptr, 18, WORD) = 0; /* Reserved (must be zero) */
566 PTR_AT(ptr, 20, BYTE) = 0; /* Drive letter (must be zero) */
567 PTR_AT(ptr, 21, BYTE) = 1; /* Number of units supported (one or more) FIXME*/
569 PTR_AT(io_stru, DWORD, 0) = SEGPTR_GET(ptr);
571 break;
572 #endif
574 case 1: /* location of head */
575 switch (io_stru[1]) {
576 case 0:
577 PTR_AT(io_stru, 2, DWORD) = wcda.dwCurFrame;
578 break;
579 case 1:
580 MSCDEX_StoreMSF(wcda.dwCurFrame, io_stru + 2);
581 break;
582 default:
583 ERR("CDRom-Driver: Unsupported addressing mode !!\n");
584 Error = 0x0c;
586 TRACE(" ----> HEAD LOCATION <%ld>\n", PTR_AT(io_stru, 2, DWORD));
587 break;
589 case 4: /* Audio channel info */
590 io_stru[1] = 0;
591 io_stru[2] = 0xff;
592 io_stru[3] = 1;
593 io_stru[4] = 0xff;
594 io_stru[5] = 2;
595 io_stru[6] = 0;
596 io_stru[7] = 3;
597 io_stru[8] = 0;
598 TRACE(" ----> AUDIO CHANNEL INFO\n");
599 break;
601 case 6: /* device status */
602 PTR_AT(io_stru, 1, DWORD) = 0x00000290;
603 /* 290 =>
604 * 1 Supports HSG and Red Book addressing modes
605 * 0 Supports audio channel manipulation
607 * 1 Supports prefetching requests
608 * 0 Reserved
609 * 0 No interleaving
610 * 1 Data read and plays audio/video tracks
612 * 0 Read only
613 * 0 Supports only cooked reading
614 * 0 Door locked
615 * 0 see below (Door closed/opened)
617 if (wcda.cdaMode == WINE_CDA_OPEN)
618 io_stru[1] |= 1;
619 TRACE(" ----> DEVICE STATUS <0x%08lx>\n", PTR_AT(io_stru, 1, DWORD));
620 break;
622 case 8: /* Volume size */
623 PTR_AT(io_stru, 1, DWORD) = wcda.dwTotalLen;
624 TRACE(" ----> VOLUME SIZE <%ld>\n", PTR_AT(io_stru, 1, DWORD));
625 break;
627 case 9: /* media changed ? */
628 /* answers don't know... -1/1 for yes/no would be better */
629 io_stru[1] = 0; /* FIXME? 1? */
630 TRACE(" ----> MEDIA CHANGED <%d>\n", io_stru[1]);
631 break;
633 case 10: /* audio disk info */
634 io_stru[1] = wcda.nFirstTrack; /* starting track of the disc */
635 io_stru[2] = wcda.nLastTrack; /* ending track */
636 MSCDEX_StoreMSF(wcda.dwTotalLen, io_stru + 3);
638 TRACE(" ----> AUDIO DISK INFO <%d-%d/%08lx>\n",
639 io_stru[1], io_stru[2], PTR_AT(io_stru, 3, DWORD));
640 break;
642 case 11: /* audio track info */
643 if (io_stru[1] >= wcda.nFirstTrack && io_stru[1] <= wcda.nLastTrack) {
644 int nt = io_stru[1] - wcda.nFirstTrack;
645 MSCDEX_StoreMSF(wcda.lpdwTrackPos[nt], io_stru + 2);
646 /* starting point if the track */
647 io_stru[6] = (wcda.lpbTrackFlags[nt] & 0xF0) >> 4;
648 } else {
649 PTR_AT(io_stru, 2, DWORD) = 0;
650 io_stru[6] = 0;
652 TRACE(" ----> AUDIO TRACK INFO[%d] = [%08lx:%d]\n",
653 io_stru[1], PTR_AT(io_stru, 2, DWORD), io_stru[6]);
654 break;
656 case 12: /* get Q-Channel info */
657 io_stru[1] = wcda.lpbTrackFlags[wcda.nCurTrack - 1];
658 io_stru[2] = wcda.nCurTrack;
659 io_stru[3] = 0; /* FIXME ?? */
661 /* why the heck did MS use another format for 0MSF information... sigh */
663 BYTE bTmp[4];
665 MSCDEX_StoreMSF(wcda.dwCurFrame - wcda.lpdwTrackPos[wcda.nCurTrack - 1], bTmp);
666 io_stru[ 4] = bTmp[2];
667 io_stru[ 5] = bTmp[1];
668 io_stru[ 6] = bTmp[0];
669 io_stru[ 7] = 0;
671 MSCDEX_StoreMSF(wcda.dwCurFrame, bTmp);
672 io_stru[ 8] = bTmp[2];
673 io_stru[ 9] = bTmp[1];
674 io_stru[10] = bTmp[0];
675 io_stru[11] = 0;
677 TRACE("Q-Channel info: Ctrl/adr=%02x TNO=%02x X=%02x rtt=%02x:%02x:%02x rtd=%02x:%02x:%02x (cf=%08lx, tp=%08lx)\n",
678 io_stru[ 1], io_stru[ 2], io_stru[ 3],
679 io_stru[ 4], io_stru[ 5], io_stru[ 6],
680 io_stru[ 8], io_stru[ 9], io_stru[10],
681 wcda.dwCurFrame, wcda.lpdwTrackPos[wcda.nCurTrack - 1]);
682 break;
684 case 15: /* Audio status info */
685 /* !!!! FIXME FIXME FIXME !! */
686 PTR_AT(io_stru, 1, WORD) = 2 | ((wcda.cdaMode == WINE_CDA_PAUSE) ? 1 : 0);
687 if (wcda.cdaMode == WINE_CDA_OPEN) {
688 PTR_AT(io_stru, 3, DWORD) = 0;
689 PTR_AT(io_stru, 7, DWORD) = 0;
690 } else {
691 PTR_AT(io_stru, 3, DWORD) = wcda.lpdwTrackPos[0];
692 PTR_AT(io_stru, 7, DWORD) = wcda.lpdwTrackPos[wcda.nTracks - 1];
694 TRACE("Audio status info: status=%04x startLoc=%ld endLoc=%ld\n",
695 PTR_AT(io_stru, 1, WORD), PTR_AT(io_stru, 3, DWORD), PTR_AT(io_stru, 7, DWORD));
696 break;
698 default:
699 FIXME("IOCTL INPUT: Unimplemented <%d>!!\n", io_stru[0]);
700 Error = 0x0c;
701 break;
703 break;
705 case 12:
706 io_stru = (dorealmode) ?
707 DOSMEM_MapRealToLinear(MAKELONG(PTR_AT(driver_request, 14, WORD), PTR_AT(driver_request, 16, WORD))) :
708 PTR_SEG_OFF_TO_LIN(PTR_AT(driver_request, 16, WORD), PTR_AT(driver_request, 14, WORD));
710 TRACE(" --> IOCTL OUTPUT <%d>\n", io_stru[0]);
711 switch (io_stru[0]) {
712 case 0: /* eject */
713 CDAUDIO_SetDoor(&wcda, 1);
714 TRACE(" ----> EJECT\n");
715 break;
716 case 2: /* reset drive */
717 CDAUDIO_Reset(&wcda);
718 TRACE(" ----> RESET\n");
719 break;
720 case 3: /* Audio Channel Control */
721 FIXME(" ----> AUDIO CHANNEL CONTROL (NIY)\n");
722 break;
723 case 5: /* close tray */
724 CDAUDIO_SetDoor(&wcda, 0);
725 TRACE(" ----> CLOSE TRAY\n");
726 break;
727 default:
728 FIXME(" IOCTL OUPUT: Unimplemented <%d>!!\n", io_stru[0]);
729 Error = 0x0c;
730 break;
732 break;
734 case 131: /* seek */
736 DWORD at;
738 at = PTR_AT(driver_request, 20, DWORD);
740 TRACE(" --> SEEK AUDIO mode :<0x%02X>, [%ld]\n",
741 (BYTE)driver_request[13], at);
743 switch (driver_request[13]) {
744 case 1: /* Red book addressing mode = 0:m:s:f */
745 /* FIXME : frame <=> msf conversion routines could be shared
746 * between mscdex and mcicda
748 at = LOBYTE(HIWORD(at)) * CDFRAMES_PERMIN +
749 HIBYTE(LOWORD(at)) * CDFRAMES_PERSEC +
750 LOBYTE(LOWORD(at));
751 /* fall thru */
752 case 0: /* HSG addressing mode */
753 CDAUDIO_Seek(&wcda, at);
754 break;
755 default:
756 ERR("Unsupported address mode !!\n");
757 Error = 0x0c;
758 break;
761 break;
763 case 132: /* play */
765 DWORD beg, end;
767 beg = end = PTR_AT(driver_request, 14, DWORD);
768 end += PTR_AT(driver_request, 18, DWORD);
770 TRACE(" --> PLAY AUDIO mode :<0x%02X>, [%ld-%ld]\n",
771 (BYTE)driver_request[13], beg, end);
773 switch (driver_request[13]) {
774 case 1: /* Red book addressing mode = 0:m:s:f */
775 /* FIXME : frame <=> msf conversion routines could be shared
776 * between mscdex and mcicda
778 beg = LOBYTE(HIWORD(beg)) * CDFRAMES_PERMIN +
779 HIBYTE(LOWORD(beg)) * CDFRAMES_PERSEC +
780 LOBYTE(LOWORD(beg));
781 end = LOBYTE(HIWORD(end)) * CDFRAMES_PERMIN +
782 HIBYTE(LOWORD(end)) * CDFRAMES_PERSEC +
783 LOBYTE(LOWORD(end));
784 /* fall thru */
785 case 0: /* HSG addressing mode */
786 CDAUDIO_Play(&wcda, beg, end);
787 break;
788 default:
789 ERR("Unsupported address mode !!\n");
790 Error = 0x0c;
791 break;
794 break;
796 case 133:
797 if (wcda.cdaMode == WINE_CDA_PLAY) {
798 CDAUDIO_Pause(&wcda, 1);
799 TRACE(" --> STOP AUDIO (Paused)\n");
800 } else {
801 CDAUDIO_Stop(&wcda);
802 TRACE(" --> STOP AUDIO (Stopped)\n");
804 break;
806 case 136:
807 TRACE(" --> RESUME AUDIO\n");
808 CDAUDIO_Pause(&wcda, 0);
809 break;
811 default:
812 FIXME(" ioctl uninplemented <%d>\n", driver_request[2]);
813 Error = 0x0c;
816 /* setting error codes if any */
817 if (Error < 255) {
818 driver_request[4] |= 0x80;
819 driver_request[3] = Error;
822 /* setting status bits
823 * 3 == playing && done
824 * 1 == done
826 driver_request[4] |= (wcda.cdaMode == WINE_CDA_PLAY) ? 3 : 1;
828 MSCDEX_Dump("End", driver_request, dorealmode);
830 break;
831 default:
832 FIXME("Unimplemented MSCDEX function 0x%02X.\n", AL_reg(context));
833 break;