sysbus: add a variant of sysbus_init_mmio_cb with an unmap callback

sysbus_init_mmio_cb() uses the destructive IO_MEM_UNASSIGNED to remove a
region.  Provide an alternative that calls an unmap callback, so the removal
may be done non-destructively.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Avi Kivity 2011-08-15 17:17:29 +03:00 committed by Anthony Liguori
parent b6dcbe086c
commit d76120135b
2 changed files with 18 additions and 0 deletions

View File

@ -53,6 +53,8 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, target_phys_addr_t addr)
if (dev->mmio[n].memory) { if (dev->mmio[n].memory) {
memory_region_del_subregion(get_system_memory(), memory_region_del_subregion(get_system_memory(),
dev->mmio[n].memory); dev->mmio[n].memory);
} else if (dev->mmio[n].unmap) {
dev->mmio[n].unmap(dev, dev->mmio[n].addr);
} else { } else {
cpu_register_physical_memory(dev->mmio[n].addr, dev->mmio[n].size, cpu_register_physical_memory(dev->mmio[n].addr, dev->mmio[n].size,
IO_MEM_UNASSIGNED); IO_MEM_UNASSIGNED);
@ -117,6 +119,19 @@ void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
dev->mmio[n].cb = cb; dev->mmio[n].cb = cb;
} }
void sysbus_init_mmio_cb2(SysBusDevice *dev,
mmio_mapfunc cb, mmio_mapfunc unmap)
{
int n;
assert(dev->num_mmio < QDEV_MAX_MMIO);
n = dev->num_mmio++;
dev->mmio[n].addr = -1;
dev->mmio[n].size = 0;
dev->mmio[n].cb = cb;
dev->mmio[n].unmap = unmap;
}
void sysbus_init_mmio_region(SysBusDevice *dev, MemoryRegion *memory) void sysbus_init_mmio_region(SysBusDevice *dev, MemoryRegion *memory)
{ {
int n; int n;

View File

@ -23,6 +23,7 @@ struct SysBusDevice {
target_phys_addr_t addr; target_phys_addr_t addr;
target_phys_addr_t size; target_phys_addr_t size;
mmio_mapfunc cb; mmio_mapfunc cb;
mmio_mapfunc unmap;
ram_addr_t iofunc; ram_addr_t iofunc;
MemoryRegion *memory; MemoryRegion *memory;
} mmio[QDEV_MAX_MMIO]; } mmio[QDEV_MAX_MMIO];
@ -48,6 +49,8 @@ void sysbus_init_mmio(SysBusDevice *dev, target_phys_addr_t size,
ram_addr_t iofunc); ram_addr_t iofunc);
void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size, void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
mmio_mapfunc cb); mmio_mapfunc cb);
void sysbus_init_mmio_cb2(SysBusDevice *dev,
mmio_mapfunc cb, mmio_mapfunc unmap);
void sysbus_init_mmio_region(SysBusDevice *dev, MemoryRegion *memory); void sysbus_init_mmio_region(SysBusDevice *dev, MemoryRegion *memory);
void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p); void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target); void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);