New debug scheme with explicit debug channels declaration.
[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 DEFAULT_DEBUG_CHANNEL(int)
15
16 /**********************************************************************
17  *          INT_Int26Handler
18  *
19  * Handler for int 26h (absolute disk read).
20  */
21 void WINAPI INT_Int26Handler( CONTEXT *context )
22 {
23     BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EBX_reg(context) );
24     DWORD begin, length;
25
26     if (!DRIVE_IsValid(AL_reg(context)))
27     {
28         SET_CFLAG(context);
29         AX_reg(context) = 0x0201;        /* unknown unit */
30         return;
31     }
32
33     if (CX_reg(context) == 0xffff)
34     {
35         begin   = *(DWORD *)dataptr;
36         length  = *(WORD *)(dataptr + 4);
37         dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
38                                         *(WORD *)(dataptr + 8), *(DWORD *)(dataptr + 6) );
39     }
40     else
41     {
42         begin  = DX_reg(context);
43         length = CX_reg(context);
44     }
45                 
46     TRACE(int,"int26: abs diskwrite, drive %d, sector %ld, "
47                  "count %ld, buffer %p\n",
48                  AL_reg(context), begin, length, dataptr );
49
50         DRIVE_RawWrite(AL_reg(context), begin, length, dataptr, TRUE);
51     RESET_CFLAG(context);
52 }