X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FStorage%2FATA%2Fio.c;h=44f774a21787ed31f865908772bead97dd190b86;hb=9d85201216cb35e1b1e051b1d7cdc38eaa5befa4;hp=89fcdb9f8cb28879105474e9695669023b85da41;hpb=e6b37dbe81b4492796fd262f95fc94e06cb67966;p=tpg%2Facess2.git diff --git a/Modules/Storage/ATA/io.c b/Modules/Storage/ATA/io.c index 89fcdb9f..44f774a2 100644 --- a/Modules/Storage/ATA/io.c +++ b/Modules/Storage/ATA/io.c @@ -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; } }