Message ID | 20230104220449.41337-1-philmd@linaro.org (mailing list archive) |
---|---|
Headers | show |
Series | hw: Remove implicit sysbus_mmio_map() from pflash APIs | expand |
On Wed, 4 Jan 2023 at 22:04, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > Paving the road toward heterogeneous QEMU, the limitations of > having a single machine sysbus become more apparent. > > The sysbus_mmio_map() API forces the caller to map a sysbus > device to an address on the system bus (system bus here is > the root MemoryRegion returned by get_system_memory() ). > > This is not practical when each core has its own address > space and group of cores have access to a part of the > peripherals. > > Experimenting with the PFLASH devices. Here the fix is > quite easy, we split the pflash_cfi_register() -- which > does the implicit sysbus mapping -- into an explicit qdev > pflash_cfi_create() followed by the sysbus_mmio_map() call. pflash_cfi_register() is a legacy convenience function. If you don't like the sysbus_mmio_map() it does then you can create, configure, realize and map the device directly. This is what hw/arm/virt.c does, for instance (it wants to map the flash devices into either secure or non secure RAM). (This also lets you embed the device struct into some other struct if you want rather than using qdev_new(), though we don't have any code that does that currently.) thanks -- PMM
On 6/1/23 18:51, Peter Maydell wrote: > On Wed, 4 Jan 2023 at 22:04, Philippe Mathieu-Daudé <philmd@linaro.org> wrote: >> >> Paving the road toward heterogeneous QEMU, the limitations of >> having a single machine sysbus become more apparent. >> >> The sysbus_mmio_map() API forces the caller to map a sysbus >> device to an address on the system bus (system bus here is >> the root MemoryRegion returned by get_system_memory() ). >> >> This is not practical when each core has its own address >> space and group of cores have access to a part of the >> peripherals. >> >> Experimenting with the PFLASH devices. Here the fix is >> quite easy, we split the pflash_cfi_register() -- which >> does the implicit sysbus mapping -- into an explicit qdev >> pflash_cfi_create() followed by the sysbus_mmio_map() call. > > pflash_cfi_register() is a legacy convenience function. If > you don't like the sysbus_mmio_map() it does then you can > create, configure, realize and map the device directly. > This is what hw/arm/virt.c does, for instance (it wants to > map the flash devices into either secure or non secure RAM). Good point, thanks!