X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FStorage%2FATA%2Fio.c;h=b15918e12b1ee4ba4724635a032693b439b5479b;hb=5b99856adcf93c5b8d85ea6cdd1435dc64e0d6bb;hp=9f471b7d493075192e3e516f48104e89c2378787;hpb=e7a76b0d8a0cc6aa77966509780973a6f8216ef7;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Storage/ATA/io.c b/KernelLand/Modules/Storage/ATA/io.c index 9f471b7d..b15918e1 100644 --- a/KernelLand/Modules/Storage/ATA/io.c +++ b/KernelLand/Modules/Storage/ATA/io.c @@ -249,15 +249,22 @@ Uint64 ATA_GetDiskSize(int Disk) } // Poll until BSY clears or ERR is set + tTime endtime = now() + 2*1000; // 2 second timeout // TODO: Timeout? - while( (val & 0x80) && !(val & 1) ) + while( (val & 0x80) && !(val & 1) && now() < endtime ) val = inb(base+7); LOG("BSY unset (0x%x)", val); // and, wait for DRQ to set - while( !(val & 0x08) && !(val & 1)) + while( !(val & 0x08) && !(val & 1) && now() < endtime ) val = inb(base+7); LOG("DRQ set (0x%x)", val); + if(now() >= endtime) { + Log_Warning("ATA", "Timeout on ATA IDENTIFY (Disk %i)", Disk); + LEAVE('i', 0); + return 0; + } + // Check for an error if(val & 1) { LEAVE('i', 0);