qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC] QDev explicit constructors & destructors


From: Liviu Ionescu
Subject: Re: [Qemu-devel] [RFC] QDev explicit constructors & destructors
Date: Wed, 24 Jun 2015 12:29:53 +0300

> On 24 Jun 2015, at 11:29, Peter Crosthwaite <address@hidden> wrote:
> 
>> 
>> Peter C, is this solution acceptable?
>> 
> 
> Settable props are generally acceptable, but it is unusual for a
> machine init routine.

ok, I managed to restructure my code to get rid of the explicit constructor. :-)

I also avoided properties aliases, and did prop setting in two steps, in 
machine init I set props in MCU, and from here I manually set them in specific 
peripherals, after they are created. less efficient then aliases, but 
functional.

however, there is one aspect that I'm not compliant with your requirements: I'm 
still creating objects in realize(), since many of my objects have dynamic 
content. for example MCUs have different number of GPIOs, it is possible to 
create all of them in init and then map only the used ones, but to me this 
looks sub-optimal.

but, if this is a mandatory requirement, I'll do may best to comply.


the machine init code now looks like this:

static void stm32_h103_board_init_callback(MachineState *machine)
{
    cm_board_greeting(machine);

    {
        /* Create the MCU */
        DeviceState *mcu = cm_create(TYPE_STM32F103RB);

        qdev_prop_set_ptr(mcu, "machine", 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 */

        cm_realize(mcu);
    }

    {
        /* Create the board LED */
        DeviceState *led = cm_create(TYPE_GPIO_LED);

        /* STM32-H103 Green LED, GPIOC[12], active low */
        qdev_prop_set_bit(led, "active-low", true);
        qdev_prop_set_string(led, "on-message", "[Green LED On]\n");
        qdev_prop_set_string(led, "off-message", "[Green LED Off]\n");

        gpio_led_connect(led, "/machine/stm32/gpio[c]", 12);

        cm_realize(led);
    }
}

I hope it is better now.

> Got your vite on Skype. Will probably have to be an evening your time
> to catch me in the morning.

fine with me.


regards,

Liviu




reply via email to

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