[SeaBIOS] [coreboot] Patch number 3 for floppy in SeaBIOS 1.7.3-117-g31b8b4e

Kevin O'Connor kevin at koconnor.net
Fri Dec 6 04:27:53 CET 2013


On Thu, Dec 05, 2013 at 08:48:28PM +0100, Gelip wrote:
> Is better, floppy LED light and try read but still Disk I/O error:
[...]
> 07.523: Booting from Floppy...
> 07.523: check_recal_drive 0
> 07.523: floppy_drive_recal 0
> 07.523: floppy_select_drive 0
> 07.523: dor=0
> 07.544: now dor=1c
> 07.544: handle_0e
> 07.544: floppy_pio
> 07.544: port irq dor=1c
> 07.544: floppy_pio
> 07.544: handle_0e
> 07.544: floppy_pio
> 07.544: floppy_media_sense 0 ftype=4
> 07.544: floppy_drive_readid 0 rate=0 head=0
> 07.544: floppy_select_drive 0
> 07.544: dor=1c
> 07.544: floppy_pio
> 07.903: handle_0e
> 07.903: floppy_media_sense finish 0 data_rate=0 fms=17 stype=4
> 07.903: floppy_select_drive 0
> 07.903: dor=1c
> 07.907: floppy_pio
> 08.089: handle_0e
> 08.089: Booting from 0000:7c00
> 08.090: floppy_select_drive 0
> 08.090: dor=1c
> 08.090: floppy_pio
> 08.295: handle_0e
> 08.295: floppy_select_drive 0
> 08.296: dor=1c
> 08.296: floppy_pio
> 08.445: handle_0e
> 08.445: floppy_select_drive 0
> 08.445: dor=1c
> 08.448: floppy_pio
> 08.649: handle_0e
> 08.649: floppy_select_drive 0
> 08.651: dor=1c
> 08.651: floppy_pio
> 08.852: handle_0e
> 08.852: floppy error: 40 04 10 01 00 00 02
> 08.852: invalid basic_access:96:
> 08.852:    a=00000200  b=00000b00  c=00000012  d=00000100 ds=0000 es=0000 ss=dd80
> 08.853:   si=00007bd2 di=00000002 bp=00007c00 sp=0000fb28 cs=0000 ip=7d6e  f=0006

So, this looks like four successful transfers followed by a failure in
the fifth transfer.  It is definitely a different problem from the
previous issue, and it will require different debugging.  Can you go
back to a clean seabios repo and apply the patch below?

-Kevin


diff --git a/src/config.h b/src/config.h
index 64e3c92..9e03ec3 100644
--- a/src/config.h
+++ b/src/config.h
@@ -76,11 +76,11 @@
 #define DEBUG_HDL_05 1
 #define DEBUG_ISR_08 20
 #define DEBUG_ISR_09 9
-#define DEBUG_ISR_0e 9
+#define DEBUG_ISR_0e 1
 #define DEBUG_HDL_10 20
 #define DEBUG_HDL_11 2
 #define DEBUG_HDL_12 2
-#define DEBUG_HDL_13 10
+#define DEBUG_HDL_13 1
 #define DEBUG_HDL_14 2
 #define DEBUG_HDL_15 9
 #define DEBUG_HDL_16 9
diff --git a/src/hw/floppy.c b/src/hw/floppy.c
index d43b489..aae27b2 100644
--- a/src/hw/floppy.c
+++ b/src/hw/floppy.c
@@ -219,6 +219,7 @@ struct floppy_pio_s {
 static int
 floppy_pio(struct floppy_pio_s *pio)
 {
+    dprintf(1, "floppy_pio\n");
     // Send command to controller.
     u32 end = timer_calc(FLOPPY_PIO_TIMEOUT);
     int i = 0;
@@ -274,39 +275,31 @@ floppy_pio(struct floppy_pio_s *pio)
 }
 
 static int
-floppy_enable_controller(void)
-{
-    outb(inb(PORT_FD_DOR) | 0x04, PORT_FD_DOR);
-    int ret = floppy_wait_irq();
-    if (ret)
-        return ret;
-
-    struct floppy_pio_s pio;
-    pio.cmdlen = 1;
-    pio.resplen = 2;
-    pio.waitirq = 0;
-    pio.data[0] = 0x08;  // 08: Check Interrupt Status
-    return floppy_pio(&pio);
-}
-
-static int
 floppy_select_drive(u8 floppyid)
 {
     // reset the disk motor timeout value of INT 08
     SET_BDA(floppy_motor_counter, FLOPPY_MOTOR_TICKS);
 
-    // Enable controller if it isn't running.
-    u8 dor = inb(PORT_FD_DOR);
-    if (!(dor & 0x04)) {
-        int ret = floppy_enable_controller();
+    u8 origdor = inb(PORT_FD_DOR);
+    // Turn on motor of selected drive, DMA & int enabled, normal operation
+    outb((floppyid ? 0x20 : 0x10) | 0x0c | floppyid, PORT_FD_DOR);
+
+    if (!(origdor & 0x04)) {
+        // Controller was just enabled - wait for irq.
+        int ret = floppy_wait_irq();
+        if (ret)
+            return ret;
+
+        struct floppy_pio_s pio;
+        pio.cmdlen = 1;
+        pio.resplen = 2;
+        pio.waitirq = 0;
+        pio.data[0] = 0x08;  // 08: Check Interrupt Status
+        ret = floppy_pio(&pio);
         if (ret)
             return ret;
     }
 
-    // Turn on motor of selected drive, DMA & int enabled, normal operation
-    dor = (floppyid ? 0x20 : 0x10) | 0x0c | floppyid;
-    outb(dor, PORT_FD_DOR);
-
     return DISK_RET_SUCCESS;
 }
 
@@ -324,6 +317,7 @@ set_diskette_current_cyl(u8 floppyid, u8 cyl)
 static int
 floppy_drive_recal(u8 floppyid)
 {
+    dprintf(1, "floppy_drive_recal %d\n", floppyid);
     int ret = floppy_select_drive(floppyid);
     if (ret)
         return ret;
@@ -356,6 +350,8 @@ floppy_drive_recal(u8 floppyid)
 static int
 floppy_drive_readid(u8 floppyid, u8 data_rate, u8 head)
 {
+    dprintf(1, "floppy_drive_readid %d rate=%x head=%x\n"
+            , floppyid, data_rate, head);
     int ret = floppy_select_drive(floppyid);
     if (ret)
         return ret;
@@ -383,6 +379,7 @@ floppy_media_sense(struct drive_s *drive_gf)
 {
     u8 ftype = GET_GLOBALFLAT(drive_gf->floppy_type), stype = ftype;
     u8 floppyid = GET_GLOBALFLAT(drive_gf->cntl_id);
+    dprintf(1, "floppy_media_sense %d ftype=%x\n", floppyid, ftype);
 
     u8 data_rate = GET_GLOBAL(FloppyInfo[stype].data_rate);
     int ret = floppy_drive_readid(floppyid, data_rate, 0);
@@ -416,6 +413,8 @@ floppy_media_sense(struct drive_s *drive_gf)
         < GET_GLOBAL(FloppyInfo[ftype].chs.cylinder))
         fms |= FMS_DOUBLE_STEPPING;
     SET_BDA(floppy_media_state[floppyid], fms);
+    dprintf(1, "floppy_media_sense finish %d data_rate=%x fms=%x stype=%x\n"
+            , floppyid, data_rate, fms, stype);
 
     return DISK_RET_SUCCESS;
 }
@@ -428,6 +427,7 @@ check_recal_drive(struct drive_s *drive_gf)
         && (GET_BDA(floppy_media_state[floppyid]) & FMS_MEDIA_DRIVE_ESTABLISHED))
         // Media is known.
         return DISK_RET_SUCCESS;
+    dprintf(1, "check_recal_drive %d\n", floppyid);
 
     // Recalibrate drive.
     int ret = floppy_drive_recal(floppyid);



More information about the SeaBIOS mailing list