Patchwork [RFC,qom-cpu,14/15] target-unicore32: Introduce QOM realizefn for UniCore32CPU

login
register
mail settings
Submitter Andreas Färber
Date Jan. 16, 2013, 5:32 a.m.
Message ID <1358314380-9400-15-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/212408/
State New
Headers show

Comments

Andreas Färber - Jan. 16, 2013, 5:32 a.m.
Introduce a realizefn and set realized = true in uc32_cpu_init().

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 target-unicore32/cpu.c    |   15 +++++++++++++++
 target-unicore32/helper.c |    2 +-
 2 Dateien geändert, 16 Zeilen hinzugefügt(+), 1 Zeile entfernt(-)
Guan Xuetao - Jan. 16, 2013, 12:08 p.m.
> Introduce a realizefn and set realized = true in uc32_cpu_init().
>
> Signed-off-by: Andreas F盲rber <afaerber@suse.de>

LGTM.

Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>

> ---
>  target-unicore32/cpu.c    |   15 +++++++++++++++
>  target-unicore32/helper.c |    2 +-
>  2 Dateien ge盲ndert, 16 Zeilen hinzugef眉gt(+), 1 Zeile entfernt(-)
>
> diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c
> index 884c101..22330ad 100644
> --- a/target-unicore32/cpu.c
> +++ b/target-unicore32/cpu.c
> @@ -61,6 +61,13 @@ static const UniCore32CPUInfo uc32_cpus[] = {
>      { .name = "any",        .instance_init = uc32_any_cpu_initfn },
>  };
>
> +static void uc32_cpu_realizefn(DeviceState *dev, Error **errp)
> +{
> +    UniCore32CPU *cpu = UNICORE32_CPU(dev);
> +
> +    qemu_init_vcpu(&cpu->env);
> +}
> +
>  static void uc32_cpu_initfn(Object *obj)
>  {
>      UniCore32CPU *cpu = UNICORE32_CPU(obj);
> @@ -80,6 +87,13 @@ static void uc32_cpu_initfn(Object *obj)
>      tlb_flush(env, 1);
>  }
>
> +static void uc32_cpu_class_init(ObjectClass *oc, void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(oc);
> +
> +    dc->realize = uc32_cpu_realizefn;
> +}
> +
>  static void uc32_register_cpu_type(const UniCore32CPUInfo *info)
>  {
>      TypeInfo type_info = {
> @@ -98,6 +112,7 @@ static const TypeInfo uc32_cpu_type_info = {
>      .instance_init = uc32_cpu_initfn,
>      .abstract = true,
>      .class_size = sizeof(UniCore32CPUClass),
> +    .class_init = uc32_cpu_class_init,
>  };
>
>  static void uc32_cpu_register_types(void)
> diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c
> index 5359538..347d842 100644
> --- a/target-unicore32/helper.c
> +++ b/target-unicore32/helper.c
> @@ -42,7 +42,7 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
>          uc32_translate_init();
>      }
>
> -    qemu_init_vcpu(env);
> +    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
>      return env;
>  }
>
> --
> 1.7.10.4
>

Patch

diff --git a/target-unicore32/cpu.c b/target-unicore32/cpu.c
index 884c101..22330ad 100644
--- a/target-unicore32/cpu.c
+++ b/target-unicore32/cpu.c
@@ -61,6 +61,13 @@  static const UniCore32CPUInfo uc32_cpus[] = {
     { .name = "any",        .instance_init = uc32_any_cpu_initfn },
 };
 
+static void uc32_cpu_realizefn(DeviceState *dev, Error **errp)
+{
+    UniCore32CPU *cpu = UNICORE32_CPU(dev);
+
+    qemu_init_vcpu(&cpu->env);
+}
+
 static void uc32_cpu_initfn(Object *obj)
 {
     UniCore32CPU *cpu = UNICORE32_CPU(obj);
@@ -80,6 +87,13 @@  static void uc32_cpu_initfn(Object *obj)
     tlb_flush(env, 1);
 }
 
+static void uc32_cpu_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(oc);
+
+    dc->realize = uc32_cpu_realizefn;
+}
+
 static void uc32_register_cpu_type(const UniCore32CPUInfo *info)
 {
     TypeInfo type_info = {
@@ -98,6 +112,7 @@  static const TypeInfo uc32_cpu_type_info = {
     .instance_init = uc32_cpu_initfn,
     .abstract = true,
     .class_size = sizeof(UniCore32CPUClass),
+    .class_init = uc32_cpu_class_init,
 };
 
 static void uc32_cpu_register_types(void)
diff --git a/target-unicore32/helper.c b/target-unicore32/helper.c
index 5359538..347d842 100644
--- a/target-unicore32/helper.c
+++ b/target-unicore32/helper.c
@@ -42,7 +42,7 @@  CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
         uc32_translate_init();
     }
 
-    qemu_init_vcpu(env);
+    object_property_set_bool(OBJECT(cpu), true, "realized", NULL);
     return env;
 }