On 01/29/2012 05:50 PM, Andreas Färber wrote:
Instead of having each CPU's class_init function call its parent's
function, indirect this through arm_cpu_class_init().
Signed-off-by: Andreas Färber<afaer...@suse.de>
---
target-arm/cpu-core.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/target-arm/cpu-core.c b/target-arm/cpu-core.c
index b1ac22c..cdd049e 100644
--- a/target-arm/cpu-core.c
+++ b/target-arm/cpu-core.c
@@ -246,6 +246,13 @@ static void arm_cpu_realize(Object *obj)
cpu->env.cp15.c0_cpuid = cpu_class->id;
}
+static void arm_cpu_class_init(ObjectClass *klass, void *data)
+{
+ const struct ARMCPUDef *d = data;
+
+ (*d->class_init)(klass, NULL);
+}
+
static void cpu_register(const struct ARMCPUDef *def)
{
TypeInfo type = {
@@ -254,7 +261,8 @@ static void cpu_register(const struct ARMCPUDef *def)
.instance_size = sizeof(ARMCPU),
.instance_init = arm_cpu_realize,
.class_size = sizeof(ARMCPUClass),
- .class_init = def->class_init,
+ .class_init = arm_cpu_class_init,
+ .class_data = (void *)def,
Would be better IMHO to embed the data needed by class_init in class_data. That
way we're not going through multiple method tables.
Regards,
Anthony Liguori
};
type_register_static(&type);