On 30 April 2012 14:52, Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk> wrote:
> The key problem is that this doesn't worked with shared peripherals, such as
> the ESP device which is also used on various PPC Mac models as well as
> SPARC. That's because its init function looks like this:
> void esp_init(target_phys_addr_t espaddr, int it_shift,
> ESPDMAMemoryReadWriteFunc dma_memory_read,
> ESPDMAMemoryReadWriteFunc dma_memory_write,
> void *dma_opaque, qemu_irq irq, qemu_irq *reset,
> qemu_irq *dma_enable)
> sysbus_mmio_map(s, 0, espaddr);
> Therefore I can't change it to my (modified) sbus_mmio_map() function
> because it would break other non-SPARC platforms, and AIUI there is nothing
> in the memory API that allows me to move a subregion to a different
> MemoryRegion parent, even if I can get a reference to it with
> sysbus_mmio_get_region() after the sysbus_mmio_map() call - or have I
> misunderstood something?
Init functions like esp_init should be purely convenience functions
which create, set properties on, and map the sysbus/qdev device. If
they make use of private knowledge about the internals of the device
then this is wrong and should be fixed. For esp_init() it looks like
the handling of dma_memory_read, dma_memory_write, dma_opaque, it_shift
and dma_enabled are wrong.
If you fix that then you can just ignore the convenience function,
and create, configure and map the device as appropriate for you.