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
}
// 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;
// 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
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);
// 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;
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;
// 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
// 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;
}
}