[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH 10/22] virtio-pci: convert PIO to new memory api read/
From: |
Alexander Graf |
Subject: |
[Qemu-ppc] [PATCH 10/22] virtio-pci: convert PIO to new memory api read/write |
Date: |
Mon, 29 Oct 2012 11:25:59 +0100 |
Signed-off-by: Alexander Graf <address@hidden>
---
hw/virtio-pci.c | 126 +++++++++++++++++++++---------------------------------
1 files changed, 49 insertions(+), 77 deletions(-)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index c7f20c3..9603150 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -374,79 +374,39 @@ static uint32_t virtio_ioport_read(VirtIOPCIProxy *proxy,
uint32_t addr)
return ret;
}
-static uint32_t virtio_pci_config_readb(void *opaque, uint32_t addr)
-{
- VirtIOPCIProxy *proxy = opaque;
- uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev);
- if (addr < config)
- return virtio_ioport_read(proxy, addr);
- addr -= config;
- return virtio_config_readb(proxy->vdev, addr);
-}
-
-static uint32_t virtio_pci_config_readw(void *opaque, uint32_t addr)
-{
- VirtIOPCIProxy *proxy = opaque;
- uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev);
- uint16_t val;
- if (addr < config)
- return virtio_ioport_read(proxy, addr);
- addr -= config;
- val = virtio_config_readw(proxy->vdev, addr);
- if (virtio_is_big_endian()) {
- /*
- * virtio is odd, ioports are LE but config space is target native
- * endian. However, in qemu, all PIO is LE, so we need to re-swap
- * on BE targets
- */
- val = bswap16(val);
- }
- return val;
-}
-
-static uint32_t virtio_pci_config_readl(void *opaque, uint32_t addr)
-{
- VirtIOPCIProxy *proxy = opaque;
- uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev);
- uint32_t val;
- if (addr < config)
- return virtio_ioport_read(proxy, addr);
- addr -= config;
- val = virtio_config_readl(proxy->vdev, addr);
- if (virtio_is_big_endian()) {
- val = bswap32(val);
- }
- return val;
-}
-
-static void virtio_pci_config_writeb(void *opaque, uint32_t addr, uint32_t val)
+static uint64_t virtio_pci_config_read(void *opaque, hwaddr addr,
+ unsigned size)
{
VirtIOPCIProxy *proxy = opaque;
uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev);
+ uint64_t val = 0;
if (addr < config) {
- virtio_ioport_write(proxy, addr, val);
- return;
+ return virtio_ioport_read(proxy, addr);
}
addr -= config;
- virtio_config_writeb(proxy->vdev, addr, val);
-}
-static void virtio_pci_config_writew(void *opaque, uint32_t addr, uint32_t val)
-{
- VirtIOPCIProxy *proxy = opaque;
- uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev);
- if (addr < config) {
- virtio_ioport_write(proxy, addr, val);
- return;
- }
- addr -= config;
- if (virtio_is_big_endian()) {
- val = bswap16(val);
+ switch (size) {
+ case 1:
+ val = virtio_config_readb(proxy->vdev, addr);
+ break;
+ case 2:
+ val = virtio_config_readw(proxy->vdev, addr);
+ if (virtio_is_big_endian()) {
+ val = bswap16(val);
+ }
+ break;
+ case 4:
+ val = virtio_config_readl(proxy->vdev, addr);
+ if (virtio_is_big_endian()) {
+ val = bswap32(val);
+ }
+ break;
}
- virtio_config_writew(proxy->vdev, addr, val);
+ return val;
}
-static void virtio_pci_config_writel(void *opaque, uint32_t addr, uint32_t val)
+static void virtio_pci_config_write(void *opaque, hwaddr addr,
+ uint64_t val, unsigned size)
{
VirtIOPCIProxy *proxy = opaque;
uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev);
@@ -455,24 +415,36 @@ static void virtio_pci_config_writel(void *opaque,
uint32_t addr, uint32_t val)
return;
}
addr -= config;
- if (virtio_is_big_endian()) {
- val = bswap32(val);
+ /*
+ * Virtio-PCI is odd. Ioports are LE but config space is target native
+ * endian.
+ */
+ switch (size) {
+ case 1:
+ virtio_config_writeb(proxy->vdev, addr, val);
+ break;
+ case 2:
+ if (virtio_is_big_endian()) {
+ val = bswap16(val);
+ }
+ virtio_config_writew(proxy->vdev, addr, val);
+ break;
+ case 4:
+ if (virtio_is_big_endian()) {
+ val = bswap32(val);
+ }
+ virtio_config_writel(proxy->vdev, addr, val);
+ break;
}
- virtio_config_writel(proxy->vdev, addr, val);
}
-static const MemoryRegionPortio virtio_portio[] = {
- { 0, 0x10000, 1, .write = virtio_pci_config_writeb, },
- { 0, 0x10000, 2, .write = virtio_pci_config_writew, },
- { 0, 0x10000, 4, .write = virtio_pci_config_writel, },
- { 0, 0x10000, 1, .read = virtio_pci_config_readb, },
- { 0, 0x10000, 2, .read = virtio_pci_config_readw, },
- { 0, 0x10000, 4, .read = virtio_pci_config_readl, },
- PORTIO_END_OF_LIST()
-};
-
static const MemoryRegionOps virtio_pci_config_ops = {
- .old_portio = virtio_portio,
+ .read = virtio_pci_config_read,
+ .write = virtio_pci_config_write,
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 4,
+ },
.endianness = DEVICE_LITTLE_ENDIAN,
};
--
1.6.0.2
- [Qemu-ppc] [PULL 00/22] ppc patch queue 2012-10-29, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 01/22] Remove TARGET_PHYS_ADDR_BITS define completely, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 05/22] Add USB option in machine options, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 03/22] PPC: 440: Emulate DCBR0, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 02/22] PPC: Bamboo: Fix memory size DT property, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 06/22] pseries: Don't allow duplicate registration of hcalls or RTAS calls, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 07/22] target-ppc: Rework storage of VPA registration state, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 09/22] ac97: convert PIO to new memory api read/write, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 10/22] virtio-pci: convert PIO to new memory api read/write,
Alexander Graf <=
- [Qemu-ppc] [PATCH 14/22] mc146818rtc: convert PIO to new memory api read/write, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 13/22] m48t59: convert PIO to new memory api read/write, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 17/22] rtl8139: convert PIO to new memory api read/write, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 11/22] es1370: convert PIO to new memory api read/write, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 04/22] e500: Fix serial initialization, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 21/22] PPC: e500: Map PIO space into core memory region, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 15/22] pc port92: convert PIO to new memory api read/write, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 08/22] pseries: Implement qemu initiated shutdowns using EPOW events, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 20/22] xen_platform: convert PIO to new memory api read/write, Alexander Graf, 2012/10/29
- [Qemu-ppc] [PATCH 16/22] pckbd: convert PIO to new memory api read/write, Alexander Graf, 2012/10/29