diff mbox

[RFC,2/3] pci-testdev: add subregion

Message ID 1440926395-23540-3-git-send-email-mst@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael S. Tsirkin Aug. 30, 2015, 9:20 a.m. UTC
Make mmio a subregion of the BAR. 
This will allow mapping rom within the same BAR down the road.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/misc/pci-testdev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/hw/misc/pci-testdev.c b/hw/misc/pci-testdev.c
index 6edc1cd..94141a3 100644
--- a/hw/misc/pci-testdev.c
+++ b/hw/misc/pci-testdev.c
@@ -83,6 +83,7 @@  typedef struct PCITestDevState {
     /*< public >*/
 
     MemoryRegion mmio;
+    MemoryRegion mbar;
     MemoryRegion portio;
     IOTest *tests;
     int current;
@@ -248,9 +249,13 @@  static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp)
 
     memory_region_init_io(&d->mmio, OBJECT(d), &pci_testdev_mmio_ops, d,
                           "pci-testdev-mmio", IOTEST_MEMSIZE * 2);
+    memory_region_init(&d->mbar, OBJECT(d),
+                          "pci-testdev-mmio", IOTEST_MEMSIZE * 2);
     memory_region_init_io(&d->portio, OBJECT(d), &pci_testdev_pio_ops, d,
                           "pci-testdev-portio", IOTEST_IOSIZE * 2);
-    pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio);
+
+    memory_region_add_subregion_overlap(&d->mbar, 0, &d->mmio, 1 /* prio */);
+    pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mbar);
     pci_register_bar(pci_dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &d->portio);
 
     d->current = -1;