Am 05.07.2012 15:31, schrieb Paolo Bonzini:
> Il 05/07/2012 15:22, Andreas Färber ha scritto:
>>>> +static void openrisc_any_initfn(Object *obj)
>>>> +{
>>>> +    OpenRISCCPU *cpu = OPENRISC_CPU(obj);
>>>> +
>>>> +    set_feature(cpu, OPENRISC_FEATURE_OB32S);
>>>> +    set_feature(cpu, OPENRISC_FEATURE_OF32S);
>>>> +
>>>> +    cpu_reset(CPU(cpu));
>>>> +}
>> Paolo, could class_base_init or something help with this pattern of
>> needing to do something in every derived initfn?
> 
> I guess what you're looking for is some instance_post_init that is
> called at init time after instance_init?

Sort of. The pattern I was seeing is parent initializes something, child
modifies it, some action is performed on it.

Here we can get away by deferring the common action to realize stage,
just like we did for arm. My reasoning was that it's better to reset in
realizefn for reproducible behavior over system_reset. Not sure if we
can always escape to such a late stage, but we can worry about that when
we have a concrete use case. :)

Andreas

>> On the other hand I think we should move cpu_reset() into the realizefn
>> instead, that would avoid this issue here.
> 
> Yep.
> 
> Paolo

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Reply via email to