Removed some of the XXX_reg macros now that we are using the standard
[wine] / msdos / devices.c
1 /*
2  * DOS devices
3  *
4  * Copyright 1999 Ove Kåven
5  */
6
7 #include <stdlib.h>
8 #include <string.h>
9 #include "wine/winbase16.h"
10 #include "msdos.h"
11 #include "miscemu.h"
12 #include "dosexe.h"
13 #include "debugtools.h"
14
15 #include "pshpack1.h"
16
17 typedef struct {
18   BYTE ljmp1;
19   RMCBPROC strategy;
20   BYTE ljmp2;
21   RMCBPROC interrupt;
22 } WINEDEV_THUNK;
23
24 typedef struct {
25   BYTE size; /* length of header + data */
26   BYTE unit; /* unit (block devices only) */
27   BYTE command;
28   WORD status;
29   BYTE reserved[8];
30 } REQUEST_HEADER;
31
32 typedef struct {
33   REQUEST_HEADER hdr;
34   BYTE media; /* media descriptor from BPB */
35   SEGPTR buffer;
36   WORD count; /* byte/sector count */
37   WORD sector; /* starting sector (block devices) */
38   DWORD volume; /* volume ID (block devices) */
39 } REQ_IO;
40
41 typedef struct {
42   REQUEST_HEADER hdr;
43   BYTE data;
44 } REQ_SAFEINPUT;
45
46 #include "poppack.h"
47
48 #define CON_BUFFER 128
49
50 enum strategy { SYSTEM_STRATEGY_NUL, SYSTEM_STRATEGY_CON, NB_SYSTEM_STRATEGIES };
51
52 static void *strategy_data[NB_SYSTEM_STRATEGIES];
53
54 #define NONEXT ((DWORD)-1)
55
56 #define ATTR_STDIN     0x0001
57 #define ATTR_STDOUT    0x0002
58 #define ATTR_NUL       0x0004
59 #define ATTR_CLOCK     0x0008
60 #define ATTR_FASTCON   0x0010
61 #define ATTR_RAW       0x0020
62 #define ATTR_NOTEOF    0x0040
63 #define ATTR_DEVICE    0x0080
64 #define ATTR_REMOVABLE 0x0800
65 #define ATTR_NONIBM    0x2000 /* block devices */
66 #define ATTR_UNTILBUSY 0x2000 /* char devices */
67 #define ATTR_IOCTL     0x4000
68 #define ATTR_CHAR      0x8000
69
70 #define CMD_INIT       0
71 #define CMD_MEDIACHECK 1 /* block devices */
72 #define CMD_BUILDBPB   2 /* block devices */
73 #define CMD_INIOCTL    3
74 #define CMD_INPUT      4 /* read data */
75 #define CMD_SAFEINPUT  5 /* "non-destructive input no wait", char devices */
76 #define CMD_INSTATUS   6 /* char devices */
77 #define CMD_INFLUSH    7 /* char devices */
78 #define CMD_OUTPUT     8 /* write data */
79 #define CMD_SAFEOUTPUT 9 /* write data with verify */
80 #define CMD_OUTSTATUS 10 /* char devices */
81 #define CMD_OUTFLUSH  11 /* char devices */
82 #define CMD_OUTIOCTL  12
83 #define CMD_DEVOPEN   13
84 #define CMD_DEVCLOSE  14
85 #define CMD_REMOVABLE 15 /* block devices */
86 #define CMD_UNTILBUSY 16 /* output until busy */
87
88 #define STAT_MASK  0x00FF
89 #define STAT_DONE  0x0100
90 #define STAT_BUSY  0x0200
91 #define STAT_ERROR 0x8000
92
93 #define LJMP 0xea
94
95
96 /* prototypes */
97 static void WINAPI nul_strategy(CONTEXT86*ctx);
98 static void WINAPI nul_interrupt(CONTEXT86*ctx);
99 static void WINAPI con_strategy(CONTEXT86*ctx);
100 static void WINAPI con_interrupt(CONTEXT86*ctx);
101
102 /* devices */
103 typedef struct 
104 {
105     char name[8];
106     WORD attr;
107     RMCBPROC strategy;
108     RMCBPROC interrupt;
109     
110 } WINEDEV;
111
112 static WINEDEV devs[] = 
113 {
114   { "NUL     ",
115     ATTR_CHAR|ATTR_NUL|ATTR_DEVICE,
116     nul_strategy, nul_interrupt },
117
118   { "CON     ",
119     ATTR_CHAR|ATTR_STDIN|ATTR_STDOUT|ATTR_FASTCON|ATTR_NOTEOF|ATTR_DEVICE,
120     con_strategy, con_interrupt }
121 };
122
123 #define NR_DEVS (sizeof(devs)/sizeof(WINEDEV))
124
125 /* DOS data segment */
126 typedef struct
127 {
128     DOS_LISTOFLISTS    lol;
129     DOS_DEVICE_HEADER  dev[NR_DEVS-1];
130     WINEDEV_THUNK      thunk[NR_DEVS];
131     REQ_IO             req;
132     BYTE               buffer[CON_BUFFER];
133
134 } DOS_DATASEG;
135
136 #define DOS_DATASEG_OFF(xxx) FIELD_OFFSET(DOS_DATASEG, xxx)
137
138 DWORD DOS_LOLSeg;
139
140
141 /* the device implementations */
142 static void do_lret(CONTEXT86*ctx)
143 {
144   WORD *stack = CTX_SEG_OFF_TO_LIN(ctx, ctx->SegSs, ctx->Esp);
145
146   ctx->Eip   = *(stack++);
147   ctx->SegCs = *(stack++);
148   ctx->Esp  += 2*sizeof(WORD);
149 }
150
151 static void do_strategy(CONTEXT86*ctx, int id, int extra)
152 {
153   REQUEST_HEADER *hdr = CTX_SEG_OFF_TO_LIN(ctx, ctx->SegEs, ctx->Ebx);
154   void **hdr_ptr = strategy_data[id];
155
156   if (!hdr_ptr) {
157     hdr_ptr = calloc(1,sizeof(void *)+extra);
158     strategy_data[id] = hdr_ptr;
159   }
160   *hdr_ptr = hdr;
161   do_lret(ctx);
162 }
163
164 static REQUEST_HEADER * get_hdr(int id, void**extra)
165 {
166   void **hdr_ptr = strategy_data[id];
167   if (extra)
168     *extra = hdr_ptr ? (void*)(hdr_ptr+1) : (void *)NULL;
169   return hdr_ptr ? *hdr_ptr : (void *)NULL;
170 }
171
172 static void WINAPI nul_strategy(CONTEXT86*ctx)
173 {
174   do_strategy(ctx, SYSTEM_STRATEGY_NUL, 0);
175 }
176
177 static void WINAPI nul_interrupt(CONTEXT86*ctx)
178 {
179   REQUEST_HEADER *hdr = get_hdr(SYSTEM_STRATEGY_NUL, NULL);
180   /* eat everything and recycle nothing */
181   switch (hdr->command) {
182   case CMD_INPUT:
183     ((REQ_IO*)hdr)->count = 0;
184     hdr->status = STAT_DONE;
185     break;
186   case CMD_SAFEINPUT:
187     hdr->status = STAT_DONE|STAT_BUSY;
188     break;
189   default:
190     hdr->status = STAT_DONE;
191   }
192   do_lret(ctx);
193 }
194
195 static void WINAPI con_strategy(CONTEXT86*ctx)
196 {
197   do_strategy(ctx, SYSTEM_STRATEGY_CON, sizeof(int));
198 }
199
200 static void WINAPI con_interrupt(CONTEXT86*ctx)
201 {
202   int *scan;
203   REQUEST_HEADER *hdr = get_hdr(SYSTEM_STRATEGY_CON,(void **)&scan);
204   BIOSDATA *bios = DOSMEM_BiosData();
205   WORD CurOfs = bios->NextKbdCharPtr;
206   DOS_LISTOFLISTS *lol = DOSMEM_LOL();
207   DOS_DATASEG *dataseg = (DOS_DATASEG *)lol;
208   BYTE *linebuffer = dataseg->buffer;
209   BYTE *curbuffer = (lol->offs_unread_CON) ?
210     (((BYTE*)dataseg) + lol->offs_unread_CON) : (BYTE*)NULL;
211   DOS_DEVICE_HEADER *con = dataseg->dev;
212
213   switch (hdr->command) {
214   case CMD_INPUT:
215     {
216       REQ_IO *io = (REQ_IO *)hdr;
217       WORD count = io->count, len = 0;
218       BYTE *buffer = CTX_SEG_OFF_TO_LIN(ctx,
219                                         SELECTOROF(io->buffer),
220                                         (DWORD)OFFSETOF(io->buffer));
221
222       hdr->status = STAT_BUSY;
223       /* first, check whether we already have data in line buffer */
224       if (curbuffer) {
225         /* yep, copy as much as we can */
226         BYTE data = 0;
227         while ((len<count) && (data != '\r')) {
228           data = *curbuffer++;
229           buffer[len++] = data;
230         }
231         if (data == '\r') {
232           /* line buffer emptied */
233           lol->offs_unread_CON = 0;
234           curbuffer = NULL;
235           /* if we're not in raw mode, call it a day*/
236           if (!(con->attr & ATTR_RAW)) {
237             hdr->status = STAT_DONE;
238             io->count = len;
239             break;
240           }
241         } else {
242           /* still some data left */
243           lol->offs_unread_CON = curbuffer - (BYTE*)lol;
244           /* but buffer was filled, we're done */
245           hdr->status = STAT_DONE;
246           io->count = len;
247           break;
248         }
249       }
250
251       /* if we're in raw mode, we just need to fill the buffer */
252       if (con->attr & ATTR_RAW) {
253         while (len<count) {
254           WORD data;
255
256           /* do we have a waiting scancode? */
257           if (*scan) {
258             /* yes, store scancode in buffer */
259             buffer[len++] = *scan;
260             *scan = 0;
261             if (len==count) break;
262           }
263
264           /* check for new keyboard input */
265           while (CurOfs == bios->FirstKbdCharPtr) {
266             /* no input available yet, so wait... */
267             DOSVM_Wait( -1, 0 );
268           }
269           /* read from keyboard queue (call int16?) */
270           data = ((WORD*)bios)[CurOfs];
271           CurOfs += 2;
272           if (CurOfs >= bios->KbdBufferEnd) CurOfs = bios->KbdBufferStart;
273           bios->NextKbdCharPtr = CurOfs;
274           /* if it's an extended key, save scancode */
275           if (LOBYTE(data) == 0) *scan = HIBYTE(data);
276           /* store ASCII char in buffer */
277           buffer[len++] = LOBYTE(data);
278         }
279       } else {
280         /* we're not in raw mode, so we need to do line input... */
281         while (TRUE) {
282           WORD data;
283           /* check for new keyboard input */
284           while (CurOfs == bios->FirstKbdCharPtr) {
285             /* no input available yet, so wait... */
286             DOSVM_Wait( -1, 0 );
287           }
288           /* read from keyboard queue (call int16?) */
289           data = ((WORD*)bios)[CurOfs];
290           CurOfs += 2;
291           if (CurOfs >= bios->KbdBufferEnd) CurOfs = bios->KbdBufferStart;
292           bios->NextKbdCharPtr = CurOfs;
293
294           if (LOBYTE(data) == '\r') {
295             /* it's the return key, we're done */
296             linebuffer[len++] = LOBYTE(data);
297             break;
298           }
299           else if (LOBYTE(data) >= ' ') {
300             /* a character */
301             if ((len+1)<CON_BUFFER) {
302               linebuffer[len] = LOBYTE(data);
303               WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), &linebuffer[len++], 1, NULL, NULL);
304             }
305             /* else beep, but I don't like noise */
306           }
307           else switch (LOBYTE(data)) {
308           case '\b':
309             if (len>0) {
310               len--;
311               WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), "\b \b", 3, NULL, NULL);
312             }
313             break;
314           }
315         }
316         if (len > count) {
317           /* save rest of line for later */
318           lol->offs_unread_CON = linebuffer - (BYTE*)lol + count;
319           len = count;
320         }
321         memcpy(buffer, linebuffer, len);
322       }
323       hdr->status = STAT_DONE;
324       io->count = len;
325     }
326     break;
327   case CMD_SAFEINPUT:
328     if (curbuffer) {
329       /* some line input waiting */
330       hdr->status = STAT_DONE;
331       ((REQ_SAFEINPUT*)hdr)->data = *curbuffer;
332     }
333     else if (con->attr & ATTR_RAW) {
334       if (CurOfs == bios->FirstKbdCharPtr) {
335         /* no input */
336         hdr->status = STAT_DONE|STAT_BUSY;
337       } else {
338         /* some keyboard input waiting */
339         hdr->status = STAT_DONE;
340         ((REQ_SAFEINPUT*)hdr)->data = ((BYTE*)bios)[CurOfs];
341       }
342     } else {
343       /* no line input */
344       hdr->status = STAT_DONE|STAT_BUSY;
345     }
346     break;
347   case CMD_INSTATUS:
348     if (curbuffer) {
349       /* we have data */
350       hdr->status = STAT_DONE;
351     }
352     else if (con->attr & ATTR_RAW) {
353       if (CurOfs == bios->FirstKbdCharPtr) {
354         /* no input */
355         hdr->status = STAT_DONE|STAT_BUSY;
356       } else {
357         /* some keyboard input waiting */
358         hdr->status = STAT_DONE;
359       }
360     } else {
361       /* no line input */
362       hdr->status = STAT_DONE|STAT_BUSY;
363     }
364
365     break;
366   case CMD_INFLUSH:
367     /* flush line and keyboard queue */
368     lol->offs_unread_CON = 0;
369     bios->NextKbdCharPtr = bios->FirstKbdCharPtr;
370     break;
371   case CMD_OUTPUT:
372   case CMD_SAFEOUTPUT:
373     {
374       REQ_IO *io = (REQ_IO *)hdr;
375       BYTE *buffer = CTX_SEG_OFF_TO_LIN(ctx,
376                                         SELECTOROF(io->buffer),
377                                         (DWORD)OFFSETOF(io->buffer));
378       DWORD result = 0;
379       WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buffer, io->count, &result, NULL);
380       io->count = result;
381       hdr->status = STAT_DONE;
382     }
383     break;
384   default:
385     hdr->status = STAT_DONE;
386   }
387   do_lret(ctx);
388 }
389
390 static void InitListOfLists(DOS_LISTOFLISTS *DOS_LOL)
391 {
392 /*
393 Output of DOS 6.22:
394
395 0133:0020                    6A 13-33 01 CC 00 33 01 59 00         j.3...3.Y.
396 0133:0030  70 00 00 00 72 02 00 02-6D 00 33 01 00 00 2E 05   p...r...m.3.....
397 0133:0040  00 00 FC 04 00 00 03 08-92 21 11 E0 04 80 C6 0D   .........!......
398 0133:0050  CC 0D 4E 55 4C 20 20 20-20 20 00 00 00 00 00 00   ..NUL     ......
399 0133:0060  00 4B BA C1 06 14 00 00-00 03 01 00 04 70 CE FF   .K...........p..
400 0133:0070  FF 00 00 00 00 00 00 00-00 01 00 00 0D 05 00 00   ................
401 0133:0080  00 FF FF 00 00 00 00 FE-00 00 F8 03 FF 9F 70 02   ..............p.
402 0133:0090  D0 44 C8 FD D4 44 C8 FD-D4 44 C8 FD D0 44 C8 FD   .D...D...D...D..
403 0133:00A0  D0 44 C8 FD D0 44                                 .D...D
404 */
405   DOS_LOL->CX_Int21_5e01                = 0x0;
406   DOS_LOL->LRU_count_FCB_cache  = 0x0;
407   DOS_LOL->LRU_count_FCB_open           = 0x0;
408   DOS_LOL->OEM_func_handler             = -1; /* not available */
409   DOS_LOL->INT21_offset         = 0x0;
410   DOS_LOL->sharing_retry_count  = 3;
411   DOS_LOL->sharing_retry_delay  = 1;
412   DOS_LOL->ptr_disk_buf         = 0x0;
413   DOS_LOL->offs_unread_CON              = 0x0;
414   DOS_LOL->seg_first_MCB                = 0x0;
415   DOS_LOL->ptr_first_DPB                = 0x0;
416   DOS_LOL->ptr_first_SysFileTable       = 0x0;
417   DOS_LOL->ptr_clock_dev_hdr            = 0x0;
418   DOS_LOL->ptr_CON_dev_hdr              = 0x0;
419   DOS_LOL->max_byte_per_sec             = 512;
420   DOS_LOL->ptr_disk_buf_info            = 0x0;
421   DOS_LOL->ptr_array_CDS                = 0x0;
422   DOS_LOL->ptr_sys_FCB          = 0x0;
423   DOS_LOL->nr_protect_FCB               = 0x0;
424   DOS_LOL->nr_block_dev         = 0x0;
425   DOS_LOL->nr_avail_drive_letters       = 26; /* A - Z */
426   DOS_LOL->nr_drives_JOINed             = 0x0;
427   DOS_LOL->ptr_spec_prg_names           = 0x0;
428   DOS_LOL->ptr_SETVER_prg_list  = 0x0; /* no SETVER list */
429   DOS_LOL->DOS_HIGH_A20_func_offs       = 0x0;
430   DOS_LOL->PSP_last_exec                = 0x0;
431   DOS_LOL->BUFFERS_val          = 99; /* maximum: 99 */
432   DOS_LOL->BUFFERS_nr_lookahead = 8; /* maximum: 8 */
433   DOS_LOL->boot_drive                   = 3; /* C: */
434   DOS_LOL->flag_DWORD_moves             = 0x01; /* i386+ */
435   DOS_LOL->size_extended_mem            = 0xf000; /* very high value */
436 }
437
438 void DOSDEV_InstallDOSDevices(void)
439 {
440   DOS_DATASEG *dataseg;
441   UINT16 seg;
442   int n;
443
444   /* allocate DOS data segment or something */
445   DOS_LOLSeg = GlobalDOSAlloc16(sizeof(DOS_DATASEG));
446   seg = HIWORD(DOS_LOLSeg);
447   dataseg = PTR_SEG_OFF_TO_LIN(LOWORD(DOS_LOLSeg), 0);
448
449   /* initialize the magnificent List Of Lists */
450   InitListOfLists(&dataseg->lol);
451
452   /* Set up first device (NUL) */
453   dataseg->lol.NUL_dev.next_dev  = PTR_SEG_OFF_TO_SEGPTR(seg, DOS_DATASEG_OFF(dev[0]));
454   dataseg->lol.NUL_dev.attr      = devs[0].attr;
455   dataseg->lol.NUL_dev.strategy  = DOS_DATASEG_OFF(thunk[0].ljmp1);
456   dataseg->lol.NUL_dev.interrupt = DOS_DATASEG_OFF(thunk[0].ljmp2);
457   memcpy(dataseg->lol.NUL_dev.name, devs[0].name, 8);
458
459   /* Set up the remaining devices */
460   for (n = 1; n < NR_DEVS; n++)
461   {
462     dataseg->dev[n-1].next_dev  = (n+1) == NR_DEVS ? NONEXT :
463                                   PTR_SEG_OFF_TO_SEGPTR(seg, DOS_DATASEG_OFF(dev[n]));
464     dataseg->dev[n-1].attr      = devs[n].attr;
465     dataseg->dev[n-1].strategy  = DOS_DATASEG_OFF(thunk[n].ljmp1);
466     dataseg->dev[n-1].interrupt = DOS_DATASEG_OFF(thunk[n].ljmp2);
467     memcpy(dataseg->dev[n-1].name, devs[n].name, 8);
468   }
469
470   /* Set up thunks */
471   for (n = 0; n < NR_DEVS; n++)
472   {
473     dataseg->thunk[n].ljmp1     = LJMP;
474     dataseg->thunk[n].strategy  = (RMCBPROC)DPMI_AllocInternalRMCB(devs[n].strategy);
475     dataseg->thunk[n].ljmp2     = LJMP;
476     dataseg->thunk[n].interrupt = (RMCBPROC)DPMI_AllocInternalRMCB(devs[n].interrupt);
477   }
478
479   /* CON is device 1 */
480   dataseg->lol.ptr_CON_dev_hdr = PTR_SEG_OFF_TO_SEGPTR(seg, DOS_DATASEG_OFF(dev[0]));
481 }
482
483 DWORD DOSDEV_Console(void)
484 {
485   return DOSMEM_LOL()->ptr_CON_dev_hdr;
486 }
487
488 DWORD DOSDEV_FindCharDevice(char*name)
489 {
490   SEGPTR cur_ptr = PTR_SEG_OFF_TO_SEGPTR(HIWORD(DOS_LOLSeg),
491                                          FIELD_OFFSET(DOS_LISTOFLISTS,NUL_dev));
492   DOS_DEVICE_HEADER *cur = DOSMEM_MapRealToLinear(cur_ptr);
493   char dname[8];
494   int cnt;
495
496   /* get first 8 characters */
497   strncpy(dname,name,8);
498   /* if less than 8 characters, pad with spaces */
499   for (cnt=0; cnt<8; cnt++)
500     if (!dname[cnt]) dname[cnt]=' ';
501
502   /* search for char devices with the right name */
503   while (cur &&
504          ((!(cur->attr & ATTR_CHAR)) ||
505           memcmp(cur->name,dname,8))) {
506     cur_ptr = cur->next_dev;
507     if (cur_ptr == NONEXT) cur=NULL;
508     else cur = DOSMEM_MapRealToLinear(cur_ptr);
509   }
510   return cur_ptr;
511 }
512
513 static void DOSDEV_DoReq(void*req, DWORD dev)
514 {
515   REQUEST_HEADER *hdr = (REQUEST_HEADER *)req;
516   DOS_DEVICE_HEADER *dhdr;
517   CONTEXT86 ctx;
518   char *phdr;
519
520   dhdr = DOSMEM_MapRealToLinear(dev);
521   phdr = ((char*)DOSMEM_LOL()) + DOS_DATASEG_OFF(req);
522
523   /* copy request to request scratch area */
524   memcpy(phdr, req, hdr->size);
525
526   /* prepare to call device driver */
527   memset(&ctx, 0, sizeof(ctx));
528
529   /* ES:BX points to request for strategy routine */
530   ctx.SegEs = HIWORD(DOS_LOLSeg);
531   ctx.Ebx   = DOS_DATASEG_OFF(req);
532
533   /* call strategy routine */
534   ctx.SegCs = SELECTOROF(dev);
535   ctx.Eip   = dhdr->strategy;
536   DPMI_CallRMProc(&ctx, 0, 0, 0);
537
538   /* call interrupt routine */
539   ctx.SegCs = SELECTOROF(dev);
540   ctx.Eip   = dhdr->interrupt;
541   DPMI_CallRMProc(&ctx, 0, 0, 0);
542
543   /* completed, copy request back */
544   memcpy(req, phdr, hdr->size);
545
546   if (hdr->status & STAT_ERROR) {
547     switch (hdr->status & STAT_MASK) {
548     case 0x0F: /* invalid disk change */
549       /* this error seems to fit the bill */
550       SetLastError(ER_NotSameDevice);
551       break;
552     default:
553       SetLastError((hdr->status & STAT_MASK) + 0x13);
554       break;
555     }
556   }
557 }
558
559 static int DOSDEV_IO(unsigned cmd, DWORD dev, DWORD buf, int buflen)
560 {
561   REQ_IO req;
562
563   req.hdr.size=sizeof(req);
564   req.hdr.unit=0; /* not dealing with block devices yet */
565   req.hdr.command=cmd;
566   req.hdr.status=STAT_BUSY;
567   req.media=0; /* not dealing with block devices yet */
568   req.buffer=buf;
569   req.count=buflen;
570   req.sector=0; /* block devices */
571   req.volume=0; /* block devices */
572
573   DOSDEV_DoReq(&req, dev);
574
575   return req.count;
576 }
577
578 int DOSDEV_Peek(DWORD dev, BYTE*data)
579 {
580   REQ_SAFEINPUT req;
581
582   req.hdr.size=sizeof(req);
583   req.hdr.unit=0; /* not dealing with block devices yet */
584   req.hdr.command=CMD_SAFEINPUT;
585   req.hdr.status=STAT_BUSY;
586   req.data=0;
587
588   DOSDEV_DoReq(&req, dev);
589
590   if (req.hdr.status & STAT_BUSY) return 0;
591
592   *data = req.data;
593   return 1;
594 }
595
596 int DOSDEV_Read(DWORD dev, DWORD buf, int buflen)
597 {
598   return DOSDEV_IO(CMD_INPUT, dev, buf, buflen);
599 }
600
601 int DOSDEV_Write(DWORD dev, DWORD buf, int buflen, int verify)
602 {
603   return DOSDEV_IO(verify?CMD_SAFEOUTPUT:CMD_OUTPUT, dev, buf, buflen);
604 }
605
606 int DOSDEV_IoctlRead(DWORD dev, DWORD buf, int buflen)
607 {
608   return DOSDEV_IO(CMD_INIOCTL, dev, buf, buflen);
609 }
610
611 int DOSDEV_IoctlWrite(DWORD dev, DWORD buf, int buflen)
612 {
613   return DOSDEV_IO(CMD_OUTIOCTL, dev, buf, buflen);
614 }