From 61df6e617c2d755ef8cac91c8c4b9bc2710b2bee Mon Sep 17 00:00:00 2001 From: Shao Miller Date: Wed, 26 Jan 2011 20:10:24 -0500 Subject: [PATCH] memdisk/dskprobe.c: Additional checks in INT13h AH08h and AH41h 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 --- memdisk/dskprobe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/memdisk/dskprobe.c b/memdisk/dskprobe.c index 84400a8..ee7be12 100644 --- a/memdisk/dskprobe.c +++ b/memdisk/dskprobe.c @@ -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; -- 2.7.4