Kernel: ATA controller waits now before read/write until disk is ready

Qemu used to freeze on disk writes but now it seems fine
This commit is contained in:
Bananymous 2023-04-02 05:34:58 +03:00
parent 471ac80420
commit f2362b2b78
1 changed files with 2 additions and 0 deletions

View File

@ -216,6 +216,7 @@ namespace Kernel
if (lba < (1 << 28)) if (lba < (1 << 28))
{ {
// LBA28 // LBA28
TRY(device->wait(false));
device->io_write(ATA_PORT_DRIVE_SELECT, 0xE0 | device->m_slave_bit | ((lba >> 24) & 0x0F)); device->io_write(ATA_PORT_DRIVE_SELECT, 0xE0 | device->m_slave_bit | ((lba >> 24) & 0x0F));
device->io_write(ATA_PORT_SECTOR_COUNT, sector_count); device->io_write(ATA_PORT_SECTOR_COUNT, sector_count);
device->io_write(ATA_PORT_LBA0, (uint8_t)(lba >> 0)); device->io_write(ATA_PORT_LBA0, (uint8_t)(lba >> 0));
@ -248,6 +249,7 @@ namespace Kernel
if (lba < (1 << 28)) if (lba < (1 << 28))
{ {
// LBA28 // LBA28
TRY(device->wait(false));
device->io_write(ATA_PORT_DRIVE_SELECT, 0xE0 | device->m_slave_bit | ((lba >> 24) & 0x0F)); device->io_write(ATA_PORT_DRIVE_SELECT, 0xE0 | device->m_slave_bit | ((lba >> 24) & 0x0F));
device->io_write(ATA_PORT_SECTOR_COUNT, sector_count); device->io_write(ATA_PORT_SECTOR_COUNT, sector_count);
device->io_write(ATA_PORT_LBA0, (uint8_t)(lba >> 0)); device->io_write(ATA_PORT_LBA0, (uint8_t)(lba >> 0));