]> git.ipfire.org Git - thirdparty/qemu.git/blame - target/lm32/op_helper.c
Include qemu/main-loop.h less
[thirdparty/qemu.git] / target / lm32 / op_helper.c
CommitLineData
ea99dde1 1#include "qemu/osdep.h"
3e457172 2#include "cpu.h"
2ef6175a 3#include "exec/helper-proto.h"
1de7afc9 4#include "qemu/host-utils.h"
db725815 5#include "qemu/main-loop.h"
143e8951 6
0d09e41a 7#include "hw/lm32/lm32_pic.h"
0ee10242 8#include "hw/char/lm32_juart.h"
143e8951 9
63c91552 10#include "exec/exec-all.h"
f08b6170 11#include "exec/cpu_ldst.h"
b1669e5e 12
667ff961
MW
13#ifndef CONFIG_USER_ONLY
14#include "sysemu/sysemu.h"
15#endif
16
143e8951 17#if !defined(CONFIG_USER_ONLY)
3dd3a2b9 18void raise_exception(CPULM32State *env, int index)
143e8951 19{
6dd40a90 20 CPUState *cs = env_cpu(env);
27103424
AF
21
22 cs->exception_index = index;
5638d180 23 cpu_loop_exit(cs);
143e8951
MW
24}
25
3dd3a2b9
MW
26void HELPER(raise_exception)(CPULM32State *env, uint32_t index)
27{
28 raise_exception(env, index);
29}
30
66350755 31void HELPER(hlt)(CPULM32State *env)
143e8951 32{
6dd40a90 33 CPUState *cs = env_cpu(env);
259186a7
AF
34
35 cs->halted = 1;
27103424 36 cs->exception_index = EXCP_HLT;
5638d180 37 cpu_loop_exit(cs);
143e8951
MW
38}
39
667ff961
MW
40void HELPER(ill)(CPULM32State *env)
41{
42#ifndef CONFIG_USER_ONLY
6dd40a90 43 CPUState *cs = env_cpu(env);
667ff961
MW
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");
74892d24 47 vm_stop(RUN_STATE_PAUSED);
667ff961
MW
48 cs->halted = 1;
49 raise_exception(env, EXCP_HALTED);
50#endif
51}
52
3dd3a2b9
MW
53void 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
66void 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
81void 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
66350755 104void HELPER(wcsr_im)(CPULM32State *env, uint32_t im)
143e8951 105{
81e9cbd0 106 qemu_mutex_lock_iothread();
143e8951 107 lm32_pic_set_im(env->pic_state, im);
81e9cbd0 108 qemu_mutex_unlock_iothread();
143e8951
MW
109}
110
66350755 111void HELPER(wcsr_ip)(CPULM32State *env, uint32_t im)
143e8951 112{
81e9cbd0 113 qemu_mutex_lock_iothread();
143e8951 114 lm32_pic_set_ip(env->pic_state, im);
81e9cbd0 115 qemu_mutex_unlock_iothread();
143e8951
MW
116}
117
66350755 118void HELPER(wcsr_jtx)(CPULM32State *env, uint32_t jtx)
143e8951
MW
119{
120 lm32_juart_set_jtx(env->juart_state, jtx);
121}
122
66350755 123void HELPER(wcsr_jrx)(CPULM32State *env, uint32_t jrx)
143e8951
MW
124{
125 lm32_juart_set_jrx(env->juart_state, jrx);
126}
127
66350755 128uint32_t HELPER(rcsr_im)(CPULM32State *env)
143e8951
MW
129{
130 return lm32_pic_get_im(env->pic_state);
131}
132
66350755 133uint32_t HELPER(rcsr_ip)(CPULM32State *env)
143e8951
MW
134{
135 return lm32_pic_get_ip(env->pic_state);
136}
137
66350755 138uint32_t HELPER(rcsr_jtx)(CPULM32State *env)
143e8951
MW
139{
140 return lm32_juart_get_jtx(env->juart_state);
141}
142
66350755 143uint32_t HELPER(rcsr_jrx)(CPULM32State *env)
143e8951
MW
144{
145 return lm32_juart_get_jrx(env->juart_state);
146}
143e8951
MW
147#endif
148