2011-07-13 20:44:15 +08:00
|
|
|
#include "cpu.h"
|
|
|
|
#include "dyngen-exec.h"
|
2008-02-24 22:10:06 +08:00
|
|
|
#include "helper.h"
|
2004-10-01 05:55:55 +08:00
|
|
|
|
2011-07-13 20:44:15 +08:00
|
|
|
#if !defined(CONFIG_USER_ONLY)
|
2007-04-13 23:46:16 +08:00
|
|
|
static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
|
|
|
|
void *retaddr);
|
|
|
|
|
2005-07-05 06:18:23 +08:00
|
|
|
#define MMUSUFFIX _mmu
|
2007-04-13 23:46:16 +08:00
|
|
|
#define ALIGNED_ONLY
|
2005-07-05 06:18:23 +08:00
|
|
|
|
|
|
|
#define SHIFT 0
|
|
|
|
#include "softmmu_template.h"
|
|
|
|
|
|
|
|
#define SHIFT 1
|
|
|
|
#include "softmmu_template.h"
|
|
|
|
|
|
|
|
#define SHIFT 2
|
|
|
|
#include "softmmu_template.h"
|
|
|
|
|
|
|
|
#define SHIFT 3
|
|
|
|
#include "softmmu_template.h"
|
|
|
|
|
2008-05-12 03:24:10 +08:00
|
|
|
/* XXX: make it generic ? */
|
|
|
|
static void cpu_restore_state2(void *retaddr)
|
|
|
|
{
|
|
|
|
TranslationBlock *tb;
|
|
|
|
unsigned long pc;
|
|
|
|
|
|
|
|
if (retaddr) {
|
|
|
|
/* now we have a real cpu fault */
|
|
|
|
pc = (unsigned long)retaddr;
|
|
|
|
tb = tb_find_pc(pc);
|
|
|
|
if (tb) {
|
|
|
|
/* the PC is inside the translated code. It means that we have
|
|
|
|
a virtual CPU fault */
|
2011-04-18 14:39:53 +08:00
|
|
|
cpu_restore_state(tb, env, pc);
|
2008-05-12 03:24:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-13 23:46:16 +08:00
|
|
|
static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
|
|
|
|
void *retaddr)
|
|
|
|
{
|
2007-05-08 02:05:05 +08:00
|
|
|
#ifdef DEBUG_UNALIGNED
|
2008-05-12 03:24:10 +08:00
|
|
|
printf("Unaligned access to 0x" TARGET_FMT_lx " from 0x" TARGET_FMT_lx
|
|
|
|
"\n", addr, env->pc);
|
2007-05-08 02:05:05 +08:00
|
|
|
#endif
|
2008-05-12 03:24:10 +08:00
|
|
|
cpu_restore_state2(retaddr);
|
2011-07-03 16:19:42 +08:00
|
|
|
helper_raise_exception(env, TT_UNALIGNED);
|
2007-04-13 23:46:16 +08:00
|
|
|
}
|
2005-07-05 06:18:23 +08:00
|
|
|
|
|
|
|
/* try to fill the TLB and return an exception if error. If retaddr is
|
|
|
|
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 */
|
2011-07-05 04:57:05 +08:00
|
|
|
void tlb_fill(CPUState *env1, target_ulong addr, int is_write, int mmu_idx,
|
|
|
|
void *retaddr)
|
2005-07-05 06:18:23 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
CPUState *saved_env;
|
|
|
|
|
|
|
|
saved_env = env;
|
2011-07-05 04:57:05 +08:00
|
|
|
env = env1;
|
2005-07-05 06:18:23 +08:00
|
|
|
|
2011-08-02 00:12:17 +08:00
|
|
|
ret = cpu_sparc_handle_mmu_fault(env, addr, is_write, mmu_idx);
|
2005-07-05 06:18:23 +08:00
|
|
|
if (ret) {
|
2008-05-12 03:24:10 +08:00
|
|
|
cpu_restore_state2(retaddr);
|
2011-05-14 20:52:35 +08:00
|
|
|
cpu_loop_exit(env);
|
2005-07-05 06:18:23 +08:00
|
|
|
}
|
|
|
|
env = saved_env;
|
|
|
|
}
|
|
|
|
|
2010-03-01 12:11:28 +08:00
|
|
|
#endif /* !CONFIG_USER_ONLY */
|