16
16
* You should have received a copy of the GNU Lesser General Public
17
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
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
20
20
#include <assert.h>
23
void do_raise_exception(void)
28
24
#ifndef CONFIG_USER_ONLY
30
26
#define MMUSUFFIX _mmu
32
# define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
34
# define GETPC() (__builtin_return_address(0))
38
29
#include "softmmu_template.h"
69
60
cpu_restore_state(tb, env, pc, NULL);
79
void helper_addc_T0_T1(void)
70
void helper_ldtlb(void)
72
#ifdef CONFIG_USER_ONLY
80
void helper_raise_illegal_instruction(void)
82
env->exception_index = 0x180;
86
void helper_raise_slot_illegal_instruction(void)
88
env->exception_index = 0x1a0;
92
void helper_raise_fpu_disable(void)
94
env->exception_index = 0x800;
98
void helper_raise_slot_fpu_disable(void)
100
env->exception_index = 0x820;
104
void helper_debug(void)
106
env->exception_index = EXCP_DEBUG;
110
void helper_sleep(uint32_t next_pc)
113
env->exception_index = EXCP_HLT;
118
void helper_trapa(uint32_t tra)
121
env->exception_index = 0x160;
125
uint32_t helper_addc(uint32_t arg0, uint32_t arg1)
81
127
uint32_t tmp0, tmp1;
85
T1 = tmp1 + (env->sr & 1);
131
arg1 = tmp1 + (env->sr & 1);
94
void helper_addv_T0_T1(void)
141
uint32_t helper_addv(uint32_t arg0, uint32_t arg1)
96
143
uint32_t dest, src, ans;
98
if ((int32_t) T1 >= 0)
145
if ((int32_t) arg1 >= 0)
102
if ((int32_t) T0 >= 0)
149
if ((int32_t) arg0 >= 0)
108
if ((int32_t) T1 >= 0)
155
if ((int32_t) arg1 >= 0)
129
177
#define SETM env->sr |= SR_M
130
178
#define CLRM env->sr &= ~SR_M
132
void helper_div1_T0_T1(void)
180
uint32_t helper_div1(uint32_t arg0, uint32_t arg1)
134
182
uint32_t tmp0, tmp2;
135
183
uint8_t old_q, tmp1 = 0xff;
137
//printf("div1 T0=0x%08x T1=0x%08x M=%d Q=%d T=%d\n", T0, T1, M, Q, T);
185
//printf("div1 arg0=0x%08x arg1=0x%08x M=%d Q=%d T=%d\n", arg0, arg1, M, Q, T);
139
if ((0x80000000 & T1) != 0)
187
if ((0x80000000 & arg1) != 0)
236
//printf("Output: T1=0x%08x M=%d Q=%d T=%d\n", T1, M, Q, T);
239
void helper_dmulsl_T0_T1()
243
res = (int64_t) (int32_t) T0 *(int64_t) (int32_t) T1;
244
env->mach = (res >> 32) & 0xffffffff;
245
env->macl = res & 0xffffffff;
248
void helper_dmulul_T0_T1()
252
res = (uint64_t) (uint32_t) T0 *(uint64_t) (uint32_t) T1;
253
env->mach = (res >> 32) & 0xffffffff;
254
env->macl = res & 0xffffffff;
257
void helper_macl_T0_T1()
284
//printf("Output: arg1=0x%08x M=%d Q=%d T=%d\n", arg1, M, Q, T);
288
void helper_macl(uint32_t arg0, uint32_t arg1)
261
292
res = ((uint64_t) env->mach << 32) | env->macl;
262
res += (int64_t) (int32_t) T0 *(int64_t) (int32_t) T1;
293
res += (int64_t) (int32_t) arg0 *(int64_t) (int32_t) arg1;
263
294
env->mach = (res >> 32) & 0xffffffff;
264
295
env->macl = res & 0xffffffff;
265
296
if (env->sr & SR_S) {
344
377
env->sr &= ~SR_T;
346
379
env->sr &= ~SR_T;
349
void helper_rotcl(uint32_t * addr)
353
new = (*addr << 1) | (env->sr & SR_T);
354
if (*addr & 0x80000000)
361
void helper_rotcr(uint32_t * addr)
365
new = (*addr >> 1) | ((env->sr & SR_T) ? 0x80000000 : 0);
383
static inline void set_t(void)
388
static inline void clr_t(void)
393
void helper_ld_fpscr(uint32_t val)
395
env->fpscr = val & 0x003fffff;
397
set_float_rounding_mode(float_round_to_zero, &env->fp_status);
399
set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
402
uint32_t helper_fabs_FT(uint32_t t0)
406
f.f = float32_abs(f.f);
410
uint64_t helper_fabs_DT(uint64_t t0)
414
d.d = float64_abs(d.d);
418
uint32_t helper_fadd_FT(uint32_t t0, uint32_t t1)
423
f0.f = float32_add(f0.f, f1.f, &env->fp_status);
427
uint64_t helper_fadd_DT(uint64_t t0, uint64_t t1)
432
d0.d = float64_add(d0.d, d1.d, &env->fp_status);
436
void helper_fcmp_eq_FT(uint32_t t0, uint32_t t1)
442
if (float32_compare(f0.f, f1.f, &env->fp_status) == 0)
448
void helper_fcmp_eq_DT(uint64_t t0, uint64_t t1)
454
if (float64_compare(d0.d, d1.d, &env->fp_status) == 0)
460
void helper_fcmp_gt_FT(uint32_t t0, uint32_t t1)
466
if (float32_compare(f0.f, f1.f, &env->fp_status) == 1)
472
void helper_fcmp_gt_DT(uint64_t t0, uint64_t t1)
478
if (float64_compare(d0.d, d1.d, &env->fp_status) == 1)
484
uint64_t helper_fcnvsd_FT_DT(uint32_t t0)
489
d.d = float32_to_float64(f.f, &env->fp_status);
493
uint32_t helper_fcnvds_DT_FT(uint64_t t0)
498
f.f = float64_to_float32(d.d, &env->fp_status);
502
uint32_t helper_fdiv_FT(uint32_t t0, uint32_t t1)
507
f0.f = float32_div(f0.f, f1.f, &env->fp_status);
511
uint64_t helper_fdiv_DT(uint64_t t0, uint64_t t1)
516
d0.d = float64_div(d0.d, d1.d, &env->fp_status);
520
uint32_t helper_float_FT(uint32_t t0)
523
f.f = int32_to_float32(t0, &env->fp_status);
527
uint64_t helper_float_DT(uint32_t t0)
530
d.d = int32_to_float64(t0, &env->fp_status);
534
uint32_t helper_fmac_FT(uint32_t t0, uint32_t t1, uint32_t t2)
536
CPU_FloatU f0, f1, f2;
540
f0.f = float32_mul(f0.f, f1.f, &env->fp_status);
541
f0.f = float32_add(f0.f, f2.f, &env->fp_status);
545
uint32_t helper_fmul_FT(uint32_t t0, uint32_t t1)
550
f0.f = float32_mul(f0.f, f1.f, &env->fp_status);
554
uint64_t helper_fmul_DT(uint64_t t0, uint64_t t1)
559
d0.d = float64_mul(d0.d, d1.d, &env->fp_status);
563
uint32_t helper_fneg_T(uint32_t t0)
567
f.f = float32_chs(f.f);
571
uint32_t helper_fsqrt_FT(uint32_t t0)
575
f.f = float32_sqrt(f.f, &env->fp_status);
579
uint64_t helper_fsqrt_DT(uint64_t t0)
583
d.d = float64_sqrt(d.d, &env->fp_status);
587
uint32_t helper_fsub_FT(uint32_t t0, uint32_t t1)
592
f0.f = float32_sub(f0.f, f1.f, &env->fp_status);
596
uint64_t helper_fsub_DT(uint64_t t0, uint64_t t1)
601
d0.d = float64_sub(d0.d, d1.d, &env->fp_status);
605
uint32_t helper_ftrc_FT(uint32_t t0)
609
return float32_to_int32_round_to_zero(f.f, &env->fp_status);
612
uint32_t helper_ftrc_DT(uint64_t t0)
616
return float64_to_int32_round_to_zero(d.d, &env->fp_status);