Patchwork [RFC,v4,04/20] target-arm: Prepare model-specific class_init function

login
register
mail settings
Submitter Andreas Färber
Date March 10, 2012, 4:53 p.m.
Message ID <1331398436-20761-5-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/145886/
State New
Headers show

Comments

Andreas Färber - March 10, 2012, 4:53 p.m.
This allows to share initialization between CPU models.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-arm/cpu.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Patch

diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index 00b7ecc..1e34cba 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -102,6 +102,7 @@  static void arm_cpu_reset(CPUState *c)
 typedef struct ARMCPUInfo {
     const char *name;
     uint32_t id;
+    void (*class_init)(ARMCPUClass *klass, const struct ARMCPUInfo *info);
 } ARMCPUInfo;
 
 static const ARMCPUInfo arm_cpus[] = {
@@ -237,6 +238,10 @@  static void arm_cpu_class_init(ObjectClass *klass, void *data)
     cpu_class->reset = arm_cpu_reset;
 
     k->cp15.c0_cpuid = info->id;
+
+    if (info->class_init != NULL) {
+        (*info->class_init)(k, info);
+    }
 }
 
 static void cpu_register(const ARMCPUInfo *info)