Add a variant to sysbus_mmio_map that allow specifying a target memory region. The requested device memory region is mapped within the argument target memory region rather than the default (get_system_memory()). Behaviour of original sysbus_mmio_map remains unchanged.
The will probably go away or morph into something else with Anthony sysbus purge so its intended to be a bridging patch until those refactorings go live. Signed-off-by: Peter Crosthwaite <peter.crosthwa...@xilinx.com> --- hw/sysbus.c | 11 ++++++++--- hw/sysbus.h | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/sysbus.c b/hw/sysbus.c index c173840..bd45183 100644 --- a/hw/sysbus.c +++ b/hw/sysbus.c @@ -48,7 +48,8 @@ void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq) } } -void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr) +void sysbus_mmio_map_to_region(SysBusDevice *dev, int n, + target_phys_addr_t addr, MemoryRegion *region) { assert(n >= 0 && n < dev->num_mmio); @@ -58,14 +59,18 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr) } if (dev->mmio[n].addr != (target_phys_addr_t)-1) { /* Unregister previous mapping. */ - memory_region_del_subregion(get_system_memory(), dev->mmio[n].memory); + memory_region_del_subregion(region, dev->mmio[n].memory); } dev->mmio[n].addr = addr; - memory_region_add_subregion(get_system_memory(), + memory_region_add_subregion(region, addr, dev->mmio[n].memory); } +void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr) +{ + sysbus_mmio_map_to_region(dev, n, addr, get_system_memory()); +} /* Request an IRQ source. The actual IRQ object may be populated later. */ void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p) diff --git a/hw/sysbus.h b/hw/sysbus.h index acfbcfb..9cdb2b4 100644 --- a/hw/sysbus.h +++ b/hw/sysbus.h @@ -56,6 +56,8 @@ void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size); void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq); +void sysbus_mmio_map_to_region(SysBusDevice *dev, int n, + target_phys_addr_t addr, MemoryRegion *region); void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr); void sysbus_add_memory(SysBusDevice *dev, target_phys_addr_t addr, MemoryRegion *mem); -- 1.7.0.4