Code: Select all
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))
;
}
and
Code: Select all
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;
}
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