[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 25/42] virtio-pci: add virtio_pci_modern_regions_init
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 25/42] virtio-pci: add virtio_pci_modern_regions_init() |
Date: |
Thu, 11 Jun 2015 13:59:56 +0200 |
From: Gerd Hoffmann <address@hidden>
Add init function for the modern pci regions,
move over the init code.
Signed-off-by: Gerd Hoffmann <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/virtio/virtio-pci.c | 117 +++++++++++++++++++++++++------------------------
1 file changed, 59 insertions(+), 58 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index ebba2d1..090e95b 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1208,6 +1208,64 @@ static void virtio_pci_device_write(void *opaque, hwaddr
addr,
}
}
+static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy)
+{
+ static const MemoryRegionOps common_ops = {
+ .read = virtio_pci_common_read,
+ .write = virtio_pci_common_write,
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 4,
+ },
+ .endianness = DEVICE_LITTLE_ENDIAN,
+ };
+ static const MemoryRegionOps isr_ops = {
+ .read = virtio_pci_isr_read,
+ .write = virtio_pci_isr_write,
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 4,
+ },
+ .endianness = DEVICE_LITTLE_ENDIAN,
+ };
+ static const MemoryRegionOps device_ops = {
+ .read = virtio_pci_device_read,
+ .write = virtio_pci_device_write,
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 4,
+ },
+ .endianness = DEVICE_LITTLE_ENDIAN,
+ };
+ static const MemoryRegionOps notify_ops = {
+ .read = virtio_pci_notify_read,
+ .write = virtio_pci_notify_write,
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 4,
+ },
+ .endianness = DEVICE_LITTLE_ENDIAN,
+ };
+
+ memory_region_init_io(&proxy->common.mr, OBJECT(proxy),
+ &common_ops,
+ proxy,
+ "virtio-pci-common", 0x1000);
+ memory_region_init_io(&proxy->isr.mr, OBJECT(proxy),
+ &isr_ops,
+ proxy,
+ "virtio-pci-isr", 0x1000);
+ memory_region_init_io(&proxy->device.mr, OBJECT(proxy),
+ &device_ops,
+ virtio_bus_get_device(&proxy->bus),
+ "virtio-pci-device", 0x1000);
+ memory_region_init_io(&proxy->notify.mr, OBJECT(proxy),
+ ¬ify_ops,
+ virtio_bus_get_device(&proxy->bus),
+ "virtio-pci-notify",
+ QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
+ VIRTIO_QUEUE_MAX);
+}
/* This is called by virtio-bus just after the device is plugged. */
static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
@@ -1290,46 +1348,6 @@ static void virtio_pci_device_plugged(DeviceState *d,
Error **errp)
cpu_to_le32(QEMU_VIRTIO_PCI_QUEUE_MEM_MULT),
};
- static const MemoryRegionOps common_ops = {
- .read = virtio_pci_common_read,
- .write = virtio_pci_common_write,
- .impl = {
- .min_access_size = 1,
- .max_access_size = 4,
- },
- .endianness = DEVICE_LITTLE_ENDIAN,
- };
-
- static const MemoryRegionOps isr_ops = {
- .read = virtio_pci_isr_read,
- .write = virtio_pci_isr_write,
- .impl = {
- .min_access_size = 1,
- .max_access_size = 4,
- },
- .endianness = DEVICE_LITTLE_ENDIAN,
- };
-
- static const MemoryRegionOps device_ops = {
- .read = virtio_pci_device_read,
- .write = virtio_pci_device_write,
- .impl = {
- .min_access_size = 1,
- .max_access_size = 4,
- },
- .endianness = DEVICE_LITTLE_ENDIAN,
- };
-
- static const MemoryRegionOps notify_ops = {
- .read = virtio_pci_notify_read,
- .write = virtio_pci_notify_write,
- .impl = {
- .min_access_size = 1,
- .max_access_size = 4,
- },
- .endianness = DEVICE_LITTLE_ENDIAN,
- };
-
/* TODO: add io access for speed */
virtio_pci_add_mem_cap(proxy, &common);
virtio_pci_add_mem_cap(proxy, &isr);
@@ -1340,28 +1358,11 @@ static void virtio_pci_device_plugged(DeviceState *d,
Error **errp)
memory_region_init(&proxy->modern_bar, OBJECT(proxy), "virtio-pci",
2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
VIRTIO_QUEUE_MAX);
- memory_region_init_io(&proxy->common.mr, OBJECT(proxy),
- &common_ops,
- proxy,
- "virtio-pci-common", 0x1000);
+ virtio_pci_modern_regions_init(proxy);
memory_region_add_subregion(&proxy->modern_bar, 0, &proxy->common.mr);
- memory_region_init_io(&proxy->isr.mr, OBJECT(proxy),
- &isr_ops,
- proxy,
- "virtio-pci-isr", 0x1000);
memory_region_add_subregion(&proxy->modern_bar, 0x1000,
&proxy->isr.mr);
- memory_region_init_io(&proxy->device.mr, OBJECT(proxy),
- &device_ops,
- virtio_bus_get_device(&proxy->bus),
- "virtio-pci-device", 0x1000);
memory_region_add_subregion(&proxy->modern_bar, 0x2000,
&proxy->device.mr);
- memory_region_init_io(&proxy->notify.mr, OBJECT(proxy),
- ¬ify_ops,
- virtio_bus_get_device(&proxy->bus),
- "virtio-pci-notify",
- QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
- VIRTIO_QUEUE_MAX);
memory_region_add_subregion(&proxy->modern_bar, 0x3000,
&proxy->notify.mr);
pci_register_bar(&proxy->pci_dev, modern_mem_bar,
--
MST
- [Qemu-devel] [PULL 12/42] linux-headers: add virtio_pci, (continued)
- [Qemu-devel] [PULL 12/42] linux-headers: add virtio_pci, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 14/42] virtio: generation counter support, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 13/42] virtio-pci: initial virtio 1.0 support, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 11/42] vhost: 64 bit features, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 15/42] virtio: add modern config accessors, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 16/42] virtio-pci: switch to modern accessors for 1.0, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 17/42] virtio-pci: add flags to enable/disable legacy/modern, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 22/42] virtio_balloon: header update, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 23/42] virtio-balloon: switch to virtio_add_feature, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 24/42] virtio-pci: add struct VirtIOPCIRegion for virtio-1 regions, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 25/42] virtio-pci: add virtio_pci_modern_regions_init(),
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 26/42] virtio-pci: add virtio_pci_modern_region_map(), Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 27/42] virtio-pci: move virtio_pci_add_mem_cap call to virtio_pci_modern_region_map, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 29/42] virtio-pci: drop identical virtio_pci_cap, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 28/42] virtio-pci: move cap type to VirtIOPCIRegion, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 31/42] pci: add PCI_CLASS_INPUT_*, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 30/42] virtio-pci: fill VirtIOPCIRegions early., Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 32/42] virtio-input: core code & base class [pci], Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 34/42] virtio-net: move qdev properties into virtio-net.c, Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 33/42] virtio-input: emulated devices [pci], Michael S. Tsirkin, 2015/06/11
- [Qemu-devel] [PULL 35/42] virtio-net.h: Remove unsed DEFINE_VIRTIO_NET_PROPERTIES, Michael S. Tsirkin, 2015/06/11