I just started fiddling around with harddisk driver writing (using PIO), and I've been going through the specs in The Indespincable PC Hardware Book r3 and it looks all pretty clear-cut and easy to implement, but I'm running into an issue with my read command.
Everything is ZEROs!
im sure it's a stupid mistake, but its annoying the crap out of me.
Code: Select all
void Read_Sector(char Type)
{
outportb(0x1F6, Type); // Drive/Head
outportb(0x1F5, 0x00); // Cylinder MSB
outportb(0x1F4, 0x00); // Cylinder LSB
outportb(0x1F3, 0x00); // Sector Number
outportb(0x1F2, 0x01); // Sector Count
outportb(0x1F1, 0x20); // Command
while(inportb(0x1F7) & 0x80){} // wait for BSY bit to go low
if(inportb(0x1F7) & 0x01){printf("HDD - ERR ERROR 4. \n",0);}
int i = 0;
for(i = 0; i < 256; i++)
{
if(inportw(0x1F0) != 0xD0C4) // I wrote 0xD0C4 256 times and now im trying to read it.
{
printf("ERROR %x \nStatus %x \nSectors Left %u \n", inportb(0x1F1), inportb(0x1F7), inportb(0x1F2));
break;
}
else{printf("YAY \n",0);}
}
printf("HDD - Read Completed \n",0);
}
I havent got to putting in dynamic addressing, but I'm not too concerned with it yet, at least until i can read sectors properly.
BTW, this is just part of an experimental kernel I have going, so no DiNS work with this one. =)
not looking for someone to fix it for me, but to push me in the right direction if this is completely wrong lol.