diff mbox

[6/8] ppc: move cpu index setup to instance_init/finalize

Message ID 146723348371.9665.14803084330813305319.stgit@bahia.lan (mailing list archive)
State New, archived
Headers show

Commit Message

Greg Kurz June 29, 2016, 8:51 p.m. UTC
This patch moves cpu_index initialization to instance init: it will
allow machine code to compute cpu_dt_id between cpu initialization and
cpu realization.

It also adds the related exit code to be called at instance finalize, for
symmetry.

This doesn't change behaviour when the cpu is setup with cpu_ppc_init(),
which handles initialization and realization sequentially. This is
currently the case for all configurations in both user and system mode.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 target-ppc/translate_init.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index d7860fd7f8ee..f7571f34d6ac 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -9540,9 +9540,9 @@  static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)
         return;
     }
 #endif
 
-    cpu_exec_init(cs, &local_err);
+    cpu_exec_realize(cs, &local_err);
     if (local_err != NULL) {
         error_propagate(errp, local_err);
         return;
     }
@@ -9772,9 +9772,9 @@  static void ppc_cpu_unrealizefn(DeviceState *dev, Error **errp)
     CPUPPCState *env = &cpu->env;
     opc_handler_t **table;
     int i, j;
 
-    cpu_exec_exit(CPU(dev));
+    cpu_exec_unrealize(CPU(dev));
 
     for (i = 0; i < PPC_CPU_OPCODES_LEN; i++) {
         if (env->opcodes[i] == &invalid_handler) {
             continue;
@@ -10336,8 +10336,15 @@  static void ppc_cpu_initfn(Object *obj)
 
     if (tcg_enabled()) {
         ppc_translate_init();
     }
+
+    cpu_exec_init_cpu_index(cs, &error_abort);
+}
+
+static void ppc_cpu_finalizefn(Object *obj)
+{
+    cpu_exec_exit_cpu_index(CPU(obj));
 }
 
 static bool ppc_pvr_match_default(PowerPCCPUClass *pcc, uint32_t pvr)
 {
@@ -10413,8 +10420,9 @@  static const TypeInfo ppc_cpu_type_info = {
     .name = TYPE_POWERPC_CPU,
     .parent = TYPE_CPU,
     .instance_size = sizeof(PowerPCCPU),
     .instance_init = ppc_cpu_initfn,
+    .instance_finalize = ppc_cpu_finalizefn,
     .abstract = true,
     .class_size = sizeof(PowerPCCPUClass),
     .class_init = ppc_cpu_class_init,
 };