My floppy is OK. I tested it in this mobo with vendor BIOS and also in other PC and working good. After apply incremental patch still Disk I/O error: 08.264: Booting from Floppy... 08.264: enter handle_13: 08.264: a=00000201 b=00000000 c=00000001 d=00000000 ds=0000 es=07c0 ss=dd80 08.264: si=00000000 di=00000000 bp=00000000 sp=0000fab8 cs=f000 ip=c9a2 f=0202 08.264: disk_op d=0x000f4500 lba=0 buf=0x00007c00 count=1 cmd=2 08.264: check_recal_drive 0 08.264: floppy_drive_recal 0 08.264: handle_0e 08.264: floppy_pio 08.264: floppy_pio 08.300: floppy_pio 08.682: handle_0e 08.682: floppy_pio 08.682: floppy_media_sense 0 ftype=4 08.682: floppy_drive_readid 0 rate=0 head=0 08.687: floppy_pio 08.689: handle_0e 08.689: floppy_media_sense finish 0 data_rate=0 fms=17 stype=4 08.690: floppy_pio 08.825: handle_0e 08.825: Booting from 0000:7c00 08.825: enter handle_13: 08.825: a=00000201 b=00000700 c=00000002 d=00000100 ds=0000 es=0000 ss=dd80 08.825: si=00007bd2 di=00000700 bp=00007c00 sp=0000fab8 cs=0000 ip=7d6e f=0002 08.825: disk_op d=0x000f4500 lba=19 buf=0x00000700 count=1 cmd=2 08.825: floppy_pio 09.008: handle_0e 09.008: enter handle_13: 09.008: a=00000201 b=00000700 c=00000010 d=00000100 ds=0000 es=0000 ss=dd80 09.008: si=00007bd2 di=00000002 bp=00007c00 sp=0000fab8 cs=0000 ip=7d6e f=0002 09.008: disk_op d=0x000f4500 lba=33 buf=0x00000700 count=1 cmd=2 09.014: floppy_pio 09.138: handle_0e 09.138: enter handle_13: 09.138: a=00000201 b=00000900 c=00000011 d=00000100 ds=0000 es=0000 ss=dd80 09.138: si=00007bd2 di=00000002 bp=00007c00 sp=0000fab8 cs=0000 ip=7d6e f=0006 09.149: disk_op d=0x000f4500 lba=34 buf=0x00000900 count=1 cmd=2 09.149: floppy_pio 09.335: handle_0e 09.335: enter handle_13: 09.335: a=00000201 b=00000b00 c=00000012 d=00000100 ds=0000 es=0000 ss=dd80 09.335: si=00007bd2 di=00000002 bp=00007c00 sp=0000fab8 cs=0000 ip=7d6e f=0006 09.335: disk_op d=0x000f4500 lba=35 buf=0x00000b00 count=1 cmd=2 09.341: floppy_pio 09.721: handle_0e 09.721: floppy error: 40 04 10 01 00 00 02 09.721: invalid basic_access:96: 09.721: a=00000200 b=00000b00 c=00000012 d=00000100 ds=0000 es=0000 ss=dd80 09.722: si=00007bd2 di=00000002 bp=00007c00 sp=0000fab8 cs=0000 ip=7d6e f=0006 ================================================================================= I write how I build coreboot with SeaBIOS:
a.. make menuconfig and set payload SeaBIOS to master b.. cd /coreboot/build c.. rm -R seabios d.. git clone git://git.seabios.org/seabios.git seabios e.. apply patches to src/config.h and src/hw/floppy.c f.. change DEBUG_LEVEL default 1 to 8 in src/Kconfig g.. cd ../.. h.. make i.. ./build/seabios/scripts/encodeint.py floppy0 4 j.. ./build/cbfstool build/coreboot.rom add -f floppy0 -n etc/floppy0 -t raw
On Sat, Dec 07, 2013 at 11:05:17AM +0100, Gelip wrote:
My floppy is OK. I tested it in this mobo with vendor BIOS and also in other PC and working good. After apply incremental patch still Disk I/O error:
Looks like the seabios cyl/head/sector code was totally broken. QEMU was able to cope, but real hardware would not. Can you try the patch below (against a clean repo)?
-Kevin
diff --git a/src/hw/floppy.c b/src/hw/floppy.c index d43b489..8779078 100644 --- a/src/hw/floppy.c +++ b/src/hw/floppy.c @@ -274,38 +274,30 @@ 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; - }
- // Turn on motor of selected drive, DMA & int enabled, normal operation - dor = (floppyid ? 0x20 : 0x10) | 0x0c | floppyid; - outb(dor, PORT_FD_DOR); + 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; + }
return DISK_RET_SUCCESS; } @@ -324,12 +316,24 @@ 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;
- // send Recalibrate command (2 bytes) to controller + // send a Specify command to controller struct floppy_pio_s pio; + pio.cmdlen = 3; + pio.resplen = 0; + pio.waitirq = 0; + pio.data[0] = 0x03; // 07: Recalibrate + pio.data[1] = GET_GLOBAL(diskette_param_table2.dbt.specify1); + pio.data[2] = GET_GLOBAL(diskette_param_table2.dbt.specify2); + ret = floppy_pio(&pio); + if (ret) + return ret; + + // send Recalibrate command (2 bytes) to controller pio.cmdlen = 2; pio.resplen = 0; pio.waitirq = 1; @@ -356,6 +360,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 +389,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 +423,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 +437,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); @@ -496,11 +506,10 @@ static struct chs_s lba2chs(struct disk_op_s *op) { struct chs_s res = { }; - u32 lba = op->lba;
- u32 tmp = lba + 1; + u32 tmp = op->lba; u16 nls = GET_GLOBALFLAT(op->drive_gf->lchs.sector); - res.sector = tmp % nls; + res.sector = (tmp % nls) + 1;
tmp /= nls; u16 nlh = GET_GLOBALFLAT(op->drive_gf->lchs.head);