On Mon, Apr 16, 2012 at 12:20 PM, Andreas Färber <afaer...@suse.de> wrote: > Am 16.04.2012 11:14, schrieb Stefan Hajnoczi: >> 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. > > As stated before, I'm very grateful of your work in this area. I'd be > very interested in having PCI-based tests for the PReP devices we're > introducing - some outline of how non-x86 targets are supposed to fit in > here would be appreciated. For example, would we want to rename the file > to libpci-i440fx.c and have libpci.h be a common interface for multiple > implementations? Or are you expecting some #ifdef TARGET_FOO inside > libpci.c?
I think it's cleanest to have libpci-i440fx.c. When support for the next PCI controller gets added we can decide the details of how to split it. Stefan