qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add


From: Liviu Ionescu
Subject: Re: [Qemu-devel] [RFC] QOM design - add instance data to Object (-> add constructors)
Date: Mon, 15 Jun 2015 10:35:33 +0300

> On 14 Jun 2015, at 15:43, Liviu Ionescu <address@hidden> wrote:
> 
> in practical terms this means that realize() should be called right after 
> creation, immediately after setting the properties:
> 
>   DeviceState *mcu = qdev_create(NULL, TYPE_STM32F103RB);
>   {
>       qdev_prop_set_uint32(mcu, "hse-freq-hz", 8000000); /* 8.0 MHz */
>       qdev_prop_set_uint32(mcu, "lse-freq-hz", 32768); /* 32 KHz */
>   }
>   qdev_realize(mcu);
> 
> which is ok as long as it is strictly adhered.

after adding aliases from the mcu to the internal rcc, I discovered that this 
is no longer true, if the object creation is done at realize(), the target 
object and the aliases do not exist before realize, so these settings are not 
possible.

so, from my point of view, this topic is clear now, realize() is not the right 
place for construction and the only viable solution is to use explicit 
constructors.

    DeviceState *mcu = qdev_alloc(NULL, TYPE_STM32F103RB);
    {
        STM32F103RB_GET_CLASS(mcu)->construct(OBJECT(mcu), machine);

        /* Set the board specific oscillator frequencies. */
        qdev_prop_set_uint32(mcu, "hse-freq-hz", 8000000); /* 8.0 MHz */
        qdev_prop_set_uint32(mcu, "lse-freq-hz", 32768); /* 32 KHz */
    }
    qdev_realize(mcu);


one less issue to worry about. :-)


regards,

Liviu




reply via email to

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