Patchwork [01/20,MIPS] cpu: add a init inplace method

login
register
mail settings
Submitter Hervé Poussineau
Date Aug. 1, 2010, 5:37 p.m.
Message ID <1280684242-19611-1-git-send-email-hpoussin@reactos.org>
Download mbox | patch
Permalink /patch/60472/
State New
Headers show

Comments

Hervé Poussineau - Aug. 1, 2010, 5:37 p.m.
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 target-mips/cpu.h       |    1 +
 target-mips/translate.c |   16 ++++++++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

Patch

diff --git a/target-mips/cpu.h b/target-mips/cpu.h
index b8e6fee..b75e1e6 100644
--- a/target-mips/cpu.h
+++ b/target-mips/cpu.h
@@ -586,6 +586,7 @@  enum {
 
 int cpu_mips_exec(CPUMIPSState *s);
 CPUMIPSState *cpu_mips_init(const char *cpu_model);
+int cpu_mips_init_inplace(CPUMIPSState *env, const char *cpu_model);
 //~ uint32_t cpu_mips_get_clock (void);
 int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
 
diff --git a/target-mips/translate.c b/target-mips/translate.c
index 20b66a8..558f6ac 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -12580,15 +12580,13 @@  static void mips_tcg_init(void)
 
 #include "translate_init.c"
 
-CPUMIPSState *cpu_mips_init (const char *cpu_model)
+int cpu_mips_init_inplace(CPUMIPSState *env, const char *cpu_model)
 {
-    CPUMIPSState *env;
     const mips_def_t *def;
 
     def = cpu_mips_find_by_name(cpu_model);
     if (!def)
-        return NULL;
-    env = qemu_mallocz(sizeof(CPUMIPSState));
+        return -1;
     env->cpu_model = def;
     env->cpu_model_str = cpu_model;
 
@@ -12601,6 +12599,16 @@  CPUMIPSState *cpu_mips_init (const char *cpu_model)
     mips_tcg_init();
     cpu_reset(env);
     qemu_init_vcpu(env);
+    return 0;
+}
+
+CPUMIPSState *cpu_mips_init (const char *cpu_model)
+{
+    CPUMIPSState *env;
+
+    env = qemu_mallocz(sizeof(CPUMIPSState));
+    if (!cpu_mips_init_inplace(env, cpu_model))
+        return NULL;
     return env;
 }