[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PATCH v2 3/5] target-ppc: QOM'ify CPU init
From: |
Andreas Färber |
Subject: |
[Qemu-ppc] [PATCH v2 3/5] target-ppc: QOM'ify CPU init |
Date: |
Fri, 6 Apr 2012 18:17:10 +0200 |
Move code from cpu_ppc_init() into an initfn.
Signed-off-by: Andreas Färber <address@hidden>
---
target-ppc/helper.c | 10 +---------
target-ppc/translate_init.c | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/target-ppc/helper.c b/target-ppc/helper.c
index fa9494b..f2994ca 100644
--- a/target-ppc/helper.c
+++ b/target-ppc/helper.c
@@ -3196,19 +3196,11 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model)
cpu = POWERPC_CPU(object_new(TYPE_POWERPC_CPU));
env = &cpu->env;
- cpu_exec_init(env);
+
if (tcg_enabled()) {
ppc_translate_init();
}
- /* Adjust cpu index for SMT */
-#if !defined(CONFIG_USER_ONLY)
- if (kvm_enabled()) {
- int smt = kvmppc_smt_threads();
- env->cpu_index = (env->cpu_index / smp_threads)*smt
- + (env->cpu_index % smp_threads);
- }
-#endif /* !CONFIG_USER_ONLY */
env->cpu_model_str = cpu_model;
cpu_ppc_register_internal(env, def);
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 24817ef..860a226 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -25,6 +25,7 @@
#include "dis-asm.h"
#include "gdbstub.h"
+#include "cpus.h"
#include <kvm.h>
#include "kvm_ppc.h"
@@ -10198,6 +10199,24 @@ static void ppc_cpu_reset(CPUState *s)
cpu_state_reset(env);
}
+static void ppc_cpu_initfn(Object *obj)
+{
+ PowerPCCPU *cpu = POWERPC_CPU(obj);
+ CPUPPCState *env = &cpu->env;
+
+ cpu_exec_init(env);
+
+ /* Adjust cpu index for SMT */
+#if !defined(CONFIG_USER_ONLY)
+ if (kvm_enabled()) {
+ int smt = kvmppc_smt_threads();
+
+ env->cpu_index = (env->cpu_index / smp_threads) * smt
+ + (env->cpu_index % smp_threads);
+ }
+#endif /* !CONFIG_USER_ONLY */
+}
+
static void ppc_cpu_class_init(ObjectClass *oc, void *data)
{
PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc);
@@ -10211,6 +10230,7 @@ static const TypeInfo ppc_cpu_type_info = {
.name = TYPE_POWERPC_CPU,
.parent = TYPE_CPU,
.instance_size = sizeof(PowerPCCPU),
+ .instance_init = ppc_cpu_initfn,
.abstract = false,
.class_size = sizeof(PowerPCCPUClass),
.class_init = ppc_cpu_class_init,
--
1.7.7
[Qemu-ppc] [PATCH v2 3/5] target-ppc: QOM'ify CPU init,
Andreas Färber <=
[Qemu-ppc] [PATCH v2 5/5] target-ppc: Add CPU finalizer, Andreas Färber, 2012/04/06
[Qemu-ppc] [PATCH v2 1/5] target-ppc: Drop cpu_ppc_close(), Andreas Färber, 2012/04/06
[Qemu-ppc] [PATCH v2 4/5] target-ppc: QOM'ify CPU reset, Andreas Färber, 2012/04/06