aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2008-06-12 22:29:30 -0400
committerKevin O'Connor <kevin@koconnor.net>2008-06-12 22:29:30 -0400
commit2e3eeebc33bcf780912f3b10fb23f82d4f9afb22 (patch)
treef17f99e4de0deebd421e91c2b47f3863c266a94e
parent93479e42900e05a6aafcefa6a6ed80f4e1ee97db (diff)
downloadseabios-2e3eeebc33bcf780912f3b10fb23f82d4f9afb22.tar.gz
Wait for RDY bit when resetting ata hard drives.
If the reset doesn't wait for RDY, apparently irqs can get generated later in the boot which can confuse the OS.
-rw-r--r--src/ata.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ata.c b/src/ata.c
index 62f55d1f..998576cd 100644
--- a/src/ata.c
+++ b/src/ata.c
@@ -132,6 +132,15 @@ ata_reset(int driveid)
// select device
outb(slave ? ATA_CB_DH_DEV1 : ATA_CB_DH_DEV0, iobase1+ATA_CB_DH);
msleep(50);
+ u8 sc = inb(iobase1+ATA_CB_SC);
+ u8 sn = inb(iobase1+ATA_CB_SN);
+
+ // For predetermined ATA drives - wait for ready.
+ if (sc==0x01 && sn==0x01) {
+ u8 type=GET_EBDA(ata.devices[driveid].type);
+ if (type == ATA_TYPE_ATA)
+ await_ide(NOT_BSY_RDY, iobase1, IDE_TIMEOUT);
+ }
// 8.2.1 (h) -- wait for not BSY
status = await_ide(NOT_BSY, iobase1, IDE_TIMEOUT);