[syslinux:master] memdisk: Enhance disk-probe debugging output

syslinux-bot for Shao Miller shao.miller at yrdsb.edu.on.ca
Tue Jan 25 17:00:08 PST 2011


Commit-ID:  0e64cf5dc6584e9bfefaeb83cd266de13319baa5
Gitweb:     http://syslinux.zytor.com/commit/0e64cf5dc6584e9bfefaeb83cd266de13319baa5
Author:     Shao Miller <shao.miller at yrdsb.edu.on.ca>
AuthorDate: Tue, 25 Jan 2011 10:44:13 -0500
Committer:  Shao Miller <shao.miller at yrdsb.edu.on.ca>
CommitDate: Tue, 25 Jan 2011 16:20:12 -0500

memdisk: Enhance disk-probe debugging output

In an effort to trouble-shoot a problem report on some Dell
models (including an Optiplex GX260), we add further debugging
output to try to find out at which point things go wrong.  The
problem units are apparently probing as "drive present" for all
drives, which obviously isn't right.

Signed-off-by: Shao Miller <shao.miller at yrdsb.edu.on.ca>


---
 memdisk/dskprobe.c |   97 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 77 insertions(+), 20 deletions(-)

diff --git a/memdisk/dskprobe.c b/memdisk/dskprobe.c
index 5c9d601..8c2f27b 100644
--- a/memdisk/dskprobe.c
+++ b/memdisk/dskprobe.c
@@ -33,25 +33,65 @@ static f_printf *dskprobe_printfs[] = { no_printf, printf };
 
 #define dskprobe_printf (dskprobe_printfs[DBG_DSKPROBE])
 
-/*
- * We will probe a BIOS drive numer using INT 13h, AH=probe
- * and will pass along that call's success or failure
+static void dskprobe_pause(com32sys_t *);
+
+/* Probe routine function type */
+typedef int (f_probe) (uint8_t, com32sys_t *);
+static f_probe probe_int13h_08h, probe_int13h_15h, probe_int13h_41h;
+
+/* We will probe a BIOS drive number using INT 0x13, AH == func */
+static void probe_any(uint8_t func, uint8_t drive, com32sys_t * regs)
+{
+    regs->eax.b[1] = func;	/* AH == sub-function for probe */
+    regs->edx.b[0] = drive;	/* DL == drive number to probe */
+    intcall(0x13, regs, regs);
+    return;
+}
+
+/**
+ * INT 0x13, AH == 0x08: Get drive parameters.
  */
-int probe_int13_ah(uint8_t drive, uint8_t probe)
+static int probe_int13h_08h(uint8_t drive, com32sys_t * regs)
 {
-    int err;
-    com32sys_t regs;
+    int present;
 
-    memset(&regs, 0, sizeof regs);
+    memset(regs, 0, sizeof *regs);
+    probe_any(0x08, drive, regs);
+    present = !(regs->eflags.l & 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;
+}
 
-    regs.eax.b[1] = probe;	/* AH = probe                 */
-    regs.edx.b[0] = drive;	/* DL = drive number to probe */
-    intcall(0x13, &regs, &regs);
+/**
+ * INT 0x13, AH == 0x15: Get disk type.
+ */
+static int probe_int13h_15h(uint8_t drive, com32sys_t * regs)
+{
+    int present;
 
-    err = !(regs.eflags.l & 1);
-    dskprobe_printf("probe_int13_ah(0x%02x, 0x%02x) == %d\n", drive, probe,
-		    err);
-    return err;
+    memset(regs, 0, sizeof *regs);
+    probe_any(0x15, drive, regs);
+    present = !(regs->eflags.l & 1);
+    dskprobe_printf("  AH15: CF%d AH%02x\n", regs->eflags.l & 1,
+		    regs->eax.b[1]);
+    return present;
+}
+
+/**
+ * INT 0x13, AH == 0x41: INT 0x13 extensions installation check.
+ */
+static int probe_int13h_41h(uint8_t drive, com32sys_t * regs)
+{
+    int present;
+
+    memset(regs, 0, sizeof *regs);
+    regs->ebx.w[0] = 0x55AA;	/* BX == 0x55AA */
+    probe_any(0x41, drive, regs);
+    present = !(regs->eflags.l & 1);
+    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;
 }
 
 /*
@@ -77,7 +117,7 @@ int probe_bda_drive(uint8_t drive)
 	    bios_drives = 0;
     }
     err = (drive - (drive & 0x80)) >= bios_drives ? 0 : 1;
-    dskprobe_printf("probe_bda_drive(0x%02x) == %d, count: %d\n", drive, err,
+    dskprobe_printf("BDA drive %02x? %d, total count: %d\n", drive, err,
 		    bios_drives);
     return err;
 }
@@ -86,16 +126,21 @@ int probe_bda_drive(uint8_t drive)
  * We will probe a drive with a few different methods, returning
  * the count of succesful probes
  */
-int probe_drive(uint8_t drive)
+int multi_probe_drive(uint8_t drive)
 {
     int c = 0;
+    com32sys_t regs;
+
+    dskprobe_printf("INT 13 DL%02x:\n", drive);
     /* Only probe the BDA for floppies */
     if (drive & 0x80) {
-	c += probe_int13_ah(drive, 0x08);
-	c += probe_int13_ah(drive, 0x15);
-	c += probe_int13_ah(drive, 0x41);
+
+	c += probe_int13h_08h(drive, &regs);
+	c += probe_int13h_15h(drive, &regs);
+	c += probe_int13h_41h(drive, &regs);
     }
     c += probe_bda_drive(drive);
+    dskprobe_pause(&regs);
     return c;
 }
 
@@ -107,7 +152,7 @@ int probe_drive(uint8_t drive)
 uint8_t probe_drive_range(uint8_t start)
 {
     uint8_t drive = start;
-    while (probe_drive(drive)) {
+    while (multi_probe_drive(drive)) {
 	drive++;
 	/* Check for passing the floppy/HDD boundary */
 	if ((drive & 0x7F) == 0)
@@ -122,3 +167,15 @@ static int no_printf(const char *ignored, ...)
     (void)ignored;
     return 0;
 }
+
+/* Pause if we are in debug-mode */
+static void dskprobe_pause(com32sys_t * regs)
+{
+    if (!DBG_DSKPROBE)
+	return;
+    dskprobe_printf("Press a key to continue...\n");
+    memset(regs, 0, sizeof *regs);
+    regs->eax.w[0] = 0;
+    intcall(0x16, regs, NULL);
+    return;
+}



More information about the Syslinux-commits mailing list