[Help] Reading a hard drive (LBA).
Posted: Sat Jan 08, 2011 1:50 pm
Hi guys! Lately i have been trying to add drive reading support to my kernel. Here is what i have so far:
Unfortuantely this code doesnt work... In bochs, i get the error... read sectors issued to non-disk. I belive i am getting this because i am either not putting in the right drive id, or it cannot find the drive. The error pops up in the console on this command outportb(0x1F7, 0x20); (Tells the controller to read). This is probably a simple issue. Any support would be greatly appreciated!
Thanks!
Code: Select all
void write_read_test()
{
outportb(0x1F6, 0x40);
outportb(0x1F1, 0x00);
outportb(0x1F2, (unsigned char) 1);
outportb(0x1F3, (unsigned char) 000000000000000000000000);
outportb(0x1F4, (unsigned char) 000000000000000000000000 >> 8);
outportb(0x1F5, (unsigned char) 000000000000000000000000 >> 16);
outportb(0x1F7, 0x20);
inportb(0x3F6);
inportb(0x3F6);
inportb(0x3F6);
inportb(0x3F6);
k_printf("\n");
k_printf("Reading...\n");
char *buffer;
int i = 0;
while(buffer != 256)
{
buffer[i] = inportw(0x1F0);
i++;
}
k_printf(buffer);
}
Thanks!