2 * BIOS interrupt 13h handler
10 #include <sys/ioctl.h>
16 /* #define DEBUG_INT */
20 /**********************************************************************
23 * Handler for int 13h (disk I/O).
25 void WINAPI INT_Int13Handler( CONTEXT *context )
27 switch(AH_reg(context))
29 case 0x00: /* RESET DISK SYSTEM */
30 case 0x04: /* VERIFY DISK SECTOR(S) */
34 case 0x05: /* FORMAT TRACK */
35 case 0x06: /* FORMAT TRACK AND SET BAD SECTOR FLAGS */
36 case 0x07: /* FORMAT DRIVE STARTING AT GIVEN TRACK */
37 /* despite what Ralf Brown says, 0x06 and 0x07 seem to
38 * set CFLAG, too (at least my BIOS does that) */
39 AH_reg(context) = 0x0c;
43 case 0x08: /* GET DRIVE PARAMETERS */
44 if (DL_reg(context) & 0x80) { /* hard disk ? */
45 AH_reg(context) = 0x07;
48 else { /* floppy disk */
50 unsigned int i, nr_of_drives = 0;
51 BYTE drive_nr = DL_reg(context);
53 struct floppy_drive_params floppy_parm;
55 AH_reg(context) = 0x00; /* success */
57 for (i = 0; i < MAX_DOS_DRIVES; i++)
58 if (DRIVE_GetType(i) == TYPE_FLOPPY) nr_of_drives++;
59 DL_reg(context) = nr_of_drives;
61 if (drive_nr > 1) { /* invalid drive ? */
68 if ( (floppy_fd = DRIVE_OpenDevice( drive_nr, O_NONBLOCK)) == -1)
70 fprintf(stderr, "INT 0x13 (GET DRIVE PARAMETERS): can't determine floppy geometry !\n");
76 ioctl(floppy_fd, FDGETDRVPRM, &floppy_parm);
79 BL_reg(context) = floppy_parm.cmos;
81 /* CH = low eight bits of max cyl
82 CL = max sec nr (bits 5-0),
83 hi two bits of max cyl (bits 7-6)
85 DH_reg(context) = 0x01;
86 switch (BL_reg(context))
88 case 0: /* no drive */
89 CX_reg(context) = 0x0;
90 DX_reg(context) = 0x0;
93 CX_reg(context) = 0x2709;
96 CX_reg(context) = 0x4f0f;
99 CX_reg(context) = 0x4f09;
102 CX_reg(context) = 0x4f12;
106 CX_reg(context) = 0x4f24;
109 ES_reg(context) = 0x0000; /* FIXME: drive parameter table */
110 DI_reg(context) = 0x0000;
112 AH_reg(context) = 0x01;
119 case 0x09: /* INITIALIZE CONTROLLER WITH DRIVE PARAMETERS */
120 case 0x0c: /* SEEK TO CYLINDER */
121 case 0x0d: /* RESET HARD DISKS */
122 case 0x10: /* CHECK IF DRIVE READY */
123 case 0x11: /* RECALIBRATE DRIVE */
124 case 0x14: /* CONTROLLER INTERNAL DIAGNOSTIC */
128 case 0x0e: /* READ SECTOR BUFFER (XT only) */
129 case 0x0f: /* WRITE SECTOR BUFFER (XT only) */
130 case 0x12: /* CONTROLLER RAM DIAGNOSTIC (XT,PS) */
131 case 0x13: /* DRIVE DIAGNOSTIC (XT,PS) */
132 AH_reg(context) = 0x01;
137 INT_BARF( context, 0x13 );