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