On 08/12/2011 06:23 AM, Peter Maydell wrote:
>    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.



Yes. Yet another option is to create a container MemoryRegion and pass it upwards, then allow the device that actually implements that mmio to register its regions with the container.

I'll leave this to the device maintainer though.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.


Reply via email to