I am currently working on the ATA R/W operations using DMA, and I encountered a little problem while following the tutorial from this website. Indeed, I managed to get the BAR4 value from the IDE controller's PCI Configuration Space (for me, this value is 0x0000C001), but when I try to read a byte, a word or a dword from this address, it returns 0xFF (or 0xFFFF, ...).
It seems an error occured somewhere... I provide you with my code (read functions) :
Code: Select all
u8 PCIreadByte(u8 bus, u8 dev, u8 fn, u8 off)
{
u32 addr = 0x80000000 | (bus << 16) | (dev << 11) | (fn << 8) | (off & 0xFC);
outl(CONFIG_ADDRESS_PORT_BASE, addr);
return inb(CONFIG_DATA_PORT_BASE + (off & 3));
}
u16 PCIreadWord(u8 bus, u8 dev, u8 fn, u8 off)
{
u32 addr = 0x80000000 | (bus << 16) | (dev << 11) | (fn << 8) | (off & 0xFC);
outl(CONFIG_ADDRESS_PORT_BASE, addr);
return inw(CONFIG_DATA_PORT_BASE + (off & 2));
}
u32 PCIreadDword(u8 bus, u8 dev, u8 fn, u8 off)
{
u32 addr = 0x80000000 | (bus << 16) | (dev << 11) | (fn << 8) | (off & 0xFC);
outl(CONFIG_ADDRESS_PORT_BASE, addr);
return inl(CONFIG_DATA_PORT_BASE);
}
u8 PCIreadByteFromRawAddress(u32 addr)
{
outl(CONFIG_ADDRESS_PORT_BASE, addr & 0xFC);
return inb(CONFIG_DATA_PORT_BASE + (addr & 3));
}
u16 PCIreadWordFromRawAddress(u32 addr)
{
outl(CONFIG_ADDRESS_PORT_BASE, addr & 0xFC);
return inw(CONFIG_DATA_PORT_BASE + (addr & 2));
}
u32 PCIreadDwordFromRawAddress(u32 addr)
{
outl(CONFIG_ADDRESS_PORT_BASE, addr & 0xFC);
return inl(CONFIG_DATA_PORT_BASE);
}