Release 980329
[wine.git] / msdos / int26.c
blob0ad1b4122ce7868590488f7bafbbb7aa658c9c2a
1 /*
2 * DOS interrupt 26h handler
3 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <fcntl.h>
8 #include <unistd.h>
9 #include "msdos.h"
10 #include "ldt.h"
11 #include "miscemu.h"
12 #include "drive.h"
13 #include "debug.h"
15 /**********************************************************************
16 * INT_Int26Handler
18 * Handler for int 26h (absolute disk read).
20 void WINAPI INT_Int26Handler( CONTEXT *context )
22 BYTE *dataptr = PTR_SEG_OFF_TO_LIN( DS_reg(context), BX_reg(context) );
23 DWORD begin, length;
24 int fd;
26 if (!DRIVE_IsValid(AL_reg(context)))
28 SET_CFLAG(context);
29 AX_reg(context) = 0x0101; /* unknown unit */
30 return;
33 if (CX_reg(context) == 0xffff)
35 begin = *(DWORD *)dataptr;
36 length = *(WORD *)(dataptr + 4);
37 dataptr = (BYTE *)PTR_SEG_TO_LIN( *(SEGPTR *)(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);