[C] ATA PIO Problem
Posted: Tue May 15, 2012 10:22 am
Hello, new here, 15 years old , coding a kernel and from germany (enough information about myself)
I have a Problem with my ATA PIO Kernel Driver. I can read e.g. the MBR Sector etc, but when I try to read Sector 0x11CE (RootDir in my case), the
only output I get are some zeros. So it seems that the driver is not able to read Sector < 512, but I can't understand why, because I am already writing the Sector number with my outsw function instead of outb. Please help me. This is the code:
Any advice accepted.
Thank you very much
I have a Problem with my ATA PIO Kernel Driver. I can read e.g. the MBR Sector etc, but when I try to read Sector 0x11CE (RootDir in my case), the
only output I get are some zeros. So it seems that the driver is not able to read Sector < 512, but I can't understand why, because I am already writing the Sector number with my outsw function instead of outb. Please help me. This is the code:
Code: Select all
unsigned char *hdReadSector(short Sector)
{
unsigned char output[512];
outb(0x1f6, 0x0); // Drive 0, Head 0
outb(0x1f2, 0x1); // Read 1 Sector
outsw(0x1f3, &Sector, 0x1); //outb(0x1f3, Sector); // Sector to read
outb(0x1f4, 0); // Cylinder Low Port
outb(0x1f5, 0); // Cylinder High Port
outb(0x1f7, 0x20); // Read with retry
int x = 0;
while (x != 30000)
x++;
//while (!(inb(0x1f7) & 0x8 )) {};
int i = 0;
for (i; i < 256; i++)
{
short in = 0;
insw(0x1f0, &in, 0x1);
output[i*2] = in & 0xFF;
output[(i*2)+1] = in >> 8;
}
return output;
}
Thank you very much