i have written a super simple os and i decided to start using grub to boot it, so i started a new projected and im getting my old kernel functions to the new kernel and the ATA driver is not working stuck when i wait for RDY
Code:
void ATA_wait_BSY() // Wait for bsy to be 0
{
while (insb(0x1F7) & STATUS_BSY)
;
}
void ATA_wait_DRQ() // Wait fot drq to be 1
{
while (!(insb(0x1F7) & STATUS_RDY))
;
}
i have this 2 functions
and
Code:
int disk_read_sector(int lba, void *buf)
{
ATA_wait_BSY();
print("1");
outb(0x1F6, 0xE0 | ((lba >> 24) & 0xF));
outb(0x1F2, 1);
outb(0x1F3, (uint8_t)lba);
outb(0x1F4, (uint8_t)(lba >> 8));
outb(0x1F5, (uint8_t)(lba >> 16));
outb(0x1F7, 0x20); // Send the read command
uint16_t *ptr = (uint16_t *)buf;
ATA_wait_BSY();
print("2");
ATA_wait_DRQ();
print("3");
for (int i = 0; i < 256; i++)
{
*ptr = insw(0x1F0);
ptr++;
}
return 0;
}
i only get printed 1 and 2 so i presume it is stuck on ATA_wait_DRQ();
this used to work on my old bootloader so i think is something related to it the idt is also from the old bootloader and de gdt is the same as nanobyte used.
so im really lost... the interrupts are working fine, div 0 is good... keyboard input also, my unique current problem is this