Il 04/06/2013 14:24, Peter Maydell ha scritto: > On 4 June 2013 13:13, Paolo Bonzini <pbonz...@redhat.com> wrote: >> This matches sysbus_pass_irq in cases where a device is a thin wrapper >> of another. MMIO regions will keep the subdevice as the owner. >> >> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> >> --- >> hw/core/sysbus.c | 12 ++++++++++++ >> hw/cpu/arm11mpcore.c | 2 +- >> include/hw/sysbus.h | 1 + >> 3 files changed, 14 insertions(+), 1 deletion(-) >> >> diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c >> index 9004d8c..6dbd1f8 100644 >> --- a/hw/core/sysbus.c >> +++ b/hw/core/sysbus.c >> @@ -117,6 +117,18 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion >> *memory) >> dev->mmio[n].memory = memory; >> } >> >> +/* Pass MMIOs from a target device. */ >> +void sysbus_pass_mmio(SysBusDevice *dev, SysBusDevice *target) >> +{ >> + int i; >> + assert(dev->num_mmio == 0); >> + dev->num_mmio = target->num_mmio; >> + for (i = 0; i < dev->num_mmio; i++) { >> + assert(target->mmio[i].addr == -1); >> + dev->mmio[i] = target->mmio[i]; >> + } >> +} > > This is much less flexible than just using sysbus_mmio_get_region(), > because it only lets you pass the whole set of MMIOs from the > other device through, not just the ones you want.
How is this different from sysbus_pass_irq? > Please just make reference counting work properly with passing > MemoryRegion*s around. Do you have any idea that doesn't require touch 800 invocation of the region creation functions? This looks like a solution in search of a problem to me. Paolo