4 * Copyright (c) 2007 CodeSourcery
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include "dyngen-exec.h"
23 #if defined(CONFIG_USER_ONLY)
25 void do_interrupt(CPUState
*env1
)
27 env1
->exception_index
= -1;
30 void do_interrupt_m68k_hardirq(CPUState
*env1
)
36 extern int semihosting_enabled
;
38 #include "softmmu_exec.h"
40 #define MMUSUFFIX _mmu
43 #include "softmmu_template.h"
46 #include "softmmu_template.h"
49 #include "softmmu_template.h"
52 #include "softmmu_template.h"
54 /* Try to fill the TLB and return an exception if error. If retaddr is
55 NULL, it means that the function was called in C code (i.e. not
56 from generated code or from helper.c) */
57 /* XXX: fix it to restore all registers */
58 void tlb_fill (target_ulong addr
, int is_write
, int mmu_idx
, void *retaddr
)
65 /* XXX: hack to restore env in all cases, even if not called from
69 ret
= cpu_m68k_handle_mmu_fault(env
, addr
, is_write
, mmu_idx
);
72 /* now we have a real cpu fault */
73 pc
= (unsigned long)retaddr
;
76 /* the PC is inside the translated code. It means that we have
77 a virtual CPU fault */
78 cpu_restore_state(tb
, env
, pc
);
86 static void do_rte(void)
93 env
->pc
= ldl_kernel(sp
+ 4);
94 sp
|= (fmt
>> 28) & 3;
95 env
->sr
= fmt
& 0xffff;
97 env
->aregs
[7] = sp
+ 8;
100 static void do_interrupt_all(int is_hw
)
111 switch (env
->exception_index
) {
113 /* Return from an exception. */
117 if (semihosting_enabled
118 && (env
->sr
& SR_S
) != 0
119 && (env
->pc
& 3) == 0
120 && lduw_code(env
->pc
- 4) == 0x4e71
121 && ldl_code(env
->pc
) == 0x4e7bf000) {
123 do_m68k_semihosting(env
, env
->dregs
[0]);
127 env
->exception_index
= EXCP_HLT
;
131 if (env
->exception_index
>= EXCP_TRAP0
132 && env
->exception_index
<= EXCP_TRAP15
) {
133 /* Move the PC after the trap instruction. */
138 vector
= env
->exception_index
<< 2;
143 fmt
|= (sp
& 3) << 28;
149 env
->sr
= (env
->sr
& ~SR_I
) | (env
->pending_level
<< SR_I_SHIFT
);
154 /* ??? This could cause MMU faults. */
157 stl_kernel(sp
, retaddr
);
161 /* Jump to vector. */
162 env
->pc
= ldl_kernel(env
->vbr
+ vector
);
165 void do_interrupt(CPUState
*env1
)
175 void do_interrupt_m68k_hardirq(CPUState
*env1
)
186 static void raise_exception(int tt
)
188 env
->exception_index
= tt
;
192 void HELPER(raise_exception
)(uint32_t tt
)
197 void HELPER(divu
)(CPUState
*env
, uint32_t word
)
207 /* ??? This needs to make sure the throwing location is accurate. */
209 raise_exception(EXCP_DIV0
);
213 /* Avoid using a PARAM1 of zero. This breaks dyngen because it uses
214 the address of a symbol, and gcc knows symbols can't have address
216 if (word
&& quot
> 0xffff)
220 else if ((int32_t)quot
< 0)
224 env
->cc_dest
= flags
;
227 void HELPER(divs
)(CPUState
*env
, uint32_t word
)
238 raise_exception(EXCP_DIV0
);
242 if (word
&& quot
!= (int16_t)quot
)
250 env
->cc_dest
= flags
;