qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 11/20] target-openrisc: implement CPU realize() method


From: Eduardo Habkost
Subject: [Qemu-devel] [RFC 11/20] target-openrisc: implement CPU realize() method
Date: Tue, 18 Dec 2012 18:04:04 -0200

Signed-off-by: Eduardo Habkost <address@hidden>
---
 target-openrisc/cpu.c | 19 ++++++++++++++-----
 target-openrisc/cpu.h |  1 -
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/target-openrisc/cpu.c b/target-openrisc/cpu.c
index e152a3a..0a8253e 100644
--- a/target-openrisc/cpu.c
+++ b/target-openrisc/cpu.c
@@ -19,6 +19,7 @@
 
 #include "cpu.h"
 #include "qemu-common.h"
+#include "qemu-error.h"
 
 /* CPUClass::reset() */
 static void openrisc_cpu_reset(CPUState *s)
@@ -62,12 +63,12 @@ static inline void set_feature(OpenRISCCPU *cpu, int 
feature)
     cpu->env.cpucfgr = cpu->feature;
 }
 
-void openrisc_cpu_realize(Object *obj, Error **errp)
+static void openrisc_cpu_realize(CPUState *cpu, Error **errp)
 {
-    OpenRISCCPU *cpu = OPENRISC_CPU(obj);
+    OpenRISCCPU *oc = OPENRISC_CPU(cpu);
 
-    qemu_init_vcpu(&cpu->env);
-    cpu_reset(CPU(cpu));
+    qemu_init_vcpu(&oc->env);
+    cpu_reset(cpu);
 }
 
 static void openrisc_cpu_initfn(Object *obj)
@@ -120,6 +121,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, void 
*data)
 
     occ->parent_reset = cc->reset;
     cc->reset = openrisc_cpu_reset;
+    cc->realize = openrisc_cpu_realize;
 }
 
 static void cpu_register(const OpenRISCCPUInfo *info)
@@ -158,6 +160,7 @@ static void openrisc_cpu_register_types(void)
 OpenRISCCPU *cpu_openrisc_init(const char *cpu_model)
 {
     OpenRISCCPU *cpu;
+    Error *err = NULL;
 
     if (!object_class_by_name(cpu_model)) {
         return NULL;
@@ -165,9 +168,15 @@ OpenRISCCPU *cpu_openrisc_init(const char *cpu_model)
     cpu = OPENRISC_CPU(object_new(cpu_model));
     CPU(cpu)->cpu_model_str = cpu_model;
 
-    openrisc_cpu_realize(OBJECT(cpu), NULL);
+    cpu_realize(CPU(cpu), &err);
+    if (err) {
+        goto error;
+    }
 
     return cpu;
+error:
+    error_report("cpu_openrisc_init: %s", error_get_pretty(err));
+    return NULL;
 }
 
 typedef struct OpenRISCCPUList {
diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h
index d7470a9..d0a2fdc 100644
--- a/target-openrisc/cpu.h
+++ b/target-openrisc/cpu.h
@@ -347,7 +347,6 @@ static inline CPUOpenRISCState 
*openrisc_cpu_get_env(OpenRISCCPU *cpu)
 #define CPU_GET_ENV(cpu) openrisc_cpu_get_env(OPENRISC_CPU(cpu))
 
 OpenRISCCPU *cpu_openrisc_init(const char *cpu_model);
-void openrisc_cpu_realize(Object *obj, Error **errp);
 
 void cpu_openrisc_list(FILE *f, fprintf_function cpu_fprintf);
 int cpu_openrisc_exec(CPUOpenRISCState *s);
-- 
1.7.11.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]