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, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #if defined(CONFIG_USER_ONLY)
25 void do_interrupt(int is_hw
)
27 env
->exception_index
= -1;
32 extern int semihosting_enabled
;
34 #define MMUSUFFIX _mmu
37 #include "softmmu_template.h"
40 #include "softmmu_template.h"
43 #include "softmmu_template.h"
46 #include "softmmu_template.h"
48 /* Try to fill the TLB and return an exception if error. If retaddr is
49 NULL, it means that the function was called in C code (i.e. not
50 from generated code or from helper.c) */
51 /* XXX: fix it to restore all registers */
52 void tlb_fill (target_ulong addr
, int is_write
, int mmu_idx
, void *retaddr
)
59 /* XXX: hack to restore env in all cases, even if not called from
63 ret
= cpu_m68k_handle_mmu_fault(env
, addr
, is_write
, mmu_idx
, 1);
66 /* now we have a real cpu fault */
67 pc
= (unsigned long)retaddr
;
70 /* the PC is inside the translated code. It means that we have
71 a virtual CPU fault */
72 cpu_restore_state(tb
, env
, pc
, NULL
);
80 static void do_rte(void)
87 env
->pc
= ldl_kernel(sp
+ 4);
88 sp
|= (fmt
>> 28) & 3;
89 env
->sr
= fmt
& 0xffff;
91 env
->aregs
[7] = sp
+ 8;
94 void do_interrupt(int is_hw
)
105 switch (env
->exception_index
) {
107 /* Return from an exception. */
111 if (semihosting_enabled
112 && (env
->sr
& SR_S
) != 0
113 && (env
->pc
& 3) == 0
114 && lduw_code(env
->pc
- 4) == 0x4e71
115 && ldl_code(env
->pc
) == 0x4e7bf000) {
117 do_m68k_semihosting(env
, env
->dregs
[0]);
121 env
->exception_index
= EXCP_HLT
;
125 if (env
->exception_index
>= EXCP_TRAP0
126 && env
->exception_index
<= EXCP_TRAP15
) {
127 /* Move the PC after the trap instruction. */
132 vector
= env
->exception_index
<< 2;
137 fmt
|= (sp
& 3) << 28;
143 env
->sr
= (env
->sr
& ~SR_I
) | (env
->pending_level
<< SR_I_SHIFT
);
148 /* ??? This could cause MMU faults. */
151 stl_kernel(sp
, retaddr
);
155 /* Jump to vector. */
156 env
->pc
= ldl_kernel(env
->vbr
+ vector
);
161 static void raise_exception(int tt
)
163 env
->exception_index
= tt
;
167 void HELPER(raise_exception
)(uint32_t tt
)
172 void HELPER(divu
)(CPUState
*env
, uint32_t word
)
182 /* ??? This needs to make sure the throwing location is accurate. */
184 raise_exception(EXCP_DIV0
);
188 /* Avoid using a PARAM1 of zero. This breaks dyngen because it uses
189 the address of a symbol, and gcc knows symbols can't have address
191 if (word
&& quot
> 0xffff)
195 else if ((int32_t)quot
< 0)
199 env
->cc_dest
= flags
;
202 void HELPER(divs
)(CPUState
*env
, uint32_t word
)
213 raise_exception(EXCP_DIV0
);
217 if (word
&& quot
!= (int16_t)quot
)
225 env
->cc_dest
= flags
;