ATA PIO Mode
Posted: Sat Jan 28, 2012 4:08 pm
Hello,
I'm having trouble with the ata in pio mode. I've read the wiki and decided to setup a simple read function with lba28. For some odd reason anytime I inb or outb grub won't let me boot saying it's a invalid executable but, when I take away that from the function it boots. Here's my code:
void hdd_lba28_read_sector(uint8 port, uint16 LBA, uint8 count, uint8 *buffer)
{
outb((port | 6), 0xE0 | (port << 4) | ((LBA >> 24) & 0x0F));
outb((port | 1), 0);
outb((port | 2), (uint8) count);
outb((port | 3), (uint8) LBA);
outb((port | 4), (uint8) (LBA >> 8));
outb((port | 5), (uint8) (LBA >> 16));
outb((port | 7), 0x20);
while(!((port | 7) & 0x80))
;
uint32 i=0;
while(i < 256)
{
uint16 temp = inw(port);
buffer[i*2]=(uint8) temp;
buffer[i*2+1]=(uint8) (temp >> 8);
i++;
}
}
For some reason I keep on getting smilie faces but the numbers are 8
If you have an idea of why the outb and inb are causing this problem please respond.
Thank You
I'm having trouble with the ata in pio mode. I've read the wiki and decided to setup a simple read function with lba28. For some odd reason anytime I inb or outb grub won't let me boot saying it's a invalid executable but, when I take away that from the function it boots. Here's my code:
void hdd_lba28_read_sector(uint8 port, uint16 LBA, uint8 count, uint8 *buffer)
{
outb((port | 6), 0xE0 | (port << 4) | ((LBA >> 24) & 0x0F));
outb((port | 1), 0);
outb((port | 2), (uint8) count);
outb((port | 3), (uint8) LBA);
outb((port | 4), (uint8) (LBA >> 8));
outb((port | 5), (uint8) (LBA >> 16));
outb((port | 7), 0x20);
while(!((port | 7) & 0x80))
;
uint32 i=0;
while(i < 256)
{
uint16 temp = inw(port);
buffer[i*2]=(uint8) temp;
buffer[i*2+1]=(uint8) (temp >> 8);
i++;
}
}
For some reason I keep on getting smilie faces but the numbers are 8
If you have an idea of why the outb and inb are causing this problem please respond.
Thank You