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"
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
;
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
));
34 cs
->exception_index
= EXCP_HLT
;
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
);
47 raise_exception(env
, EXCP_HALTED
);
51 void HELPER(wcsr_bp
)(CPULM32State
*env
, uint32_t bp
, uint32_t idx
)
53 uint32_t addr
= bp
& ~1;
58 lm32_breakpoint_remove(env
, idx
);
60 lm32_breakpoint_insert(env
, idx
, addr
);
64 void HELPER(wcsr_wp
)(CPULM32State
*env
, uint32_t wp
, uint32_t idx
)
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
)
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
,
151 ret
= lm32_cpu_handle_mmu_fault(cs
, addr
, is_write
, mmu_idx
);
154 /* now we have a real cpu fault */
155 cpu_restore_state(cs
, retaddr
);