From 3e1b6496be3100d182b764a6eeee94e94e894185 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 26 May 2008 15:06:40 -0400 Subject: Fix bug causing ata_reset to not wait for BSY to clear. ata_reset is always called on a valid drive - it shouldn't need to recheck. All callers expect BSY to be clear upon completion. This fixes an issue where ata_detect was reading status before drive ready. --- src/ata.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/ata.c b/src/ata.c index ab2d170..0546dcd 100644 --- a/src/ata.c +++ b/src/ata.c @@ -118,25 +118,24 @@ ata_reset(int driveid) outb(ATA_CB_DC_HD15 | ATA_CB_DC_NIEN, iobase2+ATA_CB_DC); type=GET_EBDA(ata.devices[driveid].type); - if (type != ATA_TYPE_NONE) { - // 8.2.1 (g) -- check for sc==sn==0x01 - // select device - outb(slave?ATA_CB_DH_DEV1:ATA_CB_DH_DEV0, iobase1+ATA_CB_DH); - sc = inb(iobase1+ATA_CB_SC); - sn = inb(iobase1+ATA_CB_SN); - - if ( (sc==0x01) && (sn==0x01) ) { - if (type == ATA_TYPE_ATA) //ATA - await_ide(NOT_BSY_RDY, iobase1, IDE_TIMEOUT); - else //ATAPI - await_ide(NOT_BSY, iobase1, IDE_TIMEOUT); - } - - // 8.2.1 (h) -- wait for not BSY - await_ide(NOT_BSY, iobase1, IDE_TIMEOUT); + // 8.2.1 (g) -- check for sc==sn==0x01 + // select device + outb(slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0, iobase1+ATA_CB_DH); + sc = inb(iobase1+ATA_CB_SC); + sn = inb(iobase1+ATA_CB_SN); + + // XXX - why special check for ATA and ready? + if ( (sc==0x01) && (sn==0x01) ) { + if (type == ATA_TYPE_ATA) //ATA + await_ide(NOT_BSY_RDY, iobase1, IDE_TIMEOUT); + else //ATAPI + await_ide(NOT_BSY, iobase1, IDE_TIMEOUT); } + // 8.2.1 (h) -- wait for not BSY + await_ide(NOT_BSY, iobase1, IDE_TIMEOUT); + // Enable interrupts outb(ATA_CB_DC_HD15, iobase2+ATA_CB_DC); } -- cgit v1.1