Skip to content

Commit

Permalink
target-sparc: Introduce QOM realizefn for SPARCCPU
Browse files Browse the repository at this point in the history
Introduce realizefn and set realized = true in cpu_sparc_init().

Signed-off-by: Andreas Färber <afaerber@suse.de>
  • Loading branch information
afaerber committed Jan 20, 2013
1 parent c4792b3 commit a012e59
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions target-sparc/cpu-qom.h
Expand Up @@ -38,6 +38,7 @@

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

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

Expand Down
17 changes: 16 additions & 1 deletion target-sparc/cpu.c
Expand Up @@ -122,7 +122,8 @@ SPARCCPU *cpu_sparc_init(const char *cpu_model)
object_delete(OBJECT(cpu));
return NULL;
}
qemu_init_vcpu(env);

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

return cpu;
}
Expand Down Expand Up @@ -851,6 +852,16 @@ void cpu_dump_state(CPUSPARCState *env, FILE *f, fprintf_function cpu_fprintf,
cpu_fprintf(f, "\n");
}

static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
{
SPARCCPU *cpu = SPARC_CPU(dev);
SPARCCPUClass *scc = SPARC_CPU_GET_CLASS(dev);

qemu_init_vcpu(&cpu->env);

scc->parent_realize(dev, errp);
}

static void sparc_cpu_initfn(Object *obj)
{
SPARCCPU *cpu = SPARC_CPU(obj);
Expand All @@ -871,6 +882,10 @@ static void sparc_cpu_class_init(ObjectClass *oc, void *data)
{
SPARCCPUClass *scc = SPARC_CPU_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
DeviceClass *dc = DEVICE_CLASS(oc);

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

scc->parent_reset = cc->reset;
cc->reset = sparc_cpu_reset;
Expand Down

0 comments on commit a012e59

Please sign in to comment.