Modules/ATA - Fixed uninitialised variable
[tpg/acess2.git] / KernelLand / Modules / Storage / ATA / io.c
index 9f471b7..28ae899 100644 (file)
@@ -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);
@@ -298,7 +305,7 @@ int ATA_DoDMA(Uint8 Disk, Uint64 Address, Uint Count, int bWrite, void *Buffer)
         int    cont = (Disk>>1)&1;     // Controller ID
         int    disk = Disk & 1;
        Uint16  base;
-        int    bUseBounceBuffer;
+        int    bUseBounceBuffer = 0;
 
        ENTER("iDisk XAddress iCount bbWrite pBuffer", Disk, Address, Count, bWrite, Buffer);
 

UCC git Repository :: git.ucc.asn.au