Added stubs for several VxDs / interrupts.
[wine] / msdos / int26.c
1 /*
2  * DOS interrupt 26h handler
3  */
4
5 #include <stdlib.h>
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include "msdos.h"
9 #include "ldt.h"
10 #include "miscemu.h"
11 #include "drive.h"
12 #include "debug.h"
13
14 /**********************************************************************
15  *          INT_Int26Handler
16  *
17  * Handler for int 26h (absolute disk read).
18  */
19 void WINAPI INT_Int26Handler( CONTEXT *context )
20 {
21     BYTE *dataptr = PTR_SEG_OFF_TO_LIN( DS_reg(context), BX_reg(context) );
22     DWORD begin, length;
23     int fd;
24
25     if (!DRIVE_IsValid(AL_reg(context)))
26     {
27         SET_CFLAG(context);
28         AX_reg(context) = 0x0101;        /* unknown unit */
29         return;
30     }
31
32     if (CX_reg(context) == 0xffff)
33     {
34         begin   = *(DWORD *)dataptr;
35         length  = *(WORD *)(dataptr + 4);
36         dataptr = (BYTE *)PTR_SEG_TO_LIN( *(SEGPTR *)(dataptr + 6) );
37     }
38     else
39     {
40         begin  = DX_reg(context);
41         length = CX_reg(context);
42     }
43                 
44     TRACE(int,"int26: abs diskwrite, drive %d, sector %ld, "
45                  "count %ld, buffer %d\n",
46                  AL_reg(context), begin, length, (int) dataptr );
47
48     if ((fd = DRIVE_OpenDevice( AL_reg(context), O_WRONLY )) != -1)
49     {
50         lseek( fd, begin * 512, SEEK_SET );
51         /* FIXME: check errors */
52         write( fd, dataptr, length * 512 );
53         close( fd );
54     }
55
56     RESET_CFLAG(context);
57 }