[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCHv3 04/11] libqos: Better handling of PCI legacy IO
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PATCHv3 04/11] libqos: Better handling of PCI legacy IO |
Date: |
Thu, 20 Oct 2016 14:43:07 +1100 |
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 <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
---
tests/libqos/pci.c | 5 +++++
tests/libqos/pci.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c
index bf1c532..98a2e56 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)
{
diff --git a/tests/libqos/pci.h b/tests/libqos/pci.h
index f6f916d..b6f855e 100644
--- a/tests/libqos/pci.h
+++ b/tests/libqos/pci.h
@@ -94,6 +94,7 @@ void qpci_io_writel(QPCIDevice *dev, void *data, uint32_t
value);
void *qpci_iomap(QPCIDevice *dev, int barno, uint64_t *sizeptr);
void qpci_iounmap(QPCIDevice *dev, void *data);
+void *qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr);
void qpci_plug_device_test(const char *driver, const char *id,
uint8_t slot, const char *opts);
--
2.7.4
- [Qemu-ppc] [PATCHv3 00/11] Cleanups to qtest PCI handling, David Gibson, 2016/10/19
- [Qemu-ppc] [PATCHv3 06/11] libqos: Add streaming accessors for PCI MMIO, David Gibson, 2016/10/19
- [Qemu-ppc] [PATCHv3 05/11] tests: Adjust tco-test to use qpci_legacy_iomap(), David Gibson, 2016/10/19
- [Qemu-ppc] [PATCHv3 10/11] tests: Use qpci_mem{read, write} in ivshmem-test, David Gibson, 2016/10/19
- [Qemu-ppc] [PATCHv3 01/11] libqos: Give qvirtio_config_read*() consistent semantics, David Gibson, 2016/10/19
- [Qemu-ppc] [PATCHv3 02/11] libqos: Handle PCI IO de-multiplexing in common code, David Gibson, 2016/10/19
- [Qemu-ppc] [PATCHv3 04/11] libqos: Better handling of PCI legacy IO,
David Gibson <=
- [Qemu-ppc] [PATCHv3 09/11] libqos: Add 64-bit PCI IO accessors, David Gibson, 2016/10/19
- [Qemu-ppc] [PATCHv3 08/11] tests: Clean up IO handling in ide-test, David Gibson, 2016/10/19
- [Qemu-ppc] [PATCHv3 03/11] libqos: Move BAR assignment to common code, David Gibson, 2016/10/19
- [Qemu-ppc] [PATCHv3 07/11] libqos: Implement mmio accessors in terms of mem{read, write}, David Gibson, 2016/10/19
- [Qemu-ppc] [PATCHv3 11/11] libqos: Change PCI accessors to take opaque BAR handle, David Gibson, 2016/10/19