On 15/2/22 11:19, Damien Hedde wrote:
Hi,
I'm wondering if there are rules or convention about what we put in the
instance_init() vs realize() for simple devices ? (For complex ones we
generally have no choice to put everything in realize())
See Peter's recommendations here:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg723958.html
For example we can declare irqs and mmios in instance_init() or
realize() if they do not depend on some property.
This is not a big deal, but given how works the help message generation
in the monitor, there are difference if the device is user-creatable.
If we leave irqs and mmios declaration in the instance_init(). They
appear in the help message.
> (qemu) device_add ibex-timer,help
> ibex-timer options:
> ibex-timer[0]=<child<memory-region>>
> sysbus-irq[0]=<link<irq>>
> timebase-freq=<uint32> - (default: 10000)
If we delay the declaration in realize(), we only have the declared
qdev-properties (which is maybe more what we expect at this point):
> (qemu) device_add ibex-timer,help
> ibex-timer options:
> timebase-freq=<uint32> - (default: 10000)
Any comments ?
Thanks,
Damien