Added Win32 synchro to FILEs (useful only for terminal handles).
[wine/multimedia.git] / msdos / int26.c
blobba3e11b8418c7e847d663d6e2aa4907171f68327
1 /*
2 * DOS interrupt 26h handler
3 */
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"
14 /**********************************************************************
15 * INT_Int26Handler
17 * Handler for int 26h (absolute disk read).
19 void WINAPI INT_Int26Handler( CONTEXT *context )
21 BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EBX_reg(context) );
22 DWORD begin, length;
23 int fd;
25 if (!DRIVE_IsValid(AL_reg(context)))
27 SET_CFLAG(context);
28 AX_reg(context) = 0x0101; /* unknown unit */
29 return;
32 if (CX_reg(context) == 0xffff)
34 begin = *(DWORD *)dataptr;
35 length = *(WORD *)(dataptr + 4);
36 dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
37 *(WORD *)(dataptr + 8), *(DWORD *)(dataptr + 6) );
39 else
41 begin = DX_reg(context);
42 length = CX_reg(context);
45 TRACE(int,"int26: abs diskwrite, drive %d, sector %ld, "
46 "count %ld, buffer %d\n",
47 AL_reg(context), begin, length, (int) dataptr );
49 if ((fd = DRIVE_OpenDevice( AL_reg(context), O_WRONLY )) != -1)
51 lseek( fd, begin * 512, SEEK_SET );
52 /* FIXME: check errors */
53 write( fd, dataptr, length * 512 );
54 close( fd );
57 RESET_CFLAG(context);