4 * Copyright (c) 2005 Samuel Tardieu
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 void cpu_loop_exit(void)
25 longjmp(env->jmp_env, 1);
28 void do_raise_exception(void)
33 #ifndef CONFIG_USER_ONLY
35 #define MMUSUFFIX _mmu
36 #define GETPC() (__builtin_return_address(0))
39 #include "softmmu_template.h"
42 #include "softmmu_template.h"
45 #include "softmmu_template.h"
48 #include "softmmu_template.h"
50 void tlb_fill(target_ulong addr, int is_write, int is_user, void *retaddr)
57 /* XXX: hack to restore env in all cases, even if not called from
61 ret = cpu_sh4_handle_mmu_fault(env, addr, is_write, is_user, 1);
64 /* now we have a real cpu fault */
65 pc = (unsigned long) retaddr;
68 /* the PC is inside the translated code. It means that we have
69 a virtual CPU fault */
70 cpu_restore_state(tb, env, pc, NULL);
80 void helper_addc_T0_T1(void)
86 T1 = tmp1 + (env->sr & 1);
95 void helper_addv_T0_T1(void)
97 uint32_t dest, src, ans;
99 if ((int32_t) T1 >= 0)
103 if ((int32_t) T0 >= 0)
109 if ((int32_t) T1 >= 0)
114 if (src == 0 || src == 2) {
123 #define T (env->sr & SR_T)
124 #define Q (env->sr & SR_Q ? 1 : 0)
125 #define M (env->sr & SR_M ? 1 : 0)
126 #define SETT env->sr |= SR_T
127 #define CLRT env->sr &= ~SR_T
128 #define SETQ env->sr |= SR_Q
129 #define CLRQ env->sr &= ~SR_Q
130 #define SETM env->sr |= SR_M
131 #define CLRM env->sr &= ~SR_M
133 void helper_div1_T0_T1(void)
136 uint8_t old_q, tmp1 = 0xff;
138 //printf("div1 T0=0x%08x T1=0x%08x M=%d Q=%d T=%d\n", T0, T1, M, Q, T);
140 if ((0x80000000 & T1) != 0)
237 //printf("Output: T1=0x%08x M=%d Q=%d T=%d\n", T1, M, Q, T);
240 void helper_dmulsl_T0_T1()
244 res = (int64_t) (int32_t) T0 *(int64_t) (int32_t) T1;
245 env->mach = (res >> 32) & 0xffffffff;
246 env->macl = res & 0xffffffff;
249 void helper_dmulul_T0_T1()
253 res = (uint64_t) (uint32_t) T0 *(uint64_t) (uint32_t) T1;
254 env->mach = (res >> 32) & 0xffffffff;
255 env->macl = res & 0xffffffff;
258 void helper_macl_T0_T1()
262 res = ((uint64_t) env->mach << 32) | env->macl;
263 res += (int64_t) (int32_t) T0 *(int64_t) (int32_t) T1;
264 env->mach = (res >> 32) & 0xffffffff;
265 env->macl = res & 0xffffffff;
266 if (env->sr & SR_S) {
268 env->mach |= 0xffff0000;
270 env->mach &= 0x00007fff;
274 void helper_macw_T0_T1()
278 res = ((uint64_t) env->mach << 32) | env->macl;
279 res += (int64_t) (int16_t) T0 *(int64_t) (int16_t) T1;
280 env->mach = (res >> 32) & 0xffffffff;
281 env->macl = res & 0xffffffff;
282 if (env->sr & SR_S) {
283 if (res < -0x80000000) {
285 env->macl = 0x80000000;
286 } else if (res > 0x000000007fffffff) {
288 env->macl = 0x7fffffff;
293 void helper_negc_T0()
298 T0 = temp - (env->sr & SR_T);
307 void helper_subc_T0_T1()
313 T1 = tmp1 - (env->sr & SR_T);
322 void helper_subv_T0_T1()
324 int32_t dest, src, ans;
326 if ((int32_t) T1 >= 0)
330 if ((int32_t) T0 >= 0)
336 if ((int32_t) T1 >= 0)
350 void helper_rotcl(uint32_t * addr)
354 new = (*addr << 1) | (env->sr & SR_T);
355 if (*addr & 0x80000000)
362 void helper_rotcr(uint32_t * addr)
366 new = (*addr >> 1) | ((env->sr & SR_T) ? 0x80000000 : 0);