[SeaBIOS] [coreboot] Patch number 4 for floppy in SeaBIOS

Kevin O'Connor kevin at koconnor.net
Fri Dec 13 16:59:13 CET 2013


On Fri, Dec 13, 2013 at 10:43:18AM +0100, Gelip wrote:
> "Do you consistently see the fault in the same place?"
> 
> No, this is random place. I test BOOT-PROM3 disk and try boot PC more time. Every time is a different place e.g.:
> 
> lba=1051, lba=1086, lba=1015

Does the patch below on top of the testing git repo help?

-Kevin


diff --git a/src/hw/floppy.c b/src/hw/floppy.c
index b848203..a7f6707 100644
--- a/src/hw/floppy.c
+++ b/src/hw/floppy.c
@@ -558,7 +558,7 @@ floppy_read(struct disk_op_s *op)
         goto fail;
     return DISK_RET_SUCCESS;
 fail:
-    op->count = 0; // no sectors read
+    //op->count = 0; // no sectors read
     return res;
 }
 
@@ -587,7 +587,7 @@ floppy_write(struct disk_op_s *op)
         goto fail;
     return DISK_RET_SUCCESS;
 fail:
-    op->count = 0; // no sectors read
+    //op->count = 0; // no sectors read
     return res;
 }
 
@@ -603,7 +603,7 @@ floppy_verify(struct disk_op_s *op)
     // This command isn't implemented - just return success.
     return DISK_RET_SUCCESS;
 fail:
-    op->count = 0; // no sectors read
+    //op->count = 0; // no sectors read
     return res;
 }
 
@@ -633,20 +633,33 @@ process_floppy_op(struct disk_op_s *op)
     if (!CONFIG_FLOPPY)
         return 0;
 
-    switch (op->command) {
-    case CMD_RESET:
-        return floppy_reset(op);
-    case CMD_READ:
-        return floppy_read(op);
-    case CMD_WRITE:
-        return floppy_write(op);
-    case CMD_VERIFY:
-        return floppy_verify(op);
-    case CMD_FORMAT:
-        return floppy_format(op);
-    default:
-        op->count = 0;
-        return DISK_RET_EPARAM;
+    int origcount = op->count, retry = 0;
+    for (;;) {
+        int ret;
+        switch (op->command) {
+        case CMD_RESET:
+            return floppy_reset(op);
+        case CMD_READ:
+            ret = floppy_read(op);
+            break;
+        case CMD_WRITE:
+            ret = floppy_write(op);
+            break;
+        case CMD_VERIFY:
+            ret = floppy_verify(op);
+            break;
+        case CMD_FORMAT:
+            ret = floppy_format(op);
+            break;
+        default:
+            op->count = 0;
+            return DISK_RET_EPARAM;
+        }
+        if (ret == DISK_RET_ECONTROLLER && retry++ < 2)
+            continue;
+        if (ret != DISK_RET_SUCCESS && op->count == origcount)
+            op->count = 0;
+        return ret;
     }
 }
 



More information about the SeaBIOS mailing list