On 8 August 2011 18:07, Avi Kivity <[email protected]> wrote:
> This tells the sysbus code it need not use IO_MEM_UNASSIGNED.
>
> Signed-off-by: Avi Kivity <[email protected]>
> ---
> hw/arm11mpcore.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/hw/arm11mpcore.c b/hw/arm11mpcore.c
> index b47707f..7d60ef6 100644
> --- a/hw/arm11mpcore.c
> +++ b/hw/arm11mpcore.c
> @@ -54,6 +54,11 @@ static void mpcore_rirq_map(SysBusDevice *dev,
> target_phys_addr_t base)
> sysbus_mmio_map(s->priv, 0, base);
> }
>
> +static void mpcore_rirq_unmap(SysBusDevice *dev, target_phys_addr_t base)
> +{
> + /* nothing to do */
> +}
> +
> static int realview_mpcore_init(SysBusDevice *dev)
> {
> mpcore_rirq_state *s = FROM_SYSBUS(mpcore_rirq_state, dev);
> @@ -79,7 +84,7 @@ static int realview_mpcore_init(SysBusDevice *dev)
> }
> }
> qdev_init_gpio_in(&dev->qdev, mpcore_rirq_set_irq, 64);
> - sysbus_init_mmio_cb(dev, 0x2000, mpcore_rirq_map);
> + sysbus_init_mmio_cb2(dev, mpcore_rirq_map, mpcore_rirq_unmap);
> return 0;
> }
Since the mpcore code here is only using sysbus mmio callbacks as
a way to pass things through to a sysbus mmio provided by another
device, I think it would be cleaner to just have a way to say "my
mmio is actually provided by this other device".
For instance you could have
MemoryRegion* sysbus_mmio_get_region(SysBusDevice *dev, int n))
{
return dev->mmio[n].memory;
}
and then realview_mpcore_init() can just
sysbus_init_mmio_region(dev, sysbus_mmio_get_region(s->priv, 0));
Or you could have a sysbus_pass_mmio() which worked like
sysbus_pass_irq() and just said "my mmios are all this other
device's mmios"; that's less flexible though.
-- PMM