From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z319P-0000Uh-LN for qemu-devel@nongnu.org; Thu, 11 Jun 2015 08:00:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z319O-00070C-Nq for qemu-devel@nongnu.org; Thu, 11 Jun 2015 08:00:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43076) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z319O-0006zv-HR for qemu-devel@nongnu.org; Thu, 11 Jun 2015 08:00:02 -0400 Date: Thu, 11 Jun 2015 13:59:59 +0200 From: "Michael S. Tsirkin" Message-ID: <1434023714-30366-27-git-send-email-mst@redhat.com> References: <1434023714-30366-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1434023714-30366-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 26/42] virtio-pci: add virtio_pci_modern_region_map() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Gerd Hoffmann From: Gerd Hoffmann Add function to map modern virtio regions. Add offset to VirtIOPCIRegion. Signed-off-by: Gerd Hoffmann Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.h | 1 + hw/virtio/virtio-pci.c | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h index 8f1fc02..f5829b0 100644 --- a/hw/virtio/virtio-pci.h +++ b/hw/virtio/virtio-pci.h @@ -93,6 +93,7 @@ typedef struct VirtioPCIClass { typedef struct VirtIOPCIRegion { MemoryRegion mr; + uint32_t offset; } VirtIOPCIRegion; struct VirtIOPCIProxy { diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 090e95b..759cfc4 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1251,20 +1251,35 @@ static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy) &common_ops, proxy, "virtio-pci-common", 0x1000); + proxy->common.offset = 0x0; + memory_region_init_io(&proxy->isr.mr, OBJECT(proxy), &isr_ops, proxy, "virtio-pci-isr", 0x1000); + proxy->isr.offset = 0x1000; + memory_region_init_io(&proxy->device.mr, OBJECT(proxy), &device_ops, virtio_bus_get_device(&proxy->bus), "virtio-pci-device", 0x1000); + proxy->device.offset = 0x2000; + 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); + proxy->notify.offset = 0x3000; +} + +static void virtio_pci_modern_region_map(VirtIOPCIProxy *proxy, + VirtIOPCIRegion *region) +{ + memory_region_add_subregion(&proxy->modern_bar, + region->offset, + ®ion->mr); } /* This is called by virtio-bus just after the device is plugged. */ @@ -1359,12 +1374,10 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp) 2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT * VIRTIO_QUEUE_MAX); virtio_pci_modern_regions_init(proxy); - memory_region_add_subregion(&proxy->modern_bar, 0, &proxy->common.mr); - memory_region_add_subregion(&proxy->modern_bar, 0x1000, &proxy->isr.mr); - memory_region_add_subregion(&proxy->modern_bar, 0x2000, - &proxy->device.mr); - memory_region_add_subregion(&proxy->modern_bar, 0x3000, - &proxy->notify.mr); + virtio_pci_modern_region_map(proxy, &proxy->common); + virtio_pci_modern_region_map(proxy, &proxy->isr); + virtio_pci_modern_region_map(proxy, &proxy->device); + virtio_pci_modern_region_map(proxy, &proxy->notify); pci_register_bar(&proxy->pci_dev, modern_mem_bar, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_PREFETCH | -- MST