2 * BIOS interrupt 13h handler
11 # include <linux/fd.h>
14 /* #define DEBUG_INT */
15 #include "debugtools.h"
18 DEFAULT_DEBUG_CHANNEL(int);
20 /**********************************************************************
23 * Handler for int 13h (disk I/O).
25 void WINAPI INT_Int13Handler( CONTEXT86 *context )
27 switch(AH_reg(context))
29 case 0x00: /* RESET DISK SYSTEM */
30 break; /* no return ? */
31 case 0x01: /* STATUS OF DISK SYSTEM */
32 AL_reg(context) = 0; /* successful completion */
34 case 0x02: /* READ SECTORS INTO MEMORY */
35 AL_reg(context) = 0; /* number of sectors read */
36 AH_reg(context) = 0; /* status */
38 case 0x03: /* WRITE SECTORS FROM MEMORY */
39 break; /* no return ? */
40 case 0x04: /* VERIFY DISK SECTOR(S) */
41 AL_reg(context) = 0; /* number of sectors verified */
45 case 0x05: /* FORMAT TRACK */
46 case 0x06: /* FORMAT TRACK AND SET BAD SECTOR FLAGS */
47 case 0x07: /* FORMAT DRIVE STARTING AT GIVEN TRACK */
48 /* despite what Ralf Brown says, 0x06 and 0x07 seem to
49 * set CFLAG, too (at least my BIOS does that) */
50 AH_reg(context) = 0x0c;
54 case 0x08: /* GET DRIVE PARAMETERS */
55 if (DL_reg(context) & 0x80) { /* hard disk ? */
56 AH_reg(context) = 0x07;
59 else { /* floppy disk */
61 unsigned int i, nr_of_drives = 0;
62 BYTE drive_nr = DL_reg(context);
64 struct floppy_drive_params floppy_parm;
67 AH_reg(context) = 0x00; /* success */
69 for (i = 0; i < MAX_DOS_DRIVES; i++, root[0]++)
70 if (GetDriveTypeA(root) == DRIVE_REMOVABLE) nr_of_drives++;
71 DL_reg(context) = nr_of_drives;
73 if (drive_nr > 1) { /* invalid drive ? */
80 if ( (floppy_fd = DRIVE_OpenDevice( drive_nr, O_NONBLOCK)) == -1)
82 WARN("(GET DRIVE PARAMETERS): Can't determine floppy geometry !\n");
88 ioctl(floppy_fd, FDGETDRVPRM, &floppy_parm);
91 BL_reg(context) = floppy_parm.cmos;
93 /* CH = low eight bits of max cyl
94 CL = max sec nr (bits 5-0),
95 hi two bits of max cyl (bits 7-6)
97 DH_reg(context) = 0x01;
98 switch (BL_reg(context))
100 case 0: /* no drive */
101 CX_reg(context) = 0x0;
102 DX_reg(context) = 0x0;
105 CX_reg(context) = 0x2709;
108 CX_reg(context) = 0x4f0f;
111 CX_reg(context) = 0x4f09;
114 CX_reg(context) = 0x4f12;
118 CX_reg(context) = 0x4f24;
121 context->SegEs = 0x0000; /* FIXME: drive parameter table */
122 DI_reg(context) = 0x0000;
124 AH_reg(context) = 0x01;
131 case 0x09: /* INITIALIZE CONTROLLER WITH DRIVE PARAMETERS */
132 case 0x0a: /* FIXED DISK - READ LONG (XT,AT,XT286,PS) */
133 case 0x0b: /* FIXED DISK - WRITE LONG (XT,AT,XT286,PS) */
134 case 0x0c: /* SEEK TO CYLINDER */
135 case 0x0d: /* ALTERNATE RESET HARD DISKS */
136 case 0x10: /* CHECK IF DRIVE READY */
137 case 0x11: /* RECALIBRATE DRIVE */
138 case 0x14: /* CONTROLLER INTERNAL DIAGNOSTIC */
142 case 0x15: /* GET DISK TYPE (AT,XT2,XT286,CONV,PS) */
143 if (DL_reg(context) & 0x80) { /* hard disk ? */
144 AH_reg(context) = 3; /* fixed disk */
147 else { /* floppy disk ? */
148 AH_reg(context) = 2; /* floppy with change detection */
152 case 0x0e: /* READ SECTOR BUFFER (XT only) */
153 case 0x0f: /* WRITE SECTOR BUFFER (XT only) */
154 case 0x12: /* CONTROLLER RAM DIAGNOSTIC (XT,PS) */
155 case 0x13: /* DRIVE DIAGNOSTIC (XT,PS) */
156 AH_reg(context) = 0x01;
160 case 0x16: /* FLOPPY - CHANGE OF DISK STATUS */
161 AH_reg(context) = 0; /* FIXME - no change */
163 case 0x17: /* SET DISK TYPE FOR FORMAT */
164 if (DL_reg(context) < 4)
165 AH_reg(context) = 0x00; /* successful completion */
167 AH_reg(context) = 0x01; /* error */
169 case 0x18: /* SET MEDIA TYPE FOR FORMAT */
170 if (DL_reg(context) < 4)
171 AH_reg(context) = 0x00; /* successful completion */
173 AH_reg(context) = 0x01; /* error */
175 case 0x19: /* FIXED DISK - PARK HEADS */
177 INT_BARF( context, 0x13 );