memdisk/dskprobe.c: Additional checks in INT13h AH08h and AH41h
authorShao Miller <shao.miller@yrdsb.edu.on.ca>
Thu, 27 Jan 2011 01:10:24 +0000 (20:10 -0500)
committerGene Cumm <gene.cumm@gmail.com>
Thu, 27 Jan 2011 01:40:41 +0000 (20:40 -0500)
Some BIOSs lie and don't set CF when they should.

Additional comments from Shao:

Fix INT 0x13, AH==0x08 disk drive probe.

This function might return CF==0 ("success"), but could return a
standard response no matter which drive number is passed in DL, but
based only on DL's bit 7.  Fortunately, AH should be 0 for an existent
drive and 01h for a non-existent drive.  Now we check AH.

Fix INT 0x13, AH==0x41 disk drive probe

This function might return CF==0 ("success"), but could also include BX
left unchanged.  If extensions are present, BX should be returned with
0xAA55.  So we now check for this special value in our determination of
a drive's presence.

Signed-off-by: Gene Cumm <gene.cumm@gmail.com>
memdisk/dskprobe.c

index 84400a8..ee7be12 100644 (file)
@@ -57,7 +57,7 @@ static int probe_int13h_08h(uint8_t drive, com32sys_t * regs)
 
     memset(regs, 0, sizeof *regs);
     probe_any(0x08, drive, regs);
-    present = !(regs->eflags.l & 1);
+    present = !(regs->eflags.l & 1) && !regs->eax.b[1];
     dskprobe_printf("  AH08: CF%d BL%02x DL%02x\n", regs->eflags.l & 1,
                    regs->ebx.b[0], regs->edx.b[0]);
     return present;
@@ -88,7 +88,7 @@ static int probe_int13h_41h(uint8_t drive, com32sys_t * regs)
     memset(regs, 0, sizeof *regs);
     regs->ebx.w[0] = 0x55AA;   /* BX == 0x55AA */
     probe_any(0x41, drive, regs);
-    present = !(regs->eflags.l & 1);
+    present = !(regs->eflags.l & 1) && (regs->ebx.w[0] == 0xAA55);
     dskprobe_printf("  AH41: CF%d BX%04x AH%02x DH%02x\n", regs->eflags.l & 1,
                    regs->ebx.w[0], regs->eax.b[1], regs->edx.b[1]);
     return present;