1 #include "qemu/osdep.h"
3 #include "exec/helper-proto.h"
4 #include "qemu/host-utils.h"
5 #include "qemu/main-loop.h"
6 #include "sysemu/runstate.h"
8 #include "hw/lm32/lm32_pic.h"
9 #include "hw/char/lm32_juart.h"
11 #include "exec/exec-all.h"
12 #include "exec/cpu_ldst.h"
14 #ifndef CONFIG_USER_ONLY
17 #if !defined(CONFIG_USER_ONLY)
18 void raise_exception(CPULM32State
*env
, int index
)
20 CPUState
*cs
= env_cpu(env
);
22 cs
->exception_index
= index
;
26 void HELPER(raise_exception
)(CPULM32State
*env
, uint32_t index
)
28 raise_exception(env
, index
);
31 void HELPER(hlt
)(CPULM32State
*env
)
33 CPUState
*cs
= env_cpu(env
);
36 cs
->exception_index
= EXCP_HLT
;
40 void HELPER(ill
)(CPULM32State
*env
)
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
);
49 raise_exception(env
, EXCP_HALTED
);
53 void HELPER(wcsr_bp
)(CPULM32State
*env
, uint32_t bp
, uint32_t idx
)
55 uint32_t addr
= bp
& ~1;
60 lm32_breakpoint_remove(env
, idx
);
62 lm32_breakpoint_insert(env
, idx
, addr
);
66 void HELPER(wcsr_wp
)(CPULM32State
*env
, uint32_t wp
, uint32_t idx
)
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
);
81 void HELPER(wcsr_dc
)(CPULM32State
*env
, uint32_t dc
)
91 for (i
= 0; i
< 4; i
++) {
92 old_type
= lm32_wp_type(old_dc
, i
);
93 new_type
= lm32_wp_type(dc
, i
);
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
);
104 void HELPER(wcsr_im
)(CPULM32State
*env
, uint32_t im
)
106 qemu_mutex_lock_iothread();
107 lm32_pic_set_im(env
->pic_state
, im
);
108 qemu_mutex_unlock_iothread();
111 void HELPER(wcsr_ip
)(CPULM32State
*env
, uint32_t im
)
113 qemu_mutex_lock_iothread();
114 lm32_pic_set_ip(env
->pic_state
, im
);
115 qemu_mutex_unlock_iothread();
118 void HELPER(wcsr_jtx
)(CPULM32State
*env
, uint32_t jtx
)
120 lm32_juart_set_jtx(env
->juart_state
, jtx
);
123 void HELPER(wcsr_jrx
)(CPULM32State
*env
, uint32_t jrx
)
125 lm32_juart_set_jrx(env
->juart_state
, jrx
);
128 uint32_t HELPER(rcsr_im
)(CPULM32State
*env
)
130 return lm32_pic_get_im(env
->pic_state
);
133 uint32_t HELPER(rcsr_ip
)(CPULM32State
*env
)
135 return lm32_pic_get_ip(env
->pic_state
);
138 uint32_t HELPER(rcsr_jtx
)(CPULM32State
*env
)
140 return lm32_juart_get_jtx(env
->juart_state
);
143 uint32_t HELPER(rcsr_jrx
)(CPULM32State
*env
)
145 return lm32_juart_get_jrx(env
->juart_state
);