2 * BIOS interrupt 13h handler
15 /* #define DEBUG_INT */
19 /**********************************************************************
22 * Handler for int 13h (disk I/O).
24 void WINAPI
INT_Int13Handler( CONTEXT
*context
)
26 switch(AH_reg(context
))
28 case 0x00: /* RESET DISK SYSTEM */
29 case 0x04: /* VERIFY DISK SECTOR(S) */
33 case 0x05: /* FORMAT TRACK */
34 case 0x06: /* FORMAT TRACK AND SET BAD SECTOR FLAGS */
35 case 0x07: /* FORMAT DRIVE STARTING AT GIVEN TRACK */
36 /* despite what Ralf Brown says, 0x06 and 0x07 seem to
37 * set CFLAG, too (at least my BIOS does that) */
38 AH_reg(context
) = 0x0c;
42 case 0x08: /* GET DRIVE PARAMETERS */
43 if (DL_reg(context
) & 0x80) { /* hard disk ? */
44 AH_reg(context
) = 0x07;
47 else { /* floppy disk */
49 unsigned int i
, nr_of_drives
= 0;
50 BYTE drive_nr
= DL_reg(context
);
52 struct floppy_drive_params floppy_parm
;
54 AH_reg(context
) = 0x00; /* success */
56 for (i
= 0; i
< MAX_DOS_DRIVES
; i
++)
57 if (DRIVE_GetType(i
) == TYPE_FLOPPY
) nr_of_drives
++;
58 DL_reg(context
) = nr_of_drives
;
60 if (drive_nr
> 1) { /* invalid drive ? */
67 if ( (floppy_fd
= DRIVE_OpenDevice( drive_nr
, O_NONBLOCK
)) == -1)
69 WARN(int, "(GET DRIVE PARAMETERS): Can't determine floppy geometry !\n");
75 ioctl(floppy_fd
, FDGETDRVPRM
, &floppy_parm
);
78 BL_reg(context
) = floppy_parm
.cmos
;
80 /* CH = low eight bits of max cyl
81 CL = max sec nr (bits 5-0),
82 hi two bits of max cyl (bits 7-6)
84 DH_reg(context
) = 0x01;
85 switch (BL_reg(context
))
87 case 0: /* no drive */
88 CX_reg(context
) = 0x0;
89 DX_reg(context
) = 0x0;
92 CX_reg(context
) = 0x2709;
95 CX_reg(context
) = 0x4f0f;
98 CX_reg(context
) = 0x4f09;
101 CX_reg(context
) = 0x4f12;
105 CX_reg(context
) = 0x4f24;
108 ES_reg(context
) = 0x0000; /* FIXME: drive parameter table */
109 DI_reg(context
) = 0x0000;
111 AH_reg(context
) = 0x01;
118 case 0x09: /* INITIALIZE CONTROLLER WITH DRIVE PARAMETERS */
119 case 0x0c: /* SEEK TO CYLINDER */
120 case 0x0d: /* RESET HARD DISKS */
121 case 0x10: /* CHECK IF DRIVE READY */
122 case 0x11: /* RECALIBRATE DRIVE */
123 case 0x14: /* CONTROLLER INTERNAL DIAGNOSTIC */
127 case 0x0e: /* READ SECTOR BUFFER (XT only) */
128 case 0x0f: /* WRITE SECTOR BUFFER (XT only) */
129 case 0x12: /* CONTROLLER RAM DIAGNOSTIC (XT,PS) */
130 case 0x13: /* DRIVE DIAGNOSTIC (XT,PS) */
131 AH_reg(context
) = 0x01;
135 case 0x17: /* SET DISK TYPE FOR FORMAT */
136 if (DL_reg(context
) < 4)
137 AH_reg(context
) = 0x00; /* successful completion */
139 AH_reg(context
) = 0x01; /* error */
142 if (DL_reg(context
) < 4)
143 AH_reg(context
) = 0x00; /* successful completion */
145 AH_reg(context
) = 0x01; /* error */
148 INT_BARF( context
, 0x13 );