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 <m...@redhat.com>
---
 hw/misc/pci-testdev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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;
-- 
MST


Reply via email to