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