virtio-pci: add virtio_pci_modern_region_map()
Add function to map modern virtio regions. Add offset to VirtIOPCIRegion. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
1141ce2190
commit
a3cc2e8159
|
@ -1251,20 +1251,35 @@ static void virtio_pci_modern_regions_init(VirtIOPCIProxy *proxy)
|
||||||
&common_ops,
|
&common_ops,
|
||||||
proxy,
|
proxy,
|
||||||
"virtio-pci-common", 0x1000);
|
"virtio-pci-common", 0x1000);
|
||||||
|
proxy->common.offset = 0x0;
|
||||||
|
|
||||||
memory_region_init_io(&proxy->isr.mr, OBJECT(proxy),
|
memory_region_init_io(&proxy->isr.mr, OBJECT(proxy),
|
||||||
&isr_ops,
|
&isr_ops,
|
||||||
proxy,
|
proxy,
|
||||||
"virtio-pci-isr", 0x1000);
|
"virtio-pci-isr", 0x1000);
|
||||||
|
proxy->isr.offset = 0x1000;
|
||||||
|
|
||||||
memory_region_init_io(&proxy->device.mr, OBJECT(proxy),
|
memory_region_init_io(&proxy->device.mr, OBJECT(proxy),
|
||||||
&device_ops,
|
&device_ops,
|
||||||
virtio_bus_get_device(&proxy->bus),
|
virtio_bus_get_device(&proxy->bus),
|
||||||
"virtio-pci-device", 0x1000);
|
"virtio-pci-device", 0x1000);
|
||||||
|
proxy->device.offset = 0x2000;
|
||||||
|
|
||||||
memory_region_init_io(&proxy->notify.mr, OBJECT(proxy),
|
memory_region_init_io(&proxy->notify.mr, OBJECT(proxy),
|
||||||
¬ify_ops,
|
¬ify_ops,
|
||||||
virtio_bus_get_device(&proxy->bus),
|
virtio_bus_get_device(&proxy->bus),
|
||||||
"virtio-pci-notify",
|
"virtio-pci-notify",
|
||||||
QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
|
QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
|
||||||
VIRTIO_QUEUE_MAX);
|
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. */
|
/* 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 *
|
2 * QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
|
||||||
VIRTIO_QUEUE_MAX);
|
VIRTIO_QUEUE_MAX);
|
||||||
virtio_pci_modern_regions_init(proxy);
|
virtio_pci_modern_regions_init(proxy);
|
||||||
memory_region_add_subregion(&proxy->modern_bar, 0, &proxy->common.mr);
|
virtio_pci_modern_region_map(proxy, &proxy->common);
|
||||||
memory_region_add_subregion(&proxy->modern_bar, 0x1000, &proxy->isr.mr);
|
virtio_pci_modern_region_map(proxy, &proxy->isr);
|
||||||
memory_region_add_subregion(&proxy->modern_bar, 0x2000,
|
virtio_pci_modern_region_map(proxy, &proxy->device);
|
||||||
&proxy->device.mr);
|
virtio_pci_modern_region_map(proxy, &proxy->notify);
|
||||||
memory_region_add_subregion(&proxy->modern_bar, 0x3000,
|
|
||||||
&proxy->notify.mr);
|
|
||||||
pci_register_bar(&proxy->pci_dev, modern_mem_bar,
|
pci_register_bar(&proxy->pci_dev, modern_mem_bar,
|
||||||
PCI_BASE_ADDRESS_SPACE_MEMORY |
|
PCI_BASE_ADDRESS_SPACE_MEMORY |
|
||||||
PCI_BASE_ADDRESS_MEM_PREFETCH |
|
PCI_BASE_ADDRESS_MEM_PREFETCH |
|
||||||
|
|
|
@ -93,6 +93,7 @@ typedef struct VirtioPCIClass {
|
||||||
|
|
||||||
typedef struct VirtIOPCIRegion {
|
typedef struct VirtIOPCIRegion {
|
||||||
MemoryRegion mr;
|
MemoryRegion mr;
|
||||||
|
uint32_t offset;
|
||||||
} VirtIOPCIRegion;
|
} VirtIOPCIRegion;
|
||||||
|
|
||||||
struct VirtIOPCIProxy {
|
struct VirtIOPCIProxy {
|
||||||
|
|
Loading…
Reference in a new issue