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(CPUM68KState
*env1
)
27 env1
->exception_index
= -1;
30 void do_interrupt_m68k_hardirq(CPUM68KState
*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(CPUM68KState
*env1
, target_ulong addr
, int is_write
, int mmu_idx
,
62 CPUM68KState
*saved_env
;
68 ret
= cpu_m68k_handle_mmu_fault(env
, addr
, is_write
, mmu_idx
);
71 /* now we have a real cpu fault */
72 pc
= (unsigned long)retaddr
;
75 /* the PC is inside the translated code. It means that we have
76 a virtual CPU fault */
77 cpu_restore_state(tb
, env
, pc
);
85 static void do_rte(void)
92 env
->pc
= ldl_kernel(sp
+ 4);
93 sp
|= (fmt
>> 28) & 3;
94 env
->sr
= fmt
& 0xffff;
96 env
->aregs
[7] = sp
+ 8;
99 static void do_interrupt_all(int is_hw
)
110 switch (env
->exception_index
) {
112 /* Return from an exception. */
116 if (semihosting_enabled
117 && (env
->sr
& SR_S
) != 0
118 && (env
->pc
& 3) == 0
119 && lduw_code(env
->pc
- 4) == 0x4e71
120 && ldl_code(env
->pc
) == 0x4e7bf000) {
122 do_m68k_semihosting(env
, env
->dregs
[0]);
126 env
->exception_index
= EXCP_HLT
;
130 if (env
->exception_index
>= EXCP_TRAP0
131 && env
->exception_index
<= EXCP_TRAP15
) {
132 /* Move the PC after the trap instruction. */
137 vector
= env
->exception_index
<< 2;
142 fmt
|= (sp
& 3) << 28;
148 env
->sr
= (env
->sr
& ~SR_I
) | (env
->pending_level
<< SR_I_SHIFT
);
153 /* ??? This could cause MMU faults. */
156 stl_kernel(sp
, retaddr
);
160 /* Jump to vector. */
161 env
->pc
= ldl_kernel(env
->vbr
+ vector
);
164 void do_interrupt(CPUM68KState
*env1
)
166 CPUM68KState
*saved_env
;
174 void do_interrupt_m68k_hardirq(CPUM68KState
*env1
)
176 CPUM68KState
*saved_env
;
185 static void raise_exception(int tt
)
187 env
->exception_index
= tt
;
191 void HELPER(raise_exception
)(uint32_t tt
)
196 void HELPER(divu
)(CPUM68KState
*env
, uint32_t word
)
206 /* ??? This needs to make sure the throwing location is accurate. */
208 raise_exception(EXCP_DIV0
);
212 /* Avoid using a PARAM1 of zero. This breaks dyngen because it uses
213 the address of a symbol, and gcc knows symbols can't have address
215 if (word
&& quot
> 0xffff)
219 else if ((int32_t)quot
< 0)
223 env
->cc_dest
= flags
;
226 void HELPER(divs
)(CPUM68KState
*env
, uint32_t word
)
237 raise_exception(EXCP_DIV0
);
241 if (word
&& quot
!= (int16_t)quot
)
249 env
->cc_dest
= flags
;