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