qemu-arm
[Top][All Lists]
Advanced

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

Re: [Qemu-arm] [PATCH 2/2] hw/arm/armv7m: Remove unused armv7m_init() fu


From: Peter Maydell
Subject: Re: [Qemu-arm] [PATCH 2/2] hw/arm/armv7m: Remove unused armv7m_init() function
Date: Sun, 3 Jun 2018 13:14:09 +0100

On 3 June 2018 at 01:48, Joel Stanley <address@hidden> wrote:
> Hi Peter,
>
> On 2 June 2018 at 00:13, Peter Maydell <address@hidden> wrote:
>> Remove the now-unused armv7m_init() function. This was a legacy from
>> before we properly QOMified ARMv7M, and it has some flaws:
>>
>>  * it combines work that needs to be done by an SoC object (creating
>>    and initializing the TYPE_ARMV7M object) with work that needs to
>>    be done by the board model (setting the system up to load the ELF
>>    file specified with -kernel)
>>  * TYPE_ARMV7M creation failure is fatal, but an SoC object wants to
>>    arrange to propagate the failure outward
>>  * it uses allocate-and-create via qdev_create() whereas the current
>>    preferred style for SoC objects is to do creation in-place
>>
>> Board and SoC models can instead do the two jobs this function
>> was doing themselves, in the right places and with whatever their
>> preferred style/error handling is.

>> -DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int 
>> num_irq,
>> -                         const char *kernel_filename, const char *cpu_type)
>> -{
>> -    DeviceState *armv7m;
>> -
>> -    armv7m = qdev_create(NULL, TYPE_ARMV7M);
>> -    qdev_prop_set_uint32(armv7m, "num-irq", num_irq);
>> -    qdev_prop_set_string(armv7m, "cpu-type", cpu_type);
>> -    object_property_set_link(OBJECT(armv7m), OBJECT(get_system_memory()),
>> -                                     "memory", &error_abort);
>
> It looks like the snippet above is going to be a cut/paste for all v7m 
> machines.

If you look at pretty much all the v7m machines except stellaris,
they don't use this code fragment. (Instead you have an
object_initialize()/qdev_set_parent_bus() in the SoC container's
init function, calls to set properties and realize in the container's
realize, and a call to armv7m_load_kernel() in the board code.)

I agree that what you might call the "modern style" of writing
SoC containers like that has a lot of boilerplate, but that's
not specific to the armv7m object, and if we want to reduce
boilerplate we should look at how we can do it consistently
across devices.

thanks
-- PMM



reply via email to

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