Added some very pedantic warning flags
[tpg/acess2.git] / Modules / Storage / ATA / io.c
index 89fcdb9..44f774a 100644 (file)
@@ -94,7 +94,7 @@ Uint8 *gATA_BusMasterBasePtr; //!< Paging Mapped MMIO (If needed)
  int   gATA_IRQSec = 15;
 volatile int   gaATA_IRQs[2] = {0};
 // - Locks to avoid tripping
-tSpinlock      giaATA_ControllerLock[2];
+tMutex glaATA_ControllerLock[2];
 // - Buffers!
 Uint8  gATA_Buffers[2][(MAX_DMA_SECTORS+0xFFF)&~0xFFF] __attribute__ ((section(".padata")));
 // - PRDTs
@@ -283,7 +283,7 @@ int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer)
        }
 
        // Get exclusive access to the disk controller
-       LOCK( &giaATA_ControllerLock[ cont ] );
+       Mutex_Acquire( &glaATA_ControllerLock[ cont ] );
 
        // Set Size
        gATA_PRDTs[ cont ].Bytes = Count * SECTOR_SIZE;
@@ -332,7 +332,10 @@ int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer)
        // Wait for transfer to complete
        timeoutTime = now() + ATA_TIMEOUT;
        while( gaATA_IRQs[cont] == 0 && now() < timeoutTime)
-               Threads_Yield();
+       {
+               HALT();
+//             Threads_Yield();
+       }
 
        // Complete Transfer
        ATA_int_BusMasterWriteByte( cont << 3, 8 );     // Read and stop
@@ -345,7 +348,7 @@ int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer)
 
        if( gaATA_IRQs[cont] == 0 ) {
                // Release controller lock
-               RELEASE( &giaATA_ControllerLock[ cont ] );
+               Mutex_Release( &glaATA_ControllerLock[ cont ] );
                Log_Warning("ATA",
                        "Read timeout on disk %i (Reading sector 0x%llx)\n",
                        Disk, Address);
@@ -357,7 +360,7 @@ int ATA_ReadDMA(Uint8 Disk, Uint64 Address, Uint Count, void *Buffer)
                // Copy to destination buffer
                memcpy( Buffer, gATA_Buffers[cont], Count*SECTOR_SIZE );
                // Release controller lock
-               RELEASE( &giaATA_ControllerLock[ cont ] );
+               Mutex_Release( &glaATA_ControllerLock[ cont ] );
 
                LEAVE('i', 0);
                return 0;
@@ -384,7 +387,7 @@ int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, const void *Buffer)
        if(Count > MAX_DMA_SECTORS)     return 1;
 
        // Get exclusive access to the disk controller
-       LOCK( &giaATA_ControllerLock[ cont ] );
+       Mutex_Acquire( &glaATA_ControllerLock[ cont ] );
 
        // Set Size
        gATA_PRDTs[ cont ].Bytes = Count * SECTOR_SIZE;
@@ -429,7 +432,10 @@ int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, const void *Buffer)
        // Wait for transfer to complete
        timeoutTime = now() + ATA_TIMEOUT;
        while( gaATA_IRQs[cont] == 0 && now() < timeoutTime)
-               Threads_Yield();
+       {
+//             Threads_Yield();
+               HALT();
+       }
 
        // Complete Transfer
        ATA_int_BusMasterWriteByte( cont << 3, 0 );     // Write and stop
@@ -437,11 +443,11 @@ int ATA_WriteDMA(Uint8 Disk, Uint64 Address, Uint Count, const void *Buffer)
        // If the IRQ is unset, return error
        if( gaATA_IRQs[cont] == 0 ) {
                // Release controller lock
-               RELEASE( &giaATA_ControllerLock[ cont ] );
+               Mutex_Release( &glaATA_ControllerLock[ cont ] );
                return 1;       // Error
        }
        else {
-               RELEASE( &giaATA_ControllerLock[ cont ] );
+               Mutex_Release( &glaATA_ControllerLock[ cont ] );
                return 0;
        }
 }

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