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

Kevin O'Connor kevin at koconnor.net
Fri Dec 13 23:50:20 CET 2013


On Fri, Dec 13, 2013 at 06:05:28PM +0100, Gelip wrote:
> No, patch not help.
> ===================
[...]
> 13.775: enter handle_13:
> 13.775:    a=00000201  b=00000000  c=00001c07  d=00000000 ds=5000 es=60c0 ss=df80
> 13.775:   si=00000000 di=000056c0 bp=0000001e sp=0000f930 cs=5000 ip=0188  f=0246
> 13.777: disk_op d=0x000f5520 lba=1014 buf=0x00060c00 count=1 cmd=2
> 13.977: handle_0e
> 13.977: floppy error: 40 20 20 1c 00 07 02
> 14.178: handle_0e
> 14.178: floppy error: 40 20 20 1c 00 07 02
> 14.381: handle_0e
> 14.381: floppy error: 40 20 20 1c 00 07 02
> 14.381: invalid basic_access:96:
> 14.381:    a=00000200  b=00000000  c=00001c07  d=00000000 ds=5000 es=60c0 ss=df80
> 14.381:   si=00000000 di=000056c0 bp=0000001e sp=0000f930 cs=5000 ip=0188  f=0246

Maybe the patch below instead will help?

-Kevin


diff --git a/src/hw/floppy.c b/src/hw/floppy.c
index b848203..8d940a9 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,37 @@ 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) {
+            u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id);
+            u8 frs = GET_BDA(floppy_recalibration_status);
+            SET_BDA(floppy_recalibration_status, frs & ~(1<<floppyid));
+            continue;
+        }
+        if (ret != DISK_RET_SUCCESS && op->count == origcount)
+            op->count = 0;
+        return ret;
     }
 }
 



More information about the SeaBIOS mailing list