target-m68k: Introduce QOM realizefn for M68kCPU
Introduce realizefn and set realized = true in cpu_m68k_init(). Split off GDB registration to a new m68k_cpu_init_gdb() so that it can be called from the realizefn. Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
		
							parent
							
								
									9c23169e8c
								
							
						
					
					
						commit
						6d1bbc6273
					
				@ -33,6 +33,7 @@
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * M68kCPUClass:
 | 
			
		||||
 * @parent_realize: The parent class' realize handler.
 | 
			
		||||
 * @parent_reset: The parent class' reset handler.
 | 
			
		||||
 *
 | 
			
		||||
 * A Motorola 68k CPU model.
 | 
			
		||||
@ -42,6 +43,7 @@ typedef struct M68kCPUClass {
 | 
			
		||||
    CPUClass parent_class;
 | 
			
		||||
    /*< public >*/
 | 
			
		||||
 | 
			
		||||
    DeviceRealize parent_realize;
 | 
			
		||||
    void (*parent_reset)(CPUState *cpu);
 | 
			
		||||
} M68kCPUClass;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -139,6 +139,19 @@ static const M68kCPUInfo m68k_cpus[] = {
 | 
			
		||||
    { .name = "any",   .instance_init = any_cpu_initfn },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)
 | 
			
		||||
{
 | 
			
		||||
    M68kCPU *cpu = M68K_CPU(dev);
 | 
			
		||||
    M68kCPUClass *mcc = M68K_CPU_GET_CLASS(dev);
 | 
			
		||||
 | 
			
		||||
    m68k_cpu_init_gdb(cpu);
 | 
			
		||||
 | 
			
		||||
    cpu_reset(CPU(cpu));
 | 
			
		||||
    qemu_init_vcpu(&cpu->env);
 | 
			
		||||
 | 
			
		||||
    mcc->parent_realize(dev, errp);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void m68k_cpu_initfn(Object *obj)
 | 
			
		||||
{
 | 
			
		||||
    M68kCPU *cpu = M68K_CPU(obj);
 | 
			
		||||
@ -158,6 +171,9 @@ static void m68k_cpu_class_init(ObjectClass *c, void *data)
 | 
			
		||||
    CPUClass *cc = CPU_CLASS(c);
 | 
			
		||||
    DeviceClass *dc = DEVICE_CLASS(c);
 | 
			
		||||
 | 
			
		||||
    mcc->parent_realize = dc->realize;
 | 
			
		||||
    dc->realize = m68k_cpu_realizefn;
 | 
			
		||||
 | 
			
		||||
    mcc->parent_reset = cc->reset;
 | 
			
		||||
    cc->reset = m68k_cpu_reset;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -116,6 +116,7 @@ typedef struct CPUM68KState {
 | 
			
		||||
#include "cpu-qom.h"
 | 
			
		||||
 | 
			
		||||
void m68k_tcg_init(void);
 | 
			
		||||
void m68k_cpu_init_gdb(M68kCPU *cpu);
 | 
			
		||||
CPUM68KState *cpu_m68k_init(const char *cpu_model);
 | 
			
		||||
int cpu_m68k_exec(CPUM68KState *s);
 | 
			
		||||
void do_interrupt(CPUM68KState *env1);
 | 
			
		||||
 | 
			
		||||
@ -120,15 +120,21 @@ CPUM68KState *cpu_m68k_init(const char *cpu_model)
 | 
			
		||||
    env->cpu_model_str = cpu_model;
 | 
			
		||||
 | 
			
		||||
    register_m68k_insns(env);
 | 
			
		||||
 | 
			
		||||
    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
 | 
			
		||||
 | 
			
		||||
    return env;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void m68k_cpu_init_gdb(M68kCPU *cpu)
 | 
			
		||||
{
 | 
			
		||||
    CPUM68KState *env = &cpu->env;
 | 
			
		||||
 | 
			
		||||
    if (m68k_feature(env, M68K_FEATURE_CF_FPU)) {
 | 
			
		||||
        gdb_register_coprocessor(env, fpu_gdb_get_reg, fpu_gdb_set_reg,
 | 
			
		||||
                                 11, "cf-fp.xml", 18);
 | 
			
		||||
    }
 | 
			
		||||
    /* TODO: Add [E]MAC registers.  */
 | 
			
		||||
 | 
			
		||||
    cpu_reset(ENV_GET_CPU(env));
 | 
			
		||||
    qemu_init_vcpu(env);
 | 
			
		||||
    return env;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void cpu_m68k_flush_flags(CPUM68KState *env, int cc_op)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user