summaryrefslogtreecommitdiff
path: root/tests/libqos/pci.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2016-10-19 14:06:51 +1100
committerDavid Gibson <david@gibson.dropbear.id.au>2016-10-28 09:38:27 +1100
commitb8cc4d0231b97c3dd7930d91ab91657b5a105b78 (patch)
treef3f0277335d8f4206f949b5e189fcfc59ffe0d5c /tests/libqos/pci.h
parenta795fc08f2636013fe097e51bdac62d089ac505a (diff)
downloadqemu-b8cc4d0231b97c3dd7930d91ab91657b5a105b78.tar.gz
libqos: Move BAR assignment to common code
The PCI backends in libqos each supply an iomap() and iounmap() function which is used to set up a specified PCI BAR. But PCI BAR allocation takes place entirely within PCI space, so doesn't really need per-backend versions. For example, Linux includes generic BAR allocation code used on platforms where that isn't done by firmware. This patch merges the BAR allocation from the two existing backends into a single simplified copy. The back ends just need to set up some parameters describing the window of PCI IO and PCI memory addresses which are available for allocation. Like both the existing versions the new one uses a simple bump allocator. Note that (again like the existing versions) this doesn't really handle 64-bit memory BARs properly. It is actually used for such a BAR by the ivshmem test, and apparently the 32-bit MMIO BAR logic is close enough to work, as long as the BAR isn't too big. Fixing that to properly handle 64-bit BAR allocation is a problem for another time. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org>
Diffstat (limited to 'tests/libqos/pci.h')
-rw-r--r--tests/libqos/pci.h7
1 files changed, 3 insertions, 4 deletions
diff --git a/tests/libqos/pci.h b/tests/libqos/pci.h
index 72a2245c05..f6f916dca7 100644
--- a/tests/libqos/pci.h
+++ b/tests/libqos/pci.h
@@ -22,8 +22,7 @@
typedef struct QPCIDevice QPCIDevice;
typedef struct QPCIBus QPCIBus;
-struct QPCIBus
-{
+struct QPCIBus {
uint8_t (*pio_readb)(QPCIBus *bus, uint32_t addr);
uint16_t (*pio_readw)(QPCIBus *bus, uint32_t addr);
uint32_t (*pio_readl)(QPCIBus *bus, uint32_t addr);
@@ -51,8 +50,8 @@ struct QPCIBus
void (*config_writel)(QPCIBus *bus, int devfn,
uint8_t offset, uint32_t value);
- void *(*iomap)(QPCIBus *bus, QPCIDevice *dev, int barno, uint64_t *sizeptr);
- void (*iounmap)(QPCIBus *bus, void *data);
+ uint16_t pio_alloc_ptr;
+ uint64_t mmio_alloc_ptr, mmio_limit;
};
struct QPCIDevice