]>
git.proxmox.com Git - qemu.git/blob - target-m68k/op_helper.c
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/>.
22 #if defined(CONFIG_USER_ONLY)
24 void do_interrupt(CPUM68KState
*env
)
26 env
->exception_index
= -1;
29 void do_interrupt_m68k_hardirq(CPUM68KState
*env
)
35 extern int semihosting_enabled
;
37 #include "exec/softmmu_exec.h"
39 #define MMUSUFFIX _mmu
42 #include "exec/softmmu_template.h"
45 #include "exec/softmmu_template.h"
48 #include "exec/softmmu_template.h"
51 #include "exec/softmmu_template.h"
53 /* Try to fill the TLB and return an exception if error. If retaddr is
54 NULL, it means that the function was called in C code (i.e. not
55 from generated code or from helper.c) */
56 void tlb_fill(CPUM68KState
*env
, target_ulong addr
, int is_write
, int mmu_idx
,
61 ret
= cpu_m68k_handle_mmu_fault(env
, addr
, is_write
, mmu_idx
);
64 /* now we have a real cpu fault */
65 cpu_restore_state(env
, retaddr
);
71 static void do_rte(CPUM68KState
*env
)
77 fmt
= cpu_ldl_kernel(env
, sp
);
78 env
->pc
= cpu_ldl_kernel(env
, sp
+ 4);
79 sp
|= (fmt
>> 28) & 3;
80 env
->sr
= fmt
& 0xffff;
82 env
->aregs
[7] = sp
+ 8;
85 static void do_interrupt_all(CPUM68KState
*env
, int is_hw
)
97 switch (env
->exception_index
) {
99 /* Return from an exception. */
103 if (semihosting_enabled
104 && (env
->sr
& SR_S
) != 0
105 && (env
->pc
& 3) == 0
106 && cpu_lduw_code(env
, env
->pc
- 4) == 0x4e71
107 && cpu_ldl_code(env
, env
->pc
) == 0x4e7bf000) {
109 do_m68k_semihosting(env
, env
->dregs
[0]);
112 cs
= CPU(m68k_env_get_cpu(env
));
114 env
->exception_index
= EXCP_HLT
;
118 if (env
->exception_index
>= EXCP_TRAP0
119 && env
->exception_index
<= EXCP_TRAP15
) {
120 /* Move the PC after the trap instruction. */
125 vector
= env
->exception_index
<< 2;
130 fmt
|= (sp
& 3) << 28;
136 env
->sr
= (env
->sr
& ~SR_I
) | (env
->pending_level
<< SR_I_SHIFT
);
141 /* ??? This could cause MMU faults. */
144 cpu_stl_kernel(env
, sp
, retaddr
);
146 cpu_stl_kernel(env
, sp
, fmt
);
148 /* Jump to vector. */
149 env
->pc
= cpu_ldl_kernel(env
, env
->vbr
+ vector
);
152 void do_interrupt(CPUM68KState
*env
)
154 do_interrupt_all(env
, 0);
157 void do_interrupt_m68k_hardirq(CPUM68KState
*env
)
159 do_interrupt_all(env
, 1);
163 static void raise_exception(CPUM68KState
*env
, int tt
)
165 env
->exception_index
= tt
;
169 void HELPER(raise_exception
)(CPUM68KState
*env
, uint32_t tt
)
171 raise_exception(env
, tt
);
174 void HELPER(divu
)(CPUM68KState
*env
, uint32_t word
)
184 /* ??? This needs to make sure the throwing location is accurate. */
186 raise_exception(env
, EXCP_DIV0
);
191 if (word
&& quot
> 0xffff)
195 else if ((int32_t)quot
< 0)
199 env
->cc_dest
= flags
;
202 void HELPER(divs
)(CPUM68KState
*env
, uint32_t word
)
213 raise_exception(env
, EXCP_DIV0
);
218 if (word
&& quot
!= (int16_t)quot
)
226 env
->cc_dest
= flags
;