[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC 5/8] arm: Add NRF51 random number generator periph
From: |
Steffen Görtz |
Subject: |
Re: [Qemu-devel] [RFC 5/8] arm: Add NRF51 random number generator peripheral |
Date: |
Thu, 5 Jul 2018 19:19:34 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |
Hi Peter,
> Hi -- a couple of general notes about device modelling
> which might apply to other devices in this series as well:
>
>> +static void nrf51_rng_class_init(ObjectClass *klass, void *data)
>> +{
>> + DeviceClass *dc = DEVICE_CLASS(klass);
>> +
>> + dc->props = nrf51_rng_properties;
>
> In general, every device that has any modifiable state needs:
> * a reset function
> * a vmstate struct that defines its state for migration
>
> These get set up in the class init function by setting
> dc->vmsd and dc->reset.
>
> For devices that don't have any modifiable state, a comment
> in the init function to say so helps to reassure readers
> that the issue has been considered :-)
Thank you for your remarks!
I will add the missing handler/structure. I will have to revise the
other devices i have pending for comments as well!
>
>> +}
>
>
>> + struct {
>> + uint32_t active:1;
>> + uint32_t event_valrdy:1;
>> + uint32_t shortcut_stop_on_valrdy:1;
>> + uint32_t interrupt_enabled:1;
>> + uint32_t filter_enabled:1;
>> + } state;
>
> Prefer to avoid bitfields.
Will do!
Steffen