1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:38:11 +00:00

IDEDiskDevice: Use wait_for_irq() when waiting for DMA transfers.

Also make sure we return any device errors to caller.
This commit is contained in:
Andreas Kling 2019-05-19 03:56:06 +02:00
parent c818773983
commit ed79116e94

View file

@ -320,17 +320,12 @@ bool IDEDiskDevice::read_sector_with_dma(dword lba, byte* outbuf)
// Start bus master
IO::out8(m_bus_master_base, 0x9);
for (;;) {
auto status = IO::in8(m_bus_master_base + 2);
auto dstatus = IO::in8(io_base + ATA_REG_STATUS);
if (!(status & 4))
continue;
if (!(dstatus & ATA_SR_BSY))
break;
}
wait_for_irq();
disable_irq();
if (m_device_error)
return false;
// I read somewhere that this may trigger a cache flush so let's do it.
IO::out8(m_bus_master_base + 2, IO::in8(m_bus_master_base + 2) | 0x6);
return true;