diff mbox

[v3,04/13] target-sh4: Do not reset CPU feature flags on reset

Message ID 1334441565-26433-5-git-send-email-afaerber@suse.de
State New
Headers show

Commit Message

Andreas Färber April 14, 2012, 10:12 p.m. UTC
Move them out of CPUSH4State so that they are not zero'ed on reset.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 hw/sh7750.c            |    5 +++--
 target-sh4/cpu-qom.h   |    3 +++
 target-sh4/cpu.h       |    3 ---
 target-sh4/translate.c |    5 +++--
 4 files changed, 9 insertions(+), 7 deletions(-)

Comments

Peter Maydell April 16, 2012, 2:48 p.m. UTC | #1
On 14 April 2012 23:12, Andreas Färber <afaerber@suse.de> wrote:
> Move them out of CPUSH4State so that they are not zero'ed on reset.

Might be worth expanding this commit message a little to make
it clear that it is fixing a pre-existing bug. I initially assumed
this was just part of the QOM conversion.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM
diff mbox

Patch

diff --git a/hw/sh7750.c b/hw/sh7750.c
index e712928..c7e653c 100644
--- a/hw/sh7750.c
+++ b/hw/sh7750.c
@@ -77,10 +77,11 @@  typedef struct SH7750State {
     struct intc_desc intc;
 } SH7750State;
 
-static inline int has_bcr3_and_bcr4(SH7750State * s)
+static inline int has_bcr3_and_bcr4(SH7750State *s)
 {
-	return (s->cpu->features & SH_FEATURE_BCR3_AND_BCR4);
+    return sh_env_get_cpu(s->cpu)->features & SH_FEATURE_BCR3_AND_BCR4;
 }
+
 /**********************************************************************
  I/O ports
 **********************************************************************/
diff --git a/target-sh4/cpu-qom.h b/target-sh4/cpu-qom.h
index c41164a..7f231f1 100644
--- a/target-sh4/cpu-qom.h
+++ b/target-sh4/cpu-qom.h
@@ -48,6 +48,7 @@  typedef struct SuperHCPUClass {
 /**
  * SuperHCPU:
  * @env: #CPUSH4State
+ * @features: CPU feature flags, see #sh_features.
  *
  * A SuperH CPU.
  */
@@ -57,6 +58,8 @@  typedef struct SuperHCPU {
     /*< public >*/
 
     CPUSH4State env;
+
+    uint32_t features;
 } SuperHCPU;
 
 static inline SuperHCPU *sh_env_get_cpu(CPUSH4State *env)
diff --git a/target-sh4/cpu.h b/target-sh4/cpu.h
index b6768f1..6a518f2 100644
--- a/target-sh4/cpu.h
+++ b/target-sh4/cpu.h
@@ -157,9 +157,6 @@  typedef struct CPUSH4State {
     /* float point status register */
     float_status fp_status;
 
-    /* The features that we should emulate. See sh_features above.  */
-    uint32_t features;
-
     /* Those belong to the specific unit (SH7750) but are handled here */
     uint32_t mmucr;		/* MMU control register */
     uint32_t pteh;		/* page table entry high register */
diff --git a/target-sh4/translate.c b/target-sh4/translate.c
index b7426f1..176c7d4 100644
--- a/target-sh4/translate.c
+++ b/target-sh4/translate.c
@@ -258,7 +258,7 @@  CPUSH4State *cpu_sh4_init(const char *cpu_model)
 	return NULL;
     cpu = SUPERH_CPU(object_new(TYPE_SUPERH_CPU));
     env = &cpu->env;
-    env->features = def->features;
+    cpu->features = def->features;
     sh4_translate_init();
     env->cpu_model_str = cpu_model;
     cpu_register(env, def);
@@ -1902,6 +1902,7 @@  static inline void
 gen_intermediate_code_internal(CPUSH4State * env, TranslationBlock * tb,
                                int search_pc)
 {
+    SuperHCPU *cpu = sh_env_get_cpu(env);
     DisasContext ctx;
     target_ulong pc_start;
     static uint16_t *gen_opc_end;
@@ -1923,7 +1924,7 @@  gen_intermediate_code_internal(CPUSH4State * env, TranslationBlock * tb,
     ctx.delayed_pc = -1; /* use delayed pc from env pointer */
     ctx.tb = tb;
     ctx.singlestep_enabled = env->singlestep_enabled;
-    ctx.features = env->features;
+    ctx.features = cpu->features;
     ctx.has_movcal = (tb->flags & TB_FLAG_PENDING_MOVCA);
 
     ii = -1;