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

Kevin O'Connor kevin at koconnor.net
Wed Dec 11 19:54:18 CET 2013


On Wed, Dec 11, 2013 at 01:44:05PM -0500, Kevin O'Connor wrote:
> On Wed, Dec 11, 2013 at 07:14:47PM +0100, Gelip wrote:
> > 10.076: Booting from Floppy...
> > 10.076: enter handle_13:
> > 10.076:    a=00000201  b=00000000  c=00000001  d=00000000 ds=0000 es=07c0 ss=df80
> > 10.076:   si=00000000 di=00000000 bp=00000000 sp=0000f910 cs=f000 ip=cb8b  f=0202
> > 10.076: disk_op d=0x000f5500 lba=0 buf=0x00007c00 count=1 cmd=2
> > 10.076: Floppy_drive_recal 0
> > 10.076: Floppy_enable_controller
> > 10.076: handle_0e
> > 10.076: handle_0e
> > 10.430: handle_0e
> > 10.430: Floppy_media_sense on drive 0 found rate 0
> > 10.622: handle_0e
> > 10.622: Booting from 0000:7c00
> > 10.622: enter handle_13:
> > 10.622:    a=00000201  b=00000700  c=00000002  d=00000100 ds=0000 es=0000 ss=df80
> > 10.622:   si=00007bd2 di=00000700 bp=00007c00 sp=0000f910 cs=0000 ip=7d6e  f=0002
> > 10.622: disk_op d=0x000f5500 lba=19 buf=0x00000700 count=1 cmd=2
> > 10.811: handle_0e
> > 10.811: enter handle_13:
> > 10.811:    a=00000201  b=00000700  c=00000010  d=00000100 ds=0000 es=0000 ss=df80
> > 10.811:   si=00007bd2 di=00000002 bp=00007c00 sp=0000f910 cs=0000 ip=7d6e  f=0002
> > 10.811: disk_op d=0x000f5500 lba=33 buf=0x00000700 count=1 cmd=2
> > 10.817: Floppy seek 0 to cyl 0
> > 10.817: handle_0e
> > 10.941: handle_0e
> > 10.941: enter handle_13:
> > 10.941:    a=00000201  b=00000900  c=00000011  d=00000100 ds=0000 es=0000 ss=df80
> > 10.941:   si=00007bd2 di=00000002 bp=00007c00 sp=0000f910 cs=0000 ip=7d6e  f=0006
> > 10.944: disk_op d=0x000f5500 lba=34 buf=0x00000900 count=1 cmd=2
> > 10.944: Floppy seek 0 to cyl 0
> > 10.944: handle_0e
> > 11.129: handle_0e
> > 11.129: enter handle_13:
> > 11.129:    a=00000201  b=00000b00  c=00000012  d=00000100 ds=0000 es=0000 ss=df80
> > 11.129:   si=00007bd2 di=00000002 bp=00007c00 sp=0000f910 cs=0000 ip=7d6e  f=0006
> > 11.131: disk_op d=0x000f5500 lba=35 buf=0x00000b00 count=1 cmd=2
> > 11.131: Floppy seek 0 to cyl 0
> > 11.131: handle_0e
> > 11.315: handle_0e
> > 11.315: enter handle_13:
> > 11.315:    a=00000201  b=00000d00  c=00000101  d=00000000 ds=0000 es=0000 ss=df80
> > 11.315:   si=00007bd2 di=00000002 bp=00007c00 sp=0000f910 cs=0000 ip=7d6e  f=0002
> > 11.318: disk_op d=0x000f5500 lba=36 buf=0x00000d00 count=1 cmd=2
> > 11.697: handle_0e
> > 11.697: floppy error: 40 04 10 01 00 01 02
> > 11.697: invalid basic_access:96:
> > 11.697:    a=00000200  b=00000d00  c=00000101  d=00000000 ds=0000 es=0000 ss=df80
> > 11.697:   si=00007bd2 di=00000002 bp=00007c00 sp=0000f910 cs=0000 ip=7d6e  f=0002
> 
> The above output doesn't make sense.  Can you verify that the last
> patch was correctly applied to a clean checkout of the github testing
> branch?
> 
> git clone https://github.com/KevinOConnor/seabios -b testing

If, after confirming the patch, you get the same output, can you try
the patch below then instead?

Thanks,
-Kevin


diff --git a/src/hw/floppy.c b/src/hw/floppy.c
index 48958e6..e18394d 100644
--- a/src/hw/floppy.c
+++ b/src/hw/floppy.c
@@ -320,6 +320,32 @@ floppy_select_drive(u8 floppyid)
     return DISK_RET_SUCCESS;
 }
 
+static int
+floppy_seek(u8 floppyid, u8 cyl)
+{
+    dprintf(1, "Floppy seek %d to cyl %d\n", floppyid, cyl);
+    struct floppy_pio_s pio;
+    pio.cmdlen = 3;
+    pio.resplen = 0;
+    pio.waitirq = 1;
+    pio.data[0] = 0x0f;  // 0f: Seek
+    pio.data[1] = floppyid;
+    pio.data[2] = cyl;
+    int ret = floppy_pio(&pio);
+    if (ret)
+        return ret;
+
+    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;
+
+    return DISK_RET_SUCCESS;
+}
+
 
 /****************************************************************
  * Floppy media sense
@@ -464,6 +490,19 @@ floppy_cmd(struct disk_op_s *op, int blocksize, struct floppy_pio_s *pio)
     if (ret)
         return ret;
 
+    // XXX - seek
+    u8 floppyid = pio->data[1] & 1;
+    if (pio->data[0] == 0xe6 || pio->data[0] == 0xc5) {
+        u8 curcyl = GET_BDA(floppy_track[floppyid]);
+        u8 reqcyl = pio->data[2];
+        if (curcyl != reqcyl) {
+            ret = floppy_seek(floppyid, reqcyl);
+            if (ret)
+                return ret;
+            set_diskette_current_cyl(floppyid, reqcyl);
+        }
+    }
+
     // Setup DMA controller
     int isWrite = pio->data[0] != 0xe6;
     ret = dma_floppy((u32)op->buf_fl, op->count * blocksize, isWrite);
@@ -471,7 +510,7 @@ floppy_cmd(struct disk_op_s *op, int blocksize, struct floppy_pio_s *pio)
         return DISK_RET_EBOUNDARY;
 
     // Invoke floppy controller
-    ret = floppy_select_drive(pio->data[1] & 1);
+    ret = floppy_select_drive(floppyid);
     if (ret)
         return ret;
     pio->resplen = 7;
@@ -494,8 +533,8 @@ floppy_cmd(struct disk_op_s *op, int blocksize, struct floppy_pio_s *pio)
         return DISK_RET_ECONTROLLER;
     }
 
-    u8 track = (pio->cmdlen == 9 ? pio->data[3] : 0);
-    set_diskette_current_cyl(pio->data[0] & 1, track);
+    //u8 track = (pio->cmdlen == 9 ? pio->data[3] : 0);
+    //set_diskette_current_cyl(floppyid, track);
 
     return DISK_RET_SUCCESS;
 }
@@ -605,11 +644,11 @@ floppy_verify(struct disk_op_s *op)
     if (res)
         goto fail;
 
-    struct chs_s chs = lba2chs(op);
+    //struct chs_s chs = lba2chs(op);
 
     // ??? should track be new val from return_status[3] ?
-    u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id);
-    set_diskette_current_cyl(floppyid, chs.cylinder);
+    //u8 floppyid = GET_GLOBALFLAT(op->drive_gf->cntl_id);
+    //set_diskette_current_cyl(floppyid, chs.cylinder);
     return DISK_RET_SUCCESS;
 fail:
     op->count = 0; // no sectors read



More information about the SeaBIOS mailing list