]> xenbits.xensource.com Git - seabios.git/commitdiff
floppy: Send 4 sense interrupt commands during controller initialization
authorNikolay Nikolov <nickysn@users.sourceforge.net>
Sat, 10 Feb 2018 11:52:17 +0000 (13:52 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 15 Feb 2018 05:18:14 +0000 (00:18 -0500)
During initialization, real floppy controllers need 4 sense interrupt commands
to clear the interrupt status (this represents the transition from "not ready"
to "ready" for each of the four virtual floppy drives), instead of just one.

This is described in detail in section 7.4 - Drive Polling of the Intel 82077AA
datasheet.

Signed-off-by: Nikolay Nikolov <nickysn@users.sourceforge.net>
src/hw/floppy.c

index 933e5c06954aef7d408d3517e132a35de5b5679f..9e6647d4e2156406f09f9caf82616727220a53b7 100644 (file)
@@ -340,8 +340,21 @@ floppy_enable_controller(void)
     if (ret)
         return ret;
 
+    // After the interrupt is received, send 4 SENSE INTERRUPT commands to
+    // clear the interrupt status for each of the four logical drives,
+    // supported by the controller.
+    // See section 7.4 - "Drive Polling" of the Intel 82077AA datasheet for
+    // a more detailed description of why this voodoo needs to be done.
+    // Without this, initialization fails on real controllers (but still works
+    // in QEMU)
     u8 param[2];
-    return floppy_pio(FC_CHECKIRQ, param);
+    int i;
+    for (i=0; i<4; i++) {
+        ret = floppy_pio(FC_CHECKIRQ, param);
+        if (ret)
+            return ret;
+    }
+    return DISK_RET_SUCCESS;
 }
 
 // Activate a drive and send a command to it.