No ATA Controller in PCI Configuration Space?
Posted: Sat Feb 20, 2016 1:45 pm
Hello,
I've created some simple PCI configuration space scanning code for my kernel following the guidance of PCI, although I'm a tad concerned at the lack of an ATA controller (class 1, subclass 5) in the output on Qemu, Bochs and VirtualBox. On VirtualBox I get a SATA controller listed (class 1, subclass 6), but even though I have an IDE controller specified in the machine settings the ATA controller does not show up. I don't get a SATA controller listed in Bochs or Qemu, but I don't think I've told them to make one. I have not tried it yet on real hardware, as I want to make sure it works in emulators first. I know the ports for ATA are pretty much standardised, but according to the DMA page on the wiki I need to know BAR4 of the disk controller, so this is a concern as I am planning to use DMA with ATA.
Here is the code I'm using (C++)
I run Qemu with: qemu-system-x86_64 -drive file=drive,format=raw,media=disk,index=0 -m 2048
Attached below is a screenshot of the output on Qemu, Bochs and VirtualBox.
My questions:
1. Is my PCI scanning code correct? Should I be initialising something else first?
2. How can I get it to find the ATA controller? It is not listed in emulators?
3. If I can't find the controller, how should I get the information for DMA? ACPI?
Thanks for your help.
I've created some simple PCI configuration space scanning code for my kernel following the guidance of PCI, although I'm a tad concerned at the lack of an ATA controller (class 1, subclass 5) in the output on Qemu, Bochs and VirtualBox. On VirtualBox I get a SATA controller listed (class 1, subclass 6), but even though I have an IDE controller specified in the machine settings the ATA controller does not show up. I don't get a SATA controller listed in Bochs or Qemu, but I don't think I've told them to make one. I have not tried it yet on real hardware, as I want to make sure it works in emulators first. I know the ports for ATA are pretty much standardised, but according to the DMA page on the wiki I need to know BAR4 of the disk controller, so this is a concern as I am planning to use DMA with ATA.
Here is the code I'm using (C++)
Code: Select all
void pciInit() {
for (int bus = 0; bus < 256; bus++)
for (int device = 0; device < 32; device++) {
int vendorID = pciConfigRead(bus, device, 0, 0) & 0xFFFF;
if (vendorID == PCI_INVALID_VENDOR_ID) continue;
int headerType = 0xFF & (pciConfigRead(bus, device, 0, 0xC) >> 16);
int functions = (headerType & 0x80) ? 8 : 1;
for (int function = 0; function < functions; function++)
if ((pciConfigRead(bus, device, function, 0) & 0xFFFF) != 0xFFFF) {
int vendorID = pciConfigRead(bus, device, 0, 0) & 0xFFFF;
int deviceID = (pciConfigRead(bus, device, 0, 0) >> 16) & 0xFFFF;
int classCode = (pciConfigRead(bus, device, 0, 8) >> 24) & 0xFF;
int subclassCode = (pciConfigRead(bus, device, 0, 8) >> 16) & 0xFF;
printf("Detected device: vendor 0x%X\tdevice 0x%X \tclass 0x%X\tsubclass 0x%X\n",
vendorID, deviceID, classCode, subclassCode);
}
}
}
Attached below is a screenshot of the output on Qemu, Bochs and VirtualBox.
My questions:
1. Is my PCI scanning code correct? Should I be initialising something else first?
2. How can I get it to find the ATA controller? It is not listed in emulators?
3. If I can't find the controller, how should I get the information for DMA? ACPI?
Thanks for your help.