target/tricore: Convert to CPUClass::tlb_fill

Acked-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2019-04-03 07:27:29 +07:00
parent 7bfe4e2562
commit 68d6eee73c
4 changed files with 23 additions and 37 deletions

View File

@ -166,6 +166,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void *data)
cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb; cc->synchronize_from_tb = tricore_cpu_synchronize_from_tb;
cc->get_phys_page_attrs_debug = tricore_cpu_get_phys_page_attrs_debug; cc->get_phys_page_attrs_debug = tricore_cpu_get_phys_page_attrs_debug;
cc->tcg_initialize = tricore_tcg_init; cc->tcg_initialize = tricore_tcg_init;
cc->tlb_fill = tricore_cpu_tlb_fill;
} }
#define DEFINE_TRICORE_CPU_TYPE(cpu_model, initfn) \ #define DEFINE_TRICORE_CPU_TYPE(cpu_model, initfn) \

View File

@ -417,8 +417,8 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,
#define CPU_RESOLVING_TYPE TYPE_TRICORE_CPU #define CPU_RESOLVING_TYPE TYPE_TRICORE_CPU
/* helpers.c */ /* helpers.c */
int cpu_tricore_handle_mmu_fault(CPUState *cpu, target_ulong address, bool tricore_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
int rw, int mmu_idx); MMUAccessType access_type, int mmu_idx,
#define cpu_handle_mmu_fault cpu_tricore_handle_mmu_fault bool probe, uintptr_t retaddr);
#endif /* TRICORE_CPU_H */ #endif /* TRICORE_CPU_H */

View File

@ -50,8 +50,9 @@ static void raise_mmu_exception(CPUTriCoreState *env, target_ulong address,
{ {
} }
int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address, bool tricore_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
int rw, int mmu_idx) MMUAccessType rw, int mmu_idx,
bool probe, uintptr_t retaddr)
{ {
TriCoreCPU *cpu = TRICORE_CPU(cs); TriCoreCPU *cpu = TRICORE_CPU(cs);
CPUTriCoreState *env = &cpu->env; CPUTriCoreState *env = &cpu->env;
@ -64,20 +65,30 @@ int cpu_tricore_handle_mmu_fault(CPUState *cs, target_ulong address,
access_type = ACCESS_INT; access_type = ACCESS_INT;
ret = get_physical_address(env, &physical, &prot, ret = get_physical_address(env, &physical, &prot,
address, rw, access_type); address, rw, access_type);
qemu_log_mask(CPU_LOG_MMU, "%s address=" TARGET_FMT_lx " ret %d physical " TARGET_FMT_plx
" prot %d\n", __func__, address, ret, physical, prot); qemu_log_mask(CPU_LOG_MMU, "%s address=" TARGET_FMT_lx " ret %d physical "
TARGET_FMT_plx " prot %d\n",
__func__, (target_ulong)address, ret, physical, prot);
if (ret == TLBRET_MATCH) { if (ret == TLBRET_MATCH) {
tlb_set_page(cs, address & TARGET_PAGE_MASK, tlb_set_page(cs, address & TARGET_PAGE_MASK,
physical & TARGET_PAGE_MASK, prot | PAGE_EXEC, physical & TARGET_PAGE_MASK, prot | PAGE_EXEC,
mmu_idx, TARGET_PAGE_SIZE); mmu_idx, TARGET_PAGE_SIZE);
ret = 0; return true;
} else if (ret < 0) { } else {
raise_mmu_exception(env, address, rw, ret); assert(ret < 0);
ret = 1; if (probe) {
return false;
} }
raise_mmu_exception(env, address, rw, ret);
cpu_loop_exit_restore(cs, retaddr);
}
}
return ret; void tlb_fill(CPUState *cs, target_ulong addr, int size,
MMUAccessType access_type, int mmu_idx, uintptr_t retaddr)
{
tricore_cpu_tlb_fill(cs, addr, size, access_type, mmu_idx, false, retaddr);
} }
static void tricore_cpu_list_entry(gpointer data, gpointer user_data) static void tricore_cpu_list_entry(gpointer data, gpointer user_data)

View File

@ -2793,29 +2793,3 @@ uint32_t helper_psw_read(CPUTriCoreState *env)
{ {
return psw_read(env); return psw_read(env);
} }
static inline void QEMU_NORETURN do_raise_exception_err(CPUTriCoreState *env,
uint32_t exception,
int error_code,
uintptr_t pc)
{
CPUState *cs = CPU(tricore_env_get_cpu(env));
cs->exception_index = exception;
env->error_code = error_code;
/* now we have a real cpu fault */
cpu_loop_exit_restore(cs, pc);
}
void tlb_fill(CPUState *cs, target_ulong addr, int size,
MMUAccessType access_type, int mmu_idx, uintptr_t retaddr)
{
int ret;
ret = cpu_tricore_handle_mmu_fault(cs, addr, access_type, mmu_idx);
if (ret) {
TriCoreCPU *cpu = TRICORE_CPU(cs);
CPUTriCoreState *env = &cpu->env;
do_raise_exception_err(env, cs->exception_index,
env->error_code, retaddr);
}
}