]> Git Repo - qemu.git/blame - target-lm32/op_helper.c
exec: extract exec/tb-context.h
[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"
143e8951 5
0d09e41a 6#include "hw/lm32/lm32_pic.h"
0ee10242 7#include "hw/char/lm32_juart.h"
143e8951 8
f08b6170 9#include "exec/cpu_ldst.h"
b1669e5e 10
667ff961
MW
11#ifndef CONFIG_USER_ONLY
12#include "sysemu/sysemu.h"
13#endif
14
143e8951 15#if !defined(CONFIG_USER_ONLY)
3dd3a2b9 16void raise_exception(CPULM32State *env, int index)
143e8951 17{
27103424
AF
18 CPUState *cs = CPU(lm32_env_get_cpu(env));
19
20 cs->exception_index = index;
5638d180 21 cpu_loop_exit(cs);
143e8951
MW
22}
23
3dd3a2b9
MW
24void HELPER(raise_exception)(CPULM32State *env, uint32_t index)
25{
26 raise_exception(env, index);
27}
28
66350755 29void HELPER(hlt)(CPULM32State *env)
143e8951 30{
259186a7
AF
31 CPUState *cs = CPU(lm32_env_get_cpu(env));
32
33 cs->halted = 1;
27103424 34 cs->exception_index = EXCP_HLT;
5638d180 35 cpu_loop_exit(cs);
143e8951
MW
36}
37
667ff961
MW
38void HELPER(ill)(CPULM32State *env)
39{
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");
74892d24 45 vm_stop(RUN_STATE_PAUSED);
667ff961
MW
46 cs->halted = 1;
47 raise_exception(env, EXCP_HALTED);
48#endif
49}
50
3dd3a2b9
MW
51void HELPER(wcsr_bp)(CPULM32State *env, uint32_t bp, uint32_t idx)
52{
53 uint32_t addr = bp & ~1;
54
55 assert(idx < 4);
56
57 env->bp[idx] = bp;
58 lm32_breakpoint_remove(env, idx);
59 if (bp & 1) {
60 lm32_breakpoint_insert(env, idx, addr);
61 }
62}
63
64void HELPER(wcsr_wp)(CPULM32State *env, uint32_t wp, uint32_t idx)
65{
66 lm32_wp_t wp_type;
67
68 assert(idx < 4);
69
70 env->wp[idx] = wp;
71
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);
76 }
77}
78
79void HELPER(wcsr_dc)(CPULM32State *env, uint32_t dc)
80{
81 uint32_t old_dc;
82 int i;
83 lm32_wp_t old_type;
84 lm32_wp_t new_type;
85
86 old_dc = env->dc;
87 env->dc = dc;
88
89 for (i = 0; i < 4; i++) {
90 old_type = lm32_wp_type(old_dc, i);
91 new_type = lm32_wp_type(dc, i);
92
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);
97 }
98 }
99 }
100}
101
66350755 102void HELPER(wcsr_im)(CPULM32State *env, uint32_t im)
143e8951
MW
103{
104 lm32_pic_set_im(env->pic_state, im);
105}
106
66350755 107void HELPER(wcsr_ip)(CPULM32State *env, uint32_t im)
143e8951
MW
108{
109 lm32_pic_set_ip(env->pic_state, im);
110}
111
66350755 112void HELPER(wcsr_jtx)(CPULM32State *env, uint32_t jtx)
143e8951
MW
113{
114 lm32_juart_set_jtx(env->juart_state, jtx);
115}
116
66350755 117void HELPER(wcsr_jrx)(CPULM32State *env, uint32_t jrx)
143e8951
MW
118{
119 lm32_juart_set_jrx(env->juart_state, jrx);
120}
121
66350755 122uint32_t HELPER(rcsr_im)(CPULM32State *env)
143e8951
MW
123{
124 return lm32_pic_get_im(env->pic_state);
125}
126
66350755 127uint32_t HELPER(rcsr_ip)(CPULM32State *env)
143e8951
MW
128{
129 return lm32_pic_get_ip(env->pic_state);
130}
131
66350755 132uint32_t HELPER(rcsr_jtx)(CPULM32State *env)
143e8951
MW
133{
134 return lm32_juart_get_jtx(env->juart_state);
135}
136
66350755 137uint32_t HELPER(rcsr_jrx)(CPULM32State *env)
143e8951
MW
138{
139 return lm32_juart_get_jrx(env->juart_state);
140}
141
142/* Try to fill the TLB and return an exception if error. If retaddr is
d5a11fef
AF
143 * NULL, it means that the function was called in C code (i.e. not
144 * from generated code or from helper.c)
145 */
146void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
20503968 147 uintptr_t retaddr)
143e8951 148{
143e8951
MW
149 int ret;
150
d5a11fef 151 ret = lm32_cpu_handle_mmu_fault(cs, addr, is_write, mmu_idx);
143e8951
MW
152 if (unlikely(ret)) {
153 if (retaddr) {
154 /* now we have a real cpu fault */
3f38f309 155 cpu_restore_state(cs, retaddr);
143e8951 156 }
5638d180 157 cpu_loop_exit(cs);
143e8951 158 }
143e8951
MW
159}
160#endif
161
This page took 0.421852 seconds and 4 git commands to generate.