--- qemu/target-microblaze/op_helper.c 2018/04/24 18:58:15 1.1.1.5 +++ qemu/target-microblaze/op_helper.c 2018/04/24 19:36:31 1.1.1.7 @@ -2,6 +2,7 @@ * Microblaze helper routines. * * Copyright (c) 2009 Edgar E. Iglesias . + * Copyright (c) 2009-2012 PetaLogix Qld Pty Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,13 +19,16 @@ */ #include -#include "exec.h" +#include "cpu.h" +#include "dyngen-exec.h" #include "helper.h" #include "host-utils.h" #define D(x) #if !defined(CONFIG_USER_ONLY) +#include "softmmu_exec.h" + #define MMUSUFFIX _mmu #define SHIFT 0 #include "softmmu_template.h" @@ -39,28 +43,25 @@ NULL, it means that the function was called in C code (i.e. not from generated code or from helper.c) */ /* XXX: fix it to restore all registers */ -void tlb_fill (target_ulong addr, int is_write, int mmu_idx, void *retaddr) +void tlb_fill(CPUMBState *env1, target_ulong addr, int is_write, int mmu_idx, + uintptr_t retaddr) { TranslationBlock *tb; - CPUState *saved_env; - unsigned long pc; + CPUMBState *saved_env; int ret; - /* XXX: hack to restore env in all cases, even if not called from - generated code */ saved_env = env; - env = cpu_single_env; + env = env1; - ret = cpu_mb_handle_mmu_fault(env, addr, is_write, mmu_idx, 1); + ret = cpu_mb_handle_mmu_fault(env, addr, is_write, mmu_idx); if (unlikely(ret)) { if (retaddr) { /* now we have a real cpu fault */ - pc = (unsigned long)retaddr; - tb = tb_find_pc(pc); + tb = tb_find_pc(retaddr); if (tb) { /* the PC is inside the translated code. It means that we have a virtual CPU fault */ - cpu_restore_state(tb, env, pc); + cpu_restore_state(tb, env, retaddr); } } cpu_loop_exit(env); @@ -163,6 +164,11 @@ uint32_t helper_cmpu(uint32_t a, uint32_ return t; } +uint32_t helper_clz(uint32_t t0) +{ + return clz32(t0); +} + uint32_t helper_carry(uint32_t a, uint32_t b, uint32_t cf) { uint32_t ncf; @@ -476,6 +482,17 @@ void helper_memalign(uint32_t addr, uint } } +void helper_stackprot(uint32_t addr) +{ + if (addr < env->slr || addr > env->shr) { + qemu_log("Stack protector violation at %x %x %x\n", + addr, env->slr, env->shr); + env->sregs[SR_EAR] = addr; + env->sregs[SR_ESR] = ESR_EC_STACKPROT; + helper_raise_exception(EXCP_HW_EXCP); + } +} + #if !defined(CONFIG_USER_ONLY) /* Writes/reads to the MMU's special regs end up here. */ uint32_t helper_mmu_read(uint32_t rn) @@ -488,10 +505,10 @@ void helper_mmu_write(uint32_t rn, uint3 mmu_write(env, rn, v); } -void cpu_unassigned_access(CPUState *env1, target_phys_addr_t addr, +void cpu_unassigned_access(CPUMBState *env1, target_phys_addr_t addr, int is_write, int is_exec, int is_asi, int size) { - CPUState *saved_env; + CPUMBState *saved_env; saved_env = env; env = env1;