2 * BIOS interrupt 13h handler
10 #include <sys/ioctl.h>
17 /* #define DEBUG_INT */
21 /**********************************************************************
24 * Handler for int 13h (disk I/O).
26 void WINAPI
INT_Int13Handler( CONTEXT
*context
)
28 switch(AH_reg(context
))
30 case 0x00: /* RESET DISK SYSTEM */
31 case 0x04: /* VERIFY DISK SECTOR(S) */
35 case 0x05: /* FORMAT TRACK */
36 case 0x06: /* FORMAT TRACK AND SET BAD SECTOR FLAGS */
37 case 0x07: /* FORMAT DRIVE STARTING AT GIVEN TRACK */
38 /* despite what Ralf Brown says, 0x06 and 0x07 seem to
39 * set CFLAG, too (at least my BIOS does that) */
40 AH_reg(context
) = 0x0c;
44 case 0x08: /* GET DRIVE PARAMETERS */
45 if (DL_reg(context
) & 0x80) { /* hard disk ? */
46 AH_reg(context
) = 0x07;
49 else { /* floppy disk */
51 unsigned int i
, nr_of_drives
= 0;
52 BYTE drive_nr
= DL_reg(context
);
54 struct floppy_drive_params floppy_parm
;
56 AH_reg(context
) = 0x00; /* success */
58 for (i
= 0; i
< MAX_DOS_DRIVES
; i
++)
59 if (DRIVE_GetType(i
) == TYPE_FLOPPY
) nr_of_drives
++;
60 DL_reg(context
) = nr_of_drives
;
62 if (drive_nr
> 1) { /* invalid drive ? */
69 if ( (floppy_fd
= DRIVE_OpenDevice( drive_nr
, O_NONBLOCK
)) == -1)
71 fprintf(stderr
, "INT 0x13 (GET DRIVE PARAMETERS): can't determine floppy geometry !\n");
77 ioctl(floppy_fd
, FDGETDRVPRM
, &floppy_parm
);
80 BL_reg(context
) = floppy_parm
.cmos
;
82 /* CH = low eight bits of max cyl
83 CL = max sec nr (bits 5-0),
84 hi two bits of max cyl (bits 7-6)
86 DH_reg(context
) = 0x01;
87 switch (BL_reg(context
))
89 case 0: /* no drive */
90 CX_reg(context
) = 0x0;
91 DX_reg(context
) = 0x0;
94 CX_reg(context
) = 0x2709;
97 CX_reg(context
) = 0x4f0f;
100 CX_reg(context
) = 0x4f09;
103 CX_reg(context
) = 0x4f12;
107 CX_reg(context
) = 0x4f24;
110 ES_reg(context
) = 0x0000; /* FIXME: drive parameter table */
111 DI_reg(context
) = 0x0000;
113 AH_reg(context
) = 0x01;
120 case 0x09: /* INITIALIZE CONTROLLER WITH DRIVE PARAMETERS */
121 case 0x0c: /* SEEK TO CYLINDER */
122 case 0x0d: /* RESET HARD DISKS */
123 case 0x10: /* CHECK IF DRIVE READY */
124 case 0x11: /* RECALIBRATE DRIVE */
125 case 0x14: /* CONTROLLER INTERNAL DIAGNOSTIC */
129 case 0x0e: /* READ SECTOR BUFFER (XT only) */
130 case 0x0f: /* WRITE SECTOR BUFFER (XT only) */
131 case 0x12: /* CONTROLLER RAM DIAGNOSTIC (XT,PS) */
132 case 0x13: /* DRIVE DIAGNOSTIC (XT,PS) */
133 AH_reg(context
) = 0x01;
138 INT_BARF( context
, 0x13 );