qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 3/3] arm: Add BBC micro:bit machine


From: Joel Stanley
Subject: Re: [Qemu-devel] [PATCH v4 3/3] arm: Add BBC micro:bit machine
Date: Sat, 25 Aug 2018 18:14:06 -0700

On Thu, 16 Aug 2018 at 07:12, Peter Maydell <address@hidden> 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(&microbit_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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]