[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 2/3] target/mips: Store number of TLB entries in CPUMIPSState
From: |
Philippe Mathieu-Daudé |
Subject: |
[RFC PATCH 2/3] target/mips: Store number of TLB entries in CPUMIPSState |
Date: |
Tue, 13 Oct 2020 15:25:34 +0200 |
As we want to make the number of TLB entries configurable,
store it in CPUMIPSState.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
target/mips/cpu.h | 1 +
target/mips/translate.c | 4 +++-
target/mips/translate_init.c.inc | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/target/mips/cpu.h b/target/mips/cpu.h
index 7cf7f5239f7..b84e9a8fcae 100644
--- a/target/mips/cpu.h
+++ b/target/mips/cpu.h
@@ -1140,6 +1140,7 @@ struct CPUMIPSState {
#endif
const mips_def_t *cpu_model;
+ uint8_t tlb_entries;
void *irq[8];
QEMUTimer *timer; /* Internal timer */
struct MIPSITUState *itu;
diff --git a/target/mips/translate.c b/target/mips/translate.c
index 4c9b6216321..9d13e164c2e 100644
--- a/target/mips/translate.c
+++ b/target/mips/translate.c
@@ -31319,6 +31319,7 @@ void mips_tcg_init(void)
bool cpu_mips_realize_env(CPUMIPSState *env, Error **errp)
{
env->exception_base = (int32_t)0xBFC00000;
+ env->tlb_entries = 1 + extract32(env->cpu_model->CP0_Config1, CP0C1_MMU,
6);
#ifndef CONFIG_USER_ONLY
mmu_init(env, env->cpu_model);
@@ -31357,7 +31358,8 @@ void cpu_state_reset(CPUMIPSState *env)
#ifdef TARGET_WORDS_BIGENDIAN
env->CP0_Config0 |= (1 << CP0C0_BE);
#endif
- env->CP0_Config1 = env->cpu_model->CP0_Config1;
+ env->CP0_Config1 = deposit32(env->cpu_model->CP0_Config1, CP0C1_MMU, 6,
+ env->tlb_entries - 1);
env->CP0_Config2 = env->cpu_model->CP0_Config2;
env->CP0_Config3 = env->cpu_model->CP0_Config3;
env->CP0_Config4 = env->cpu_model->CP0_Config4;
diff --git a/target/mips/translate_init.c.inc b/target/mips/translate_init.c.inc
index 637caccd890..a426463c434 100644
--- a/target/mips/translate_init.c.inc
+++ b/target/mips/translate_init.c.inc
@@ -946,7 +946,7 @@ static void fixed_mmu_init (CPUMIPSState *env, const
mips_def_t *def)
static void r4k_mmu_init (CPUMIPSState *env, const mips_def_t *def)
{
- env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63);
+ env->tlb->nb_tlb = env->tlb_entries;
env->tlb->map_address = &r4k_map_address;
env->tlb->helper_tlbwi = r4k_helper_tlbwi;
env->tlb->helper_tlbwr = r4k_helper_tlbwr;
--
2.26.2