1 | #include "qemu/osdep.h" |
2 | #include "cpu.h" |
3 | #include "exec/helper-proto.h" |
4 | #include "qemu/host-utils.h" |
5 | #include "qemu/main-loop.h" |
6 | #include "sysemu/runstate.h" |
7 | |
8 | #include "hw/lm32/lm32_pic.h" |
9 | #include "hw/char/lm32_juart.h" |
10 | |
11 | #include "exec/exec-all.h" |
12 | #include "exec/cpu_ldst.h" |
13 | |
14 | #ifndef CONFIG_USER_ONLY |
15 | #endif |
16 | |
17 | #if !defined(CONFIG_USER_ONLY) |
18 | void raise_exception(CPULM32State *env, int index) |
19 | { |
20 | CPUState *cs = env_cpu(env); |
21 | |
22 | cs->exception_index = index; |
23 | cpu_loop_exit(cs); |
24 | } |
25 | |
26 | void HELPER(raise_exception)(CPULM32State *env, uint32_t index) |
27 | { |
28 | raise_exception(env, index); |
29 | } |
30 | |
31 | void HELPER(hlt)(CPULM32State *env) |
32 | { |
33 | CPUState *cs = env_cpu(env); |
34 | |
35 | cs->halted = 1; |
36 | cs->exception_index = EXCP_HLT; |
37 | cpu_loop_exit(cs); |
38 | } |
39 | |
40 | void HELPER(ill)(CPULM32State *env) |
41 | { |
42 | #ifndef CONFIG_USER_ONLY |
43 | CPUState *cs = env_cpu(env); |
44 | fprintf(stderr, "VM paused due to illegal instruction. " |
45 | "Connect a debugger or switch to the monitor console " |
46 | "to find out more.\n" ); |
47 | vm_stop(RUN_STATE_PAUSED); |
48 | cs->halted = 1; |
49 | raise_exception(env, EXCP_HALTED); |
50 | #endif |
51 | } |
52 | |
53 | void HELPER(wcsr_bp)(CPULM32State *env, uint32_t bp, uint32_t idx) |
54 | { |
55 | uint32_t addr = bp & ~1; |
56 | |
57 | assert(idx < 4); |
58 | |
59 | env->bp[idx] = bp; |
60 | lm32_breakpoint_remove(env, idx); |
61 | if (bp & 1) { |
62 | lm32_breakpoint_insert(env, idx, addr); |
63 | } |
64 | } |
65 | |
66 | void HELPER(wcsr_wp)(CPULM32State *env, uint32_t wp, uint32_t idx) |
67 | { |
68 | lm32_wp_t wp_type; |
69 | |
70 | assert(idx < 4); |
71 | |
72 | env->wp[idx] = wp; |
73 | |
74 | wp_type = lm32_wp_type(env->dc, idx); |
75 | lm32_watchpoint_remove(env, idx); |
76 | if (wp_type != LM32_WP_DISABLED) { |
77 | lm32_watchpoint_insert(env, idx, wp, wp_type); |
78 | } |
79 | } |
80 | |
81 | void HELPER(wcsr_dc)(CPULM32State *env, uint32_t dc) |
82 | { |
83 | uint32_t old_dc; |
84 | int i; |
85 | lm32_wp_t old_type; |
86 | lm32_wp_t new_type; |
87 | |
88 | old_dc = env->dc; |
89 | env->dc = dc; |
90 | |
91 | for (i = 0; i < 4; i++) { |
92 | old_type = lm32_wp_type(old_dc, i); |
93 | new_type = lm32_wp_type(dc, i); |
94 | |
95 | if (old_type != new_type) { |
96 | lm32_watchpoint_remove(env, i); |
97 | if (new_type != LM32_WP_DISABLED) { |
98 | lm32_watchpoint_insert(env, i, env->wp[i], new_type); |
99 | } |
100 | } |
101 | } |
102 | } |
103 | |
104 | void HELPER(wcsr_im)(CPULM32State *env, uint32_t im) |
105 | { |
106 | qemu_mutex_lock_iothread(); |
107 | lm32_pic_set_im(env->pic_state, im); |
108 | qemu_mutex_unlock_iothread(); |
109 | } |
110 | |
111 | void HELPER(wcsr_ip)(CPULM32State *env, uint32_t im) |
112 | { |
113 | qemu_mutex_lock_iothread(); |
114 | lm32_pic_set_ip(env->pic_state, im); |
115 | qemu_mutex_unlock_iothread(); |
116 | } |
117 | |
118 | void HELPER(wcsr_jtx)(CPULM32State *env, uint32_t jtx) |
119 | { |
120 | lm32_juart_set_jtx(env->juart_state, jtx); |
121 | } |
122 | |
123 | void HELPER(wcsr_jrx)(CPULM32State *env, uint32_t jrx) |
124 | { |
125 | lm32_juart_set_jrx(env->juart_state, jrx); |
126 | } |
127 | |
128 | uint32_t HELPER(rcsr_im)(CPULM32State *env) |
129 | { |
130 | return lm32_pic_get_im(env->pic_state); |
131 | } |
132 | |
133 | uint32_t HELPER(rcsr_ip)(CPULM32State *env) |
134 | { |
135 | return lm32_pic_get_ip(env->pic_state); |
136 | } |
137 | |
138 | uint32_t HELPER(rcsr_jtx)(CPULM32State *env) |
139 | { |
140 | return lm32_juart_get_jtx(env->juart_state); |
141 | } |
142 | |
143 | uint32_t HELPER(rcsr_jrx)(CPULM32State *env) |
144 | { |
145 | return lm32_juart_get_jrx(env->juart_state); |
146 | } |
147 | #endif |
148 | |
149 | |