I have been developping an OS for two months now and today, I intend to implement ATA R/W via DMA. I have read the tutorial on the website, which is quite consistent. However, to configure DMA, I need to access the hard drive controller's PCI Configuration Space and my problem is this device is not detected on the PCI bus.
To be more precise, the only detected devices are the following (and there references do exist, cf. http://www.pcidatabase.com) :
Device 1 :
VendorID : 0x8086
DeviceID : 0x1237
Class code : 0x0006
Subclass : 0x0000
Device 2 :
VendorID : 0x8086
DeviceID : 0x7000
Class code : 0x0006
Subclass : 0x0001
Device 3 :
VendorID : 0x1013
DeviceID : 0x00B8
Class code : 0x0003
Subclass : 0x0000
Device 4 :
VendorID : 0x10EC
DeviceID : 0x8139
Class code : 0x0002
Subclass : 0x0000
Finally, you have here my code. I implemented PCI read/write functions in the same way as in Linux source code, that is to say that the functions belonging to PCIread.../PCIwrite... family work with the following parameters : bus, device, function, offset.
Code: Select all
void PCItest()
{
u32 bus = 0, dev = 0;
u16 vendorId = 0;
while(bus < 2)
{
dev = 0;
while(1)
{
vendorId = PCIreadWord(bus, dev, 0, PCI_REG_VENDOR_ID);
if(vendorId != 0xFFFF)
{
print("Bus "); printnumber(bus); print(" device "); printnumber(dev); print("\n");
print(" Vendor ID : "); printnumber(vendorId); print("\n");
print(" Device ID : "); printnumber(PCIreadWord(bus, dev, 0, PCI_REG_DEVICE_ID)); print("\n");
print(" Class code : "); printnumber(PCIreadByte(bus, dev, 0, PCI_REG_CLASS_CODE)); print("\n");
print(" Subclass : "); printnumber(PCIreadByte(bus, dev, 0, PCI_REG_SUBCLASS)); print("\n");
dev++;
}
else
break;
}
bus++;
}
}
Thanks for your help.
PS : My code may be someway wrong. Indeed, it scans bus 0 and 1, but actually, I do not know if there can be more than one PCI bus in a machine.
PS 2 : Sorry if my English is not so good, I am French.