]>
git.proxmox.com Git - qemu.git/blob - target-sparc/op_helper.c
2 #include "host-utils.h"
4 #if !defined(CONFIG_USER_ONLY)
5 #include "softmmu_exec.h"
6 #endif /* !defined(CONFIG_USER_ONLY) */
11 //#define DEBUG_UNALIGNED
12 //#define DEBUG_UNASSIGNED
16 #define DPRINTF_MMU(fmt, args...) \
17 do { printf("MMU: " fmt , ##args); } while (0)
19 #define DPRINTF_MMU(fmt, args...) do {} while (0)
23 #define DPRINTF_MXCC(fmt, args...) \
24 do { printf("MXCC: " fmt , ##args); } while (0)
26 #define DPRINTF_MXCC(fmt, args...) do {} while (0)
30 #define DPRINTF_ASI(fmt, args...) \
31 do { printf("ASI: " fmt , ##args); } while (0)
33 #define DPRINTF_ASI(fmt, args...) do {} while (0)
37 #define ABI32_MASK(addr) do { (addr) &= 0xffffffffULL; } while (0)
39 #define ABI32_MASK(addr) do {} while (0)
42 void raise_exception(int tt
)
44 env
->exception_index
= tt
;
48 void helper_trap(target_ulong nb_trap
)
50 env
->exception_index
= TT_TRAP
+ (nb_trap
& 0x7f);
54 void helper_trapcc(target_ulong nb_trap
, target_ulong do_trap
)
57 env
->exception_index
= TT_TRAP
+ (nb_trap
& 0x7f);
62 void helper_check_align(target_ulong addr
, uint32_t align
)
65 #ifdef DEBUG_UNALIGNED
66 printf("Unaligned access to 0x" TARGET_FMT_lx
" from 0x" TARGET_FMT_lx
69 raise_exception(TT_UNALIGNED
);
73 #define F_HELPER(name, p) void helper_f##name##p(void)
75 #define F_BINOP(name) \
78 FT0 = float32_ ## name (FT0, FT1, &env->fp_status); \
82 DT0 = float64_ ## name (DT0, DT1, &env->fp_status); \
86 QT0 = float128_ ## name (QT0, QT1, &env->fp_status); \
95 void helper_fsmuld(void)
97 DT0
= float64_mul(float32_to_float64(FT0
, &env
->fp_status
),
98 float32_to_float64(FT1
, &env
->fp_status
),
102 void helper_fdmulq(void)
104 QT0
= float128_mul(float64_to_float128(DT0
, &env
->fp_status
),
105 float64_to_float128(DT1
, &env
->fp_status
),
111 FT0
= float32_chs(FT1
);
114 #ifdef TARGET_SPARC64
117 DT0
= float64_chs(DT1
);
122 QT0
= float128_chs(QT1
);
126 /* Integer to float conversion. */
129 FT0
= int32_to_float32(*((int32_t *)&FT1
), &env
->fp_status
);
134 DT0
= int32_to_float64(*((int32_t *)&FT1
), &env
->fp_status
);
139 QT0
= int32_to_float128(*((int32_t *)&FT1
), &env
->fp_status
);
142 #ifdef TARGET_SPARC64
145 FT0
= int64_to_float32(*((int64_t *)&DT1
), &env
->fp_status
);
150 DT0
= int64_to_float64(*((int64_t *)&DT1
), &env
->fp_status
);
155 QT0
= int64_to_float128(*((int64_t *)&DT1
), &env
->fp_status
);
160 /* floating point conversion */
161 void helper_fdtos(void)
163 FT0
= float64_to_float32(DT1
, &env
->fp_status
);
166 void helper_fstod(void)
168 DT0
= float32_to_float64(FT1
, &env
->fp_status
);
171 void helper_fqtos(void)
173 FT0
= float128_to_float32(QT1
, &env
->fp_status
);
176 void helper_fstoq(void)
178 QT0
= float32_to_float128(FT1
, &env
->fp_status
);
181 void helper_fqtod(void)
183 DT0
= float128_to_float64(QT1
, &env
->fp_status
);
186 void helper_fdtoq(void)
188 QT0
= float64_to_float128(DT1
, &env
->fp_status
);
191 /* Float to integer conversion. */
192 void helper_fstoi(void)
194 *((int32_t *)&FT0
) = float32_to_int32_round_to_zero(FT1
, &env
->fp_status
);
197 void helper_fdtoi(void)
199 *((int32_t *)&FT0
) = float64_to_int32_round_to_zero(DT1
, &env
->fp_status
);
202 void helper_fqtoi(void)
204 *((int32_t *)&FT0
) = float128_to_int32_round_to_zero(QT1
, &env
->fp_status
);
207 #ifdef TARGET_SPARC64
208 void helper_fstox(void)
210 *((int64_t *)&DT0
) = float32_to_int64_round_to_zero(FT1
, &env
->fp_status
);
213 void helper_fdtox(void)
215 *((int64_t *)&DT0
) = float64_to_int64_round_to_zero(DT1
, &env
->fp_status
);
218 void helper_fqtox(void)
220 *((int64_t *)&DT0
) = float128_to_int64_round_to_zero(QT1
, &env
->fp_status
);
223 void helper_faligndata(void)
227 tmp
= (*((uint64_t *)&DT0
)) << ((env
->gsr
& 7) * 8);
228 tmp
|= (*((uint64_t *)&DT1
)) >> (64 - (env
->gsr
& 7) * 8);
229 *((uint64_t *)&DT0
) = tmp
;
232 void helper_movl_FT0_0(void)
234 *((uint32_t *)&FT0
) = 0;
237 void helper_movl_DT0_0(void)
239 *((uint64_t *)&DT0
) = 0;
242 void helper_movl_FT0_1(void)
244 *((uint32_t *)&FT0
) = 0xffffffff;
247 void helper_movl_DT0_1(void)
249 *((uint64_t *)&DT0
) = 0xffffffffffffffffULL
;
252 void helper_fnot(void)
254 *(uint64_t *)&DT0
= ~*(uint64_t *)&DT1
;
257 void helper_fnots(void)
259 *(uint32_t *)&FT0
= ~*(uint32_t *)&FT1
;
262 void helper_fnor(void)
264 *(uint64_t *)&DT0
= ~(*(uint64_t *)&DT0
| *(uint64_t *)&DT1
);
267 void helper_fnors(void)
269 *(uint32_t *)&FT0
= ~(*(uint32_t *)&FT0
| *(uint32_t *)&FT1
);
272 void helper_for(void)
274 *(uint64_t *)&DT0
|= *(uint64_t *)&DT1
;
277 void helper_fors(void)
279 *(uint32_t *)&FT0
|= *(uint32_t *)&FT1
;
282 void helper_fxor(void)
284 *(uint64_t *)&DT0
^= *(uint64_t *)&DT1
;
287 void helper_fxors(void)
289 *(uint32_t *)&FT0
^= *(uint32_t *)&FT1
;
292 void helper_fand(void)
294 *(uint64_t *)&DT0
&= *(uint64_t *)&DT1
;
297 void helper_fands(void)
299 *(uint32_t *)&FT0
&= *(uint32_t *)&FT1
;
302 void helper_fornot(void)
304 *(uint64_t *)&DT0
= *(uint64_t *)&DT0
| ~*(uint64_t *)&DT1
;
307 void helper_fornots(void)
309 *(uint32_t *)&FT0
= *(uint32_t *)&FT0
| ~*(uint32_t *)&FT1
;
312 void helper_fandnot(void)
314 *(uint64_t *)&DT0
= *(uint64_t *)&DT0
& ~*(uint64_t *)&DT1
;
317 void helper_fandnots(void)
319 *(uint32_t *)&FT0
= *(uint32_t *)&FT0
& ~*(uint32_t *)&FT1
;
322 void helper_fnand(void)
324 *(uint64_t *)&DT0
= ~(*(uint64_t *)&DT0
& *(uint64_t *)&DT1
);
327 void helper_fnands(void)
329 *(uint32_t *)&FT0
= ~(*(uint32_t *)&FT0
& *(uint32_t *)&FT1
);
332 void helper_fxnor(void)
334 *(uint64_t *)&DT0
^= ~*(uint64_t *)&DT1
;
337 void helper_fxnors(void)
339 *(uint32_t *)&FT0
^= ~*(uint32_t *)&FT1
;
342 #ifdef WORDS_BIGENDIAN
343 #define VIS_B64(n) b[7 - (n)]
344 #define VIS_W64(n) w[3 - (n)]
345 #define VIS_SW64(n) sw[3 - (n)]
346 #define VIS_L64(n) l[1 - (n)]
347 #define VIS_B32(n) b[3 - (n)]
348 #define VIS_W32(n) w[1 - (n)]
350 #define VIS_B64(n) b[n]
351 #define VIS_W64(n) w[n]
352 #define VIS_SW64(n) sw[n]
353 #define VIS_L64(n) l[n]
354 #define VIS_B32(n) b[n]
355 #define VIS_W32(n) w[n]
373 void helper_fpmerge(void)
380 // Reverse calculation order to handle overlap
381 d
.VIS_B64(7) = s
.VIS_B64(3);
382 d
.VIS_B64(6) = d
.VIS_B64(3);
383 d
.VIS_B64(5) = s
.VIS_B64(2);
384 d
.VIS_B64(4) = d
.VIS_B64(2);
385 d
.VIS_B64(3) = s
.VIS_B64(1);
386 d
.VIS_B64(2) = d
.VIS_B64(1);
387 d
.VIS_B64(1) = s
.VIS_B64(0);
388 //d.VIS_B64(0) = d.VIS_B64(0);
393 void helper_fmul8x16(void)
402 tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B64(r); \
403 if ((tmp & 0xff) > 0x7f) \
405 d.VIS_W64(r) = tmp >> 8;
416 void helper_fmul8x16al(void)
425 tmp = (int32_t)d.VIS_SW64(1) * (int32_t)s.VIS_B64(r); \
426 if ((tmp & 0xff) > 0x7f) \
428 d.VIS_W64(r) = tmp >> 8;
439 void helper_fmul8x16au(void)
448 tmp = (int32_t)d.VIS_SW64(0) * (int32_t)s.VIS_B64(r); \
449 if ((tmp & 0xff) > 0x7f) \
451 d.VIS_W64(r) = tmp >> 8;
462 void helper_fmul8sux16(void)
471 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
472 if ((tmp & 0xff) > 0x7f) \
474 d.VIS_W64(r) = tmp >> 8;
485 void helper_fmul8ulx16(void)
494 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
495 if ((tmp & 0xff) > 0x7f) \
497 d.VIS_W64(r) = tmp >> 8;
508 void helper_fmuld8sux16(void)
517 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
518 if ((tmp & 0xff) > 0x7f) \
522 // Reverse calculation order to handle overlap
530 void helper_fmuld8ulx16(void)
539 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
540 if ((tmp & 0xff) > 0x7f) \
544 // Reverse calculation order to handle overlap
552 void helper_fexpand(void)
557 s
.l
= (uint32_t)(*(uint64_t *)&DT0
& 0xffffffff);
559 d
.VIS_L64(0) = s
.VIS_W32(0) << 4;
560 d
.VIS_L64(1) = s
.VIS_W32(1) << 4;
561 d
.VIS_L64(2) = s
.VIS_W32(2) << 4;
562 d
.VIS_L64(3) = s
.VIS_W32(3) << 4;
567 #define VIS_HELPER(name, F) \
568 void name##16(void) \
575 d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0)); \
576 d.VIS_W64(1) = F(d.VIS_W64(1), s.VIS_W64(1)); \
577 d.VIS_W64(2) = F(d.VIS_W64(2), s.VIS_W64(2)); \
578 d.VIS_W64(3) = F(d.VIS_W64(3), s.VIS_W64(3)); \
583 void name##16s(void) \
590 d.VIS_W32(0) = F(d.VIS_W32(0), s.VIS_W32(0)); \
591 d.VIS_W32(1) = F(d.VIS_W32(1), s.VIS_W32(1)); \
596 void name##32(void) \
603 d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0)); \
604 d.VIS_L64(1) = F(d.VIS_L64(1), s.VIS_L64(1)); \
609 void name##32s(void) \
621 #define FADD(a, b) ((a) + (b))
622 #define FSUB(a, b) ((a) - (b))
623 VIS_HELPER(helper_fpadd
, FADD
)
624 VIS_HELPER(helper_fpsub
, FSUB
)
626 #define VIS_CMPHELPER(name, F) \
627 void name##16(void) \
634 d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0))? 1: 0; \
635 d.VIS_W64(0) |= F(d.VIS_W64(1), s.VIS_W64(1))? 2: 0; \
636 d.VIS_W64(0) |= F(d.VIS_W64(2), s.VIS_W64(2))? 4: 0; \
637 d.VIS_W64(0) |= F(d.VIS_W64(3), s.VIS_W64(3))? 8: 0; \
642 void name##32(void) \
649 d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0))? 1: 0; \
650 d.VIS_L64(0) |= F(d.VIS_L64(1), s.VIS_L64(1))? 2: 0; \
655 #define FCMPGT(a, b) ((a) > (b))
656 #define FCMPEQ(a, b) ((a) == (b))
657 #define FCMPLE(a, b) ((a) <= (b))
658 #define FCMPNE(a, b) ((a) != (b))
660 VIS_CMPHELPER(helper_fcmpgt
, FCMPGT
)
661 VIS_CMPHELPER(helper_fcmpeq
, FCMPEQ
)
662 VIS_CMPHELPER(helper_fcmple
, FCMPLE
)
663 VIS_CMPHELPER(helper_fcmpne
, FCMPNE
)
666 void helper_check_ieee_exceptions(void)
670 status
= get_float_exception_flags(&env
->fp_status
);
672 /* Copy IEEE 754 flags into FSR */
673 if (status
& float_flag_invalid
)
675 if (status
& float_flag_overflow
)
677 if (status
& float_flag_underflow
)
679 if (status
& float_flag_divbyzero
)
681 if (status
& float_flag_inexact
)
684 if ((env
->fsr
& FSR_CEXC_MASK
) & ((env
->fsr
& FSR_TEM_MASK
) >> 23)) {
685 /* Unmasked exception, generate a trap */
686 env
->fsr
|= FSR_FTT_IEEE_EXCP
;
687 raise_exception(TT_FP_EXCP
);
689 /* Accumulate exceptions */
690 env
->fsr
|= (env
->fsr
& FSR_CEXC_MASK
) << 5;
695 void helper_clear_float_exceptions(void)
697 set_float_exception_flags(0, &env
->fp_status
);
700 void helper_fabss(void)
702 FT0
= float32_abs(FT1
);
705 #ifdef TARGET_SPARC64
706 void helper_fabsd(void)
708 DT0
= float64_abs(DT1
);
711 void helper_fabsq(void)
713 QT0
= float128_abs(QT1
);
717 void helper_fsqrts(void)
719 FT0
= float32_sqrt(FT1
, &env
->fp_status
);
722 void helper_fsqrtd(void)
724 DT0
= float64_sqrt(DT1
, &env
->fp_status
);
727 void helper_fsqrtq(void)
729 QT0
= float128_sqrt(QT1
, &env
->fp_status
);
732 #define GEN_FCMP(name, size, reg1, reg2, FS, TRAP) \
733 void glue(helper_, name) (void) \
735 target_ulong new_fsr; \
737 env->fsr &= ~((FSR_FCC1 | FSR_FCC0) << FS); \
738 switch (glue(size, _compare) (reg1, reg2, &env->fp_status)) { \
739 case float_relation_unordered: \
740 new_fsr = (FSR_FCC1 | FSR_FCC0) << FS; \
741 if ((env->fsr & FSR_NVM) || TRAP) { \
742 env->fsr |= new_fsr; \
743 env->fsr |= FSR_NVC; \
744 env->fsr |= FSR_FTT_IEEE_EXCP; \
745 raise_exception(TT_FP_EXCP); \
747 env->fsr |= FSR_NVA; \
750 case float_relation_less: \
751 new_fsr = FSR_FCC0 << FS; \
753 case float_relation_greater: \
754 new_fsr = FSR_FCC1 << FS; \
760 env->fsr |= new_fsr; \
763 GEN_FCMP(fcmps
, float32
, FT0
, FT1
, 0, 0);
764 GEN_FCMP(fcmpd
, float64
, DT0
, DT1
, 0, 0);
766 GEN_FCMP(fcmpes
, float32
, FT0
, FT1
, 0, 1);
767 GEN_FCMP(fcmped
, float64
, DT0
, DT1
, 0, 1);
769 GEN_FCMP(fcmpq
, float128
, QT0
, QT1
, 0, 0);
770 GEN_FCMP(fcmpeq
, float128
, QT0
, QT1
, 0, 1);
772 #ifdef TARGET_SPARC64
773 GEN_FCMP(fcmps_fcc1
, float32
, FT0
, FT1
, 22, 0);
774 GEN_FCMP(fcmpd_fcc1
, float64
, DT0
, DT1
, 22, 0);
775 GEN_FCMP(fcmpq_fcc1
, float128
, QT0
, QT1
, 22, 0);
777 GEN_FCMP(fcmps_fcc2
, float32
, FT0
, FT1
, 24, 0);
778 GEN_FCMP(fcmpd_fcc2
, float64
, DT0
, DT1
, 24, 0);
779 GEN_FCMP(fcmpq_fcc2
, float128
, QT0
, QT1
, 24, 0);
781 GEN_FCMP(fcmps_fcc3
, float32
, FT0
, FT1
, 26, 0);
782 GEN_FCMP(fcmpd_fcc3
, float64
, DT0
, DT1
, 26, 0);
783 GEN_FCMP(fcmpq_fcc3
, float128
, QT0
, QT1
, 26, 0);
785 GEN_FCMP(fcmpes_fcc1
, float32
, FT0
, FT1
, 22, 1);
786 GEN_FCMP(fcmped_fcc1
, float64
, DT0
, DT1
, 22, 1);
787 GEN_FCMP(fcmpeq_fcc1
, float128
, QT0
, QT1
, 22, 1);
789 GEN_FCMP(fcmpes_fcc2
, float32
, FT0
, FT1
, 24, 1);
790 GEN_FCMP(fcmped_fcc2
, float64
, DT0
, DT1
, 24, 1);
791 GEN_FCMP(fcmpeq_fcc2
, float128
, QT0
, QT1
, 24, 1);
793 GEN_FCMP(fcmpes_fcc3
, float32
, FT0
, FT1
, 26, 1);
794 GEN_FCMP(fcmped_fcc3
, float64
, DT0
, DT1
, 26, 1);
795 GEN_FCMP(fcmpeq_fcc3
, float128
, QT0
, QT1
, 26, 1);
798 #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) && \
800 static void dump_mxcc(CPUState
*env
)
802 printf("mxccdata: %016llx %016llx %016llx %016llx\n",
803 env
->mxccdata
[0], env
->mxccdata
[1],
804 env
->mxccdata
[2], env
->mxccdata
[3]);
805 printf("mxccregs: %016llx %016llx %016llx %016llx\n"
806 " %016llx %016llx %016llx %016llx\n",
807 env
->mxccregs
[0], env
->mxccregs
[1],
808 env
->mxccregs
[2], env
->mxccregs
[3],
809 env
->mxccregs
[4], env
->mxccregs
[5],
810 env
->mxccregs
[6], env
->mxccregs
[7]);
814 #if (defined(TARGET_SPARC64) || !defined(CONFIG_USER_ONLY)) \
815 && defined(DEBUG_ASI)
816 static void dump_asi(const char *txt
, target_ulong addr
, int asi
, int size
,
822 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %02" PRIx64
"\n", txt
,
823 addr
, asi
, r1
& 0xff);
826 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %04" PRIx64
"\n", txt
,
827 addr
, asi
, r1
& 0xffff);
830 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %08" PRIx64
"\n", txt
,
831 addr
, asi
, r1
& 0xffffffff);
834 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %016" PRIx64
"\n", txt
,
841 #ifndef TARGET_SPARC64
842 #ifndef CONFIG_USER_ONLY
843 uint64_t helper_ld_asi(target_ulong addr
, int asi
, int size
, int sign
)
846 #if defined(DEBUG_MXCC) || defined(DEBUG_ASI)
847 uint32_t last_addr
= addr
;
850 helper_check_align(addr
, size
- 1);
852 case 2: /* SuperSparc MXCC registers */
854 case 0x01c00a00: /* MXCC control register */
856 ret
= env
->mxccregs
[3];
858 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
861 case 0x01c00a04: /* MXCC control register */
863 ret
= env
->mxccregs
[3];
865 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
868 case 0x01c00c00: /* Module reset register */
870 ret
= env
->mxccregs
[5];
871 // should we do something here?
873 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
876 case 0x01c00f00: /* MBus port address register */
878 ret
= env
->mxccregs
[7];
880 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
884 DPRINTF_MXCC("%08x: unimplemented address, size: %d\n", addr
,
888 DPRINTF_MXCC("asi = %d, size = %d, sign = %d, "
889 "addr = %08x -> ret = %08x,"
890 "addr = %08x\n", asi
, size
, sign
, last_addr
, ret
, addr
);
895 case 3: /* MMU probe */
899 mmulev
= (addr
>> 8) & 15;
903 ret
= mmu_probe(env
, addr
, mmulev
);
904 DPRINTF_MMU("mmu_probe: 0x%08x (lev %d) -> 0x%08" PRIx64
"\n",
908 case 4: /* read MMU regs */
910 int reg
= (addr
>> 8) & 0x1f;
912 ret
= env
->mmuregs
[reg
];
913 if (reg
== 3) /* Fault status cleared on read */
915 else if (reg
== 0x13) /* Fault status read */
916 ret
= env
->mmuregs
[3];
917 else if (reg
== 0x14) /* Fault address read */
918 ret
= env
->mmuregs
[4];
919 DPRINTF_MMU("mmu_read: reg[%d] = 0x%08" PRIx64
"\n", reg
, ret
);
922 case 5: // Turbosparc ITLB Diagnostic
923 case 6: // Turbosparc DTLB Diagnostic
924 case 7: // Turbosparc IOTLB Diagnostic
926 case 9: /* Supervisor code access */
929 ret
= ldub_code(addr
);
932 ret
= lduw_code(addr
& ~1);
936 ret
= ldl_code(addr
& ~3);
939 ret
= ldq_code(addr
& ~7);
943 case 0xa: /* User data access */
946 ret
= ldub_user(addr
);
949 ret
= lduw_user(addr
& ~1);
953 ret
= ldl_user(addr
& ~3);
956 ret
= ldq_user(addr
& ~7);
960 case 0xb: /* Supervisor data access */
963 ret
= ldub_kernel(addr
);
966 ret
= lduw_kernel(addr
& ~1);
970 ret
= ldl_kernel(addr
& ~3);
973 ret
= ldq_kernel(addr
& ~7);
977 case 0xc: /* I-cache tag */
978 case 0xd: /* I-cache data */
979 case 0xe: /* D-cache tag */
980 case 0xf: /* D-cache data */
982 case 0x20: /* MMU passthrough */
985 ret
= ldub_phys(addr
);
988 ret
= lduw_phys(addr
& ~1);
992 ret
= ldl_phys(addr
& ~3);
995 ret
= ldq_phys(addr
& ~7);
999 case 0x21 ... 0x2f: /* MMU passthrough, 0x100000000 to 0xfffffffff */
1002 ret
= ldub_phys((target_phys_addr_t
)addr
1003 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
1006 ret
= lduw_phys((target_phys_addr_t
)(addr
& ~1)
1007 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
1011 ret
= ldl_phys((target_phys_addr_t
)(addr
& ~3)
1012 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
1015 ret
= ldq_phys((target_phys_addr_t
)(addr
& ~7)
1016 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
1020 case 0x30: // Turbosparc secondary cache diagnostic
1021 case 0x31: // Turbosparc RAM snoop
1022 case 0x32: // Turbosparc page table descriptor diagnostic
1023 case 0x39: /* data cache diagnostic register */
1026 case 8: /* User code access, XXX */
1028 do_unassigned_access(addr
, 0, 0, asi
);
1038 ret
= (int16_t) ret
;
1041 ret
= (int32_t) ret
;
1048 dump_asi("read ", last_addr
, asi
, size
, ret
);
1053 void helper_st_asi(target_ulong addr
, uint64_t val
, int asi
, int size
)
1055 helper_check_align(addr
, size
- 1);
1057 case 2: /* SuperSparc MXCC registers */
1059 case 0x01c00000: /* MXCC stream data register 0 */
1061 env
->mxccdata
[0] = val
;
1063 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
1066 case 0x01c00008: /* MXCC stream data register 1 */
1068 env
->mxccdata
[1] = val
;
1070 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
1073 case 0x01c00010: /* MXCC stream data register 2 */
1075 env
->mxccdata
[2] = val
;
1077 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
1080 case 0x01c00018: /* MXCC stream data register 3 */
1082 env
->mxccdata
[3] = val
;
1084 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
1087 case 0x01c00100: /* MXCC stream source */
1089 env
->mxccregs
[0] = val
;
1091 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
1093 env
->mxccdata
[0] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) +
1095 env
->mxccdata
[1] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) +
1097 env
->mxccdata
[2] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) +
1099 env
->mxccdata
[3] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) +
1102 case 0x01c00200: /* MXCC stream destination */
1104 env
->mxccregs
[1] = val
;
1106 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
1108 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 0,
1110 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 8,
1112 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 16,
1114 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 24,
1117 case 0x01c00a00: /* MXCC control register */
1119 env
->mxccregs
[3] = val
;
1121 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
1124 case 0x01c00a04: /* MXCC control register */
1126 env
->mxccregs
[3] = (env
->mxccregs
[0xa] & 0xffffffff00000000ULL
)
1129 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
1132 case 0x01c00e00: /* MXCC error register */
1133 // writing a 1 bit clears the error
1135 env
->mxccregs
[6] &= ~val
;
1137 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
1140 case 0x01c00f00: /* MBus port address register */
1142 env
->mxccregs
[7] = val
;
1144 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
,
1148 DPRINTF_MXCC("%08x: unimplemented address, size: %d\n", addr
,
1152 DPRINTF_MXCC("asi = %d, size = %d, addr = %08x, val = %08x\n", asi
,
1158 case 3: /* MMU flush */
1162 mmulev
= (addr
>> 8) & 15;
1163 DPRINTF_MMU("mmu flush level %d\n", mmulev
);
1165 case 0: // flush page
1166 tlb_flush_page(env
, addr
& 0xfffff000);
1168 case 1: // flush segment (256k)
1169 case 2: // flush region (16M)
1170 case 3: // flush context (4G)
1171 case 4: // flush entire
1182 case 4: /* write MMU regs */
1184 int reg
= (addr
>> 8) & 0x1f;
1187 oldreg
= env
->mmuregs
[reg
];
1189 case 0: // Control Register
1190 env
->mmuregs
[reg
] = (env
->mmuregs
[reg
] & 0xff000000) |
1192 // Mappings generated during no-fault mode or MMU
1193 // disabled mode are invalid in normal mode
1194 if ((oldreg
& (MMU_E
| MMU_NF
| env
->mmu_bm
)) !=
1195 (env
->mmuregs
[reg
] & (MMU_E
| MMU_NF
| env
->mmu_bm
)))
1198 case 1: // Context Table Pointer Register
1199 env
->mmuregs
[reg
] = val
& env
->mmu_ctpr_mask
;
1201 case 2: // Context Register
1202 env
->mmuregs
[reg
] = val
& env
->mmu_cxr_mask
;
1203 if (oldreg
!= env
->mmuregs
[reg
]) {
1204 /* we flush when the MMU context changes because
1205 QEMU has no MMU context support */
1209 case 3: // Synchronous Fault Status Register with Clear
1210 case 4: // Synchronous Fault Address Register
1212 case 0x10: // TLB Replacement Control Register
1213 env
->mmuregs
[reg
] = val
& env
->mmu_trcr_mask
;
1215 case 0x13: // Synchronous Fault Status Register with Read and Clear
1216 env
->mmuregs
[3] = val
& env
->mmu_sfsr_mask
;
1218 case 0x14: // Synchronous Fault Address Register
1219 env
->mmuregs
[4] = val
;
1222 env
->mmuregs
[reg
] = val
;
1225 if (oldreg
!= env
->mmuregs
[reg
]) {
1226 DPRINTF_MMU("mmu change reg[%d]: 0x%08x -> 0x%08x\n",
1227 reg
, oldreg
, env
->mmuregs
[reg
]);
1234 case 5: // Turbosparc ITLB Diagnostic
1235 case 6: // Turbosparc DTLB Diagnostic
1236 case 7: // Turbosparc IOTLB Diagnostic
1238 case 0xa: /* User data access */
1241 stb_user(addr
, val
);
1244 stw_user(addr
& ~1, val
);
1248 stl_user(addr
& ~3, val
);
1251 stq_user(addr
& ~7, val
);
1255 case 0xb: /* Supervisor data access */
1258 stb_kernel(addr
, val
);
1261 stw_kernel(addr
& ~1, val
);
1265 stl_kernel(addr
& ~3, val
);
1268 stq_kernel(addr
& ~7, val
);
1272 case 0xc: /* I-cache tag */
1273 case 0xd: /* I-cache data */
1274 case 0xe: /* D-cache tag */
1275 case 0xf: /* D-cache data */
1276 case 0x10: /* I/D-cache flush page */
1277 case 0x11: /* I/D-cache flush segment */
1278 case 0x12: /* I/D-cache flush region */
1279 case 0x13: /* I/D-cache flush context */
1280 case 0x14: /* I/D-cache flush user */
1282 case 0x17: /* Block copy, sta access */
1288 uint32_t src
= val
& ~3, dst
= addr
& ~3, temp
;
1290 for (i
= 0; i
< 32; i
+= 4, src
+= 4, dst
+= 4) {
1291 temp
= ldl_kernel(src
);
1292 stl_kernel(dst
, temp
);
1296 case 0x1f: /* Block fill, stda access */
1299 // fill 32 bytes with val
1301 uint32_t dst
= addr
& 7;
1303 for (i
= 0; i
< 32; i
+= 8, dst
+= 8)
1304 stq_kernel(dst
, val
);
1307 case 0x20: /* MMU passthrough */
1311 stb_phys(addr
, val
);
1314 stw_phys(addr
& ~1, val
);
1318 stl_phys(addr
& ~3, val
);
1321 stq_phys(addr
& ~7, val
);
1326 case 0x21 ... 0x2f: /* MMU passthrough, 0x100000000 to 0xfffffffff */
1330 stb_phys((target_phys_addr_t
)addr
1331 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1334 stw_phys((target_phys_addr_t
)(addr
& ~1)
1335 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1339 stl_phys((target_phys_addr_t
)(addr
& ~3)
1340 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1343 stq_phys((target_phys_addr_t
)(addr
& ~7)
1344 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1349 case 0x30: // store buffer tags or Turbosparc secondary cache diagnostic
1350 case 0x31: // store buffer data, Ross RT620 I-cache flush or
1351 // Turbosparc snoop RAM
1352 case 0x32: // store buffer control or Turbosparc page table
1353 // descriptor diagnostic
1354 case 0x36: /* I-cache flash clear */
1355 case 0x37: /* D-cache flash clear */
1356 case 0x38: /* breakpoint diagnostics */
1357 case 0x4c: /* breakpoint action */
1359 case 8: /* User code access, XXX */
1360 case 9: /* Supervisor code access, XXX */
1362 do_unassigned_access(addr
, 1, 0, asi
);
1366 dump_asi("write", addr
, asi
, size
, val
);
1370 #endif /* CONFIG_USER_ONLY */
1371 #else /* TARGET_SPARC64 */
1373 #ifdef CONFIG_USER_ONLY
1374 uint64_t helper_ld_asi(target_ulong addr
, int asi
, int size
, int sign
)
1377 #if defined(DEBUG_ASI)
1378 target_ulong last_addr
= addr
;
1382 raise_exception(TT_PRIV_ACT
);
1384 helper_check_align(addr
, size
- 1);
1388 case 0x80: // Primary
1389 case 0x82: // Primary no-fault
1390 case 0x88: // Primary LE
1391 case 0x8a: // Primary no-fault LE
1395 ret
= ldub_raw(addr
);
1398 ret
= lduw_raw(addr
& ~1);
1401 ret
= ldl_raw(addr
& ~3);
1405 ret
= ldq_raw(addr
& ~7);
1410 case 0x81: // Secondary
1411 case 0x83: // Secondary no-fault
1412 case 0x89: // Secondary LE
1413 case 0x8b: // Secondary no-fault LE
1420 /* Convert from little endian */
1422 case 0x88: // Primary LE
1423 case 0x89: // Secondary LE
1424 case 0x8a: // Primary no-fault LE
1425 case 0x8b: // Secondary no-fault LE
1443 /* Convert to signed number */
1450 ret
= (int16_t) ret
;
1453 ret
= (int32_t) ret
;
1460 dump_asi("read ", last_addr
, asi
, size
, ret
);
1465 void helper_st_asi(target_ulong addr
, target_ulong val
, int asi
, int size
)
1468 dump_asi("write", addr
, asi
, size
, val
);
1471 raise_exception(TT_PRIV_ACT
);
1473 helper_check_align(addr
, size
- 1);
1476 /* Convert to little endian */
1478 case 0x88: // Primary LE
1479 case 0x89: // Secondary LE
1482 addr
= bswap16(addr
);
1485 addr
= bswap32(addr
);
1488 addr
= bswap64(addr
);
1498 case 0x80: // Primary
1499 case 0x88: // Primary LE
1506 stw_raw(addr
& ~1, val
);
1509 stl_raw(addr
& ~3, val
);
1513 stq_raw(addr
& ~7, val
);
1518 case 0x81: // Secondary
1519 case 0x89: // Secondary LE
1523 case 0x82: // Primary no-fault, RO
1524 case 0x83: // Secondary no-fault, RO
1525 case 0x8a: // Primary no-fault LE, RO
1526 case 0x8b: // Secondary no-fault LE, RO
1528 do_unassigned_access(addr
, 1, 0, 1);
1533 #else /* CONFIG_USER_ONLY */
1535 uint64_t helper_ld_asi(target_ulong addr
, int asi
, int size
, int sign
)
1538 #if defined(DEBUG_ASI)
1539 target_ulong last_addr
= addr
;
1542 if ((asi
< 0x80 && (env
->pstate
& PS_PRIV
) == 0)
1543 || (asi
>= 0x30 && asi
< 0x80 && !(env
->hpstate
& HS_PRIV
)))
1544 raise_exception(TT_PRIV_ACT
);
1546 helper_check_align(addr
, size
- 1);
1548 case 0x10: // As if user primary
1549 case 0x18: // As if user primary LE
1550 case 0x80: // Primary
1551 case 0x82: // Primary no-fault
1552 case 0x88: // Primary LE
1553 case 0x8a: // Primary no-fault LE
1554 if ((asi
& 0x80) && (env
->pstate
& PS_PRIV
)) {
1555 if (env
->hpstate
& HS_PRIV
) {
1558 ret
= ldub_hypv(addr
);
1561 ret
= lduw_hypv(addr
& ~1);
1564 ret
= ldl_hypv(addr
& ~3);
1568 ret
= ldq_hypv(addr
& ~7);
1574 ret
= ldub_kernel(addr
);
1577 ret
= lduw_kernel(addr
& ~1);
1580 ret
= ldl_kernel(addr
& ~3);
1584 ret
= ldq_kernel(addr
& ~7);
1591 ret
= ldub_user(addr
);
1594 ret
= lduw_user(addr
& ~1);
1597 ret
= ldl_user(addr
& ~3);
1601 ret
= ldq_user(addr
& ~7);
1606 case 0x14: // Bypass
1607 case 0x15: // Bypass, non-cacheable
1608 case 0x1c: // Bypass LE
1609 case 0x1d: // Bypass, non-cacheable LE
1613 ret
= ldub_phys(addr
);
1616 ret
= lduw_phys(addr
& ~1);
1619 ret
= ldl_phys(addr
& ~3);
1623 ret
= ldq_phys(addr
& ~7);
1628 case 0x04: // Nucleus
1629 case 0x0c: // Nucleus Little Endian (LE)
1630 case 0x11: // As if user secondary
1631 case 0x19: // As if user secondary LE
1632 case 0x24: // Nucleus quad LDD 128 bit atomic
1633 case 0x2c: // Nucleus quad LDD 128 bit atomic
1634 case 0x4a: // UPA config
1635 case 0x81: // Secondary
1636 case 0x83: // Secondary no-fault
1637 case 0x89: // Secondary LE
1638 case 0x8b: // Secondary no-fault LE
1644 case 0x50: // I-MMU regs
1646 int reg
= (addr
>> 3) & 0xf;
1648 ret
= env
->immuregs
[reg
];
1651 case 0x51: // I-MMU 8k TSB pointer
1652 case 0x52: // I-MMU 64k TSB pointer
1653 case 0x55: // I-MMU data access
1656 case 0x56: // I-MMU tag read
1660 for (i
= 0; i
< 64; i
++) {
1661 // Valid, ctx match, vaddr match
1662 if ((env
->itlb_tte
[i
] & 0x8000000000000000ULL
) != 0 &&
1663 env
->itlb_tag
[i
] == addr
) {
1664 ret
= env
->itlb_tag
[i
];
1670 case 0x58: // D-MMU regs
1672 int reg
= (addr
>> 3) & 0xf;
1674 ret
= env
->dmmuregs
[reg
];
1677 case 0x5e: // D-MMU tag read
1681 for (i
= 0; i
< 64; i
++) {
1682 // Valid, ctx match, vaddr match
1683 if ((env
->dtlb_tte
[i
] & 0x8000000000000000ULL
) != 0 &&
1684 env
->dtlb_tag
[i
] == addr
) {
1685 ret
= env
->dtlb_tag
[i
];
1691 case 0x59: // D-MMU 8k TSB pointer
1692 case 0x5a: // D-MMU 64k TSB pointer
1693 case 0x5b: // D-MMU data pointer
1694 case 0x5d: // D-MMU data access
1695 case 0x48: // Interrupt dispatch, RO
1696 case 0x49: // Interrupt data receive
1697 case 0x7f: // Incoming interrupt vector, RO
1700 case 0x54: // I-MMU data in, WO
1701 case 0x57: // I-MMU demap, WO
1702 case 0x5c: // D-MMU data in, WO
1703 case 0x5f: // D-MMU demap, WO
1704 case 0x77: // Interrupt vector, WO
1706 do_unassigned_access(addr
, 0, 0, 1);
1711 /* Convert from little endian */
1713 case 0x0c: // Nucleus Little Endian (LE)
1714 case 0x18: // As if user primary LE
1715 case 0x19: // As if user secondary LE
1716 case 0x1c: // Bypass LE
1717 case 0x1d: // Bypass, non-cacheable LE
1718 case 0x88: // Primary LE
1719 case 0x89: // Secondary LE
1720 case 0x8a: // Primary no-fault LE
1721 case 0x8b: // Secondary no-fault LE
1739 /* Convert to signed number */
1746 ret
= (int16_t) ret
;
1749 ret
= (int32_t) ret
;
1756 dump_asi("read ", last_addr
, asi
, size
, ret
);
1761 void helper_st_asi(target_ulong addr
, target_ulong val
, int asi
, int size
)
1764 dump_asi("write", addr
, asi
, size
, val
);
1766 if ((asi
< 0x80 && (env
->pstate
& PS_PRIV
) == 0)
1767 || (asi
>= 0x30 && asi
< 0x80 && !(env
->hpstate
& HS_PRIV
)))
1768 raise_exception(TT_PRIV_ACT
);
1770 helper_check_align(addr
, size
- 1);
1771 /* Convert to little endian */
1773 case 0x0c: // Nucleus Little Endian (LE)
1774 case 0x18: // As if user primary LE
1775 case 0x19: // As if user secondary LE
1776 case 0x1c: // Bypass LE
1777 case 0x1d: // Bypass, non-cacheable LE
1778 case 0x88: // Primary LE
1779 case 0x89: // Secondary LE
1782 addr
= bswap16(addr
);
1785 addr
= bswap32(addr
);
1788 addr
= bswap64(addr
);
1798 case 0x10: // As if user primary
1799 case 0x18: // As if user primary LE
1800 case 0x80: // Primary
1801 case 0x88: // Primary LE
1802 if ((asi
& 0x80) && (env
->pstate
& PS_PRIV
)) {
1803 if (env
->hpstate
& HS_PRIV
) {
1806 stb_hypv(addr
, val
);
1809 stw_hypv(addr
& ~1, val
);
1812 stl_hypv(addr
& ~3, val
);
1816 stq_hypv(addr
& ~7, val
);
1822 stb_kernel(addr
, val
);
1825 stw_kernel(addr
& ~1, val
);
1828 stl_kernel(addr
& ~3, val
);
1832 stq_kernel(addr
& ~7, val
);
1839 stb_user(addr
, val
);
1842 stw_user(addr
& ~1, val
);
1845 stl_user(addr
& ~3, val
);
1849 stq_user(addr
& ~7, val
);
1854 case 0x14: // Bypass
1855 case 0x15: // Bypass, non-cacheable
1856 case 0x1c: // Bypass LE
1857 case 0x1d: // Bypass, non-cacheable LE
1861 stb_phys(addr
, val
);
1864 stw_phys(addr
& ~1, val
);
1867 stl_phys(addr
& ~3, val
);
1871 stq_phys(addr
& ~7, val
);
1876 case 0x04: // Nucleus
1877 case 0x0c: // Nucleus Little Endian (LE)
1878 case 0x11: // As if user secondary
1879 case 0x19: // As if user secondary LE
1880 case 0x24: // Nucleus quad LDD 128 bit atomic
1881 case 0x2c: // Nucleus quad LDD 128 bit atomic
1882 case 0x4a: // UPA config
1883 case 0x81: // Secondary
1884 case 0x89: // Secondary LE
1892 env
->lsu
= val
& (DMMU_E
| IMMU_E
);
1893 // Mappings generated during D/I MMU disabled mode are
1894 // invalid in normal mode
1895 if (oldreg
!= env
->lsu
) {
1896 DPRINTF_MMU("LSU change: 0x%" PRIx64
" -> 0x%" PRIx64
"\n",
1905 case 0x50: // I-MMU regs
1907 int reg
= (addr
>> 3) & 0xf;
1910 oldreg
= env
->immuregs
[reg
];
1915 case 1: // Not in I-MMU
1922 val
= 0; // Clear SFSR
1924 case 5: // TSB access
1925 case 6: // Tag access
1929 env
->immuregs
[reg
] = val
;
1930 if (oldreg
!= env
->immuregs
[reg
]) {
1931 DPRINTF_MMU("mmu change reg[%d]: 0x%08" PRIx64
" -> 0x%08"
1932 PRIx64
"\n", reg
, oldreg
, env
->immuregs
[reg
]);
1939 case 0x54: // I-MMU data in
1943 // Try finding an invalid entry
1944 for (i
= 0; i
< 64; i
++) {
1945 if ((env
->itlb_tte
[i
] & 0x8000000000000000ULL
) == 0) {
1946 env
->itlb_tag
[i
] = env
->immuregs
[6];
1947 env
->itlb_tte
[i
] = val
;
1951 // Try finding an unlocked entry
1952 for (i
= 0; i
< 64; i
++) {
1953 if ((env
->itlb_tte
[i
] & 0x40) == 0) {
1954 env
->itlb_tag
[i
] = env
->immuregs
[6];
1955 env
->itlb_tte
[i
] = val
;
1962 case 0x55: // I-MMU data access
1964 unsigned int i
= (addr
>> 3) & 0x3f;
1966 env
->itlb_tag
[i
] = env
->immuregs
[6];
1967 env
->itlb_tte
[i
] = val
;
1970 case 0x57: // I-MMU demap
1973 case 0x58: // D-MMU regs
1975 int reg
= (addr
>> 3) & 0xf;
1978 oldreg
= env
->dmmuregs
[reg
];
1984 if ((val
& 1) == 0) {
1985 val
= 0; // Clear SFSR, Fault address
1986 env
->dmmuregs
[4] = 0;
1988 env
->dmmuregs
[reg
] = val
;
1990 case 1: // Primary context
1991 case 2: // Secondary context
1992 case 5: // TSB access
1993 case 6: // Tag access
1994 case 7: // Virtual Watchpoint
1995 case 8: // Physical Watchpoint
1999 env
->dmmuregs
[reg
] = val
;
2000 if (oldreg
!= env
->dmmuregs
[reg
]) {
2001 DPRINTF_MMU("mmu change reg[%d]: 0x%08" PRIx64
" -> 0x%08"
2002 PRIx64
"\n", reg
, oldreg
, env
->dmmuregs
[reg
]);
2009 case 0x5c: // D-MMU data in
2013 // Try finding an invalid entry
2014 for (i
= 0; i
< 64; i
++) {
2015 if ((env
->dtlb_tte
[i
] & 0x8000000000000000ULL
) == 0) {
2016 env
->dtlb_tag
[i
] = env
->dmmuregs
[6];
2017 env
->dtlb_tte
[i
] = val
;
2021 // Try finding an unlocked entry
2022 for (i
= 0; i
< 64; i
++) {
2023 if ((env
->dtlb_tte
[i
] & 0x40) == 0) {
2024 env
->dtlb_tag
[i
] = env
->dmmuregs
[6];
2025 env
->dtlb_tte
[i
] = val
;
2032 case 0x5d: // D-MMU data access
2034 unsigned int i
= (addr
>> 3) & 0x3f;
2036 env
->dtlb_tag
[i
] = env
->dmmuregs
[6];
2037 env
->dtlb_tte
[i
] = val
;
2040 case 0x5f: // D-MMU demap
2041 case 0x49: // Interrupt data receive
2044 case 0x51: // I-MMU 8k TSB pointer, RO
2045 case 0x52: // I-MMU 64k TSB pointer, RO
2046 case 0x56: // I-MMU tag read, RO
2047 case 0x59: // D-MMU 8k TSB pointer, RO
2048 case 0x5a: // D-MMU 64k TSB pointer, RO
2049 case 0x5b: // D-MMU data pointer, RO
2050 case 0x5e: // D-MMU tag read, RO
2051 case 0x48: // Interrupt dispatch, RO
2052 case 0x7f: // Incoming interrupt vector, RO
2053 case 0x82: // Primary no-fault, RO
2054 case 0x83: // Secondary no-fault, RO
2055 case 0x8a: // Primary no-fault LE, RO
2056 case 0x8b: // Secondary no-fault LE, RO
2058 do_unassigned_access(addr
, 1, 0, 1);
2062 #endif /* CONFIG_USER_ONLY */
2064 void helper_ldf_asi(target_ulong addr
, int asi
, int size
, int rd
)
2069 helper_check_align(addr
, 3);
2071 case 0xf0: // Block load primary
2072 case 0xf1: // Block load secondary
2073 case 0xf8: // Block load primary LE
2074 case 0xf9: // Block load secondary LE
2076 raise_exception(TT_ILL_INSN
);
2079 helper_check_align(addr
, 0x3f);
2080 for (i
= 0; i
< 16; i
++) {
2081 *(uint32_t *)&env
->fpr
[rd
++] = helper_ld_asi(addr
, asi
& 0x8f, 4,
2091 val
= helper_ld_asi(addr
, asi
, size
, 0);
2095 *((uint32_t *)&FT0
) = val
;
2098 *((int64_t *)&DT0
) = val
;
2106 void helper_stf_asi(target_ulong addr
, int asi
, int size
, int rd
)
2109 target_ulong val
= 0;
2111 helper_check_align(addr
, 3);
2113 case 0xf0: // Block store primary
2114 case 0xf1: // Block store secondary
2115 case 0xf8: // Block store primary LE
2116 case 0xf9: // Block store secondary LE
2118 raise_exception(TT_ILL_INSN
);
2121 helper_check_align(addr
, 0x3f);
2122 for (i
= 0; i
< 16; i
++) {
2123 val
= *(uint32_t *)&env
->fpr
[rd
++];
2124 helper_st_asi(addr
, val
, asi
& 0x8f, 4);
2136 val
= *((uint32_t *)&FT0
);
2139 val
= *((int64_t *)&DT0
);
2145 helper_st_asi(addr
, val
, asi
, size
);
2148 target_ulong
helper_cas_asi(target_ulong addr
, target_ulong val1
,
2149 target_ulong val2
, uint32_t asi
)
2153 val1
&= 0xffffffffUL
;
2154 ret
= helper_ld_asi(addr
, asi
, 4, 0);
2155 ret
&= 0xffffffffUL
;
2157 helper_st_asi(addr
, val2
& 0xffffffffUL
, asi
, 4);
2161 target_ulong
helper_casx_asi(target_ulong addr
, target_ulong val1
,
2162 target_ulong val2
, uint32_t asi
)
2166 ret
= helper_ld_asi(addr
, asi
, 8, 0);
2168 helper_st_asi(addr
, val2
, asi
, 8);
2171 #endif /* TARGET_SPARC64 */
2173 #ifndef TARGET_SPARC64
2174 void helper_rett(void)
2178 if (env
->psret
== 1)
2179 raise_exception(TT_ILL_INSN
);
2182 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
2183 if (env
->wim
& (1 << cwp
)) {
2184 raise_exception(TT_WIN_UNF
);
2187 env
->psrs
= env
->psrps
;
2191 target_ulong
helper_udiv(target_ulong a
, target_ulong b
)
2196 x0
= a
| ((uint64_t) (env
->y
) << 32);
2200 raise_exception(TT_DIV_ZERO
);
2204 if (x0
> 0xffffffff) {
2213 target_ulong
helper_sdiv(target_ulong a
, target_ulong b
)
2218 x0
= a
| ((int64_t) (env
->y
) << 32);
2222 raise_exception(TT_DIV_ZERO
);
2226 if ((int32_t) x0
!= x0
) {
2228 return x0
< 0? 0x80000000: 0x7fffffff;
2235 uint64_t helper_pack64(target_ulong high
, target_ulong low
)
2237 return ((uint64_t)high
<< 32) | (uint64_t)(low
& 0xffffffff);
2240 void helper_stdf(target_ulong addr
, int mem_idx
)
2242 helper_check_align(addr
, 7);
2243 #if !defined(CONFIG_USER_ONLY)
2246 stfq_user(addr
, DT0
);
2249 stfq_kernel(addr
, DT0
);
2251 #ifdef TARGET_SPARC64
2253 stfq_hypv(addr
, DT0
);
2261 stfq_raw(addr
, DT0
);
2265 void helper_lddf(target_ulong addr
, int mem_idx
)
2267 helper_check_align(addr
, 7);
2268 #if !defined(CONFIG_USER_ONLY)
2271 DT0
= ldfq_user(addr
);
2274 DT0
= ldfq_kernel(addr
);
2276 #ifdef TARGET_SPARC64
2278 DT0
= ldfq_hypv(addr
);
2286 DT0
= ldfq_raw(addr
);
2290 void helper_ldqf(target_ulong addr
, int mem_idx
)
2292 // XXX add 128 bit load
2295 helper_check_align(addr
, 7);
2296 #if !defined(CONFIG_USER_ONLY)
2299 u
.ll
.upper
= ldq_user(addr
);
2300 u
.ll
.lower
= ldq_user(addr
+ 8);
2304 u
.ll
.upper
= ldq_kernel(addr
);
2305 u
.ll
.lower
= ldq_kernel(addr
+ 8);
2308 #ifdef TARGET_SPARC64
2310 u
.ll
.upper
= ldq_hypv(addr
);
2311 u
.ll
.lower
= ldq_hypv(addr
+ 8);
2320 u
.ll
.upper
= ldq_raw(addr
);
2321 u
.ll
.lower
= ldq_raw((addr
+ 8) & 0xffffffffULL
);
2326 void helper_stqf(target_ulong addr
, int mem_idx
)
2328 // XXX add 128 bit store
2331 helper_check_align(addr
, 7);
2332 #if !defined(CONFIG_USER_ONLY)
2336 stq_user(addr
, u
.ll
.upper
);
2337 stq_user(addr
+ 8, u
.ll
.lower
);
2341 stq_kernel(addr
, u
.ll
.upper
);
2342 stq_kernel(addr
+ 8, u
.ll
.lower
);
2344 #ifdef TARGET_SPARC64
2347 stq_hypv(addr
, u
.ll
.upper
);
2348 stq_hypv(addr
+ 8, u
.ll
.lower
);
2357 stq_raw(addr
, u
.ll
.upper
);
2358 stq_raw((addr
+ 8) & 0xffffffffULL
, u
.ll
.lower
);
2362 void helper_ldfsr(void)
2366 PUT_FSR32(env
, *((uint32_t *) &FT0
));
2367 switch (env
->fsr
& FSR_RD_MASK
) {
2368 case FSR_RD_NEAREST
:
2369 rnd_mode
= float_round_nearest_even
;
2373 rnd_mode
= float_round_to_zero
;
2376 rnd_mode
= float_round_up
;
2379 rnd_mode
= float_round_down
;
2382 set_float_rounding_mode(rnd_mode
, &env
->fp_status
);
2385 void helper_stfsr(void)
2387 *((uint32_t *) &FT0
) = GET_FSR32(env
);
2390 void helper_debug(void)
2392 env
->exception_index
= EXCP_DEBUG
;
2396 #ifndef TARGET_SPARC64
2397 /* XXX: use another pointer for %iN registers to avoid slow wrapping
2399 void helper_save(void)
2403 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
2404 if (env
->wim
& (1 << cwp
)) {
2405 raise_exception(TT_WIN_OVF
);
2410 void helper_restore(void)
2414 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
2415 if (env
->wim
& (1 << cwp
)) {
2416 raise_exception(TT_WIN_UNF
);
2421 void helper_wrpsr(target_ulong new_psr
)
2423 if ((new_psr
& PSR_CWP
) >= NWINDOWS
)
2424 raise_exception(TT_ILL_INSN
);
2426 PUT_PSR(env
, new_psr
);
2429 target_ulong
helper_rdpsr(void)
2431 return GET_PSR(env
);
2435 /* XXX: use another pointer for %iN registers to avoid slow wrapping
2437 void helper_save(void)
2441 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
2442 if (env
->cansave
== 0) {
2443 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
2444 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
2445 ((env
->wstate
& 0x7) << 2)));
2447 if (env
->cleanwin
- env
->canrestore
== 0) {
2448 // XXX Clean windows without trap
2449 raise_exception(TT_CLRWIN
);
2458 void helper_restore(void)
2462 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
2463 if (env
->canrestore
== 0) {
2464 raise_exception(TT_FILL
| (env
->otherwin
!= 0 ?
2465 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
2466 ((env
->wstate
& 0x7) << 2)));
2474 void helper_flushw(void)
2476 if (env
->cansave
!= NWINDOWS
- 2) {
2477 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
2478 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
2479 ((env
->wstate
& 0x7) << 2)));
2483 void helper_saved(void)
2486 if (env
->otherwin
== 0)
2492 void helper_restored(void)
2495 if (env
->cleanwin
< NWINDOWS
- 1)
2497 if (env
->otherwin
== 0)
2503 target_ulong
helper_rdccr(void)
2505 return GET_CCR(env
);
2508 void helper_wrccr(target_ulong new_ccr
)
2510 PUT_CCR(env
, new_ccr
);
2513 // CWP handling is reversed in V9, but we still use the V8 register
2515 target_ulong
helper_rdcwp(void)
2517 return GET_CWP64(env
);
2520 void helper_wrcwp(target_ulong new_cwp
)
2522 PUT_CWP64(env
, new_cwp
);
2525 // This function uses non-native bit order
2526 #define GET_FIELD(X, FROM, TO) \
2527 ((X) >> (63 - (TO)) & ((1ULL << ((TO) - (FROM) + 1)) - 1))
2529 // This function uses the order in the manuals, i.e. bit 0 is 2^0
2530 #define GET_FIELD_SP(X, FROM, TO) \
2531 GET_FIELD(X, 63 - (TO), 63 - (FROM))
2533 target_ulong
helper_array8(target_ulong pixel_addr
, target_ulong cubesize
)
2535 return (GET_FIELD_SP(pixel_addr
, 60, 63) << (17 + 2 * cubesize
)) |
2536 (GET_FIELD_SP(pixel_addr
, 39, 39 + cubesize
- 1) << (17 + cubesize
)) |
2537 (GET_FIELD_SP(pixel_addr
, 17 + cubesize
- 1, 17) << 17) |
2538 (GET_FIELD_SP(pixel_addr
, 56, 59) << 13) |
2539 (GET_FIELD_SP(pixel_addr
, 35, 38) << 9) |
2540 (GET_FIELD_SP(pixel_addr
, 13, 16) << 5) |
2541 (((pixel_addr
>> 55) & 1) << 4) |
2542 (GET_FIELD_SP(pixel_addr
, 33, 34) << 2) |
2543 GET_FIELD_SP(pixel_addr
, 11, 12);
2546 target_ulong
helper_alignaddr(target_ulong addr
, target_ulong offset
)
2550 tmp
= addr
+ offset
;
2552 env
->gsr
|= tmp
& 7ULL;
2556 target_ulong
helper_popc(target_ulong val
)
2558 return ctpop64(val
);
2561 static inline uint64_t *get_gregset(uint64_t pstate
)
2576 static inline void change_pstate(uint64_t new_pstate
)
2578 uint64_t pstate_regs
, new_pstate_regs
;
2579 uint64_t *src
, *dst
;
2581 pstate_regs
= env
->pstate
& 0xc01;
2582 new_pstate_regs
= new_pstate
& 0xc01;
2583 if (new_pstate_regs
!= pstate_regs
) {
2584 // Switch global register bank
2585 src
= get_gregset(new_pstate_regs
);
2586 dst
= get_gregset(pstate_regs
);
2587 memcpy32(dst
, env
->gregs
);
2588 memcpy32(env
->gregs
, src
);
2590 env
->pstate
= new_pstate
;
2593 void helper_wrpstate(target_ulong new_state
)
2595 change_pstate(new_state
& 0xf3f);
2598 void helper_done(void)
2601 env
->tsptr
= &env
->ts
[env
->tl
];
2602 env
->pc
= env
->tsptr
->tpc
;
2603 env
->npc
= env
->tsptr
->tnpc
+ 4;
2604 PUT_CCR(env
, env
->tsptr
->tstate
>> 32);
2605 env
->asi
= (env
->tsptr
->tstate
>> 24) & 0xff;
2606 change_pstate((env
->tsptr
->tstate
>> 8) & 0xf3f);
2607 PUT_CWP64(env
, env
->tsptr
->tstate
& 0xff);
2610 void helper_retry(void)
2613 env
->tsptr
= &env
->ts
[env
->tl
];
2614 env
->pc
= env
->tsptr
->tpc
;
2615 env
->npc
= env
->tsptr
->tnpc
;
2616 PUT_CCR(env
, env
->tsptr
->tstate
>> 32);
2617 env
->asi
= (env
->tsptr
->tstate
>> 24) & 0xff;
2618 change_pstate((env
->tsptr
->tstate
>> 8) & 0xf3f);
2619 PUT_CWP64(env
, env
->tsptr
->tstate
& 0xff);
2623 void set_cwp(int new_cwp
)
2625 /* put the modified wrap registers at their proper location */
2626 if (env
->cwp
== (NWINDOWS
- 1))
2627 memcpy32(env
->regbase
, env
->regbase
+ NWINDOWS
* 16);
2629 /* put the wrap registers at their temporary location */
2630 if (new_cwp
== (NWINDOWS
- 1))
2631 memcpy32(env
->regbase
+ NWINDOWS
* 16, env
->regbase
);
2632 env
->regwptr
= env
->regbase
+ (new_cwp
* 16);
2633 REGWPTR
= env
->regwptr
;
2636 void cpu_set_cwp(CPUState
*env1
, int new_cwp
)
2638 CPUState
*saved_env
;
2640 target_ulong
*saved_regwptr
;
2645 saved_regwptr
= REGWPTR
;
2651 REGWPTR
= saved_regwptr
;
2655 #ifdef TARGET_SPARC64
2657 static const char * const excp_names
[0x50] = {
2658 [TT_TFAULT
] = "Instruction Access Fault",
2659 [TT_TMISS
] = "Instruction Access MMU Miss",
2660 [TT_CODE_ACCESS
] = "Instruction Access Error",
2661 [TT_ILL_INSN
] = "Illegal Instruction",
2662 [TT_PRIV_INSN
] = "Privileged Instruction",
2663 [TT_NFPU_INSN
] = "FPU Disabled",
2664 [TT_FP_EXCP
] = "FPU Exception",
2665 [TT_TOVF
] = "Tag Overflow",
2666 [TT_CLRWIN
] = "Clean Windows",
2667 [TT_DIV_ZERO
] = "Division By Zero",
2668 [TT_DFAULT
] = "Data Access Fault",
2669 [TT_DMISS
] = "Data Access MMU Miss",
2670 [TT_DATA_ACCESS
] = "Data Access Error",
2671 [TT_DPROT
] = "Data Protection Error",
2672 [TT_UNALIGNED
] = "Unaligned Memory Access",
2673 [TT_PRIV_ACT
] = "Privileged Action",
2674 [TT_EXTINT
| 0x1] = "External Interrupt 1",
2675 [TT_EXTINT
| 0x2] = "External Interrupt 2",
2676 [TT_EXTINT
| 0x3] = "External Interrupt 3",
2677 [TT_EXTINT
| 0x4] = "External Interrupt 4",
2678 [TT_EXTINT
| 0x5] = "External Interrupt 5",
2679 [TT_EXTINT
| 0x6] = "External Interrupt 6",
2680 [TT_EXTINT
| 0x7] = "External Interrupt 7",
2681 [TT_EXTINT
| 0x8] = "External Interrupt 8",
2682 [TT_EXTINT
| 0x9] = "External Interrupt 9",
2683 [TT_EXTINT
| 0xa] = "External Interrupt 10",
2684 [TT_EXTINT
| 0xb] = "External Interrupt 11",
2685 [TT_EXTINT
| 0xc] = "External Interrupt 12",
2686 [TT_EXTINT
| 0xd] = "External Interrupt 13",
2687 [TT_EXTINT
| 0xe] = "External Interrupt 14",
2688 [TT_EXTINT
| 0xf] = "External Interrupt 15",
2692 void do_interrupt(int intno
)
2695 if (loglevel
& CPU_LOG_INT
) {
2699 if (intno
< 0 || intno
>= 0x180 || (intno
> 0x4f && intno
< 0x80))
2701 else if (intno
>= 0x100)
2702 name
= "Trap Instruction";
2703 else if (intno
>= 0xc0)
2704 name
= "Window Fill";
2705 else if (intno
>= 0x80)
2706 name
= "Window Spill";
2708 name
= excp_names
[intno
];
2713 fprintf(logfile
, "%6d: %s (v=%04x) pc=%016" PRIx64
" npc=%016" PRIx64
2714 " SP=%016" PRIx64
"\n",
2717 env
->npc
, env
->regwptr
[6]);
2718 cpu_dump_state(env
, logfile
, fprintf
, 0);
2724 fprintf(logfile
, " code=");
2725 ptr
= (uint8_t *)env
->pc
;
2726 for(i
= 0; i
< 16; i
++) {
2727 fprintf(logfile
, " %02x", ldub(ptr
+ i
));
2729 fprintf(logfile
, "\n");
2735 #if !defined(CONFIG_USER_ONLY)
2736 if (env
->tl
== MAXTL
) {
2737 cpu_abort(env
, "Trap 0x%04x while trap level is MAXTL, Error state",
2738 env
->exception_index
);
2742 env
->tsptr
->tstate
= ((uint64_t)GET_CCR(env
) << 32) |
2743 ((env
->asi
& 0xff) << 24) | ((env
->pstate
& 0xf3f) << 8) |
2745 env
->tsptr
->tpc
= env
->pc
;
2746 env
->tsptr
->tnpc
= env
->npc
;
2747 env
->tsptr
->tt
= intno
;
2748 change_pstate(PS_PEF
| PS_PRIV
| PS_AG
);
2750 if (intno
== TT_CLRWIN
)
2751 set_cwp((env
->cwp
- 1) & (NWINDOWS
- 1));
2752 else if ((intno
& 0x1c0) == TT_SPILL
)
2753 set_cwp((env
->cwp
- env
->cansave
- 2) & (NWINDOWS
- 1));
2754 else if ((intno
& 0x1c0) == TT_FILL
)
2755 set_cwp((env
->cwp
+ 1) & (NWINDOWS
- 1));
2756 env
->tbr
&= ~0x7fffULL
;
2757 env
->tbr
|= ((env
->tl
> 1) ? 1 << 14 : 0) | (intno
<< 5);
2758 if (env
->tl
< MAXTL
- 1) {
2761 env
->pstate
|= PS_RED
;
2762 if (env
->tl
!= MAXTL
)
2765 env
->tsptr
= &env
->ts
[env
->tl
];
2767 env
->npc
= env
->pc
+ 4;
2768 env
->exception_index
= 0;
2772 static const char * const excp_names
[0x80] = {
2773 [TT_TFAULT
] = "Instruction Access Fault",
2774 [TT_ILL_INSN
] = "Illegal Instruction",
2775 [TT_PRIV_INSN
] = "Privileged Instruction",
2776 [TT_NFPU_INSN
] = "FPU Disabled",
2777 [TT_WIN_OVF
] = "Window Overflow",
2778 [TT_WIN_UNF
] = "Window Underflow",
2779 [TT_UNALIGNED
] = "Unaligned Memory Access",
2780 [TT_FP_EXCP
] = "FPU Exception",
2781 [TT_DFAULT
] = "Data Access Fault",
2782 [TT_TOVF
] = "Tag Overflow",
2783 [TT_EXTINT
| 0x1] = "External Interrupt 1",
2784 [TT_EXTINT
| 0x2] = "External Interrupt 2",
2785 [TT_EXTINT
| 0x3] = "External Interrupt 3",
2786 [TT_EXTINT
| 0x4] = "External Interrupt 4",
2787 [TT_EXTINT
| 0x5] = "External Interrupt 5",
2788 [TT_EXTINT
| 0x6] = "External Interrupt 6",
2789 [TT_EXTINT
| 0x7] = "External Interrupt 7",
2790 [TT_EXTINT
| 0x8] = "External Interrupt 8",
2791 [TT_EXTINT
| 0x9] = "External Interrupt 9",
2792 [TT_EXTINT
| 0xa] = "External Interrupt 10",
2793 [TT_EXTINT
| 0xb] = "External Interrupt 11",
2794 [TT_EXTINT
| 0xc] = "External Interrupt 12",
2795 [TT_EXTINT
| 0xd] = "External Interrupt 13",
2796 [TT_EXTINT
| 0xe] = "External Interrupt 14",
2797 [TT_EXTINT
| 0xf] = "External Interrupt 15",
2798 [TT_TOVF
] = "Tag Overflow",
2799 [TT_CODE_ACCESS
] = "Instruction Access Error",
2800 [TT_DATA_ACCESS
] = "Data Access Error",
2801 [TT_DIV_ZERO
] = "Division By Zero",
2802 [TT_NCP_INSN
] = "Coprocessor Disabled",
2806 void do_interrupt(int intno
)
2811 if (loglevel
& CPU_LOG_INT
) {
2815 if (intno
< 0 || intno
>= 0x100)
2817 else if (intno
>= 0x80)
2818 name
= "Trap Instruction";
2820 name
= excp_names
[intno
];
2825 fprintf(logfile
, "%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n",
2828 env
->npc
, env
->regwptr
[6]);
2829 cpu_dump_state(env
, logfile
, fprintf
, 0);
2835 fprintf(logfile
, " code=");
2836 ptr
= (uint8_t *)env
->pc
;
2837 for(i
= 0; i
< 16; i
++) {
2838 fprintf(logfile
, " %02x", ldub(ptr
+ i
));
2840 fprintf(logfile
, "\n");
2846 #if !defined(CONFIG_USER_ONLY)
2847 if (env
->psret
== 0) {
2848 cpu_abort(env
, "Trap 0x%02x while interrupts disabled, Error state",
2849 env
->exception_index
);
2854 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
2856 env
->regwptr
[9] = env
->pc
;
2857 env
->regwptr
[10] = env
->npc
;
2858 env
->psrps
= env
->psrs
;
2860 env
->tbr
= (env
->tbr
& TBR_BASE_MASK
) | (intno
<< 4);
2862 env
->npc
= env
->pc
+ 4;
2863 env
->exception_index
= 0;
2867 #if !defined(CONFIG_USER_ONLY)
2869 static void do_unaligned_access(target_ulong addr
, int is_write
, int is_user
,
2872 #define MMUSUFFIX _mmu
2873 #define ALIGNED_ONLY
2875 # define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & \
2878 # define GETPC() (__builtin_return_address(0))
2882 #include "softmmu_template.h"
2885 #include "softmmu_template.h"
2888 #include "softmmu_template.h"
2891 #include "softmmu_template.h"
2893 /* XXX: make it generic ? */
2894 static void cpu_restore_state2(void *retaddr
)
2896 TranslationBlock
*tb
;
2900 /* now we have a real cpu fault */
2901 pc
= (unsigned long)retaddr
;
2902 tb
= tb_find_pc(pc
);
2904 /* the PC is inside the translated code. It means that we have
2905 a virtual CPU fault */
2906 cpu_restore_state(tb
, env
, pc
, (void *)(long)env
->cond
);
2911 static void do_unaligned_access(target_ulong addr
, int is_write
, int is_user
,
2914 #ifdef DEBUG_UNALIGNED
2915 printf("Unaligned access to 0x" TARGET_FMT_lx
" from 0x" TARGET_FMT_lx
2916 "\n", addr
, env
->pc
);
2918 cpu_restore_state2(retaddr
);
2919 raise_exception(TT_UNALIGNED
);
2922 /* try to fill the TLB and return an exception if error. If retaddr is
2923 NULL, it means that the function was called in C code (i.e. not
2924 from generated code or from helper.c) */
2925 /* XXX: fix it to restore all registers */
2926 void tlb_fill(target_ulong addr
, int is_write
, int mmu_idx
, void *retaddr
)
2929 CPUState
*saved_env
;
2931 /* XXX: hack to restore env in all cases, even if not called from
2934 env
= cpu_single_env
;
2936 ret
= cpu_sparc_handle_mmu_fault(env
, addr
, is_write
, mmu_idx
, 1);
2938 cpu_restore_state2(retaddr
);
2946 #ifndef TARGET_SPARC64
2947 void do_unassigned_access(target_phys_addr_t addr
, int is_write
, int is_exec
,
2950 CPUState
*saved_env
;
2952 /* XXX: hack to restore env in all cases, even if not called from
2955 env
= cpu_single_env
;
2956 #ifdef DEBUG_UNASSIGNED
2958 printf("Unassigned mem %s access to " TARGET_FMT_plx
2959 " asi 0x%02x from " TARGET_FMT_lx
"\n",
2960 is_exec
? "exec" : is_write
? "write" : "read", addr
, is_asi
,
2963 printf("Unassigned mem %s access to " TARGET_FMT_plx
" from "
2965 is_exec
? "exec" : is_write
? "write" : "read", addr
, env
->pc
);
2967 if (env
->mmuregs
[3]) /* Fault status register */
2968 env
->mmuregs
[3] = 1; /* overflow (not read before another fault) */
2970 env
->mmuregs
[3] |= 1 << 16;
2972 env
->mmuregs
[3] |= 1 << 5;
2974 env
->mmuregs
[3] |= 1 << 6;
2976 env
->mmuregs
[3] |= 1 << 7;
2977 env
->mmuregs
[3] |= (5 << 2) | 2;
2978 env
->mmuregs
[4] = addr
; /* Fault address register */
2979 if ((env
->mmuregs
[0] & MMU_E
) && !(env
->mmuregs
[0] & MMU_NF
)) {
2981 raise_exception(TT_CODE_ACCESS
);
2983 raise_exception(TT_DATA_ACCESS
);
2988 void do_unassigned_access(target_phys_addr_t addr
, int is_write
, int is_exec
,
2991 #ifdef DEBUG_UNASSIGNED
2992 CPUState
*saved_env
;
2994 /* XXX: hack to restore env in all cases, even if not called from
2997 env
= cpu_single_env
;
2998 printf("Unassigned mem access to " TARGET_FMT_plx
" from " TARGET_FMT_lx
2999 "\n", addr
, env
->pc
);
3003 raise_exception(TT_CODE_ACCESS
);
3005 raise_exception(TT_DATA_ACCESS
);