qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH RFC 8/7] target-arm: Use IoC for CPU init


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH RFC 8/7] target-arm: Use IoC for CPU init
Date: Sun, 29 Jan 2012 20:23:39 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Lightning/1.0b2 Thunderbird/3.1.15

On 01/29/2012 05:50 PM, Andreas Färber wrote:
Instead of having each CPU's class_init function call its parent's
function, indirect this through arm_cpu_class_init().

Signed-off-by: Andreas Färber<address@hidden>
---
  target-arm/cpu-core.c |   10 +++++++++-
  1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/target-arm/cpu-core.c b/target-arm/cpu-core.c
index b1ac22c..cdd049e 100644
--- a/target-arm/cpu-core.c
+++ b/target-arm/cpu-core.c
@@ -246,6 +246,13 @@ static void arm_cpu_realize(Object *obj)
      cpu->env.cp15.c0_cpuid = cpu_class->id;
  }

+static void arm_cpu_class_init(ObjectClass *klass, void *data)
+{
+    const struct ARMCPUDef *d = data;
+
+    (*d->class_init)(klass, NULL);
+}
+
  static void cpu_register(const struct ARMCPUDef *def)
  {
      TypeInfo type = {
@@ -254,7 +261,8 @@ static void cpu_register(const struct ARMCPUDef *def)
          .instance_size = sizeof(ARMCPU),
          .instance_init = arm_cpu_realize,
          .class_size = sizeof(ARMCPUClass),
-        .class_init = def->class_init,
+        .class_init = arm_cpu_class_init,
+        .class_data = (void *)def,

Would be better IMHO to embed the data needed by class_init in class_data. That way we're not going through multiple method tables.

Regards,

Anthony Liguori

      };

      type_register_static(&type);




reply via email to

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