summaryrefslogtreecommitdiff
path: root/tests/libqos/pci.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2016-10-19 14:20:44 +1100
committerDavid Gibson <david@gibson.dropbear.id.au>2016-10-28 09:38:27 +1100
commit352d664cce514a94228fbf6e05d03920b2d6bd69 (patch)
tree8bbad2bc422cf795483df500634269d40cff3fd3 /tests/libqos/pci.c
parent9a84f889471de50144632100109f93aabea68ff6 (diff)
downloadqemu-352d664cce514a94228fbf6e05d03920b2d6bd69.tar.gz
qemu-352d664cce514a94228fbf6e05d03920b2d6bd69.tar.bz2
qemu-352d664cce514a94228fbf6e05d03920b2d6bd69.zip
libqos: Implement mmio accessors in terms of mem{read,write}
In the libqos PCI code we now have accessors both for registers (byte significance preserving) and for streaming data (byte address order preserving). These exist in both the interface for qtest drivers and in the machine specific backends. However, the register-style accessors aren't actually necessary in the backend. They can be implemented in terms of the byte address order preserving accessors by the libqos wrappers. This works because PCI is always little endian. This does assume that the back end byte address order preserving accessors will perform the equivalent of a single bus transaction for short lengths. This is the case, and in fact they currently end up using the same cpu_physical_memory_rw() implementation within the qtest accelerator. 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.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c
index 146b06311c..bdffeb3ec2 100644
--- a/tests/libqos/pci.c
+++ b/tests/libqos/pci.c
@@ -230,7 +230,9 @@ uint8_t qpci_io_readb(QPCIDevice *dev, void *data)
if (addr < QPCI_PIO_LIMIT) {
return dev->bus->pio_readb(dev->bus, addr);
} else {
- return dev->bus->mmio_readb(dev->bus, addr);
+ uint8_t val;
+ dev->bus->memread(dev->bus, addr, &val, sizeof(val));
+ return val;
}
}
@@ -241,7 +243,9 @@ uint16_t qpci_io_readw(QPCIDevice *dev, void *data)
if (addr < QPCI_PIO_LIMIT) {
return dev->bus->pio_readw(dev->bus, addr);
} else {
- return dev->bus->mmio_readw(dev->bus, addr);
+ uint16_t val;
+ dev->bus->memread(dev->bus, addr, &val, sizeof(val));
+ return le16_to_cpu(val);
}
}
@@ -252,7 +256,9 @@ uint32_t qpci_io_readl(QPCIDevice *dev, void *data)
if (addr < QPCI_PIO_LIMIT) {
return dev->bus->pio_readl(dev->bus, addr);
} else {
- return dev->bus->mmio_readl(dev->bus, addr);
+ uint32_t val;
+ dev->bus->memread(dev->bus, addr, &val, sizeof(val));
+ return le32_to_cpu(val);
}
}
@@ -263,7 +269,7 @@ void qpci_io_writeb(QPCIDevice *dev, void *data, uint8_t value)
if (addr < QPCI_PIO_LIMIT) {
dev->bus->pio_writeb(dev->bus, addr, value);
} else {
- dev->bus->mmio_writeb(dev->bus, addr, value);
+ dev->bus->memwrite(dev->bus, addr, &value, sizeof(value));
}
}
@@ -274,7 +280,8 @@ void qpci_io_writew(QPCIDevice *dev, void *data, uint16_t value)
if (addr < QPCI_PIO_LIMIT) {
dev->bus->pio_writew(dev->bus, addr, value);
} else {
- dev->bus->mmio_writew(dev->bus, addr, value);
+ value = cpu_to_le16(value);
+ dev->bus->memwrite(dev->bus, addr, &value, sizeof(value));
}
}
@@ -285,7 +292,8 @@ void qpci_io_writel(QPCIDevice *dev, void *data, uint32_t value)
if (addr < QPCI_PIO_LIMIT) {
dev->bus->pio_writel(dev->bus, addr, value);
} else {
- dev->bus->mmio_writel(dev->bus, addr, value);
+ value = cpu_to_le32(value);
+ dev->bus->memwrite(dev->bus, addr, &value, sizeof(value));
}
}