X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FStorage%2FATA%2Fmain.c;h=5e9eaac0f5ad8988dc8e6365acbe45fbc5f51ec0;hb=30e30d7bc325852a8677819d11a47373b08d6271;hp=4aee411ca70f59bcce462d7f466d9bb3e182196d;hpb=b24ae17361b2ad2d7a9bd57ad5a9bf6bdbdda59c;p=tpg%2Facess2.git diff --git a/Modules/Storage/ATA/main.c b/Modules/Storage/ATA/main.c index 4aee411c..5e9eaac0 100644 --- a/Modules/Storage/ATA/main.c +++ b/Modules/Storage/ATA/main.c @@ -12,6 +12,8 @@ #include #include "common.h" +#define IO_DELAY() do{inb(0x80); inb(0x80); inb(0x80); inb(0x80);}while(0) + // === STRUCTURES === typedef struct { @@ -251,21 +253,34 @@ int ATA_ScanDisk(int Disk) LOG("base = 0x%x", base); - if( 0xFF == inb(base+7) ) { - LOG("Floating bus"); - LEAVE('i', 0); - return 0; - } - // Send Disk Selector if(Disk == 1 || Disk == 3) outb(base+6, 0xB0); else outb(base+6, 0xA0); + IO_DELAY(); + + // Check for a floating bus + if( 0xFF == inb(base+7) ) { + LOG("Floating bus"); + LEAVE('i', 0); + return 0; + } + + // Check for the controller + outb(base+0x02, 0x66); + outb(base+0x03, 0xFF); + if(inb(base+0x02) != 0x66 || inb(base+0x03) != 0xFF) { + LOG("No controller"); + LEAVE('i', 0); + return 0; + } // Send IDENTIFY outb(base+7, 0xEC); + IO_DELAY(); val = inb(base+7); // Read status + LOG("val = 0x%02x", val); if(val == 0) { LEAVE('i', 0); return 0; // Disk does not exist