Search code examples
macosdriverdevice-driveriokitdarwin

Reading PCI config space in OS X / Darwin KEXTs


In Linux or Windows, one can read the PCI config space of a device from an arbitrary driver (not necessarily the one "owning" that particular PCI device). On Linux, one can do it via pci_read_config_*().

Is there any way of doing this from a KEXT for OS X?


Solution

  • The IOKit class IOPCIDevice, of which there is one for every PCI/Thunderbolt device in the system, has a bunch of configRead* functions for this purpose. You don't have to have exclusive access (with open()) to the instance to do this.