On Sat, Apr 14, 2012 at 12:32:00PM +0000, Blue Swirl wrote: > On Fri, Apr 13, 2012 at 14:27, Stefan Hajnoczi > <stefa...@linux.vnet.ibm.com> wrote: > > This patch adds a common PCI bus driver library which works for > > i386/x86-64 targets. Tests can use the library to probe for PCI > > devices, map BARs, and access configuration space. > > I guess we have almost identical code in SeaBIOS, OpenBIOS, various OS > and maybe userland PCI tools. Would it be possible to reduce NIH > somewhere?
Probably not given how small these functions are and how they use glib assert calls because they are part of tests. > > +void pci_config_writel(PciDevice *dev, unsigned int offset, uint32_t l) > > +{ > > + pci_config_setup(dev, offset); > > + outl(PCI_CONFIG_DATA, l); > > +} > > All code above is specific to i440fx or similar PCI bridges, other > bridges may use different config space access methods. If we want to > share the rest for example with Sparc64 or PPC, the above would need > to be changed. How about splitting the above to a separate file? It > could be done later too. Yes, it's only i440fx for now. I think it makes sense to move it later since we have no non-x86 qtests yet. > > + > > +/* Initialize a PciDevice if a device is present on the bus */ > > The comment talks about initalizing instead of only probing which is > actually what the code does, please fix. Sorry this comment is unclear. I meant initializing the "PciDevice" struct, not the physical PCI device. Will change. Stefan