]>
Commit | Line | Data |
---|---|---|
143e8951 | 1 | #include <assert.h> |
3e457172 BS |
2 | #include "cpu.h" |
3 | #include "dyngen-exec.h" | |
143e8951 MW |
4 | #include "helper.h" |
5 | #include "host-utils.h" | |
6 | ||
7 | #include "hw/lm32_pic.h" | |
8 | #include "hw/lm32_juart.h" | |
9 | ||
10 | #if !defined(CONFIG_USER_ONLY) | |
11 | #define MMUSUFFIX _mmu | |
12 | #define SHIFT 0 | |
13 | #include "softmmu_template.h" | |
14 | #define SHIFT 1 | |
15 | #include "softmmu_template.h" | |
16 | #define SHIFT 2 | |
17 | #include "softmmu_template.h" | |
18 | #define SHIFT 3 | |
19 | #include "softmmu_template.h" | |
20 | ||
21 | void helper_raise_exception(uint32_t index) | |
22 | { | |
23 | env->exception_index = index; | |
1162c041 | 24 | cpu_loop_exit(env); |
143e8951 MW |
25 | } |
26 | ||
27 | void helper_hlt(void) | |
28 | { | |
29 | env->halted = 1; | |
30 | env->exception_index = EXCP_HLT; | |
1162c041 | 31 | cpu_loop_exit(env); |
143e8951 MW |
32 | } |
33 | ||
34 | void helper_wcsr_im(uint32_t im) | |
35 | { | |
36 | lm32_pic_set_im(env->pic_state, im); | |
37 | } | |
38 | ||
39 | void helper_wcsr_ip(uint32_t im) | |
40 | { | |
41 | lm32_pic_set_ip(env->pic_state, im); | |
42 | } | |
43 | ||
44 | void helper_wcsr_jtx(uint32_t jtx) | |
45 | { | |
46 | lm32_juart_set_jtx(env->juart_state, jtx); | |
47 | } | |
48 | ||
49 | void helper_wcsr_jrx(uint32_t jrx) | |
50 | { | |
51 | lm32_juart_set_jrx(env->juart_state, jrx); | |
52 | } | |
53 | ||
54 | uint32_t helper_rcsr_im(void) | |
55 | { | |
56 | return lm32_pic_get_im(env->pic_state); | |
57 | } | |
58 | ||
59 | uint32_t helper_rcsr_ip(void) | |
60 | { | |
61 | return lm32_pic_get_ip(env->pic_state); | |
62 | } | |
63 | ||
64 | uint32_t helper_rcsr_jtx(void) | |
65 | { | |
66 | return lm32_juart_get_jtx(env->juart_state); | |
67 | } | |
68 | ||
69 | uint32_t helper_rcsr_jrx(void) | |
70 | { | |
71 | return lm32_juart_get_jrx(env->juart_state); | |
72 | } | |
73 | ||
74 | /* Try to fill the TLB and return an exception if error. If retaddr is | |
75 | NULL, it means that the function was called in C code (i.e. not | |
76 | from generated code or from helper.c) */ | |
77 | /* XXX: fix it to restore all registers */ | |
6393c08d | 78 | void tlb_fill(CPULM32State *env1, target_ulong addr, int is_write, int mmu_idx, |
20503968 | 79 | uintptr_t retaddr) |
143e8951 MW |
80 | { |
81 | TranslationBlock *tb; | |
6393c08d | 82 | CPULM32State *saved_env; |
143e8951 MW |
83 | int ret; |
84 | ||
143e8951 | 85 | saved_env = env; |
bccd9ec5 | 86 | env = env1; |
143e8951 | 87 | |
97b348e7 | 88 | ret = cpu_lm32_handle_mmu_fault(env, addr, is_write, mmu_idx); |
143e8951 MW |
89 | if (unlikely(ret)) { |
90 | if (retaddr) { | |
91 | /* now we have a real cpu fault */ | |
20503968 | 92 | tb = tb_find_pc(retaddr); |
143e8951 MW |
93 | if (tb) { |
94 | /* the PC is inside the translated code. It means that we have | |
95 | a virtual CPU fault */ | |
20503968 | 96 | cpu_restore_state(tb, env, retaddr); |
143e8951 MW |
97 | } |
98 | } | |
1162c041 | 99 | cpu_loop_exit(env); |
143e8951 MW |
100 | } |
101 | env = saved_env; | |
102 | } | |
103 | #endif | |
104 |