Fix ata device detection

After grub loading sector and LBA could have been altered
This commit is contained in:
Mathieu Maret 2023-11-20 23:11:12 +01:00 committed by Mathieu Maret
parent f110f85498
commit 8a4e0ff10f

View File

@ -418,6 +418,10 @@ int ATADetectDevice(struct ata_device *dev)
struct ata_controller *ctl = dev->ctl; struct ata_controller *ctl = dev->ctl;
outb(ctl->base + ATA_PIO_DRIVE, outb(ctl->base + ATA_PIO_DRIVE,
ATA_PIO_DRIVE_IBM | (dev->isSlave ? ATA_PIO_DRIVE_SLAVE : ATA_PIO_DRIVE_MASTER)); ATA_PIO_DRIVE_IBM | (dev->isSlave ? ATA_PIO_DRIVE_SLAVE : ATA_PIO_DRIVE_MASTER));
outb(ctl->base + ATA_PIO_SEC_COUNT, 0);
outb(ctl->base + ATA_PIO_LBALO, 0);
outb(ctl->base + ATA_PIO_LBAMID, 0);
outb(ctl->base + ATA_PIO_LBAHI, 0);
unsigned st = inb(ctl->base + ATA_PIO_STATUS); unsigned st = inb(ctl->base + ATA_PIO_STATUS);
if (st & ATA_PIO_STATUS_DRIVE_BUSY) if (st & ATA_PIO_STATUS_DRIVE_BUSY)
goto no_disk; goto no_disk;