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 DRQ
void ATA_wait_DRQ() // Wait fot drq to be 1
{
while (!(insb(0x1F7) & STATUS_RDY))
;
}
and the function to read the sector
int disk_read_sector(int lba, void *buf)
{
ATA_wait_BSY();
print("f1");
ATA_wait_DRQ(); // estes dois nao estavam aqui antes pus so pq no write tive de por
print("f2");
lba = lba + OS_SECTORS + HEADER_SECTORS;
outb(0x1F6, (lba >> 24) | 0xE0);
outb(0x1F2, 1);
outb(0x1F3, (unsigned char)(lba & 0xff));
outb(0x1F4, (unsigned char)(lba >> 8));
outb(0x1F5, (unsigned char)(lba >> 16));
outb(0x1F7, 0x20);
unsigned short *ptr = (unsigned short *)buf;
ATA_wait_BSY();
ATA_wait_DRQ();
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 in this video so im really lost the interrupts are working fine, div 0 is good keyboard input also, my unique current problem
i added this function
void checkPort()
{
char a = insb(0x1F7);
a = a + 48;
write_char_pos(5, 5, a, 0x00ff00);
if (a == '0')
{
char b = insb(0x1F1);
b = b + 48;
write_char_pos(6, 6, a, 0x00ff00);
}
}
and it wrote on pos 5,5 the 0 so i think im getting an error and on line 6,6 also a 0