I'm making a ext2fs driver and while I was debugging it, I noticed the extended superblock was not loading.
When I looked a little further into it, I noticed my drive_read function was returning only zeros the second time it was run.
But if I tried to run it a third time, then it would work... I tried a few thing and it appears like it works in the following pattern:
1 - Works
2 - Doesn't work
3 - Works
4 - Doesn't work
(and so on)
Code: Select all
int ATAPIO_Class::readBlock(int drive, int numblock, int count, char *buf) {
uint16_t tmpword;
int idx;
if (count == 0) {
kernel_panic(0x1234, "Null sector count read");
}
selectDrive(drive, numblock, count);
outb(0x1F7, 0x20);
// Wait for ready signal
uint8_t status = (inb(0x1F7) & 0x08);
while (!status) {
status = (inb(0x1F7) & 0x08);
}
for (idx = 0; idx < 256 * count; idx++) {
tmpword = inw(0x1F0);
buf[idx * 2] = (uint8_t)tmpword;
buf[idx * 2 + 1] = (uint8_t)(tmpword >> 8);
}
return count;
}
also, reading 5 times like it says on the wiki doesn't change anything either :/
I talked to someone who had also tried making a ATAPIO driver and he said he also had issues
so he switched to AHCI, but I don't want to get into AHCI just yet, seems too complicated just
to test my ext2fs driver...
I'm testing my code on QEMU btw.
Hope someone can figure out what's going on