mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-22 22:51:01 +00:00
target-arm: Move get/set_r13_banked() to op_helper.c
Move get/set_r13_banked() from helper.c to op_helper.c. This will let us add exception-raising code to them, and also puts them in the same file as get/set_user_reg(), which makes some conceptual sense. (The original reason for the helper.c/op_helper.c split was that only op_helper.c had access to the CPU env pointer; this distinction has not been true for a long time, though, and so the split is now rather arbitrary.) Backports commit 72309cee482868d6c4711931c3f7e02ab9dec229 from qemu target-arm: Move bank_number() into internals.h Move bank_number()'s implementation into internals.h, so it's available in the user-mode-only compile as well. Backports commit c766568d3604082c6fd45cbabe42c48e4861a13f from qemu
This commit is contained in:
parent
a6aac0dbb4
commit
3d4f8b2d8f
|
@ -4688,21 +4688,6 @@ void switch_mode(CPUARMState *env, int mode)
|
|||
}
|
||||
}
|
||||
|
||||
void HELPER(set_r13_banked)(CPUARMState *env, uint32_t mode, uint32_t val)
|
||||
{
|
||||
ARMCPU *cpu = arm_env_get_cpu(env);
|
||||
|
||||
cpu_abort(CPU(cpu), "banked r13 write\n");
|
||||
}
|
||||
|
||||
uint32_t HELPER(get_r13_banked)(CPUARMState *env, uint32_t mode)
|
||||
{
|
||||
ARMCPU *cpu = arm_env_get_cpu(env);
|
||||
|
||||
cpu_abort(CPU(cpu), "banked r13 read\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
|
||||
uint32_t cur_el, bool secure)
|
||||
{
|
||||
|
@ -4716,32 +4701,6 @@ void aarch64_sync_64_to_32(CPUARMState *env)
|
|||
|
||||
#else
|
||||
|
||||
/* Map CPU modes onto saved register banks. */
|
||||
int bank_number(int mode)
|
||||
{
|
||||
switch (mode) {
|
||||
default:
|
||||
case ARM_CPU_MODE_USR:
|
||||
case ARM_CPU_MODE_SYS:
|
||||
return BANK_USRSYS;
|
||||
case ARM_CPU_MODE_SVC:
|
||||
return BANK_SVC;
|
||||
case ARM_CPU_MODE_ABT:
|
||||
return BANK_ABT;
|
||||
case ARM_CPU_MODE_UND:
|
||||
return BANK_UND;
|
||||
case ARM_CPU_MODE_IRQ:
|
||||
return BANK_IRQ;
|
||||
case ARM_CPU_MODE_FIQ:
|
||||
return BANK_FIQ;
|
||||
case ARM_CPU_MODE_HYP:
|
||||
return BANK_HYP;
|
||||
case ARM_CPU_MODE_MON:
|
||||
return BANK_MON;
|
||||
}
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
void switch_mode(CPUARMState *env, int mode)
|
||||
{
|
||||
int old_mode;
|
||||
|
@ -7096,24 +7055,6 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr,
|
|||
return phys_addr;
|
||||
}
|
||||
|
||||
void HELPER(set_r13_banked)(CPUARMState *env, uint32_t mode, uint32_t val)
|
||||
{
|
||||
if ((env->uncached_cpsr & CPSR_M) == mode) {
|
||||
env->regs[13] = val;
|
||||
} else {
|
||||
env->banked_r13[bank_number(mode)] = val;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t HELPER(get_r13_banked)(CPUARMState *env, uint32_t mode)
|
||||
{
|
||||
if ((env->uncached_cpsr & CPSR_M) == mode) {
|
||||
return env->regs[13];
|
||||
} else {
|
||||
return env->banked_r13[bank_number(mode)];
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
|
||||
{
|
||||
ARMCPU *cpu = arm_env_get_cpu(env);
|
||||
|
|
|
@ -111,7 +111,32 @@ static inline unsigned int aarch64_banked_spsr_index(unsigned int el)
|
|||
return map[el];
|
||||
}
|
||||
|
||||
int bank_number(int mode);
|
||||
/* Map CPU modes onto saved register banks. */
|
||||
static inline int bank_number(int mode)
|
||||
{
|
||||
switch (mode) {
|
||||
default:
|
||||
case ARM_CPU_MODE_USR:
|
||||
case ARM_CPU_MODE_SYS:
|
||||
return BANK_USRSYS;
|
||||
case ARM_CPU_MODE_SVC:
|
||||
return BANK_SVC;
|
||||
case ARM_CPU_MODE_ABT:
|
||||
return BANK_ABT;
|
||||
case ARM_CPU_MODE_UND:
|
||||
return BANK_UND;
|
||||
case ARM_CPU_MODE_IRQ:
|
||||
return BANK_IRQ;
|
||||
case ARM_CPU_MODE_FIQ:
|
||||
return BANK_FIQ;
|
||||
case ARM_CPU_MODE_HYP:
|
||||
return BANK_HYP;
|
||||
case ARM_CPU_MODE_MON:
|
||||
return BANK_MON;
|
||||
}
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
void switch_mode(CPUARMState *, int);
|
||||
void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu);
|
||||
void arm_translate_init(struct uc_struct *uc);
|
||||
|
|
|
@ -457,6 +457,43 @@ void HELPER(set_user_reg)(CPUARMState *env, uint32_t regno, uint32_t val)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
void HELPER(set_r13_banked)(CPUARMState *env, uint32_t mode, uint32_t val)
|
||||
{
|
||||
ARMCPU *cpu = arm_env_get_cpu(env);
|
||||
|
||||
cpu_abort(CPU(cpu), "banked r13 write\n");
|
||||
}
|
||||
|
||||
uint32_t HELPER(get_r13_banked)(CPUARMState *env, uint32_t mode)
|
||||
{
|
||||
ARMCPU *cpu = arm_env_get_cpu(env);
|
||||
|
||||
cpu_abort(CPU(cpu), "banked r13 read\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void HELPER(set_r13_banked)(CPUARMState *env, uint32_t mode, uint32_t val)
|
||||
{
|
||||
if ((env->uncached_cpsr & CPSR_M) == mode) {
|
||||
env->regs[13] = val;
|
||||
} else {
|
||||
env->banked_r13[bank_number(mode)] = val;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t HELPER(get_r13_banked)(CPUARMState *env, uint32_t mode)
|
||||
{
|
||||
if ((env->uncached_cpsr & CPSR_M) == mode) {
|
||||
return env->regs[13];
|
||||
} else {
|
||||
return env->banked_r13[bank_number(mode)];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome,
|
||||
uint32_t isread)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue