Skip to content

Commit

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

Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
[AF: Invoke the parent's realizefn]
Signed-off-by: Andreas Färber <afaerber@suse.de>
  • Loading branch information
afaerber committed Jan 27, 2013
1 parent 86a3900 commit 7242c83
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions target-unicore32/cpu-qom.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@

/**
* UniCore32CPUClass:
* @parent_realize: The parent class' realize handler.
*
* A UniCore32 CPU model.
*/
typedef struct UniCore32CPUClass {
/*< private >*/
CPUClass parent_class;
/*< public >*/

DeviceRealize parent_realize;
} UniCore32CPUClass;

/**
Expand Down
15 changes: 15 additions & 0 deletions target-unicore32/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ static const UniCore32CPUInfo uc32_cpus[] = {
{ .name = "any", .instance_init = uc32_any_cpu_initfn },
};

static void uc32_cpu_realizefn(DeviceState *dev, Error **errp)
{
UniCore32CPU *cpu = UNICORE32_CPU(dev);
UniCore32CPUClass *ucc = UNICORE32_CPU_GET_CLASS(dev);

qemu_init_vcpu(&cpu->env);

ucc->parent_realize(dev, errp);
}

static void uc32_cpu_initfn(Object *obj)
{
UniCore32CPU *cpu = UNICORE32_CPU(obj);
Expand All @@ -98,9 +108,14 @@ static void uc32_cpu_initfn(Object *obj)

static void uc32_cpu_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
UniCore32CPUClass *ucc = UNICORE32_CPU_CLASS(oc);

cc->class_by_name = uc32_cpu_class_by_name;

ucc->parent_realize = dc->realize;
dc->realize = uc32_cpu_realizefn;
}

static void uc32_register_cpu_type(const UniCore32CPUInfo *info)
Expand Down
3 changes: 2 additions & 1 deletion target-unicore32/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
uc32_translate_init();
}

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

return env;
}

Expand Down

0 comments on commit 7242c83

Please sign in to comment.