2 * BIOS interrupt 13h handler
15 /* #define DEBUG_INT */
16 #include "debugtools.h"
19 DEFAULT_DEBUG_CHANNEL(int);
21 /**********************************************************************
24 * Handler for int 13h (disk I/O).
26 void WINAPI
INT_Int13Handler( CONTEXT86
*context
)
28 switch(AH_reg(context
))
30 case 0x00: /* RESET DISK SYSTEM */
31 break; /* no return ? */
32 case 0x01: /* STATUS OF DISK SYSTEM */
33 AL_reg(context
) = 0; /* successful completion */
35 case 0x02: /* READ SECTORS INTO MEMORY */
36 AL_reg(context
) = 0; /* number of sectors read */
37 AH_reg(context
) = 0; /* status */
39 case 0x03: /* WRITE SECTORS FROM MEMORY */
40 break; /* no return ? */
41 case 0x04: /* VERIFY DISK SECTOR(S) */
42 AL_reg(context
) = 0; /* number of sectors verified */
46 case 0x05: /* FORMAT TRACK */
47 case 0x06: /* FORMAT TRACK AND SET BAD SECTOR FLAGS */
48 case 0x07: /* FORMAT DRIVE STARTING AT GIVEN TRACK */
49 /* despite what Ralf Brown says, 0x06 and 0x07 seem to
50 * set CFLAG, too (at least my BIOS does that) */
51 AH_reg(context
) = 0x0c;
55 case 0x08: /* GET DRIVE PARAMETERS */
56 if (DL_reg(context
) & 0x80) { /* hard disk ? */
57 AH_reg(context
) = 0x07;
60 else { /* floppy disk */
62 unsigned int i
, nr_of_drives
= 0;
63 BYTE drive_nr
= DL_reg(context
);
65 struct floppy_drive_params floppy_parm
;
68 AH_reg(context
) = 0x00; /* success */
70 for (i
= 0; i
< MAX_DOS_DRIVES
; i
++, root
[0]++)
71 if (GetDriveTypeA(root
) == DRIVE_REMOVABLE
) nr_of_drives
++;
72 DL_reg(context
) = nr_of_drives
;
74 if (drive_nr
> 1) { /* invalid drive ? */
81 if ( (floppy_fd
= DRIVE_OpenDevice( drive_nr
, O_NONBLOCK
)) == -1)
83 WARN("(GET DRIVE PARAMETERS): Can't determine floppy geometry !\n");
89 ioctl(floppy_fd
, FDGETDRVPRM
, &floppy_parm
);
92 BL_reg(context
) = floppy_parm
.cmos
;
94 /* CH = low eight bits of max cyl
95 CL = max sec nr (bits 5-0),
96 hi two bits of max cyl (bits 7-6)
98 DH_reg(context
) = 0x01;
99 switch (BL_reg(context
))
101 case 0: /* no drive */
102 CX_reg(context
) = 0x0;
103 DX_reg(context
) = 0x0;
106 CX_reg(context
) = 0x2709;
109 CX_reg(context
) = 0x4f0f;
112 CX_reg(context
) = 0x4f09;
115 CX_reg(context
) = 0x4f12;
119 CX_reg(context
) = 0x4f24;
122 context
->SegEs
= 0x0000; /* FIXME: drive parameter table */
123 DI_reg(context
) = 0x0000;
125 AH_reg(context
) = 0x01;
132 case 0x09: /* INITIALIZE CONTROLLER WITH DRIVE PARAMETERS */
133 case 0x0a: /* FIXED DISK - READ LONG (XT,AT,XT286,PS) */
134 case 0x0b: /* FIXED DISK - WRITE LONG (XT,AT,XT286,PS) */
135 case 0x0c: /* SEEK TO CYLINDER */
136 case 0x0d: /* ALTERNATE RESET HARD DISKS */
137 case 0x10: /* CHECK IF DRIVE READY */
138 case 0x11: /* RECALIBRATE DRIVE */
139 case 0x14: /* CONTROLLER INTERNAL DIAGNOSTIC */
143 case 0x15: /* GET DISK TYPE (AT,XT2,XT286,CONV,PS) */
144 if (DL_reg(context
) & 0x80) { /* hard disk ? */
145 AH_reg(context
) = 3; /* fixed disk */
148 else { /* floppy disk ? */
149 AH_reg(context
) = 2; /* floppy with change detection */
153 case 0x0e: /* READ SECTOR BUFFER (XT only) */
154 case 0x0f: /* WRITE SECTOR BUFFER (XT only) */
155 case 0x12: /* CONTROLLER RAM DIAGNOSTIC (XT,PS) */
156 case 0x13: /* DRIVE DIAGNOSTIC (XT,PS) */
157 AH_reg(context
) = 0x01;
161 case 0x16: /* FLOPPY - CHANGE OF DISK STATUS */
162 AH_reg(context
) = 0; /* FIXME - no change */
164 case 0x17: /* SET DISK TYPE FOR FORMAT */
165 if (DL_reg(context
) < 4)
166 AH_reg(context
) = 0x00; /* successful completion */
168 AH_reg(context
) = 0x01; /* error */
170 case 0x18: /* SET MEDIA TYPE FOR FORMAT */
171 if (DL_reg(context
) < 4)
172 AH_reg(context
) = 0x00; /* successful completion */
174 AH_reg(context
) = 0x01; /* error */
176 case 0x19: /* FIXED DISK - PARK HEADS */
178 INT_BARF( context
, 0x13 );