From 9a84f889471de50144632100109f93aabea68ff6 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 19 Oct 2016 14:19:47 +1100 Subject: libqos: Add streaming accessors for PCI MMIO Currently PCI memory (aka MMIO) space is accessed via a set of readb/writeb style accessors. This is what we want for accessing discrete registers of a certain size. However, there are a few cases where we instead need a "bag of bytes" style streaming interface to PCI MMIO space. This can be either for streaming data style registers or when there's actual memory rather than registers in PCI space, for example frame buffers or ivshmem. This patch adds backend callbacks, and libqos wrappers for this type of byte address order preserving accesses. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier Reviewed-by: Greg Kurz --- tests/libqos/pci-pc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/libqos/pci-pc.c') diff --git a/tests/libqos/pci-pc.c b/tests/libqos/pci-pc.c index d0eb84a134..84aee25350 100644 --- a/tests/libqos/pci-pc.c +++ b/tests/libqos/pci-pc.c @@ -87,6 +87,17 @@ static void qpci_pc_mmio_writel(QPCIBus *bus, uint32_t addr, uint32_t val) writel(addr, val); } +static void qpci_pc_memread(QPCIBus *bus, uint32_t addr, void *buf, size_t len) +{ + memread(addr, buf, len); +} + +static void qpci_pc_memwrite(QPCIBus *bus, uint32_t addr, + const void *buf, size_t len) +{ + memwrite(addr, buf, len); +} + static uint8_t qpci_pc_config_readb(QPCIBus *bus, int devfn, uint8_t offset) { outl(0xcf8, (1U << 31) | (devfn << 8) | offset); @@ -145,6 +156,9 @@ QPCIBus *qpci_init_pc(QGuestAllocator *alloc) ret->bus.mmio_writew = qpci_pc_mmio_writew; ret->bus.mmio_writel = qpci_pc_mmio_writel; + ret->bus.memread = qpci_pc_memread; + ret->bus.memwrite = qpci_pc_memwrite; + ret->bus.config_readb = qpci_pc_config_readb; ret->bus.config_readw = qpci_pc_config_readw; ret->bus.config_readl = qpci_pc_config_readl; -- cgit v1.2.3