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)
36 void raise_exception(int tt
)
38 env
->exception_index
= tt
;
42 void helper_trap(target_ulong nb_trap
)
44 env
->exception_index
= TT_TRAP
+ (nb_trap
& 0x7f);
48 void helper_trapcc(target_ulong nb_trap
, target_ulong do_trap
)
51 env
->exception_index
= TT_TRAP
+ (nb_trap
& 0x7f);
56 void helper_check_align(target_ulong addr
, uint32_t align
)
59 raise_exception(TT_UNALIGNED
);
62 #define F_HELPER(name, p) void helper_f##name##p(void)
64 #define F_BINOP(name) \
67 FT0 = float32_ ## name (FT0, FT1, &env->fp_status); \
71 DT0 = float64_ ## name (DT0, DT1, &env->fp_status); \
75 QT0 = float128_ ## name (QT0, QT1, &env->fp_status); \
84 void helper_fsmuld(void)
86 DT0
= float64_mul(float32_to_float64(FT0
, &env
->fp_status
),
87 float32_to_float64(FT1
, &env
->fp_status
),
91 void helper_fdmulq(void)
93 QT0
= float128_mul(float64_to_float128(DT0
, &env
->fp_status
),
94 float64_to_float128(DT1
, &env
->fp_status
),
100 FT0
= float32_chs(FT1
);
103 #ifdef TARGET_SPARC64
106 DT0
= float64_chs(DT1
);
111 QT0
= float128_chs(QT1
);
115 /* Integer to float conversion. */
118 FT0
= int32_to_float32(*((int32_t *)&FT1
), &env
->fp_status
);
123 DT0
= int32_to_float64(*((int32_t *)&FT1
), &env
->fp_status
);
128 QT0
= int32_to_float128(*((int32_t *)&FT1
), &env
->fp_status
);
131 #ifdef TARGET_SPARC64
134 FT0
= int64_to_float32(*((int64_t *)&DT1
), &env
->fp_status
);
139 DT0
= int64_to_float64(*((int64_t *)&DT1
), &env
->fp_status
);
144 QT0
= int64_to_float128(*((int64_t *)&DT1
), &env
->fp_status
);
149 /* floating point conversion */
150 void helper_fdtos(void)
152 FT0
= float64_to_float32(DT1
, &env
->fp_status
);
155 void helper_fstod(void)
157 DT0
= float32_to_float64(FT1
, &env
->fp_status
);
160 void helper_fqtos(void)
162 FT0
= float128_to_float32(QT1
, &env
->fp_status
);
165 void helper_fstoq(void)
167 QT0
= float32_to_float128(FT1
, &env
->fp_status
);
170 void helper_fqtod(void)
172 DT0
= float128_to_float64(QT1
, &env
->fp_status
);
175 void helper_fdtoq(void)
177 QT0
= float64_to_float128(DT1
, &env
->fp_status
);
180 /* Float to integer conversion. */
181 void helper_fstoi(void)
183 *((int32_t *)&FT0
) = float32_to_int32_round_to_zero(FT1
, &env
->fp_status
);
186 void helper_fdtoi(void)
188 *((int32_t *)&FT0
) = float64_to_int32_round_to_zero(DT1
, &env
->fp_status
);
191 void helper_fqtoi(void)
193 *((int32_t *)&FT0
) = float128_to_int32_round_to_zero(QT1
, &env
->fp_status
);
196 #ifdef TARGET_SPARC64
197 void helper_fstox(void)
199 *((int64_t *)&DT0
) = float32_to_int64_round_to_zero(FT1
, &env
->fp_status
);
202 void helper_fdtox(void)
204 *((int64_t *)&DT0
) = float64_to_int64_round_to_zero(DT1
, &env
->fp_status
);
207 void helper_fqtox(void)
209 *((int64_t *)&DT0
) = float128_to_int64_round_to_zero(QT1
, &env
->fp_status
);
212 void helper_faligndata(void)
216 tmp
= (*((uint64_t *)&DT0
)) << ((env
->gsr
& 7) * 8);
217 tmp
|= (*((uint64_t *)&DT1
)) >> (64 - (env
->gsr
& 7) * 8);
218 *((uint64_t *)&DT0
) = tmp
;
221 void helper_movl_FT0_0(void)
223 *((uint32_t *)&FT0
) = 0;
226 void helper_movl_DT0_0(void)
228 *((uint64_t *)&DT0
) = 0;
231 void helper_movl_FT0_1(void)
233 *((uint32_t *)&FT0
) = 0xffffffff;
236 void helper_movl_DT0_1(void)
238 *((uint64_t *)&DT0
) = 0xffffffffffffffffULL
;
241 void helper_fnot(void)
243 *(uint64_t *)&DT0
= ~*(uint64_t *)&DT1
;
246 void helper_fnots(void)
248 *(uint32_t *)&FT0
= ~*(uint32_t *)&FT1
;
251 void helper_fnor(void)
253 *(uint64_t *)&DT0
= ~(*(uint64_t *)&DT0
| *(uint64_t *)&DT1
);
256 void helper_fnors(void)
258 *(uint32_t *)&FT0
= ~(*(uint32_t *)&FT0
| *(uint32_t *)&FT1
);
261 void helper_for(void)
263 *(uint64_t *)&DT0
|= *(uint64_t *)&DT1
;
266 void helper_fors(void)
268 *(uint32_t *)&FT0
|= *(uint32_t *)&FT1
;
271 void helper_fxor(void)
273 *(uint64_t *)&DT0
^= *(uint64_t *)&DT1
;
276 void helper_fxors(void)
278 *(uint32_t *)&FT0
^= *(uint32_t *)&FT1
;
281 void helper_fand(void)
283 *(uint64_t *)&DT0
&= *(uint64_t *)&DT1
;
286 void helper_fands(void)
288 *(uint32_t *)&FT0
&= *(uint32_t *)&FT1
;
291 void helper_fornot(void)
293 *(uint64_t *)&DT0
= *(uint64_t *)&DT0
| ~*(uint64_t *)&DT1
;
296 void helper_fornots(void)
298 *(uint32_t *)&FT0
= *(uint32_t *)&FT0
| ~*(uint32_t *)&FT1
;
301 void helper_fandnot(void)
303 *(uint64_t *)&DT0
= *(uint64_t *)&DT0
& ~*(uint64_t *)&DT1
;
306 void helper_fandnots(void)
308 *(uint32_t *)&FT0
= *(uint32_t *)&FT0
& ~*(uint32_t *)&FT1
;
311 void helper_fnand(void)
313 *(uint64_t *)&DT0
= ~(*(uint64_t *)&DT0
& *(uint64_t *)&DT1
);
316 void helper_fnands(void)
318 *(uint32_t *)&FT0
= ~(*(uint32_t *)&FT0
& *(uint32_t *)&FT1
);
321 void helper_fxnor(void)
323 *(uint64_t *)&DT0
^= ~*(uint64_t *)&DT1
;
326 void helper_fxnors(void)
328 *(uint32_t *)&FT0
^= ~*(uint32_t *)&FT1
;
331 #ifdef WORDS_BIGENDIAN
332 #define VIS_B64(n) b[7 - (n)]
333 #define VIS_W64(n) w[3 - (n)]
334 #define VIS_SW64(n) sw[3 - (n)]
335 #define VIS_L64(n) l[1 - (n)]
336 #define VIS_B32(n) b[3 - (n)]
337 #define VIS_W32(n) w[1 - (n)]
339 #define VIS_B64(n) b[n]
340 #define VIS_W64(n) w[n]
341 #define VIS_SW64(n) sw[n]
342 #define VIS_L64(n) l[n]
343 #define VIS_B32(n) b[n]
344 #define VIS_W32(n) w[n]
362 void helper_fpmerge(void)
369 // Reverse calculation order to handle overlap
370 d
.VIS_B64(7) = s
.VIS_B64(3);
371 d
.VIS_B64(6) = d
.VIS_B64(3);
372 d
.VIS_B64(5) = s
.VIS_B64(2);
373 d
.VIS_B64(4) = d
.VIS_B64(2);
374 d
.VIS_B64(3) = s
.VIS_B64(1);
375 d
.VIS_B64(2) = d
.VIS_B64(1);
376 d
.VIS_B64(1) = s
.VIS_B64(0);
377 //d.VIS_B64(0) = d.VIS_B64(0);
382 void helper_fmul8x16(void)
391 tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B64(r); \
392 if ((tmp & 0xff) > 0x7f) \
394 d.VIS_W64(r) = tmp >> 8;
405 void helper_fmul8x16al(void)
414 tmp = (int32_t)d.VIS_SW64(1) * (int32_t)s.VIS_B64(r); \
415 if ((tmp & 0xff) > 0x7f) \
417 d.VIS_W64(r) = tmp >> 8;
428 void helper_fmul8x16au(void)
437 tmp = (int32_t)d.VIS_SW64(0) * (int32_t)s.VIS_B64(r); \
438 if ((tmp & 0xff) > 0x7f) \
440 d.VIS_W64(r) = tmp >> 8;
451 void helper_fmul8sux16(void)
460 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
461 if ((tmp & 0xff) > 0x7f) \
463 d.VIS_W64(r) = tmp >> 8;
474 void helper_fmul8ulx16(void)
483 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
484 if ((tmp & 0xff) > 0x7f) \
486 d.VIS_W64(r) = tmp >> 8;
497 void helper_fmuld8sux16(void)
506 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
507 if ((tmp & 0xff) > 0x7f) \
511 // Reverse calculation order to handle overlap
519 void helper_fmuld8ulx16(void)
528 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
529 if ((tmp & 0xff) > 0x7f) \
533 // Reverse calculation order to handle overlap
541 void helper_fexpand(void)
546 s
.l
= (uint32_t)(*(uint64_t *)&DT0
& 0xffffffff);
548 d
.VIS_L64(0) = s
.VIS_W32(0) << 4;
549 d
.VIS_L64(1) = s
.VIS_W32(1) << 4;
550 d
.VIS_L64(2) = s
.VIS_W32(2) << 4;
551 d
.VIS_L64(3) = s
.VIS_W32(3) << 4;
556 #define VIS_HELPER(name, F) \
557 void name##16(void) \
564 d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0)); \
565 d.VIS_W64(1) = F(d.VIS_W64(1), s.VIS_W64(1)); \
566 d.VIS_W64(2) = F(d.VIS_W64(2), s.VIS_W64(2)); \
567 d.VIS_W64(3) = F(d.VIS_W64(3), s.VIS_W64(3)); \
572 void name##16s(void) \
579 d.VIS_W32(0) = F(d.VIS_W32(0), s.VIS_W32(0)); \
580 d.VIS_W32(1) = F(d.VIS_W32(1), s.VIS_W32(1)); \
585 void name##32(void) \
592 d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0)); \
593 d.VIS_L64(1) = F(d.VIS_L64(1), s.VIS_L64(1)); \
598 void name##32s(void) \
610 #define FADD(a, b) ((a) + (b))
611 #define FSUB(a, b) ((a) - (b))
612 VIS_HELPER(helper_fpadd
, FADD
)
613 VIS_HELPER(helper_fpsub
, FSUB
)
615 #define VIS_CMPHELPER(name, F) \
616 void name##16(void) \
623 d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0))? 1: 0; \
624 d.VIS_W64(0) |= F(d.VIS_W64(1), s.VIS_W64(1))? 2: 0; \
625 d.VIS_W64(0) |= F(d.VIS_W64(2), s.VIS_W64(2))? 4: 0; \
626 d.VIS_W64(0) |= F(d.VIS_W64(3), s.VIS_W64(3))? 8: 0; \
631 void name##32(void) \
638 d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0))? 1: 0; \
639 d.VIS_L64(0) |= F(d.VIS_L64(1), s.VIS_L64(1))? 2: 0; \
644 #define FCMPGT(a, b) ((a) > (b))
645 #define FCMPEQ(a, b) ((a) == (b))
646 #define FCMPLE(a, b) ((a) <= (b))
647 #define FCMPNE(a, b) ((a) != (b))
649 VIS_CMPHELPER(helper_fcmpgt
, FCMPGT
)
650 VIS_CMPHELPER(helper_fcmpeq
, FCMPEQ
)
651 VIS_CMPHELPER(helper_fcmple
, FCMPLE
)
652 VIS_CMPHELPER(helper_fcmpne
, FCMPNE
)
655 void helper_check_ieee_exceptions(void)
659 status
= get_float_exception_flags(&env
->fp_status
);
661 /* Copy IEEE 754 flags into FSR */
662 if (status
& float_flag_invalid
)
664 if (status
& float_flag_overflow
)
666 if (status
& float_flag_underflow
)
668 if (status
& float_flag_divbyzero
)
670 if (status
& float_flag_inexact
)
673 if ((env
->fsr
& FSR_CEXC_MASK
) & ((env
->fsr
& FSR_TEM_MASK
) >> 23)) {
674 /* Unmasked exception, generate a trap */
675 env
->fsr
|= FSR_FTT_IEEE_EXCP
;
676 raise_exception(TT_FP_EXCP
);
678 /* Accumulate exceptions */
679 env
->fsr
|= (env
->fsr
& FSR_CEXC_MASK
) << 5;
684 void helper_clear_float_exceptions(void)
686 set_float_exception_flags(0, &env
->fp_status
);
689 void helper_fabss(void)
691 FT0
= float32_abs(FT1
);
694 #ifdef TARGET_SPARC64
695 void helper_fabsd(void)
697 DT0
= float64_abs(DT1
);
700 void helper_fabsq(void)
702 QT0
= float128_abs(QT1
);
706 void helper_fsqrts(void)
708 FT0
= float32_sqrt(FT1
, &env
->fp_status
);
711 void helper_fsqrtd(void)
713 DT0
= float64_sqrt(DT1
, &env
->fp_status
);
716 void helper_fsqrtq(void)
718 QT0
= float128_sqrt(QT1
, &env
->fp_status
);
721 #define GEN_FCMP(name, size, reg1, reg2, FS, TRAP) \
722 void glue(helper_, name) (void) \
724 target_ulong new_fsr; \
726 env->fsr &= ~((FSR_FCC1 | FSR_FCC0) << FS); \
727 switch (glue(size, _compare) (reg1, reg2, &env->fp_status)) { \
728 case float_relation_unordered: \
729 new_fsr = (FSR_FCC1 | FSR_FCC0) << FS; \
730 if ((env->fsr & FSR_NVM) || TRAP) { \
731 env->fsr |= new_fsr; \
732 env->fsr |= FSR_NVC; \
733 env->fsr |= FSR_FTT_IEEE_EXCP; \
734 raise_exception(TT_FP_EXCP); \
736 env->fsr |= FSR_NVA; \
739 case float_relation_less: \
740 new_fsr = FSR_FCC0 << FS; \
742 case float_relation_greater: \
743 new_fsr = FSR_FCC1 << FS; \
749 env->fsr |= new_fsr; \
752 GEN_FCMP(fcmps
, float32
, FT0
, FT1
, 0, 0);
753 GEN_FCMP(fcmpd
, float64
, DT0
, DT1
, 0, 0);
755 GEN_FCMP(fcmpes
, float32
, FT0
, FT1
, 0, 1);
756 GEN_FCMP(fcmped
, float64
, DT0
, DT1
, 0, 1);
758 GEN_FCMP(fcmpq
, float128
, QT0
, QT1
, 0, 0);
759 GEN_FCMP(fcmpeq
, float128
, QT0
, QT1
, 0, 1);
761 #ifdef TARGET_SPARC64
762 GEN_FCMP(fcmps_fcc1
, float32
, FT0
, FT1
, 22, 0);
763 GEN_FCMP(fcmpd_fcc1
, float64
, DT0
, DT1
, 22, 0);
764 GEN_FCMP(fcmpq_fcc1
, float128
, QT0
, QT1
, 22, 0);
766 GEN_FCMP(fcmps_fcc2
, float32
, FT0
, FT1
, 24, 0);
767 GEN_FCMP(fcmpd_fcc2
, float64
, DT0
, DT1
, 24, 0);
768 GEN_FCMP(fcmpq_fcc2
, float128
, QT0
, QT1
, 24, 0);
770 GEN_FCMP(fcmps_fcc3
, float32
, FT0
, FT1
, 26, 0);
771 GEN_FCMP(fcmpd_fcc3
, float64
, DT0
, DT1
, 26, 0);
772 GEN_FCMP(fcmpq_fcc3
, float128
, QT0
, QT1
, 26, 0);
774 GEN_FCMP(fcmpes_fcc1
, float32
, FT0
, FT1
, 22, 1);
775 GEN_FCMP(fcmped_fcc1
, float64
, DT0
, DT1
, 22, 1);
776 GEN_FCMP(fcmpeq_fcc1
, float128
, QT0
, QT1
, 22, 1);
778 GEN_FCMP(fcmpes_fcc2
, float32
, FT0
, FT1
, 24, 1);
779 GEN_FCMP(fcmped_fcc2
, float64
, DT0
, DT1
, 24, 1);
780 GEN_FCMP(fcmpeq_fcc2
, float128
, QT0
, QT1
, 24, 1);
782 GEN_FCMP(fcmpes_fcc3
, float32
, FT0
, FT1
, 26, 1);
783 GEN_FCMP(fcmped_fcc3
, float64
, DT0
, DT1
, 26, 1);
784 GEN_FCMP(fcmpeq_fcc3
, float128
, QT0
, QT1
, 26, 1);
787 #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) && defined(DEBUG_MXCC)
788 static void dump_mxcc(CPUState
*env
)
790 printf("mxccdata: %016llx %016llx %016llx %016llx\n",
791 env
->mxccdata
[0], env
->mxccdata
[1], env
->mxccdata
[2], env
->mxccdata
[3]);
792 printf("mxccregs: %016llx %016llx %016llx %016llx\n"
793 " %016llx %016llx %016llx %016llx\n",
794 env
->mxccregs
[0], env
->mxccregs
[1], env
->mxccregs
[2], env
->mxccregs
[3],
795 env
->mxccregs
[4], env
->mxccregs
[5], env
->mxccregs
[6], env
->mxccregs
[7]);
799 #if (defined(TARGET_SPARC64) || !defined(CONFIG_USER_ONLY)) \
800 && defined(DEBUG_ASI)
801 static void dump_asi(const char *txt
, target_ulong addr
, int asi
, int size
,
807 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %02" PRIx64
"\n", txt
,
808 addr
, asi
, r1
& 0xff);
811 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %04" PRIx64
"\n", txt
,
812 addr
, asi
, r1
& 0xffff);
815 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %08" PRIx64
"\n", txt
,
816 addr
, asi
, r1
& 0xffffffff);
819 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %016" PRIx64
"\n", txt
,
826 #ifndef TARGET_SPARC64
827 #ifndef CONFIG_USER_ONLY
828 uint64_t helper_ld_asi(target_ulong addr
, int asi
, int size
, int sign
)
831 #if defined(DEBUG_MXCC) || defined(DEBUG_ASI)
832 uint32_t last_addr
= addr
;
836 case 2: /* SuperSparc MXCC registers */
838 case 0x01c00a00: /* MXCC control register */
840 ret
= env
->mxccregs
[3];
842 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
844 case 0x01c00a04: /* MXCC control register */
846 ret
= env
->mxccregs
[3];
848 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
850 case 0x01c00c00: /* Module reset register */
852 ret
= env
->mxccregs
[5];
853 // should we do something here?
855 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
857 case 0x01c00f00: /* MBus port address register */
859 ret
= env
->mxccregs
[7];
861 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
864 DPRINTF_MXCC("%08x: unimplemented address, size: %d\n", addr
, size
);
867 DPRINTF_MXCC("asi = %d, size = %d, sign = %d, addr = %08x -> ret = %08x,"
868 "addr = %08x\n", asi
, size
, sign
, last_addr
, ret
, addr
);
873 case 3: /* MMU probe */
877 mmulev
= (addr
>> 8) & 15;
881 ret
= mmu_probe(env
, addr
, mmulev
);
882 DPRINTF_MMU("mmu_probe: 0x%08x (lev %d) -> 0x%08" PRIx64
"\n",
886 case 4: /* read MMU regs */
888 int reg
= (addr
>> 8) & 0x1f;
890 ret
= env
->mmuregs
[reg
];
891 if (reg
== 3) /* Fault status cleared on read */
893 else if (reg
== 0x13) /* Fault status read */
894 ret
= env
->mmuregs
[3];
895 else if (reg
== 0x14) /* Fault address read */
896 ret
= env
->mmuregs
[4];
897 DPRINTF_MMU("mmu_read: reg[%d] = 0x%08" PRIx64
"\n", reg
, ret
);
900 case 5: // Turbosparc ITLB Diagnostic
901 case 6: // Turbosparc DTLB Diagnostic
902 case 7: // Turbosparc IOTLB Diagnostic
904 case 9: /* Supervisor code access */
907 ret
= ldub_code(addr
);
910 ret
= lduw_code(addr
& ~1);
914 ret
= ldl_code(addr
& ~3);
917 ret
= ldq_code(addr
& ~7);
921 case 0xa: /* User data access */
924 ret
= ldub_user(addr
);
927 ret
= lduw_user(addr
& ~1);
931 ret
= ldl_user(addr
& ~3);
934 ret
= ldq_user(addr
& ~7);
938 case 0xb: /* Supervisor data access */
941 ret
= ldub_kernel(addr
);
944 ret
= lduw_kernel(addr
& ~1);
948 ret
= ldl_kernel(addr
& ~3);
951 ret
= ldq_kernel(addr
& ~7);
955 case 0xc: /* I-cache tag */
956 case 0xd: /* I-cache data */
957 case 0xe: /* D-cache tag */
958 case 0xf: /* D-cache data */
960 case 0x20: /* MMU passthrough */
963 ret
= ldub_phys(addr
);
966 ret
= lduw_phys(addr
& ~1);
970 ret
= ldl_phys(addr
& ~3);
973 ret
= ldq_phys(addr
& ~7);
977 case 0x21 ... 0x2f: /* MMU passthrough, 0x100000000 to 0xfffffffff */
980 ret
= ldub_phys((target_phys_addr_t
)addr
981 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
984 ret
= lduw_phys((target_phys_addr_t
)(addr
& ~1)
985 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
989 ret
= ldl_phys((target_phys_addr_t
)(addr
& ~3)
990 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
993 ret
= ldq_phys((target_phys_addr_t
)(addr
& ~7)
994 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
998 case 0x30: // Turbosparc secondary cache diagnostic
999 case 0x31: // Turbosparc RAM snoop
1000 case 0x32: // Turbosparc page table descriptor diagnostic
1001 case 0x39: /* data cache diagnostic register */
1004 case 8: /* User code access, XXX */
1006 do_unassigned_access(addr
, 0, 0, asi
);
1016 ret
= (int16_t) ret
;
1019 ret
= (int32_t) ret
;
1026 dump_asi("read ", last_addr
, asi
, size
, ret
);
1031 void helper_st_asi(target_ulong addr
, uint64_t val
, int asi
, int size
)
1034 case 2: /* SuperSparc MXCC registers */
1036 case 0x01c00000: /* MXCC stream data register 0 */
1038 env
->mxccdata
[0] = val
;
1040 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1042 case 0x01c00008: /* MXCC stream data register 1 */
1044 env
->mxccdata
[1] = val
;
1046 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1048 case 0x01c00010: /* MXCC stream data register 2 */
1050 env
->mxccdata
[2] = val
;
1052 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1054 case 0x01c00018: /* MXCC stream data register 3 */
1056 env
->mxccdata
[3] = val
;
1058 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1060 case 0x01c00100: /* MXCC stream source */
1062 env
->mxccregs
[0] = val
;
1064 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1065 env
->mxccdata
[0] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) + 0);
1066 env
->mxccdata
[1] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) + 8);
1067 env
->mxccdata
[2] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) + 16);
1068 env
->mxccdata
[3] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) + 24);
1070 case 0x01c00200: /* MXCC stream destination */
1072 env
->mxccregs
[1] = val
;
1074 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1075 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 0, env
->mxccdata
[0]);
1076 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 8, env
->mxccdata
[1]);
1077 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 16, env
->mxccdata
[2]);
1078 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 24, env
->mxccdata
[3]);
1080 case 0x01c00a00: /* MXCC control register */
1082 env
->mxccregs
[3] = val
;
1084 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1086 case 0x01c00a04: /* MXCC control register */
1088 env
->mxccregs
[3] = (env
->mxccregs
[0xa] & 0xffffffff00000000ULL
) | val
;
1090 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1092 case 0x01c00e00: /* MXCC error register */
1093 // writing a 1 bit clears the error
1095 env
->mxccregs
[6] &= ~val
;
1097 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1099 case 0x01c00f00: /* MBus port address register */
1101 env
->mxccregs
[7] = val
;
1103 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1106 DPRINTF_MXCC("%08x: unimplemented address, size: %d\n", addr
, size
);
1109 DPRINTF_MXCC("asi = %d, size = %d, addr = %08x, val = %08x\n", asi
, size
, addr
, val
);
1114 case 3: /* MMU flush */
1118 mmulev
= (addr
>> 8) & 15;
1119 DPRINTF_MMU("mmu flush level %d\n", mmulev
);
1121 case 0: // flush page
1122 tlb_flush_page(env
, addr
& 0xfffff000);
1124 case 1: // flush segment (256k)
1125 case 2: // flush region (16M)
1126 case 3: // flush context (4G)
1127 case 4: // flush entire
1138 case 4: /* write MMU regs */
1140 int reg
= (addr
>> 8) & 0x1f;
1143 oldreg
= env
->mmuregs
[reg
];
1145 case 0: // Control Register
1146 env
->mmuregs
[reg
] = (env
->mmuregs
[reg
] & 0xff000000) |
1148 // Mappings generated during no-fault mode or MMU
1149 // disabled mode are invalid in normal mode
1150 if ((oldreg
& (MMU_E
| MMU_NF
| env
->mmu_bm
)) !=
1151 (env
->mmuregs
[reg
] & (MMU_E
| MMU_NF
| env
->mmu_bm
)))
1154 case 1: // Context Table Pointer Register
1155 env
->mmuregs
[reg
] = val
& env
->mmu_ctpr_mask
;
1157 case 2: // Context Register
1158 env
->mmuregs
[reg
] = val
& env
->mmu_cxr_mask
;
1159 if (oldreg
!= env
->mmuregs
[reg
]) {
1160 /* we flush when the MMU context changes because
1161 QEMU has no MMU context support */
1165 case 3: // Synchronous Fault Status Register with Clear
1166 case 4: // Synchronous Fault Address Register
1168 case 0x10: // TLB Replacement Control Register
1169 env
->mmuregs
[reg
] = val
& env
->mmu_trcr_mask
;
1171 case 0x13: // Synchronous Fault Status Register with Read and Clear
1172 env
->mmuregs
[3] = val
& env
->mmu_sfsr_mask
;
1174 case 0x14: // Synchronous Fault Address Register
1175 env
->mmuregs
[4] = val
;
1178 env
->mmuregs
[reg
] = val
;
1181 if (oldreg
!= env
->mmuregs
[reg
]) {
1182 DPRINTF_MMU("mmu change reg[%d]: 0x%08x -> 0x%08x\n", reg
, oldreg
, env
->mmuregs
[reg
]);
1189 case 5: // Turbosparc ITLB Diagnostic
1190 case 6: // Turbosparc DTLB Diagnostic
1191 case 7: // Turbosparc IOTLB Diagnostic
1193 case 0xa: /* User data access */
1196 stb_user(addr
, val
);
1199 stw_user(addr
& ~1, val
);
1203 stl_user(addr
& ~3, val
);
1206 stq_user(addr
& ~7, val
);
1210 case 0xb: /* Supervisor data access */
1213 stb_kernel(addr
, val
);
1216 stw_kernel(addr
& ~1, val
);
1220 stl_kernel(addr
& ~3, val
);
1223 stq_kernel(addr
& ~7, val
);
1227 case 0xc: /* I-cache tag */
1228 case 0xd: /* I-cache data */
1229 case 0xe: /* D-cache tag */
1230 case 0xf: /* D-cache data */
1231 case 0x10: /* I/D-cache flush page */
1232 case 0x11: /* I/D-cache flush segment */
1233 case 0x12: /* I/D-cache flush region */
1234 case 0x13: /* I/D-cache flush context */
1235 case 0x14: /* I/D-cache flush user */
1237 case 0x17: /* Block copy, sta access */
1243 uint32_t src
= val
& ~3, dst
= addr
& ~3, temp
;
1245 for (i
= 0; i
< 32; i
+= 4, src
+= 4, dst
+= 4) {
1246 temp
= ldl_kernel(src
);
1247 stl_kernel(dst
, temp
);
1251 case 0x1f: /* Block fill, stda access */
1254 // fill 32 bytes with val
1256 uint32_t dst
= addr
& 7;
1258 for (i
= 0; i
< 32; i
+= 8, dst
+= 8)
1259 stq_kernel(dst
, val
);
1262 case 0x20: /* MMU passthrough */
1266 stb_phys(addr
, val
);
1269 stw_phys(addr
& ~1, val
);
1273 stl_phys(addr
& ~3, val
);
1276 stq_phys(addr
& ~7, val
);
1281 case 0x21 ... 0x2f: /* MMU passthrough, 0x100000000 to 0xfffffffff */
1285 stb_phys((target_phys_addr_t
)addr
1286 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1289 stw_phys((target_phys_addr_t
)(addr
& ~1)
1290 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1294 stl_phys((target_phys_addr_t
)(addr
& ~3)
1295 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1298 stq_phys((target_phys_addr_t
)(addr
& ~7)
1299 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1304 case 0x30: // store buffer tags or Turbosparc secondary cache diagnostic
1305 case 0x31: // store buffer data, Ross RT620 I-cache flush or
1306 // Turbosparc snoop RAM
1307 case 0x32: // store buffer control or Turbosparc page table descriptor diagnostic
1308 case 0x36: /* I-cache flash clear */
1309 case 0x37: /* D-cache flash clear */
1310 case 0x38: /* breakpoint diagnostics */
1311 case 0x4c: /* breakpoint action */
1313 case 8: /* User code access, XXX */
1314 case 9: /* Supervisor code access, XXX */
1316 do_unassigned_access(addr
, 1, 0, asi
);
1320 dump_asi("write", addr
, asi
, size
, val
);
1324 #endif /* CONFIG_USER_ONLY */
1325 #else /* TARGET_SPARC64 */
1327 #ifdef CONFIG_USER_ONLY
1328 uint64_t helper_ld_asi(target_ulong addr
, int asi
, int size
, int sign
)
1331 #if defined(DEBUG_ASI)
1332 target_ulong last_addr
= addr
;
1336 raise_exception(TT_PRIV_ACT
);
1339 case 0x80: // Primary
1340 case 0x82: // Primary no-fault
1341 case 0x88: // Primary LE
1342 case 0x8a: // Primary no-fault LE
1346 ret
= ldub_raw(addr
);
1349 ret
= lduw_raw(addr
& ~1);
1352 ret
= ldl_raw(addr
& ~3);
1356 ret
= ldq_raw(addr
& ~7);
1361 case 0x81: // Secondary
1362 case 0x83: // Secondary no-fault
1363 case 0x89: // Secondary LE
1364 case 0x8b: // Secondary no-fault LE
1371 /* Convert from little endian */
1373 case 0x88: // Primary LE
1374 case 0x89: // Secondary LE
1375 case 0x8a: // Primary no-fault LE
1376 case 0x8b: // Secondary no-fault LE
1394 /* Convert to signed number */
1401 ret
= (int16_t) ret
;
1404 ret
= (int32_t) ret
;
1411 dump_asi("read ", last_addr
, asi
, size
, ret
);
1416 void helper_st_asi(target_ulong addr
, target_ulong val
, int asi
, int size
)
1419 dump_asi("write", addr
, asi
, size
, val
);
1422 raise_exception(TT_PRIV_ACT
);
1424 /* Convert to little endian */
1426 case 0x88: // Primary LE
1427 case 0x89: // Secondary LE
1430 addr
= bswap16(addr
);
1433 addr
= bswap32(addr
);
1436 addr
= bswap64(addr
);
1446 case 0x80: // Primary
1447 case 0x88: // Primary LE
1454 stw_raw(addr
& ~1, val
);
1457 stl_raw(addr
& ~3, val
);
1461 stq_raw(addr
& ~7, val
);
1466 case 0x81: // Secondary
1467 case 0x89: // Secondary LE
1471 case 0x82: // Primary no-fault, RO
1472 case 0x83: // Secondary no-fault, RO
1473 case 0x8a: // Primary no-fault LE, RO
1474 case 0x8b: // Secondary no-fault LE, RO
1476 do_unassigned_access(addr
, 1, 0, 1);
1481 #else /* CONFIG_USER_ONLY */
1483 uint64_t helper_ld_asi(target_ulong addr
, int asi
, int size
, int sign
)
1486 #if defined(DEBUG_ASI)
1487 target_ulong last_addr
= addr
;
1490 if ((asi
< 0x80 && (env
->pstate
& PS_PRIV
) == 0)
1491 || (asi
>= 0x30 && asi
< 0x80 && !(env
->hpstate
& HS_PRIV
)))
1492 raise_exception(TT_PRIV_ACT
);
1495 case 0x10: // As if user primary
1496 case 0x18: // As if user primary LE
1497 case 0x80: // Primary
1498 case 0x82: // Primary no-fault
1499 case 0x88: // Primary LE
1500 case 0x8a: // Primary no-fault LE
1501 if ((asi
& 0x80) && (env
->pstate
& PS_PRIV
)) {
1502 if (env
->hpstate
& HS_PRIV
) {
1505 ret
= ldub_hypv(addr
);
1508 ret
= lduw_hypv(addr
& ~1);
1511 ret
= ldl_hypv(addr
& ~3);
1515 ret
= ldq_hypv(addr
& ~7);
1521 ret
= ldub_kernel(addr
);
1524 ret
= lduw_kernel(addr
& ~1);
1527 ret
= ldl_kernel(addr
& ~3);
1531 ret
= ldq_kernel(addr
& ~7);
1538 ret
= ldub_user(addr
);
1541 ret
= lduw_user(addr
& ~1);
1544 ret
= ldl_user(addr
& ~3);
1548 ret
= ldq_user(addr
& ~7);
1553 case 0x14: // Bypass
1554 case 0x15: // Bypass, non-cacheable
1555 case 0x1c: // Bypass LE
1556 case 0x1d: // Bypass, non-cacheable LE
1560 ret
= ldub_phys(addr
);
1563 ret
= lduw_phys(addr
& ~1);
1566 ret
= ldl_phys(addr
& ~3);
1570 ret
= ldq_phys(addr
& ~7);
1575 case 0x04: // Nucleus
1576 case 0x0c: // Nucleus Little Endian (LE)
1577 case 0x11: // As if user secondary
1578 case 0x19: // As if user secondary LE
1579 case 0x24: // Nucleus quad LDD 128 bit atomic
1580 case 0x2c: // Nucleus quad LDD 128 bit atomic
1581 case 0x4a: // UPA config
1582 case 0x81: // Secondary
1583 case 0x83: // Secondary no-fault
1584 case 0x89: // Secondary LE
1585 case 0x8b: // Secondary no-fault LE
1591 case 0x50: // I-MMU regs
1593 int reg
= (addr
>> 3) & 0xf;
1595 ret
= env
->immuregs
[reg
];
1598 case 0x51: // I-MMU 8k TSB pointer
1599 case 0x52: // I-MMU 64k TSB pointer
1600 case 0x55: // I-MMU data access
1603 case 0x56: // I-MMU tag read
1607 for (i
= 0; i
< 64; i
++) {
1608 // Valid, ctx match, vaddr match
1609 if ((env
->itlb_tte
[i
] & 0x8000000000000000ULL
) != 0 &&
1610 env
->itlb_tag
[i
] == addr
) {
1611 ret
= env
->itlb_tag
[i
];
1617 case 0x58: // D-MMU regs
1619 int reg
= (addr
>> 3) & 0xf;
1621 ret
= env
->dmmuregs
[reg
];
1624 case 0x5e: // D-MMU tag read
1628 for (i
= 0; i
< 64; i
++) {
1629 // Valid, ctx match, vaddr match
1630 if ((env
->dtlb_tte
[i
] & 0x8000000000000000ULL
) != 0 &&
1631 env
->dtlb_tag
[i
] == addr
) {
1632 ret
= env
->dtlb_tag
[i
];
1638 case 0x59: // D-MMU 8k TSB pointer
1639 case 0x5a: // D-MMU 64k TSB pointer
1640 case 0x5b: // D-MMU data pointer
1641 case 0x5d: // D-MMU data access
1642 case 0x48: // Interrupt dispatch, RO
1643 case 0x49: // Interrupt data receive
1644 case 0x7f: // Incoming interrupt vector, RO
1647 case 0x54: // I-MMU data in, WO
1648 case 0x57: // I-MMU demap, WO
1649 case 0x5c: // D-MMU data in, WO
1650 case 0x5f: // D-MMU demap, WO
1651 case 0x77: // Interrupt vector, WO
1653 do_unassigned_access(addr
, 0, 0, 1);
1658 /* Convert from little endian */
1660 case 0x0c: // Nucleus Little Endian (LE)
1661 case 0x18: // As if user primary LE
1662 case 0x19: // As if user secondary LE
1663 case 0x1c: // Bypass LE
1664 case 0x1d: // Bypass, non-cacheable LE
1665 case 0x88: // Primary LE
1666 case 0x89: // Secondary LE
1667 case 0x8a: // Primary no-fault LE
1668 case 0x8b: // Secondary no-fault LE
1686 /* Convert to signed number */
1693 ret
= (int16_t) ret
;
1696 ret
= (int32_t) ret
;
1703 dump_asi("read ", last_addr
, asi
, size
, ret
);
1708 void helper_st_asi(target_ulong addr
, target_ulong val
, int asi
, int size
)
1711 dump_asi("write", addr
, asi
, size
, val
);
1713 if ((asi
< 0x80 && (env
->pstate
& PS_PRIV
) == 0)
1714 || (asi
>= 0x30 && asi
< 0x80 && !(env
->hpstate
& HS_PRIV
)))
1715 raise_exception(TT_PRIV_ACT
);
1717 /* Convert to little endian */
1719 case 0x0c: // Nucleus Little Endian (LE)
1720 case 0x18: // As if user primary LE
1721 case 0x19: // As if user secondary LE
1722 case 0x1c: // Bypass LE
1723 case 0x1d: // Bypass, non-cacheable LE
1724 case 0x88: // Primary LE
1725 case 0x89: // Secondary LE
1728 addr
= bswap16(addr
);
1731 addr
= bswap32(addr
);
1734 addr
= bswap64(addr
);
1744 case 0x10: // As if user primary
1745 case 0x18: // As if user primary LE
1746 case 0x80: // Primary
1747 case 0x88: // Primary LE
1748 if ((asi
& 0x80) && (env
->pstate
& PS_PRIV
)) {
1749 if (env
->hpstate
& HS_PRIV
) {
1752 stb_hypv(addr
, val
);
1755 stw_hypv(addr
& ~1, val
);
1758 stl_hypv(addr
& ~3, val
);
1762 stq_hypv(addr
& ~7, val
);
1768 stb_kernel(addr
, val
);
1771 stw_kernel(addr
& ~1, val
);
1774 stl_kernel(addr
& ~3, val
);
1778 stq_kernel(addr
& ~7, val
);
1785 stb_user(addr
, val
);
1788 stw_user(addr
& ~1, val
);
1791 stl_user(addr
& ~3, val
);
1795 stq_user(addr
& ~7, val
);
1800 case 0x14: // Bypass
1801 case 0x15: // Bypass, non-cacheable
1802 case 0x1c: // Bypass LE
1803 case 0x1d: // Bypass, non-cacheable LE
1807 stb_phys(addr
, val
);
1810 stw_phys(addr
& ~1, val
);
1813 stl_phys(addr
& ~3, val
);
1817 stq_phys(addr
& ~7, val
);
1822 case 0x04: // Nucleus
1823 case 0x0c: // Nucleus Little Endian (LE)
1824 case 0x11: // As if user secondary
1825 case 0x19: // As if user secondary LE
1826 case 0x24: // Nucleus quad LDD 128 bit atomic
1827 case 0x2c: // Nucleus quad LDD 128 bit atomic
1828 case 0x4a: // UPA config
1829 case 0x81: // Secondary
1830 case 0x89: // Secondary LE
1838 env
->lsu
= val
& (DMMU_E
| IMMU_E
);
1839 // Mappings generated during D/I MMU disabled mode are
1840 // invalid in normal mode
1841 if (oldreg
!= env
->lsu
) {
1842 DPRINTF_MMU("LSU change: 0x%" PRIx64
" -> 0x%" PRIx64
"\n", oldreg
, env
->lsu
);
1850 case 0x50: // I-MMU regs
1852 int reg
= (addr
>> 3) & 0xf;
1855 oldreg
= env
->immuregs
[reg
];
1860 case 1: // Not in I-MMU
1867 val
= 0; // Clear SFSR
1869 case 5: // TSB access
1870 case 6: // Tag access
1874 env
->immuregs
[reg
] = val
;
1875 if (oldreg
!= env
->immuregs
[reg
]) {
1876 DPRINTF_MMU("mmu change reg[%d]: 0x%08" PRIx64
" -> 0x%08" PRIx64
"\n", reg
, oldreg
, env
->immuregs
[reg
]);
1883 case 0x54: // I-MMU data in
1887 // Try finding an invalid entry
1888 for (i
= 0; i
< 64; i
++) {
1889 if ((env
->itlb_tte
[i
] & 0x8000000000000000ULL
) == 0) {
1890 env
->itlb_tag
[i
] = env
->immuregs
[6];
1891 env
->itlb_tte
[i
] = val
;
1895 // Try finding an unlocked entry
1896 for (i
= 0; i
< 64; i
++) {
1897 if ((env
->itlb_tte
[i
] & 0x40) == 0) {
1898 env
->itlb_tag
[i
] = env
->immuregs
[6];
1899 env
->itlb_tte
[i
] = val
;
1906 case 0x55: // I-MMU data access
1908 unsigned int i
= (addr
>> 3) & 0x3f;
1910 env
->itlb_tag
[i
] = env
->immuregs
[6];
1911 env
->itlb_tte
[i
] = val
;
1914 case 0x57: // I-MMU demap
1917 case 0x58: // D-MMU regs
1919 int reg
= (addr
>> 3) & 0xf;
1922 oldreg
= env
->dmmuregs
[reg
];
1928 if ((val
& 1) == 0) {
1929 val
= 0; // Clear SFSR, Fault address
1930 env
->dmmuregs
[4] = 0;
1932 env
->dmmuregs
[reg
] = val
;
1934 case 1: // Primary context
1935 case 2: // Secondary context
1936 case 5: // TSB access
1937 case 6: // Tag access
1938 case 7: // Virtual Watchpoint
1939 case 8: // Physical Watchpoint
1943 env
->dmmuregs
[reg
] = val
;
1944 if (oldreg
!= env
->dmmuregs
[reg
]) {
1945 DPRINTF_MMU("mmu change reg[%d]: 0x%08" PRIx64
" -> 0x%08" PRIx64
"\n", reg
, oldreg
, env
->dmmuregs
[reg
]);
1952 case 0x5c: // D-MMU data in
1956 // Try finding an invalid entry
1957 for (i
= 0; i
< 64; i
++) {
1958 if ((env
->dtlb_tte
[i
] & 0x8000000000000000ULL
) == 0) {
1959 env
->dtlb_tag
[i
] = env
->dmmuregs
[6];
1960 env
->dtlb_tte
[i
] = val
;
1964 // Try finding an unlocked entry
1965 for (i
= 0; i
< 64; i
++) {
1966 if ((env
->dtlb_tte
[i
] & 0x40) == 0) {
1967 env
->dtlb_tag
[i
] = env
->dmmuregs
[6];
1968 env
->dtlb_tte
[i
] = val
;
1975 case 0x5d: // D-MMU data access
1977 unsigned int i
= (addr
>> 3) & 0x3f;
1979 env
->dtlb_tag
[i
] = env
->dmmuregs
[6];
1980 env
->dtlb_tte
[i
] = val
;
1983 case 0x5f: // D-MMU demap
1984 case 0x49: // Interrupt data receive
1987 case 0x51: // I-MMU 8k TSB pointer, RO
1988 case 0x52: // I-MMU 64k TSB pointer, RO
1989 case 0x56: // I-MMU tag read, RO
1990 case 0x59: // D-MMU 8k TSB pointer, RO
1991 case 0x5a: // D-MMU 64k TSB pointer, RO
1992 case 0x5b: // D-MMU data pointer, RO
1993 case 0x5e: // D-MMU tag read, RO
1994 case 0x48: // Interrupt dispatch, RO
1995 case 0x7f: // Incoming interrupt vector, RO
1996 case 0x82: // Primary no-fault, RO
1997 case 0x83: // Secondary no-fault, RO
1998 case 0x8a: // Primary no-fault LE, RO
1999 case 0x8b: // Secondary no-fault LE, RO
2001 do_unassigned_access(addr
, 1, 0, 1);
2005 #endif /* CONFIG_USER_ONLY */
2007 void helper_ldf_asi(target_ulong addr
, int asi
, int size
, int rd
)
2013 case 0xf0: // Block load primary
2014 case 0xf1: // Block load secondary
2015 case 0xf8: // Block load primary LE
2016 case 0xf9: // Block load secondary LE
2018 raise_exception(TT_ILL_INSN
);
2022 raise_exception(TT_UNALIGNED
);
2025 for (i
= 0; i
< 16; i
++) {
2026 *(uint32_t *)&env
->fpr
[rd
++] = helper_ld_asi(addr
, asi
& 0x8f, 4, 0);
2035 val
= helper_ld_asi(addr
, asi
, size
, 0);
2039 *((uint32_t *)&FT0
) = val
;
2042 *((int64_t *)&DT0
) = val
;
2050 void helper_stf_asi(target_ulong addr
, int asi
, int size
, int rd
)
2053 target_ulong val
= 0;
2056 case 0xf0: // Block store primary
2057 case 0xf1: // Block store secondary
2058 case 0xf8: // Block store primary LE
2059 case 0xf9: // Block store secondary LE
2061 raise_exception(TT_ILL_INSN
);
2065 raise_exception(TT_UNALIGNED
);
2068 for (i
= 0; i
< 16; i
++) {
2069 val
= *(uint32_t *)&env
->fpr
[rd
++];
2070 helper_st_asi(addr
, val
, asi
& 0x8f, 4);
2082 val
= *((uint32_t *)&FT0
);
2085 val
= *((int64_t *)&DT0
);
2091 helper_st_asi(addr
, val
, asi
, size
);
2094 target_ulong
helper_cas_asi(target_ulong addr
, target_ulong val1
,
2095 target_ulong val2
, uint32_t asi
)
2099 val1
&= 0xffffffffUL
;
2100 ret
= helper_ld_asi(addr
, asi
, 4, 0);
2101 ret
&= 0xffffffffUL
;
2103 helper_st_asi(addr
, val2
& 0xffffffffUL
, asi
, 4);
2107 target_ulong
helper_casx_asi(target_ulong addr
, target_ulong val1
,
2108 target_ulong val2
, uint32_t asi
)
2112 ret
= helper_ld_asi(addr
, asi
, 8, 0);
2114 helper_st_asi(addr
, val2
, asi
, 8);
2117 #endif /* TARGET_SPARC64 */
2119 #ifndef TARGET_SPARC64
2120 void helper_rett(void)
2124 if (env
->psret
== 1)
2125 raise_exception(TT_ILL_INSN
);
2128 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
2129 if (env
->wim
& (1 << cwp
)) {
2130 raise_exception(TT_WIN_UNF
);
2133 env
->psrs
= env
->psrps
;
2137 target_ulong
helper_udiv(target_ulong a
, target_ulong b
)
2142 x0
= a
| ((uint64_t) (env
->y
) << 32);
2146 raise_exception(TT_DIV_ZERO
);
2150 if (x0
> 0xffffffff) {
2159 target_ulong
helper_sdiv(target_ulong a
, target_ulong b
)
2164 x0
= a
| ((int64_t) (env
->y
) << 32);
2168 raise_exception(TT_DIV_ZERO
);
2172 if ((int32_t) x0
!= x0
) {
2174 return x0
< 0? 0x80000000: 0x7fffffff;
2181 uint64_t helper_pack64(target_ulong high
, target_ulong low
)
2183 return ((uint64_t)high
<< 32) | (uint64_t)(low
& 0xffffffff);
2187 #define ADDR(x) ((x) & 0xffffffff)
2192 void helper_stdf(target_ulong addr
, int mem_idx
)
2194 #if !defined(CONFIG_USER_ONLY)
2197 stfq_user(ADDR(addr
), DT0
);
2200 stfq_kernel(ADDR(addr
), DT0
);
2202 #ifdef TARGET_SPARC64
2204 stfq_hypv(ADDR(addr
), DT0
);
2211 stfq_raw(ADDR(addr
), DT0
);
2215 void helper_lddf(target_ulong addr
, int mem_idx
)
2217 #if !defined(CONFIG_USER_ONLY)
2220 DT0
= ldfq_user(ADDR(addr
));
2223 DT0
= ldfq_kernel(ADDR(addr
));
2225 #ifdef TARGET_SPARC64
2227 DT0
= ldfq_hypv(ADDR(addr
));
2234 DT0
= ldfq_raw(ADDR(addr
));
2238 void helper_ldqf(target_ulong addr
, int mem_idx
)
2240 // XXX add 128 bit load
2243 #if !defined(CONFIG_USER_ONLY)
2246 u
.ll
.upper
= ldq_user(ADDR(addr
));
2247 u
.ll
.lower
= ldq_user(ADDR(addr
+ 8));
2251 u
.ll
.upper
= ldq_kernel(ADDR(addr
));
2252 u
.ll
.lower
= ldq_kernel(ADDR(addr
+ 8));
2255 #ifdef TARGET_SPARC64
2257 u
.ll
.upper
= ldq_hypv(ADDR(addr
));
2258 u
.ll
.lower
= ldq_hypv(ADDR(addr
+ 8));
2266 u
.ll
.upper
= ldq_raw(ADDR(addr
));
2267 u
.ll
.lower
= ldq_raw(ADDR(addr
+ 8));
2272 void helper_stqf(target_ulong addr
, int mem_idx
)
2274 // XXX add 128 bit store
2277 #if !defined(CONFIG_USER_ONLY)
2281 stq_user(ADDR(addr
), u
.ll
.upper
);
2282 stq_user(ADDR(addr
+ 8), u
.ll
.lower
);
2286 stq_kernel(ADDR(addr
), u
.ll
.upper
);
2287 stq_kernel(ADDR(addr
+ 8), u
.ll
.lower
);
2289 #ifdef TARGET_SPARC64
2292 stq_hypv(ADDR(addr
), u
.ll
.upper
);
2293 stq_hypv(ADDR(addr
+ 8), u
.ll
.lower
);
2301 stq_raw(ADDR(addr
), u
.ll
.upper
);
2302 stq_raw(ADDR(addr
+ 8), u
.ll
.lower
);
2308 void helper_ldfsr(void)
2312 PUT_FSR32(env
, *((uint32_t *) &FT0
));
2313 switch (env
->fsr
& FSR_RD_MASK
) {
2314 case FSR_RD_NEAREST
:
2315 rnd_mode
= float_round_nearest_even
;
2319 rnd_mode
= float_round_to_zero
;
2322 rnd_mode
= float_round_up
;
2325 rnd_mode
= float_round_down
;
2328 set_float_rounding_mode(rnd_mode
, &env
->fp_status
);
2331 void helper_stfsr(void)
2333 *((uint32_t *) &FT0
) = GET_FSR32(env
);
2336 void helper_debug(void)
2338 env
->exception_index
= EXCP_DEBUG
;
2342 #ifndef TARGET_SPARC64
2343 /* XXX: use another pointer for %iN registers to avoid slow wrapping
2345 void helper_save(void)
2349 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
2350 if (env
->wim
& (1 << cwp
)) {
2351 raise_exception(TT_WIN_OVF
);
2356 void helper_restore(void)
2360 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
2361 if (env
->wim
& (1 << cwp
)) {
2362 raise_exception(TT_WIN_UNF
);
2367 void helper_wrpsr(target_ulong new_psr
)
2369 if ((new_psr
& PSR_CWP
) >= NWINDOWS
)
2370 raise_exception(TT_ILL_INSN
);
2372 PUT_PSR(env
, new_psr
);
2375 target_ulong
helper_rdpsr(void)
2377 return GET_PSR(env
);
2381 /* XXX: use another pointer for %iN registers to avoid slow wrapping
2383 void helper_save(void)
2387 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
2388 if (env
->cansave
== 0) {
2389 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
2390 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
2391 ((env
->wstate
& 0x7) << 2)));
2393 if (env
->cleanwin
- env
->canrestore
== 0) {
2394 // XXX Clean windows without trap
2395 raise_exception(TT_CLRWIN
);
2404 void helper_restore(void)
2408 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
2409 if (env
->canrestore
== 0) {
2410 raise_exception(TT_FILL
| (env
->otherwin
!= 0 ?
2411 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
2412 ((env
->wstate
& 0x7) << 2)));
2420 void helper_flushw(void)
2422 if (env
->cansave
!= NWINDOWS
- 2) {
2423 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
2424 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
2425 ((env
->wstate
& 0x7) << 2)));
2429 void helper_saved(void)
2432 if (env
->otherwin
== 0)
2438 void helper_restored(void)
2441 if (env
->cleanwin
< NWINDOWS
- 1)
2443 if (env
->otherwin
== 0)
2449 target_ulong
helper_rdccr(void)
2451 return GET_CCR(env
);
2454 void helper_wrccr(target_ulong new_ccr
)
2456 PUT_CCR(env
, new_ccr
);
2459 // CWP handling is reversed in V9, but we still use the V8 register
2461 target_ulong
helper_rdcwp(void)
2463 return GET_CWP64(env
);
2466 void helper_wrcwp(target_ulong new_cwp
)
2468 PUT_CWP64(env
, new_cwp
);
2471 // This function uses non-native bit order
2472 #define GET_FIELD(X, FROM, TO) \
2473 ((X) >> (63 - (TO)) & ((1ULL << ((TO) - (FROM) + 1)) - 1))
2475 // This function uses the order in the manuals, i.e. bit 0 is 2^0
2476 #define GET_FIELD_SP(X, FROM, TO) \
2477 GET_FIELD(X, 63 - (TO), 63 - (FROM))
2479 target_ulong
helper_array8(target_ulong pixel_addr
, target_ulong cubesize
)
2481 return (GET_FIELD_SP(pixel_addr
, 60, 63) << (17 + 2 * cubesize
)) |
2482 (GET_FIELD_SP(pixel_addr
, 39, 39 + cubesize
- 1) << (17 + cubesize
)) |
2483 (GET_FIELD_SP(pixel_addr
, 17 + cubesize
- 1, 17) << 17) |
2484 (GET_FIELD_SP(pixel_addr
, 56, 59) << 13) |
2485 (GET_FIELD_SP(pixel_addr
, 35, 38) << 9) |
2486 (GET_FIELD_SP(pixel_addr
, 13, 16) << 5) |
2487 (((pixel_addr
>> 55) & 1) << 4) |
2488 (GET_FIELD_SP(pixel_addr
, 33, 34) << 2) |
2489 GET_FIELD_SP(pixel_addr
, 11, 12);
2492 target_ulong
helper_alignaddr(target_ulong addr
, target_ulong offset
)
2496 tmp
= addr
+ offset
;
2498 env
->gsr
|= tmp
& 7ULL;
2502 target_ulong
helper_popc(target_ulong val
)
2504 return ctpop64(val
);
2507 static inline uint64_t *get_gregset(uint64_t pstate
)
2522 static inline void change_pstate(uint64_t new_pstate
)
2524 uint64_t pstate_regs
, new_pstate_regs
;
2525 uint64_t *src
, *dst
;
2527 pstate_regs
= env
->pstate
& 0xc01;
2528 new_pstate_regs
= new_pstate
& 0xc01;
2529 if (new_pstate_regs
!= pstate_regs
) {
2530 // Switch global register bank
2531 src
= get_gregset(new_pstate_regs
);
2532 dst
= get_gregset(pstate_regs
);
2533 memcpy32(dst
, env
->gregs
);
2534 memcpy32(env
->gregs
, src
);
2536 env
->pstate
= new_pstate
;
2539 void helper_wrpstate(target_ulong new_state
)
2541 change_pstate(new_state
& 0xf3f);
2544 void helper_done(void)
2547 env
->tsptr
= &env
->ts
[env
->tl
];
2548 env
->pc
= env
->tsptr
->tpc
;
2549 env
->npc
= env
->tsptr
->tnpc
+ 4;
2550 PUT_CCR(env
, env
->tsptr
->tstate
>> 32);
2551 env
->asi
= (env
->tsptr
->tstate
>> 24) & 0xff;
2552 change_pstate((env
->tsptr
->tstate
>> 8) & 0xf3f);
2553 PUT_CWP64(env
, env
->tsptr
->tstate
& 0xff);
2556 void helper_retry(void)
2559 env
->tsptr
= &env
->ts
[env
->tl
];
2560 env
->pc
= env
->tsptr
->tpc
;
2561 env
->npc
= env
->tsptr
->tnpc
;
2562 PUT_CCR(env
, env
->tsptr
->tstate
>> 32);
2563 env
->asi
= (env
->tsptr
->tstate
>> 24) & 0xff;
2564 change_pstate((env
->tsptr
->tstate
>> 8) & 0xf3f);
2565 PUT_CWP64(env
, env
->tsptr
->tstate
& 0xff);
2569 void set_cwp(int new_cwp
)
2571 /* put the modified wrap registers at their proper location */
2572 if (env
->cwp
== (NWINDOWS
- 1))
2573 memcpy32(env
->regbase
, env
->regbase
+ NWINDOWS
* 16);
2575 /* put the wrap registers at their temporary location */
2576 if (new_cwp
== (NWINDOWS
- 1))
2577 memcpy32(env
->regbase
+ NWINDOWS
* 16, env
->regbase
);
2578 env
->regwptr
= env
->regbase
+ (new_cwp
* 16);
2579 REGWPTR
= env
->regwptr
;
2582 void cpu_set_cwp(CPUState
*env1
, int new_cwp
)
2584 CPUState
*saved_env
;
2586 target_ulong
*saved_regwptr
;
2591 saved_regwptr
= REGWPTR
;
2597 REGWPTR
= saved_regwptr
;
2601 #ifdef TARGET_SPARC64
2603 static const char * const excp_names
[0x50] = {
2604 [TT_TFAULT
] = "Instruction Access Fault",
2605 [TT_TMISS
] = "Instruction Access MMU Miss",
2606 [TT_CODE_ACCESS
] = "Instruction Access Error",
2607 [TT_ILL_INSN
] = "Illegal Instruction",
2608 [TT_PRIV_INSN
] = "Privileged Instruction",
2609 [TT_NFPU_INSN
] = "FPU Disabled",
2610 [TT_FP_EXCP
] = "FPU Exception",
2611 [TT_TOVF
] = "Tag Overflow",
2612 [TT_CLRWIN
] = "Clean Windows",
2613 [TT_DIV_ZERO
] = "Division By Zero",
2614 [TT_DFAULT
] = "Data Access Fault",
2615 [TT_DMISS
] = "Data Access MMU Miss",
2616 [TT_DATA_ACCESS
] = "Data Access Error",
2617 [TT_DPROT
] = "Data Protection Error",
2618 [TT_UNALIGNED
] = "Unaligned Memory Access",
2619 [TT_PRIV_ACT
] = "Privileged Action",
2620 [TT_EXTINT
| 0x1] = "External Interrupt 1",
2621 [TT_EXTINT
| 0x2] = "External Interrupt 2",
2622 [TT_EXTINT
| 0x3] = "External Interrupt 3",
2623 [TT_EXTINT
| 0x4] = "External Interrupt 4",
2624 [TT_EXTINT
| 0x5] = "External Interrupt 5",
2625 [TT_EXTINT
| 0x6] = "External Interrupt 6",
2626 [TT_EXTINT
| 0x7] = "External Interrupt 7",
2627 [TT_EXTINT
| 0x8] = "External Interrupt 8",
2628 [TT_EXTINT
| 0x9] = "External Interrupt 9",
2629 [TT_EXTINT
| 0xa] = "External Interrupt 10",
2630 [TT_EXTINT
| 0xb] = "External Interrupt 11",
2631 [TT_EXTINT
| 0xc] = "External Interrupt 12",
2632 [TT_EXTINT
| 0xd] = "External Interrupt 13",
2633 [TT_EXTINT
| 0xe] = "External Interrupt 14",
2634 [TT_EXTINT
| 0xf] = "External Interrupt 15",
2638 void do_interrupt(int intno
)
2641 if (loglevel
& CPU_LOG_INT
) {
2645 if (intno
< 0 || intno
>= 0x180 || (intno
> 0x4f && intno
< 0x80))
2647 else if (intno
>= 0x100)
2648 name
= "Trap Instruction";
2649 else if (intno
>= 0xc0)
2650 name
= "Window Fill";
2651 else if (intno
>= 0x80)
2652 name
= "Window Spill";
2654 name
= excp_names
[intno
];
2659 fprintf(logfile
, "%6d: %s (v=%04x) pc=%016" PRIx64
" npc=%016" PRIx64
2660 " SP=%016" PRIx64
"\n",
2663 env
->npc
, env
->regwptr
[6]);
2664 cpu_dump_state(env
, logfile
, fprintf
, 0);
2670 fprintf(logfile
, " code=");
2671 ptr
= (uint8_t *)env
->pc
;
2672 for(i
= 0; i
< 16; i
++) {
2673 fprintf(logfile
, " %02x", ldub(ptr
+ i
));
2675 fprintf(logfile
, "\n");
2681 #if !defined(CONFIG_USER_ONLY)
2682 if (env
->tl
== MAXTL
) {
2683 cpu_abort(env
, "Trap 0x%04x while trap level is MAXTL, Error state", env
->exception_index
);
2687 env
->tsptr
->tstate
= ((uint64_t)GET_CCR(env
) << 32) |
2688 ((env
->asi
& 0xff) << 24) | ((env
->pstate
& 0xf3f) << 8) |
2690 env
->tsptr
->tpc
= env
->pc
;
2691 env
->tsptr
->tnpc
= env
->npc
;
2692 env
->tsptr
->tt
= intno
;
2693 change_pstate(PS_PEF
| PS_PRIV
| PS_AG
);
2695 if (intno
== TT_CLRWIN
)
2696 set_cwp((env
->cwp
- 1) & (NWINDOWS
- 1));
2697 else if ((intno
& 0x1c0) == TT_SPILL
)
2698 set_cwp((env
->cwp
- env
->cansave
- 2) & (NWINDOWS
- 1));
2699 else if ((intno
& 0x1c0) == TT_FILL
)
2700 set_cwp((env
->cwp
+ 1) & (NWINDOWS
- 1));
2701 env
->tbr
&= ~0x7fffULL
;
2702 env
->tbr
|= ((env
->tl
> 1) ? 1 << 14 : 0) | (intno
<< 5);
2703 if (env
->tl
< MAXTL
- 1) {
2706 env
->pstate
|= PS_RED
;
2707 if (env
->tl
!= MAXTL
)
2710 env
->tsptr
= &env
->ts
[env
->tl
];
2712 env
->npc
= env
->pc
+ 4;
2713 env
->exception_index
= 0;
2717 static const char * const excp_names
[0x80] = {
2718 [TT_TFAULT
] = "Instruction Access Fault",
2719 [TT_ILL_INSN
] = "Illegal Instruction",
2720 [TT_PRIV_INSN
] = "Privileged Instruction",
2721 [TT_NFPU_INSN
] = "FPU Disabled",
2722 [TT_WIN_OVF
] = "Window Overflow",
2723 [TT_WIN_UNF
] = "Window Underflow",
2724 [TT_UNALIGNED
] = "Unaligned Memory Access",
2725 [TT_FP_EXCP
] = "FPU Exception",
2726 [TT_DFAULT
] = "Data Access Fault",
2727 [TT_TOVF
] = "Tag Overflow",
2728 [TT_EXTINT
| 0x1] = "External Interrupt 1",
2729 [TT_EXTINT
| 0x2] = "External Interrupt 2",
2730 [TT_EXTINT
| 0x3] = "External Interrupt 3",
2731 [TT_EXTINT
| 0x4] = "External Interrupt 4",
2732 [TT_EXTINT
| 0x5] = "External Interrupt 5",
2733 [TT_EXTINT
| 0x6] = "External Interrupt 6",
2734 [TT_EXTINT
| 0x7] = "External Interrupt 7",
2735 [TT_EXTINT
| 0x8] = "External Interrupt 8",
2736 [TT_EXTINT
| 0x9] = "External Interrupt 9",
2737 [TT_EXTINT
| 0xa] = "External Interrupt 10",
2738 [TT_EXTINT
| 0xb] = "External Interrupt 11",
2739 [TT_EXTINT
| 0xc] = "External Interrupt 12",
2740 [TT_EXTINT
| 0xd] = "External Interrupt 13",
2741 [TT_EXTINT
| 0xe] = "External Interrupt 14",
2742 [TT_EXTINT
| 0xf] = "External Interrupt 15",
2743 [TT_TOVF
] = "Tag Overflow",
2744 [TT_CODE_ACCESS
] = "Instruction Access Error",
2745 [TT_DATA_ACCESS
] = "Data Access Error",
2746 [TT_DIV_ZERO
] = "Division By Zero",
2747 [TT_NCP_INSN
] = "Coprocessor Disabled",
2751 void do_interrupt(int intno
)
2756 if (loglevel
& CPU_LOG_INT
) {
2760 if (intno
< 0 || intno
>= 0x100)
2762 else if (intno
>= 0x80)
2763 name
= "Trap Instruction";
2765 name
= excp_names
[intno
];
2770 fprintf(logfile
, "%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n",
2773 env
->npc
, env
->regwptr
[6]);
2774 cpu_dump_state(env
, logfile
, fprintf
, 0);
2780 fprintf(logfile
, " code=");
2781 ptr
= (uint8_t *)env
->pc
;
2782 for(i
= 0; i
< 16; i
++) {
2783 fprintf(logfile
, " %02x", ldub(ptr
+ i
));
2785 fprintf(logfile
, "\n");
2791 #if !defined(CONFIG_USER_ONLY)
2792 if (env
->psret
== 0) {
2793 cpu_abort(env
, "Trap 0x%02x while interrupts disabled, Error state", env
->exception_index
);
2798 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
2800 env
->regwptr
[9] = env
->pc
;
2801 env
->regwptr
[10] = env
->npc
;
2802 env
->psrps
= env
->psrs
;
2804 env
->tbr
= (env
->tbr
& TBR_BASE_MASK
) | (intno
<< 4);
2806 env
->npc
= env
->pc
+ 4;
2807 env
->exception_index
= 0;
2811 #if !defined(CONFIG_USER_ONLY)
2813 static void do_unaligned_access(target_ulong addr
, int is_write
, int is_user
,
2816 #define MMUSUFFIX _mmu
2817 #define ALIGNED_ONLY
2819 # define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
2821 # define GETPC() (__builtin_return_address(0))
2825 #include "softmmu_template.h"
2828 #include "softmmu_template.h"
2831 #include "softmmu_template.h"
2834 #include "softmmu_template.h"
2836 static void do_unaligned_access(target_ulong addr
, int is_write
, int is_user
,
2839 #ifdef DEBUG_UNALIGNED
2840 printf("Unaligned access to 0x%x from 0x%x\n", addr
, env
->pc
);
2842 raise_exception(TT_UNALIGNED
);
2845 /* try to fill the TLB and return an exception if error. If retaddr is
2846 NULL, it means that the function was called in C code (i.e. not
2847 from generated code or from helper.c) */
2848 /* XXX: fix it to restore all registers */
2849 void tlb_fill(target_ulong addr
, int is_write
, int mmu_idx
, void *retaddr
)
2851 TranslationBlock
*tb
;
2854 CPUState
*saved_env
;
2856 /* XXX: hack to restore env in all cases, even if not called from
2859 env
= cpu_single_env
;
2861 ret
= cpu_sparc_handle_mmu_fault(env
, addr
, is_write
, mmu_idx
, 1);
2864 /* now we have a real cpu fault */
2865 pc
= (unsigned long)retaddr
;
2866 tb
= tb_find_pc(pc
);
2868 /* the PC is inside the translated code. It means that we have
2869 a virtual CPU fault */
2870 cpu_restore_state(tb
, env
, pc
, (void *)env
->cond
);
2880 #ifndef TARGET_SPARC64
2881 void do_unassigned_access(target_phys_addr_t addr
, int is_write
, int is_exec
,
2884 CPUState
*saved_env
;
2886 /* XXX: hack to restore env in all cases, even if not called from
2889 env
= cpu_single_env
;
2890 #ifdef DEBUG_UNASSIGNED
2892 printf("Unassigned mem %s access to " TARGET_FMT_plx
" asi 0x%02x from "
2894 is_exec
? "exec" : is_write
? "write" : "read", addr
, is_asi
,
2897 printf("Unassigned mem %s access to " TARGET_FMT_plx
" from "
2899 is_exec
? "exec" : is_write
? "write" : "read", addr
, env
->pc
);
2901 if (env
->mmuregs
[3]) /* Fault status register */
2902 env
->mmuregs
[3] = 1; /* overflow (not read before another fault) */
2904 env
->mmuregs
[3] |= 1 << 16;
2906 env
->mmuregs
[3] |= 1 << 5;
2908 env
->mmuregs
[3] |= 1 << 6;
2910 env
->mmuregs
[3] |= 1 << 7;
2911 env
->mmuregs
[3] |= (5 << 2) | 2;
2912 env
->mmuregs
[4] = addr
; /* Fault address register */
2913 if ((env
->mmuregs
[0] & MMU_E
) && !(env
->mmuregs
[0] & MMU_NF
)) {
2915 raise_exception(TT_CODE_ACCESS
);
2917 raise_exception(TT_DATA_ACCESS
);
2922 void do_unassigned_access(target_phys_addr_t addr
, int is_write
, int is_exec
,
2925 #ifdef DEBUG_UNASSIGNED
2926 CPUState
*saved_env
;
2928 /* XXX: hack to restore env in all cases, even if not called from
2931 env
= cpu_single_env
;
2932 printf("Unassigned mem access to " TARGET_FMT_plx
" from " TARGET_FMT_lx
"\n",
2937 raise_exception(TT_CODE_ACCESS
);
2939 raise_exception(TT_DATA_ACCESS
);