@@ -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;
@@ -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;
@@ -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;
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(-)