Patchwork [RFC,qom-cpu,v2,02/28] target-alpha: Update AlphaCPU to QOM realizefn

login
register
mail settings
Submitter Andreas Färber
Date Jan. 20, 2013, 7:22 a.m.
Message ID <1358666571-1737-3-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/213939/
State New
Headers show

Comments

Andreas Färber - Jan. 20, 2013, 7:22 a.m.
Update the alpha_cpu_realize() signature and hook up to
DeviceClass::realize. Set realized = true in cpu_alpha_init().

qapi/error.h is included through qdev now and no longer needed.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-alpha/cpu-qom.h |    2 ++
 target-alpha/cpu.c     |   21 +++++++++++++++++----
 2 Dateien geändert, 19 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)
Richard Henderson - Jan. 21, 2013, 3:26 p.m.
On 2013-01-19 23:22, Andreas Färber wrote:
> Update the alpha_cpu_realize() signature and hook up to
> DeviceClass::realize. Set realized = true in cpu_alpha_init().
>
> qapi/error.h is included through qdev now and no longer needed.
>
> Signed-off-by: Andreas Färber<afaerber@suse.de>
> ---
>   target-alpha/cpu-qom.h |    2 ++
>   target-alpha/cpu.c     |   21 +++++++++++++++++----
>   2 Dateien geändert, 19 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-)

Acked-by: Richard Henderson <rth@twiddle.net>


r~

Patch

diff --git a/target-alpha/cpu-qom.h b/target-alpha/cpu-qom.h
index 16367d2..c0f6c6d 100644
--- a/target-alpha/cpu-qom.h
+++ b/target-alpha/cpu-qom.h
@@ -34,6 +34,7 @@ 
 
 /**
  * AlphaCPUClass:
+ * @parent_realize: The parent class' realize handler.
  * @parent_reset: The parent class' reset handler.
  *
  * An Alpha CPU model.
@@ -43,6 +44,7 @@  typedef struct AlphaCPUClass {
     CPUClass parent_class;
     /*< public >*/
 
+    DeviceRealize parent_realize;
     void (*parent_reset)(CPUState *cpu);
 } AlphaCPUClass;
 
diff --git a/target-alpha/cpu.c b/target-alpha/cpu.c
index 40e9809..9222731 100644
--- a/target-alpha/cpu.c
+++ b/target-alpha/cpu.c
@@ -21,14 +21,16 @@ 
 
 #include "cpu.h"
 #include "qemu-common.h"
-#include "qapi/error.h"
 
 
-static void alpha_cpu_realize(Object *obj, Error **errp)
+static void alpha_cpu_realizefn(DeviceState *dev, Error **errp)
 {
-    AlphaCPU *cpu = ALPHA_CPU(obj);
+    AlphaCPU *cpu = ALPHA_CPU(dev);
+    AlphaCPUClass *acc = ALPHA_CPU_GET_CLASS(dev);
 
     qemu_init_vcpu(&cpu->env);
+
+    acc->parent_realize(dev, errp);
 }
 
 /* Sort alphabetically by type name. */
@@ -130,7 +132,8 @@  AlphaCPU *cpu_alpha_init(const char *cpu_model)
 
     env->cpu_model_str = cpu_model;
 
-    alpha_cpu_realize(OBJECT(cpu), NULL);
+    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
+
     return cpu;
 }
 
@@ -244,6 +247,15 @@  static void alpha_cpu_initfn(Object *obj)
     env->fen = 1;
 }
 
+static void alpha_cpu_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(oc);
+    AlphaCPUClass *acc = ALPHA_CPU_CLASS(oc);
+
+    acc->parent_realize = dc->realize;
+    dc->realize = alpha_cpu_realizefn;
+}
+
 static const TypeInfo alpha_cpu_type_info = {
     .name = TYPE_ALPHA_CPU,
     .parent = TYPE_CPU,
@@ -251,6 +263,7 @@  static const TypeInfo alpha_cpu_type_info = {
     .instance_init = alpha_cpu_initfn,
     .abstract = true,
     .class_size = sizeof(AlphaCPUClass),
+    .class_init = alpha_cpu_class_init,
 };
 
 static void alpha_cpu_register_types(void)