[vbox-dev] PCI config read/write

Knut St. Osmundsen bird at innotek.de
Wed May 9 18:06:00 GMT 2007

Robert Zeljko wrote:
> I was wondering if there is an interface which can be used to register callback
> read/write functions for the PCI config space.
> I'm adding a network device to the Virtual Box and need to trap all read/writes
> to the PCI config space.
> I've solved my problem by "hacking" VBox PCIDevice structure and exposing
> PCIDEVICEINT structure which is embedded within. This way, after calling
> PDMDevHlpPCIRegister, I change pfnConfigRead and pfnConfigWrite to point to my
> own handlers. I also had to store original pfnConfigWrite pointer and call it
> later from my write handler to keep everything in sync.
> Again, I don't know if there is a way to do this without a hack, however, this
> feature is very important one for anyone who wishes to add a new device to the
> Virtual Box.

Since we haven't yet needed this feature, there is no interface for it 
yet. So, it has to be added and the callback prototypes has to be 
exposed by VBox/pci.h. I'm not entirely sure what would makes the most 
sense here, to adding a pfnPCIRegisterEx or a pfnPCISetConfigCallbacks. 
Probably the latter since the former might be needed to deal with 
multiple pci device/functions per device. Anyway, I won't have time to 
implement this for a while, so a patche would be welcome.

Kind Regards,

More information about the vbox-dev mailing list