Upload Tizen 2.0.0a sources.
[sdk/emulator/qemu.git] / target-sparc / op_helper.c
1 #include "cpu.h"
2 #include "dyngen-exec.h"
3 #include "helper.h"
4
5 #if !defined(CONFIG_USER_ONLY)
6 static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
7                                 void *retaddr);
8
9 #define MMUSUFFIX _mmu
10 #define ALIGNED_ONLY
11
12 #define SHIFT 0
13 #include "softmmu_template.h"
14
15 #define SHIFT 1
16 #include "softmmu_template.h"
17
18 #define SHIFT 2
19 #include "softmmu_template.h"
20
21 #define SHIFT 3
22 #include "softmmu_template.h"
23
24 /* XXX: make it generic ? */
25 static void cpu_restore_state2(void *retaddr)
26 {
27     TranslationBlock *tb;
28     unsigned long pc;
29
30     if (retaddr) {
31         /* now we have a real cpu fault */
32         pc = (unsigned long)retaddr;
33         tb = tb_find_pc(pc);
34         if (tb) {
35             /* the PC is inside the translated code. It means that we have
36                a virtual CPU fault */
37             cpu_restore_state(tb, env, pc);
38         }
39     }
40 }
41
42 static void do_unaligned_access(target_ulong addr, int is_write, int is_user,
43                                 void *retaddr)
44 {
45 #ifdef DEBUG_UNALIGNED
46     printf("Unaligned access to 0x" TARGET_FMT_lx " from 0x" TARGET_FMT_lx
47            "\n", addr, env->pc);
48 #endif
49     cpu_restore_state2(retaddr);
50     helper_raise_exception(env, TT_UNALIGNED);
51 }
52
53 /* try to fill the TLB and return an exception if error. If retaddr is
54    NULL, it means that the function was called in C code (i.e. not
55    from generated code or from helper.c) */
56 /* XXX: fix it to restore all registers */
57 void tlb_fill(CPUState *env1, target_ulong addr, int is_write, int mmu_idx,
58               void *retaddr)
59 {
60     int ret;
61     CPUState *saved_env;
62
63     saved_env = env;
64     env = env1;
65
66     ret = cpu_sparc_handle_mmu_fault(env, addr, is_write, mmu_idx);
67     if (ret) {
68         cpu_restore_state2(retaddr);
69         cpu_loop_exit(env);
70     }
71     env = saved_env;
72 }
73
74 #endif /* !CONFIG_USER_ONLY */