mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 10:12:25 -05:00
Kernel: Fix PATA reads without DMA
Apparently we need to poll the drive for its status after each sector we read if we're not doing DMA. Previously we only did it at the start, which resulted in every sector after the first in a batch having 12 bytes of garbage on the end. This manifested as silent read corruption.
This commit is contained in:
parent
d1a7316799
commit
f6dd76b915
Notes:
sideshowbarker
2024-07-19 12:45:48 +09:00
Author: https://github.com/deoxxa Commit: https://github.com/SerenityOS/serenity/commit/f6dd76b9159 Pull-request: https://github.com/SerenityOS/serenity/pull/437
1 changed files with 12 additions and 4 deletions
|
@ -443,13 +443,21 @@ bool PATAChannel::ata_read_sectors(u32 start_sector, u16 count, u8* outbuf, bool
|
||||||
if (m_device_error)
|
if (m_device_error)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
u8 status = IO::in8(m_io_base + ATA_REG_STATUS);
|
for (int i = 0; i < count; i++) {
|
||||||
ASSERT(status & ATA_SR_DRQ);
|
wait_400ns(m_io_base);
|
||||||
|
|
||||||
|
while (IO::in8(m_io_base + ATA_REG_STATUS) & ATA_SR_BSY)
|
||||||
|
;
|
||||||
|
|
||||||
|
u8 status = IO::in8(m_io_base + ATA_REG_STATUS);
|
||||||
|
ASSERT(status & ATA_SR_DRQ);
|
||||||
#ifdef PATA_DEBUG
|
#ifdef PATA_DEBUG
|
||||||
kprintf("Retrieving %u bytes (status=%b), outbuf=%p...\n", count * 512, status, outbuf);
|
kprintf("PATAChannel: Retrieving 512 bytes (part %d) (status=%b), outbuf=%p...\n", i, status, outbuf + (512 * i));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IO::repeated_in16(m_io_base + ATA_REG_DATA, outbuf, count * 256);
|
IO::repeated_in16(m_io_base + ATA_REG_DATA, outbuf + (512 * i), 256);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue