[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/9] target-mips: Abstract mmu_idx from hflags
From: |
James Hogan |
Subject: |
[Qemu-devel] [PATCH 5/9] target-mips: Abstract mmu_idx from hflags |
Date: |
Tue, 6 Sep 2016 12:03:40 +0100 |
The MIPS mmu_idx is sometimes calculated from hflags without an env
pointer available as cpu_mmu_index() requires.
Create a common hflags_mmu_index() for the purpose of this calculation
which can operate on any hflags, not just with an env pointer, and
update cpu_mmu_index() itself and gen_intermediate_code() to use it.
This will also allow the logic to be more easily updated when a new MMU
mode is added.
Signed-off-by: James Hogan <address@hidden>
Cc: Leon Alrae <address@hidden>
Cc: Aurelien Jarno <address@hidden>
---
target-mips/cpu.h | 8 +++++++-
target-mips/translate.c | 2 +-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/target-mips/cpu.h b/target-mips/cpu.h
index 6ea2bf14c817..8ddc965e4735 100644
--- a/target-mips/cpu.h
+++ b/target-mips/cpu.h
@@ -695,9 +695,15 @@ extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState
*env);
#define MMU_MODE1_SUFFIX _super
#define MMU_MODE2_SUFFIX _user
#define MMU_USER_IDX 2
+
+static inline int hflags_mmu_index(uint32_t hflags)
+{
+ return hflags & MIPS_HFLAG_KSU;
+}
+
static inline int cpu_mmu_index (CPUMIPSState *env, bool ifetch)
{
- return env->hflags & MIPS_HFLAG_KSU;
+ return hflags_mmu_index(env->hflags);
}
static inline bool cpu_mips_hw_interrupts_enabled(CPUMIPSState *env)
diff --git a/target-mips/translate.c b/target-mips/translate.c
index 8506c39a359c..af17fc95eb8f 100644
--- a/target-mips/translate.c
+++ b/target-mips/translate.c
@@ -20004,7 +20004,7 @@ void gen_intermediate_code(CPUMIPSState *env, struct
TranslationBlock *tb)
#ifdef CONFIG_USER_ONLY
ctx.mem_idx = MIPS_HFLAG_UM;
#else
- ctx.mem_idx = ctx.hflags & MIPS_HFLAG_KSU;
+ ctx.mem_idx = hflags_mmu_index(ctx.hflags);
#endif
ctx.default_tcg_memop_mask = (ctx.insn_flags & ISA_MIPS32R6) ?
MO_UNALN : MO_ALIGN;
--
git-series 0.8.10
- [Qemu-devel] [PATCH 0/9] target-mips: Add Enhanced Virtual Addressing (EVA) support, James Hogan, 2016/09/06
- [Qemu-devel] [PATCH 5/9] target-mips: Abstract mmu_idx from hflags,
James Hogan <=
- [Qemu-devel] [PATCH 4/9] target-mips: Check memory permissions with mem_idx, James Hogan, 2016/09/06
- [Qemu-devel] [PATCH 1/9] target-mips: Add CP0_Ebase.WG (write gate) support, James Hogan, 2016/09/06
- [Qemu-devel] [PATCH 6/9] target-mips: Add an MMU mode for ERL, James Hogan, 2016/09/06
- [Qemu-devel] [PATCH 2/9] target-mips: Prepare loads/stores for EVA, James Hogan, 2016/09/06
- [Qemu-devel] [PATCH 7/9] target-mips: Add segmentation control registers, James Hogan, 2016/09/06
- [Qemu-devel] [PATCH 9/9] target-mips: Add EVA support to P5600, James Hogan, 2016/09/06
- [Qemu-devel] [PATCH 8/9] target-mips: Implement segmentation control, James Hogan, 2016/09/06
- [Qemu-devel] [PATCH 3/9] target-mips: Decode EVA load & store instructions, James Hogan, 2016/09/06
- Re: [Qemu-devel] [PATCH 0/9] target-mips: Add Enhanced Virtual Addressing (EVA) support, no-reply, 2016/09/06