block: Add BlockJobTxn support to backup_run
[qemu/rayw.git] / target-lm32 / op_helper.c
blob61209c19b23910c1d825b47f8e2951c707af26ff
1 #include <assert.h>
2 #include "cpu.h"
3 #include "exec/helper-proto.h"
4 #include "qemu/host-utils.h"
6 #include "hw/lm32/lm32_pic.h"
7 #include "hw/char/lm32_juart.h"
9 #include "exec/cpu_ldst.h"
11 #ifndef CONFIG_USER_ONLY
12 #include "sysemu/sysemu.h"
13 #endif
15 #if !defined(CONFIG_USER_ONLY)
16 void raise_exception(CPULM32State *env, int index)
18 CPUState *cs = CPU(lm32_env_get_cpu(env));
20 cs->exception_index = index;
21 cpu_loop_exit(cs);
24 void HELPER(raise_exception)(CPULM32State *env, uint32_t index)
26 raise_exception(env, index);
29 void HELPER(hlt)(CPULM32State *env)
31 CPUState *cs = CPU(lm32_env_get_cpu(env));
33 cs->halted = 1;
34 cs->exception_index = EXCP_HLT;
35 cpu_loop_exit(cs);
38 void HELPER(ill)(CPULM32State *env)
40 #ifndef CONFIG_USER_ONLY
41 CPUState *cs = CPU(lm32_env_get_cpu(env));
42 fprintf(stderr, "VM paused due to illegal instruction. "
43 "Connect a debugger or switch to the monitor console "
44 "to find out more.\n");
45 vm_stop(RUN_STATE_PAUSED);
46 cs->halted = 1;
47 raise_exception(env, EXCP_HALTED);
48 #endif
51 void HELPER(wcsr_bp)(CPULM32State *env, uint32_t bp, uint32_t idx)
53 uint32_t addr = bp & ~1;
55 assert(idx < 4);
57 env->bp[idx] = bp;
58 lm32_breakpoint_remove(env, idx);
59 if (bp & 1) {
60 lm32_breakpoint_insert(env, idx, addr);
64 void HELPER(wcsr_wp)(CPULM32State *env, uint32_t wp, uint32_t idx)
66 lm32_wp_t wp_type;
68 assert(idx < 4);
70 env->wp[idx] = wp;
72 wp_type = lm32_wp_type(env->dc, idx);
73 lm32_watchpoint_remove(env, idx);
74 if (wp_type != LM32_WP_DISABLED) {
75 lm32_watchpoint_insert(env, idx, wp, wp_type);
79 void HELPER(wcsr_dc)(CPULM32State *env, uint32_t dc)
81 uint32_t old_dc;
82 int i;
83 lm32_wp_t old_type;
84 lm32_wp_t new_type;
86 old_dc = env->dc;
87 env->dc = dc;
89 for (i = 0; i < 4; i++) {
90 old_type = lm32_wp_type(old_dc, i);
91 new_type = lm32_wp_type(dc, i);
93 if (old_type != new_type) {
94 lm32_watchpoint_remove(env, i);
95 if (new_type != LM32_WP_DISABLED) {
96 lm32_watchpoint_insert(env, i, env->wp[i], new_type);
102 void HELPER(wcsr_im)(CPULM32State *env, uint32_t im)
104 lm32_pic_set_im(env->pic_state, im);
107 void HELPER(wcsr_ip)(CPULM32State *env, uint32_t im)
109 lm32_pic_set_ip(env->pic_state, im);
112 void HELPER(wcsr_jtx)(CPULM32State *env, uint32_t jtx)
114 lm32_juart_set_jtx(env->juart_state, jtx);
117 void HELPER(wcsr_jrx)(CPULM32State *env, uint32_t jrx)
119 lm32_juart_set_jrx(env->juart_state, jrx);
122 uint32_t HELPER(rcsr_im)(CPULM32State *env)
124 return lm32_pic_get_im(env->pic_state);
127 uint32_t HELPER(rcsr_ip)(CPULM32State *env)
129 return lm32_pic_get_ip(env->pic_state);
132 uint32_t HELPER(rcsr_jtx)(CPULM32State *env)
134 return lm32_juart_get_jtx(env->juart_state);
137 uint32_t HELPER(rcsr_jrx)(CPULM32State *env)
139 return lm32_juart_get_jrx(env->juart_state);
142 /* Try to fill the TLB and return an exception if error. If retaddr is
143 * NULL, it means that the function was called in C code (i.e. not
144 * from generated code or from helper.c)
146 void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
147 uintptr_t retaddr)
149 int ret;
151 ret = lm32_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
152 if (unlikely(ret)) {
153 if (retaddr) {
154 /* now we have a real cpu fault */
155 cpu_restore_state(cs, retaddr);
157 cpu_loop_exit(cs);
160 #endif