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 break; /* no return ? */
30 case 0x01: /* STATUS OF DISK SYSTEM */
31 AL_reg(context
) = 0; /* successful completion */
33 case 0x02: /* READ SECTORS INTO MEMORY */
34 AL_reg(context
) = 0; /* number of sectors read */
35 AH_reg(context
) = 0; /* status */
37 case 0x03: /* WRITE SECTORS FROM MEMORY */
38 break; /* no return ? */
39 case 0x04: /* VERIFY DISK SECTOR(S) */
40 AL_reg(context
) = 0; /* number of sectors verified */
44 case 0x05: /* FORMAT TRACK */
45 case 0x06: /* FORMAT TRACK AND SET BAD SECTOR FLAGS */
46 case 0x07: /* FORMAT DRIVE STARTING AT GIVEN TRACK */
47 /* despite what Ralf Brown says, 0x06 and 0x07 seem to
48 * set CFLAG, too (at least my BIOS does that) */
49 AH_reg(context
) = 0x0c;
53 case 0x08: /* GET DRIVE PARAMETERS */
54 if (DL_reg(context
) & 0x80) { /* hard disk ? */
55 AH_reg(context
) = 0x07;
58 else { /* floppy disk */
60 unsigned int i
, nr_of_drives
= 0;
61 BYTE drive_nr
= DL_reg(context
);
63 struct floppy_drive_params floppy_parm
;
65 AH_reg(context
) = 0x00; /* success */
67 for (i
= 0; i
< MAX_DOS_DRIVES
; i
++)
68 if (DRIVE_GetType(i
) == TYPE_FLOPPY
) nr_of_drives
++;
69 DL_reg(context
) = nr_of_drives
;
71 if (drive_nr
> 1) { /* invalid drive ? */
78 if ( (floppy_fd
= DRIVE_OpenDevice( drive_nr
, O_NONBLOCK
)) == -1)
80 WARN(int, "(GET DRIVE PARAMETERS): Can't determine floppy geometry !\n");
86 ioctl(floppy_fd
, FDGETDRVPRM
, &floppy_parm
);
89 BL_reg(context
) = floppy_parm
.cmos
;
91 /* CH = low eight bits of max cyl
92 CL = max sec nr (bits 5-0),
93 hi two bits of max cyl (bits 7-6)
95 DH_reg(context
) = 0x01;
96 switch (BL_reg(context
))
98 case 0: /* no drive */
99 CX_reg(context
) = 0x0;
100 DX_reg(context
) = 0x0;
103 CX_reg(context
) = 0x2709;
106 CX_reg(context
) = 0x4f0f;
109 CX_reg(context
) = 0x4f09;
112 CX_reg(context
) = 0x4f12;
116 CX_reg(context
) = 0x4f24;
119 ES_reg(context
) = 0x0000; /* FIXME: drive parameter table */
120 DI_reg(context
) = 0x0000;
122 AH_reg(context
) = 0x01;
129 case 0x09: /* INITIALIZE CONTROLLER WITH DRIVE PARAMETERS */
130 case 0x0a: /* FIXED DISK - READ LONG (XT,AT,XT286,PS) */
131 case 0x0b: /* FIXED DISK - WRITE LONG (XT,AT,XT286,PS) */
132 case 0x0c: /* SEEK TO CYLINDER */
133 case 0x0d: /* ALTERNATE RESET HARD DISKS */
134 case 0x10: /* CHECK IF DRIVE READY */
135 case 0x11: /* RECALIBRATE DRIVE */
136 case 0x14: /* CONTROLLER INTERNAL DIAGNOSTIC */
140 case 0x15: /* GET DISK TYPE (AT,XT2,XT286,CONV,PS) */
141 if (DL_reg(context
) & 0x80) { /* hard disk ? */
142 AH_reg(context
) = 3; /* fixed disk */
145 else { /* floppy disk ? */
146 AH_reg(context
) = 2; /* floppy with change detection */
150 case 0x0e: /* READ SECTOR BUFFER (XT only) */
151 case 0x0f: /* WRITE SECTOR BUFFER (XT only) */
152 case 0x12: /* CONTROLLER RAM DIAGNOSTIC (XT,PS) */
153 case 0x13: /* DRIVE DIAGNOSTIC (XT,PS) */
154 AH_reg(context
) = 0x01;
158 case 0x16: /* FLOPPY - CHANGE OF DISK STATUS */
159 AH_reg(context
) = 0; /* FIXME - no change */
161 case 0x17: /* SET DISK TYPE FOR FORMAT */
162 if (DL_reg(context
) < 4)
163 AH_reg(context
) = 0x00; /* successful completion */
165 AH_reg(context
) = 0x01; /* error */
167 case 0x18: /* SET MEDIA TYPE FOR FORMAT */
168 if (DL_reg(context
) < 4)
169 AH_reg(context
) = 0x00; /* successful completion */
171 AH_reg(context
) = 0x01; /* error */
173 case 0x19: /* FIXED DISK - PARK HEADS */
175 INT_BARF( context
, 0x13 );