Patchwork [RFC,qom-cpu,v2,07/28] target-cris: Introduce QOM realizefn for CRISCPU

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

Comments

Andreas Färber - Jan. 20, 2013, 7:22 a.m.
Introduce realizefn and set realized = true from cpu_cris_init().

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-cris/cpu-qom.h   |    2 ++
 target-cris/cpu.c       |   15 +++++++++++++++
 target-cris/translate.c |    3 +--
 3 Dateien geändert, 18 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
Eduardo Habkost - Feb. 7, 2013, 4:32 p.m.
On Sun, Jan 20, 2013 at 08:22:30AM +0100, Andreas Färber wrote:
> Introduce realizefn and set realized = true from cpu_cris_init().
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

> ---
>  target-cris/cpu-qom.h   |    2 ++
>  target-cris/cpu.c       |   15 +++++++++++++++
>  target-cris/translate.c |    3 +--
>  3 Dateien geändert, 18 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
> 
> diff --git a/target-cris/cpu-qom.h b/target-cris/cpu-qom.h
> index 41ab9b2..7ad8398 100644
> --- a/target-cris/cpu-qom.h
> +++ b/target-cris/cpu-qom.h
> @@ -33,6 +33,7 @@
>  
>  /**
>   * CRISCPUClass:
> + * @parent_realize: The parent class' realize handler.
>   * @parent_reset: The parent class' reset handler.
>   *
>   * A CRIS CPU model.
> @@ -42,6 +43,7 @@ typedef struct CRISCPUClass {
>      CPUClass parent_class;
>      /*< public >*/
>  
> +    DeviceRealize parent_realize;
>      void (*parent_reset)(CPUState *cpu);
>  } CRISCPUClass;
>  
> diff --git a/target-cris/cpu.c b/target-cris/cpu.c
> index 3f64a57..34c4f75 100644
> --- a/target-cris/cpu.c
> +++ b/target-cris/cpu.c
> @@ -55,6 +55,17 @@ static void cris_cpu_reset(CPUState *s)
>  #endif
>  }
>  
> +static void cris_cpu_realizefn(DeviceState *dev, Error **errp)
> +{
> +    CRISCPU *cpu = CRIS_CPU(dev);
> +    CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(dev);
> +
> +    cpu_reset(CPU(cpu));
> +    qemu_init_vcpu(&cpu->env);
> +
> +    ccc->parent_realize(dev, errp);
> +}
> +
>  static void cris_cpu_initfn(Object *obj)
>  {
>      CRISCPU *cpu = CRIS_CPU(obj);
> @@ -65,9 +76,13 @@ static void cris_cpu_initfn(Object *obj)
>  
>  static void cris_cpu_class_init(ObjectClass *oc, void *data)
>  {
> +    DeviceClass *dc = DEVICE_CLASS(oc);
>      CPUClass *cc = CPU_CLASS(oc);
>      CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
>  
> +    ccc->parent_realize = dc->realize;
> +    dc->realize = cris_cpu_realizefn;
> +
>      ccc->parent_reset = cc->reset;
>      cc->reset = cris_cpu_reset;
>  }
> diff --git a/target-cris/translate.c b/target-cris/translate.c
> index 09e6011..25ff490 100644
> --- a/target-cris/translate.c
> +++ b/target-cris/translate.c
> @@ -3558,8 +3558,7 @@ CRISCPU *cpu_cris_init(const char *cpu_model)
>  
>      env->pregs[PR_VR] = vr_by_name(cpu_model);
>  
> -    cpu_reset(CPU(cpu));
> -    qemu_init_vcpu(env);
> +    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
>  
>      if (tcg_initialized) {
>          return cpu;
> -- 
> 1.7.10.4
> 
>

Patch

diff --git a/target-cris/cpu-qom.h b/target-cris/cpu-qom.h
index 41ab9b2..7ad8398 100644
--- a/target-cris/cpu-qom.h
+++ b/target-cris/cpu-qom.h
@@ -33,6 +33,7 @@ 
 
 /**
  * CRISCPUClass:
+ * @parent_realize: The parent class' realize handler.
  * @parent_reset: The parent class' reset handler.
  *
  * A CRIS CPU model.
@@ -42,6 +43,7 @@  typedef struct CRISCPUClass {
     CPUClass parent_class;
     /*< public >*/
 
+    DeviceRealize parent_realize;
     void (*parent_reset)(CPUState *cpu);
 } CRISCPUClass;
 
diff --git a/target-cris/cpu.c b/target-cris/cpu.c
index 3f64a57..34c4f75 100644
--- a/target-cris/cpu.c
+++ b/target-cris/cpu.c
@@ -55,6 +55,17 @@  static void cris_cpu_reset(CPUState *s)
 #endif
 }
 
+static void cris_cpu_realizefn(DeviceState *dev, Error **errp)
+{
+    CRISCPU *cpu = CRIS_CPU(dev);
+    CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(dev);
+
+    cpu_reset(CPU(cpu));
+    qemu_init_vcpu(&cpu->env);
+
+    ccc->parent_realize(dev, errp);
+}
+
 static void cris_cpu_initfn(Object *obj)
 {
     CRISCPU *cpu = CRIS_CPU(obj);
@@ -65,9 +76,13 @@  static void cris_cpu_initfn(Object *obj)
 
 static void cris_cpu_class_init(ObjectClass *oc, void *data)
 {
+    DeviceClass *dc = DEVICE_CLASS(oc);
     CPUClass *cc = CPU_CLASS(oc);
     CRISCPUClass *ccc = CRIS_CPU_CLASS(oc);
 
+    ccc->parent_realize = dc->realize;
+    dc->realize = cris_cpu_realizefn;
+
     ccc->parent_reset = cc->reset;
     cc->reset = cris_cpu_reset;
 }
diff --git a/target-cris/translate.c b/target-cris/translate.c
index 09e6011..25ff490 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -3558,8 +3558,7 @@  CRISCPU *cpu_cris_init(const char *cpu_model)
 
     env->pregs[PR_VR] = vr_by_name(cpu_model);
 
-    cpu_reset(CPU(cpu));
-    qemu_init_vcpu(env);
+    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
 
     if (tcg_initialized) {
         return cpu;