qemu-devel
[Top][All Lists]
Advanced

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

Re: all class init functions for all types in QEMU are called in select_


From: Claudio Fontana
Subject: Re: all class init functions for all types in QEMU are called in select_machine(). Expected?
Date: Fri, 12 Mar 2021 14:40:19 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0

On 3/12/21 1:02 PM, Paolo Bonzini wrote:
> On 12/03/21 12:51, Claudio Fontana wrote:
>> seems to me we already have, as the accel class init, fe, for x86/tcg:
>>
>> static void tcg_cpu_accel_class_init(ObjectClass *oc, void *data)
>> {
>>      AccelCPUClass *acc = ACCEL_CPU_CLASS(oc);
>>
>> #ifndef CONFIG_USER_ONLY
>>      acc->cpu_realizefn = tcg_cpu_realizefn;
>> #endif /* CONFIG_USER_ONLY */
>>
>>      acc->cpu_class_init = tcg_cpu_class_init;
>>      acc->cpu_instance_init = tcg_cpu_instance_init;
>> }
>>
>> acc->cpu_class_init() call would then be the acc->init_cpu call you mention.
>>
>> The only thing we seem to be missing is the cc->init_tcg_ops(cc)..
> 
> Yes, called by tcg_cpu_class_init or tcg_cpu_instance_init.
> 
> Paolo
> 
> 

.. I wonder if we should make it a bit more general like:

static void accel_init_cpu_int_aux(ObjectClass *klass, void *opaque)
{
    CPUClass *cc = CPU_CLASS(klass);
    AccelCPUClass *accel_cpu = opaque;

    /*                                                                          
                                                            
     * double dispatch. The first callback allows the accel cpu                 
                                                            
     * to run initializations for the CPU,                                      
                                                            
     * the second one allows the CPU to customize the accel cpu                 
                                                            
     * behavior according to the CPU.                                           
                                                            
     *                                                                          
                                                            
     * The second is currently only used by TCG, to specialize the              
                                                            
     * TCGCPUOps depending on the CPU type.                                     
                                                            
     */
    cc->accel_cpu = accel_cpu;
    if (accel_cpu->cpu_class_init) {
        accel_cpu->cpu_class_init(cc);
    }
    if (cc->init_accel_cpu) {
        cc->init_accel_cpu(accel_cpu, cc);
    }
}

.. but maybe this is premature, and should wait for actual users of this beyond 
TCG on ARM?

Ciao,

C





reply via email to

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