diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2016-10-19 17:43:42 +1100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2016-10-28 09:38:27 +1100 |
commit | a7b85b60623a862e2c55d5a6cd2e17f5fc26b256 (patch) | |
tree | 75e709646fbbec836adef029c61f83e2375832b1 /tests/libqos/pci.c | |
parent | b8cc4d0231b97c3dd7930d91ab91657b5a105b78 (diff) | |
download | qemu-a7b85b60623a862e2c55d5a6cd2e17f5fc26b256.tar.gz qemu-a7b85b60623a862e2c55d5a6cd2e17f5fc26b256.tar.bz2 qemu-a7b85b60623a862e2c55d5a6cd2e17f5fc26b256.zip |
libqos: Better handling of PCI legacy IO
The usual model for PCI IO with libqos is to use qpci_iomap() to map a
specific BAR for a PCI device, then perform IOs within that BAR using
qpci_io_{read,write}*().
However, certain devices also have legacy PCI IO. In this case, instead of
(or as well as) being accessed via PCI BARs, the device can be accessed
via certain well-known, fixed addresses in PCI IO space.
Two existing tests use legacy PCI IO, and take different flawed approaches
to it:
* tco-test manually constructs a tco_io_base value instead of calling
qpci_iomap(), which assumes internal knowledge of the structure of
the value it shouldn't have
* ide-test uses direct in*() and out*() calls instead of using
qpci_io_*() accessors, meaning it's not portable to non-x86 machine
types.
This patch implements a new qpci_iomap_legacy() interface which gets a
handle in the same format as qpci_iomap() but refers to a region in
the legacy PIO space. For a device which has the same registers
available both in a BAR and in legacy space (quite common), this
allows the same test code to test both options with just a different
iomap() at the beginning.
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.c')
-rw-r--r-- | tests/libqos/pci.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c index bf1c53240b..98a2e56569 100644 --- a/tests/libqos/pci.c +++ b/tests/libqos/pci.c @@ -350,6 +350,11 @@ void qpci_iounmap(QPCIDevice *dev, void *data) /* FIXME */ } +void *qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr) +{ + return (void *)(uintptr_t)addr; +} + void qpci_plug_device_test(const char *driver, const char *id, uint8_t slot, const char *opts) { |