[SeaBIOS] [PATCH 5/5] floppy: Send 4 sense interrupt commands during controller initialization.

Nikolay Nikolov nickysn at users.sourceforge.net
Fri Feb 9 01:31:03 CET 2018


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 at users.sourceforge.net>
---
 src/hw/floppy.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/hw/floppy.c b/src/hw/floppy.c
index 21389bc..d80851b 100644
--- a/src/hw/floppy.c
+++ b/src/hw/floppy.c
@@ -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.
-- 
2.14.3




More information about the SeaBIOS mailing list