Skip to content

Commit

Permalink
target-sh4: Introduce QOM realizefn for SuperHCPU
Browse files Browse the repository at this point in the history
Introduce a realizefn and set realized = true in cpu_sh4_init().

Signed-off-by: Andreas Färber <[email protected]>
  • Loading branch information
afaerber committed Feb 16, 2013
1 parent 1f13663 commit 55acb58
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions target-sh4/cpu-qom.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

/**
* SuperHCPUClass:
* @parent_realize: The parent class' realize handler.
* @parent_reset: The parent class' reset handler.
*
* A SuperH CPU model.
Expand All @@ -42,6 +43,7 @@ typedef struct SuperHCPUClass {
CPUClass parent_class;
/*< public >*/

DeviceRealize parent_realize;
void (*parent_reset)(CPUState *cpu);
} SuperHCPUClass;

Expand Down
14 changes: 14 additions & 0 deletions target-sh4/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ static void superh_cpu_reset(CPUState *s)
set_default_nan_mode(1, &env->fp_status);
}

static void superh_cpu_realizefn(DeviceState *dev, Error **errp)
{
SuperHCPU *cpu = SUPERH_CPU(dev);
SuperHCPUClass *scc = SUPERH_CPU_GET_CLASS(dev);

cpu_reset(CPU(cpu));
qemu_init_vcpu(&cpu->env);

scc->parent_realize(dev, errp);
}

static void superh_cpu_initfn(Object *obj)
{
SuperHCPU *cpu = SUPERH_CPU(obj);
Expand All @@ -75,6 +86,9 @@ static void superh_cpu_class_init(ObjectClass *oc, void *data)
CPUClass *cc = CPU_CLASS(oc);
SuperHCPUClass *scc = SUPERH_CPU_CLASS(oc);

scc->parent_realize = dc->realize;
dc->realize = superh_cpu_realizefn;

scc->parent_reset = cc->reset;
cc->reset = superh_cpu_reset;

Expand Down
5 changes: 3 additions & 2 deletions target-sh4/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,10 @@ SuperHCPU *cpu_sh4_init(const char *cpu_model)
env->features = def->features;
sh4_translate_init();
env->cpu_model_str = cpu_model;
cpu_reset(CPU(cpu));
cpu_register(env, def);
qemu_init_vcpu(env);

object_property_set_bool(OBJECT(cpu), true, "realized", NULL);

return cpu;
}

Expand Down

0 comments on commit 55acb58

Please sign in to comment.