On Thu, 16 Aug 2018 at 07:12, Peter Maydell <peter.mayd...@linaro.org> wrote:
> > +static void microbit_machine_init(MachineClass *mc) > > +{ > > + mc->desc = "BBC micro:bit"; > > + mc->init = microbit_init; > > + mc->max_cpus = 1; > > +} > > +DEFINE_MACHINE("microbit", microbit_machine_init); > > Your subclass of TYPE_MACHINE has extra state, so it can't > use DEFINE_MACHINE (which creates a subclass whose instance_size > is the same as the parent TYPE_MACHINE). You need to do this > longhand: > > static void machine_class_init(ObjectClass *oc, void *data) > { > MachineClass *mc = MACHINE_CLASS(oc); > > mc->desc = "BBC micro:bit"; > mc->init = microbit_init; > mc->max_cpus = 1; > } > > static const TypeInfo microbit_info = { > .name = TYPE_MICROBIT_MACHINE, > .parent = TYPE_MACHINE, > .instance_size = sizeof(MICROBITMachineState), > .class_init = microbit_class_init, > }; > > static void microbit_machine_init(void) > { > type_register_static(µbit_info); > } > > type_init(microbit_machine_init); > > > (code untested but should be correct; compare against other boards.) Thanks for spelling it out. I spent a decent chunk of time looking at other boards, and this aspect of Qemu still baffles me.