]>
git.proxmox.com Git - qemu.git/blob - target-sh4/op_helper.c
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 #ifndef CONFIG_USER_ONLY
25 #define MMUSUFFIX _mmu
28 #include "softmmu_template.h"
31 #include "softmmu_template.h"
34 #include "softmmu_template.h"
37 #include "softmmu_template.h"
39 void tlb_fill(target_ulong addr
, int is_write
, int mmu_idx
, void *retaddr
)
46 /* XXX: hack to restore env in all cases, even if not called from
50 ret
= cpu_sh4_handle_mmu_fault(env
, addr
, is_write
, mmu_idx
, 1);
53 /* now we have a real cpu fault */
54 pc
= (unsigned long) retaddr
;
57 /* the PC is inside the translated code. It means that we have
58 a virtual CPU fault */
59 cpu_restore_state(tb
, env
, pc
, NULL
);
69 void helper_ldtlb(void)
71 #ifdef CONFIG_USER_ONLY
79 void helper_raise_illegal_instruction(void)
81 env
->exception_index
= 0x180;
85 void helper_raise_slot_illegal_instruction(void)
87 env
->exception_index
= 0x1a0;
91 void helper_debug(void)
93 env
->exception_index
= EXCP_DEBUG
;
97 void helper_sleep(void)
100 env
->exception_index
= EXCP_HLT
;
104 void helper_trapa(uint32_t tra
)
107 env
->exception_index
= 0x160;
111 void helper_addc_T0_T1(void)
117 T1
= tmp1
+ (env
->sr
& 1);
126 void helper_addv_T0_T1(void)
128 uint32_t dest
, src
, ans
;
130 if ((int32_t) T1
>= 0)
134 if ((int32_t) T0
>= 0)
140 if ((int32_t) T1
>= 0)
145 if (src
== 0 || src
== 2) {
154 #define T (env->sr & SR_T)
155 #define Q (env->sr & SR_Q ? 1 : 0)
156 #define M (env->sr & SR_M ? 1 : 0)
157 #define SETT env->sr |= SR_T
158 #define CLRT env->sr &= ~SR_T
159 #define SETQ env->sr |= SR_Q
160 #define CLRQ env->sr &= ~SR_Q
161 #define SETM env->sr |= SR_M
162 #define CLRM env->sr &= ~SR_M
164 void helper_div1_T0_T1(void)
167 uint8_t old_q
, tmp1
= 0xff;
169 //printf("div1 T0=0x%08x T1=0x%08x M=%d Q=%d T=%d\n", T0, T1, M, Q, T);
171 if ((0x80000000 & T1
) != 0)
268 //printf("Output: T1=0x%08x M=%d Q=%d T=%d\n", T1, M, Q, T);
271 void helper_dmulsl_T0_T1()
275 res
= (int64_t) (int32_t) T0
*(int64_t) (int32_t) T1
;
276 env
->mach
= (res
>> 32) & 0xffffffff;
277 env
->macl
= res
& 0xffffffff;
280 void helper_dmulul_T0_T1()
284 res
= (uint64_t) (uint32_t) T0
*(uint64_t) (uint32_t) T1
;
285 env
->mach
= (res
>> 32) & 0xffffffff;
286 env
->macl
= res
& 0xffffffff;
289 void helper_macl_T0_T1()
293 res
= ((uint64_t) env
->mach
<< 32) | env
->macl
;
294 res
+= (int64_t) (int32_t) T0
*(int64_t) (int32_t) T1
;
295 env
->mach
= (res
>> 32) & 0xffffffff;
296 env
->macl
= res
& 0xffffffff;
297 if (env
->sr
& SR_S
) {
299 env
->mach
|= 0xffff0000;
301 env
->mach
&= 0x00007fff;
305 void helper_macw_T0_T1()
309 res
= ((uint64_t) env
->mach
<< 32) | env
->macl
;
310 res
+= (int64_t) (int16_t) T0
*(int64_t) (int16_t) T1
;
311 env
->mach
= (res
>> 32) & 0xffffffff;
312 env
->macl
= res
& 0xffffffff;
313 if (env
->sr
& SR_S
) {
314 if (res
< -0x80000000) {
316 env
->macl
= 0x80000000;
317 } else if (res
> 0x000000007fffffff) {
319 env
->macl
= 0x7fffffff;
324 void helper_negc_T0()
329 T0
= temp
- (env
->sr
& SR_T
);
338 void helper_subc_T0_T1()
344 T1
= tmp1
- (env
->sr
& SR_T
);
353 void helper_subv_T0_T1()
355 int32_t dest
, src
, ans
;
357 if ((int32_t) T1
>= 0)
361 if ((int32_t) T0
>= 0)
367 if ((int32_t) T1
>= 0)
381 void helper_rotcl(uint32_t * addr
)
385 new = (*addr
<< 1) | (env
->sr
& SR_T
);
386 if (*addr
& 0x80000000)
393 void helper_rotcr(uint32_t * addr
)
397 new = (*addr
>> 1) | ((env
->sr
& SR_T
) ? 0x80000000 : 0);