[SeaBIOS] [coreboot] Patch number 2 - floppy "dor" test
Kevin O'Connor
kevin at koconnor.net
Thu Dec 5 17:20:19 CET 2013
On Thu, Dec 05, 2013 at 10:55:37AM +0100, Gelip wrote:
> 08.313: Booting from Floppy...
> 08.313: check_recal_drive 0
> 08.313: floppy_drive_recal 0
> 08.313: floppy_select_drive 0
> 08.313: dor=0
> 08.313: floppy_enable_controller dor=0
> 08.348: now dor=4
> 10.296: floppy_disable_controller
> 10.296: invalid basic_access:96:
> 10.296: a=00000200 b=00000000 c=00000001 d=00000000 ds=0000 es=07c0 ss=dd80
> 10.296: si=00000000 di=00000000 bp=00000000 sp=0000fb08 cs=f000 ip=c996 f=0202
> 10.297: Boot failed: could not read the boot disk
Okay - I think I see what is happening. Can you try the patch below
(which is against seabios git master - the compile problem you had
yesterday should be fixed). This patch isn't fully correct, but I'd
like to see if it helps.
-Kevin
diff --git a/src/hw/floppy.c b/src/hw/floppy.c
index d43b489..a8e5b2a 100644
--- a/src/hw/floppy.c
+++ b/src/hw/floppy.c
@@ -183,6 +183,7 @@ find_floppy_type(u32 size)
static void
floppy_disable_controller(void)
{
+ dprintf(1, "floppy_disable_controller\n");
outb(inb(PORT_FD_DOR) & ~0x04, PORT_FD_DOR);
}
@@ -219,6 +220,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 +276,35 @@ 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)
{
+ dprintf(1, "floppy_select_drive %d\n", 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);
+ dprintf(1, "dor=%x\n", origdor);
+ // Turn on motor of selected drive, DMA & int enabled, normal operation
+ outb((floppyid ? 0x20 : 0x10) | 0x0c | floppyid, PORT_FD_DOR);
+
+ if (!(origdor & 0x04)) {
+ dprintf(1, "now dor=%x\n", inb(PORT_FD_DOR));
+ // 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;
+ dprintf(1, "port irq dor=%x\n", inb(PORT_FD_DOR));
}
- // 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 +322,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 +355,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 +384,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 +418,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 +432,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);
@@ -658,7 +663,7 @@ handle_0e(void)
{
if (! CONFIG_FLOPPY)
return;
- debug_isr(DEBUG_ISR_0e);
+ debug_isr(1);
// diskette interrupt has occurred
u8 frs = GET_BDA(floppy_recalibration_status);
More information about the SeaBIOS
mailing list