]>
git.proxmox.com Git - qemu.git/blob - target-sparc/op_helper.c
2 #include "host-utils.h"
8 //#define DEBUG_UNALIGNED
9 //#define DEBUG_UNASSIGNED
13 #define DPRINTF_MMU(fmt, args...) \
14 do { printf("MMU: " fmt , ##args); } while (0)
16 #define DPRINTF_MMU(fmt, args...)
20 #define DPRINTF_MXCC(fmt, args...) \
21 do { printf("MXCC: " fmt , ##args); } while (0)
23 #define DPRINTF_MXCC(fmt, args...)
27 #define DPRINTF_ASI(fmt, args...) \
28 do { printf("ASI: " fmt , ##args); } while (0)
30 #define DPRINTF_ASI(fmt, args...)
33 void raise_exception(int tt
)
35 env
->exception_index
= tt
;
39 void helper_trap(target_ulong nb_trap
)
41 env
->exception_index
= TT_TRAP
+ (nb_trap
& 0x7f);
45 void helper_trapcc(target_ulong nb_trap
, target_ulong do_trap
)
48 env
->exception_index
= TT_TRAP
+ (nb_trap
& 0x7f);
53 void helper_check_align(target_ulong addr
, uint32_t align
)
56 raise_exception(TT_UNALIGNED
);
59 #define F_HELPER(name, p) void helper_f##name##p(void)
61 #if defined(CONFIG_USER_ONLY)
62 #define F_BINOP(name) \
65 FT0 = float32_ ## name (FT0, FT1, &env->fp_status); \
69 DT0 = float64_ ## name (DT0, DT1, &env->fp_status); \
73 QT0 = float128_ ## name (QT0, QT1, &env->fp_status); \
76 #define F_BINOP(name) \
79 FT0 = float32_ ## name (FT0, FT1, &env->fp_status); \
83 DT0 = float64_ ## name (DT0, DT1, &env->fp_status); \
93 void helper_fsmuld(void)
95 DT0
= float64_mul(float32_to_float64(FT0
, &env
->fp_status
),
96 float32_to_float64(FT1
, &env
->fp_status
),
100 #if defined(CONFIG_USER_ONLY)
101 void helper_fdmulq(void)
103 QT0
= float128_mul(float64_to_float128(DT0
, &env
->fp_status
),
104 float64_to_float128(DT1
, &env
->fp_status
),
111 FT0
= float32_chs(FT1
);
114 #ifdef TARGET_SPARC64
117 DT0
= float64_chs(DT1
);
120 #if defined(CONFIG_USER_ONLY)
123 QT0
= float128_chs(QT1
);
128 /* Integer to float conversion. */
131 FT0
= int32_to_float32(*((int32_t *)&FT1
), &env
->fp_status
);
136 DT0
= int32_to_float64(*((int32_t *)&FT1
), &env
->fp_status
);
139 #if defined(CONFIG_USER_ONLY)
142 QT0
= int32_to_float128(*((int32_t *)&FT1
), &env
->fp_status
);
146 #ifdef TARGET_SPARC64
149 FT0
= int64_to_float32(*((int64_t *)&DT1
), &env
->fp_status
);
154 DT0
= int64_to_float64(*((int64_t *)&DT1
), &env
->fp_status
);
156 #if defined(CONFIG_USER_ONLY)
159 QT0
= int64_to_float128(*((int64_t *)&DT1
), &env
->fp_status
);
165 /* floating point conversion */
166 void helper_fdtos(void)
168 FT0
= float64_to_float32(DT1
, &env
->fp_status
);
171 void helper_fstod(void)
173 DT0
= float32_to_float64(FT1
, &env
->fp_status
);
176 #if defined(CONFIG_USER_ONLY)
177 void helper_fqtos(void)
179 FT0
= float128_to_float32(QT1
, &env
->fp_status
);
182 void helper_fstoq(void)
184 QT0
= float32_to_float128(FT1
, &env
->fp_status
);
187 void helper_fqtod(void)
189 DT0
= float128_to_float64(QT1
, &env
->fp_status
);
192 void helper_fdtoq(void)
194 QT0
= float64_to_float128(DT1
, &env
->fp_status
);
198 /* Float to integer conversion. */
199 void helper_fstoi(void)
201 *((int32_t *)&FT0
) = float32_to_int32_round_to_zero(FT1
, &env
->fp_status
);
204 void helper_fdtoi(void)
206 *((int32_t *)&FT0
) = float64_to_int32_round_to_zero(DT1
, &env
->fp_status
);
209 #if defined(CONFIG_USER_ONLY)
210 void helper_fqtoi(void)
212 *((int32_t *)&FT0
) = float128_to_int32_round_to_zero(QT1
, &env
->fp_status
);
216 #ifdef TARGET_SPARC64
217 void helper_fstox(void)
219 *((int64_t *)&DT0
) = float32_to_int64_round_to_zero(FT1
, &env
->fp_status
);
222 void helper_fdtox(void)
224 *((int64_t *)&DT0
) = float64_to_int64_round_to_zero(DT1
, &env
->fp_status
);
227 #if defined(CONFIG_USER_ONLY)
228 void helper_fqtox(void)
230 *((int64_t *)&DT0
) = float128_to_int64_round_to_zero(QT1
, &env
->fp_status
);
234 void helper_faligndata(void)
238 tmp
= (*((uint64_t *)&DT0
)) << ((env
->gsr
& 7) * 8);
239 tmp
|= (*((uint64_t *)&DT1
)) >> (64 - (env
->gsr
& 7) * 8);
240 *((uint64_t *)&DT0
) = tmp
;
243 void helper_movl_FT0_0(void)
245 *((uint32_t *)&FT0
) = 0;
248 void helper_movl_DT0_0(void)
250 *((uint64_t *)&DT0
) = 0;
253 void helper_movl_FT0_1(void)
255 *((uint32_t *)&FT0
) = 0xffffffff;
258 void helper_movl_DT0_1(void)
260 *((uint64_t *)&DT0
) = 0xffffffffffffffffULL
;
263 void helper_fnot(void)
265 *(uint64_t *)&DT0
= ~*(uint64_t *)&DT1
;
268 void helper_fnots(void)
270 *(uint32_t *)&FT0
= ~*(uint32_t *)&FT1
;
273 void helper_fnor(void)
275 *(uint64_t *)&DT0
= ~(*(uint64_t *)&DT0
| *(uint64_t *)&DT1
);
278 void helper_fnors(void)
280 *(uint32_t *)&FT0
= ~(*(uint32_t *)&FT0
| *(uint32_t *)&FT1
);
283 void helper_for(void)
285 *(uint64_t *)&DT0
|= *(uint64_t *)&DT1
;
288 void helper_fors(void)
290 *(uint32_t *)&FT0
|= *(uint32_t *)&FT1
;
293 void helper_fxor(void)
295 *(uint64_t *)&DT0
^= *(uint64_t *)&DT1
;
298 void helper_fxors(void)
300 *(uint32_t *)&FT0
^= *(uint32_t *)&FT1
;
303 void helper_fand(void)
305 *(uint64_t *)&DT0
&= *(uint64_t *)&DT1
;
308 void helper_fands(void)
310 *(uint32_t *)&FT0
&= *(uint32_t *)&FT1
;
313 void helper_fornot(void)
315 *(uint64_t *)&DT0
= *(uint64_t *)&DT0
| ~*(uint64_t *)&DT1
;
318 void helper_fornots(void)
320 *(uint32_t *)&FT0
= *(uint32_t *)&FT0
| ~*(uint32_t *)&FT1
;
323 void helper_fandnot(void)
325 *(uint64_t *)&DT0
= *(uint64_t *)&DT0
& ~*(uint64_t *)&DT1
;
328 void helper_fandnots(void)
330 *(uint32_t *)&FT0
= *(uint32_t *)&FT0
& ~*(uint32_t *)&FT1
;
333 void helper_fnand(void)
335 *(uint64_t *)&DT0
= ~(*(uint64_t *)&DT0
& *(uint64_t *)&DT1
);
338 void helper_fnands(void)
340 *(uint32_t *)&FT0
= ~(*(uint32_t *)&FT0
& *(uint32_t *)&FT1
);
343 void helper_fxnor(void)
345 *(uint64_t *)&DT0
^= ~*(uint64_t *)&DT1
;
348 void helper_fxnors(void)
350 *(uint32_t *)&FT0
^= ~*(uint32_t *)&FT1
;
353 #ifdef WORDS_BIGENDIAN
354 #define VIS_B64(n) b[7 - (n)]
355 #define VIS_W64(n) w[3 - (n)]
356 #define VIS_SW64(n) sw[3 - (n)]
357 #define VIS_L64(n) l[1 - (n)]
358 #define VIS_B32(n) b[3 - (n)]
359 #define VIS_W32(n) w[1 - (n)]
361 #define VIS_B64(n) b[n]
362 #define VIS_W64(n) w[n]
363 #define VIS_SW64(n) sw[n]
364 #define VIS_L64(n) l[n]
365 #define VIS_B32(n) b[n]
366 #define VIS_W32(n) w[n]
384 void helper_fpmerge(void)
391 // Reverse calculation order to handle overlap
392 d
.VIS_B64(7) = s
.VIS_B64(3);
393 d
.VIS_B64(6) = d
.VIS_B64(3);
394 d
.VIS_B64(5) = s
.VIS_B64(2);
395 d
.VIS_B64(4) = d
.VIS_B64(2);
396 d
.VIS_B64(3) = s
.VIS_B64(1);
397 d
.VIS_B64(2) = d
.VIS_B64(1);
398 d
.VIS_B64(1) = s
.VIS_B64(0);
399 //d.VIS_B64(0) = d.VIS_B64(0);
404 void helper_fmul8x16(void)
413 tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B64(r); \
414 if ((tmp & 0xff) > 0x7f) \
416 d.VIS_W64(r) = tmp >> 8;
427 void helper_fmul8x16al(void)
436 tmp = (int32_t)d.VIS_SW64(1) * (int32_t)s.VIS_B64(r); \
437 if ((tmp & 0xff) > 0x7f) \
439 d.VIS_W64(r) = tmp >> 8;
450 void helper_fmul8x16au(void)
459 tmp = (int32_t)d.VIS_SW64(0) * (int32_t)s.VIS_B64(r); \
460 if ((tmp & 0xff) > 0x7f) \
462 d.VIS_W64(r) = tmp >> 8;
473 void helper_fmul8sux16(void)
482 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
483 if ((tmp & 0xff) > 0x7f) \
485 d.VIS_W64(r) = tmp >> 8;
496 void helper_fmul8ulx16(void)
505 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
506 if ((tmp & 0xff) > 0x7f) \
508 d.VIS_W64(r) = tmp >> 8;
519 void helper_fmuld8sux16(void)
528 tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
529 if ((tmp & 0xff) > 0x7f) \
533 // Reverse calculation order to handle overlap
541 void helper_fmuld8ulx16(void)
550 tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
551 if ((tmp & 0xff) > 0x7f) \
555 // Reverse calculation order to handle overlap
563 void helper_fexpand(void)
568 s
.l
= (uint32_t)(*(uint64_t *)&DT0
& 0xffffffff);
570 d
.VIS_L64(0) = s
.VIS_W32(0) << 4;
571 d
.VIS_L64(1) = s
.VIS_W32(1) << 4;
572 d
.VIS_L64(2) = s
.VIS_W32(2) << 4;
573 d
.VIS_L64(3) = s
.VIS_W32(3) << 4;
578 #define VIS_HELPER(name, F) \
579 void name##16(void) \
586 d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0)); \
587 d.VIS_W64(1) = F(d.VIS_W64(1), s.VIS_W64(1)); \
588 d.VIS_W64(2) = F(d.VIS_W64(2), s.VIS_W64(2)); \
589 d.VIS_W64(3) = F(d.VIS_W64(3), s.VIS_W64(3)); \
594 void name##16s(void) \
601 d.VIS_W32(0) = F(d.VIS_W32(0), s.VIS_W32(0)); \
602 d.VIS_W32(1) = F(d.VIS_W32(1), s.VIS_W32(1)); \
607 void name##32(void) \
614 d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0)); \
615 d.VIS_L64(1) = F(d.VIS_L64(1), s.VIS_L64(1)); \
620 void name##32s(void) \
632 #define FADD(a, b) ((a) + (b))
633 #define FSUB(a, b) ((a) - (b))
634 VIS_HELPER(helper_fpadd
, FADD
)
635 VIS_HELPER(helper_fpsub
, FSUB
)
637 #define VIS_CMPHELPER(name, F) \
638 void name##16(void) \
645 d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0))? 1: 0; \
646 d.VIS_W64(0) |= F(d.VIS_W64(1), s.VIS_W64(1))? 2: 0; \
647 d.VIS_W64(0) |= F(d.VIS_W64(2), s.VIS_W64(2))? 4: 0; \
648 d.VIS_W64(0) |= F(d.VIS_W64(3), s.VIS_W64(3))? 8: 0; \
653 void name##32(void) \
660 d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0))? 1: 0; \
661 d.VIS_L64(0) |= F(d.VIS_L64(1), s.VIS_L64(1))? 2: 0; \
666 #define FCMPGT(a, b) ((a) > (b))
667 #define FCMPEQ(a, b) ((a) == (b))
668 #define FCMPLE(a, b) ((a) <= (b))
669 #define FCMPNE(a, b) ((a) != (b))
671 VIS_CMPHELPER(helper_fcmpgt
, FCMPGT
)
672 VIS_CMPHELPER(helper_fcmpeq
, FCMPEQ
)
673 VIS_CMPHELPER(helper_fcmple
, FCMPLE
)
674 VIS_CMPHELPER(helper_fcmpne
, FCMPNE
)
677 void helper_check_ieee_exceptions(void)
681 status
= get_float_exception_flags(&env
->fp_status
);
683 /* Copy IEEE 754 flags into FSR */
684 if (status
& float_flag_invalid
)
686 if (status
& float_flag_overflow
)
688 if (status
& float_flag_underflow
)
690 if (status
& float_flag_divbyzero
)
692 if (status
& float_flag_inexact
)
695 if ((env
->fsr
& FSR_CEXC_MASK
) & ((env
->fsr
& FSR_TEM_MASK
) >> 23)) {
696 /* Unmasked exception, generate a trap */
697 env
->fsr
|= FSR_FTT_IEEE_EXCP
;
698 raise_exception(TT_FP_EXCP
);
700 /* Accumulate exceptions */
701 env
->fsr
|= (env
->fsr
& FSR_CEXC_MASK
) << 5;
706 void helper_clear_float_exceptions(void)
708 set_float_exception_flags(0, &env
->fp_status
);
711 void helper_fabss(void)
713 FT0
= float32_abs(FT1
);
716 #ifdef TARGET_SPARC64
717 void helper_fabsd(void)
719 DT0
= float64_abs(DT1
);
722 #if defined(CONFIG_USER_ONLY)
723 void helper_fabsq(void)
725 QT0
= float128_abs(QT1
);
730 void helper_fsqrts(void)
732 FT0
= float32_sqrt(FT1
, &env
->fp_status
);
735 void helper_fsqrtd(void)
737 DT0
= float64_sqrt(DT1
, &env
->fp_status
);
740 #if defined(CONFIG_USER_ONLY)
741 void helper_fsqrtq(void)
743 QT0
= float128_sqrt(QT1
, &env
->fp_status
);
747 #define GEN_FCMP(name, size, reg1, reg2, FS, TRAP) \
748 void glue(helper_, name) (void) \
750 target_ulong new_fsr; \
752 env->fsr &= ~((FSR_FCC1 | FSR_FCC0) << FS); \
753 switch (glue(size, _compare) (reg1, reg2, &env->fp_status)) { \
754 case float_relation_unordered: \
755 new_fsr = (FSR_FCC1 | FSR_FCC0) << FS; \
756 if ((env->fsr & FSR_NVM) || TRAP) { \
757 env->fsr |= new_fsr; \
758 env->fsr |= FSR_NVC; \
759 env->fsr |= FSR_FTT_IEEE_EXCP; \
760 raise_exception(TT_FP_EXCP); \
762 env->fsr |= FSR_NVA; \
765 case float_relation_less: \
766 new_fsr = FSR_FCC0 << FS; \
768 case float_relation_greater: \
769 new_fsr = FSR_FCC1 << FS; \
775 env->fsr |= new_fsr; \
778 GEN_FCMP(fcmps
, float32
, FT0
, FT1
, 0, 0);
779 GEN_FCMP(fcmpd
, float64
, DT0
, DT1
, 0, 0);
781 GEN_FCMP(fcmpes
, float32
, FT0
, FT1
, 0, 1);
782 GEN_FCMP(fcmped
, float64
, DT0
, DT1
, 0, 1);
784 #ifdef CONFIG_USER_ONLY
785 GEN_FCMP(fcmpq
, float128
, QT0
, QT1
, 0, 0);
786 GEN_FCMP(fcmpeq
, float128
, QT0
, QT1
, 0, 1);
789 #ifdef TARGET_SPARC64
790 GEN_FCMP(fcmps_fcc1
, float32
, FT0
, FT1
, 22, 0);
791 GEN_FCMP(fcmpd_fcc1
, float64
, DT0
, DT1
, 22, 0);
793 GEN_FCMP(fcmps_fcc2
, float32
, FT0
, FT1
, 24, 0);
794 GEN_FCMP(fcmpd_fcc2
, float64
, DT0
, DT1
, 24, 0);
796 GEN_FCMP(fcmps_fcc3
, float32
, FT0
, FT1
, 26, 0);
797 GEN_FCMP(fcmpd_fcc3
, float64
, DT0
, DT1
, 26, 0);
799 GEN_FCMP(fcmpes_fcc1
, float32
, FT0
, FT1
, 22, 1);
800 GEN_FCMP(fcmped_fcc1
, float64
, DT0
, DT1
, 22, 1);
802 GEN_FCMP(fcmpes_fcc2
, float32
, FT0
, FT1
, 24, 1);
803 GEN_FCMP(fcmped_fcc2
, float64
, DT0
, DT1
, 24, 1);
805 GEN_FCMP(fcmpes_fcc3
, float32
, FT0
, FT1
, 26, 1);
806 GEN_FCMP(fcmped_fcc3
, float64
, DT0
, DT1
, 26, 1);
807 #ifdef CONFIG_USER_ONLY
808 GEN_FCMP(fcmpq_fcc1
, float128
, QT0
, QT1
, 22, 0);
809 GEN_FCMP(fcmpq_fcc2
, float128
, QT0
, QT1
, 24, 0);
810 GEN_FCMP(fcmpq_fcc3
, float128
, QT0
, QT1
, 26, 0);
811 GEN_FCMP(fcmpeq_fcc1
, float128
, QT0
, QT1
, 22, 1);
812 GEN_FCMP(fcmpeq_fcc2
, float128
, QT0
, QT1
, 24, 1);
813 GEN_FCMP(fcmpeq_fcc3
, float128
, QT0
, QT1
, 26, 1);
817 #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) && defined(DEBUG_MXCC)
818 static void dump_mxcc(CPUState
*env
)
820 printf("mxccdata: %016llx %016llx %016llx %016llx\n",
821 env
->mxccdata
[0], env
->mxccdata
[1], env
->mxccdata
[2], env
->mxccdata
[3]);
822 printf("mxccregs: %016llx %016llx %016llx %016llx\n"
823 " %016llx %016llx %016llx %016llx\n",
824 env
->mxccregs
[0], env
->mxccregs
[1], env
->mxccregs
[2], env
->mxccregs
[3],
825 env
->mxccregs
[4], env
->mxccregs
[5], env
->mxccregs
[6], env
->mxccregs
[7]);
829 #if (defined(TARGET_SPARC64) || !defined(CONFIG_USER_ONLY)) \
830 && defined(DEBUG_ASI)
831 static void dump_asi(const char *txt
, target_ulong addr
, int asi
, int size
,
837 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %02" PRIx64
"\n", txt
,
838 addr
, asi
, r1
& 0xff);
841 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %04" PRIx64
"\n", txt
,
842 addr
, asi
, r1
& 0xffff);
845 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %08" PRIx64
"\n", txt
,
846 addr
, asi
, r1
& 0xffffffff);
849 DPRINTF_ASI("%s "TARGET_FMT_lx
" asi 0x%02x = %016" PRIx64
"\n", txt
,
856 #ifndef TARGET_SPARC64
857 #ifndef CONFIG_USER_ONLY
858 uint64_t helper_ld_asi(target_ulong addr
, int asi
, int size
, int sign
)
861 #if defined(DEBUG_MXCC) || defined(DEBUG_ASI)
862 uint32_t last_addr
= addr
;
866 case 2: /* SuperSparc MXCC registers */
868 case 0x01c00a00: /* MXCC control register */
870 ret
= env
->mxccregs
[3];
872 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
874 case 0x01c00a04: /* MXCC control register */
876 ret
= env
->mxccregs
[3];
878 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
880 case 0x01c00c00: /* Module reset register */
882 ret
= env
->mxccregs
[5];
883 // should we do something here?
885 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
887 case 0x01c00f00: /* MBus port address register */
889 ret
= env
->mxccregs
[7];
891 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
894 DPRINTF_MXCC("%08x: unimplemented address, size: %d\n", addr
, size
);
897 DPRINTF_MXCC("asi = %d, size = %d, sign = %d, addr = %08x -> ret = %08x,"
898 "addr = %08x\n", asi
, size
, sign
, last_addr
, ret
, addr
);
903 case 3: /* MMU probe */
907 mmulev
= (addr
>> 8) & 15;
911 ret
= mmu_probe(env
, addr
, mmulev
);
912 DPRINTF_MMU("mmu_probe: 0x%08x (lev %d) -> 0x%08" PRIx64
"\n",
916 case 4: /* read MMU regs */
918 int reg
= (addr
>> 8) & 0x1f;
920 ret
= env
->mmuregs
[reg
];
921 if (reg
== 3) /* Fault status cleared on read */
923 else if (reg
== 0x13) /* Fault status read */
924 ret
= env
->mmuregs
[3];
925 else if (reg
== 0x14) /* Fault address read */
926 ret
= env
->mmuregs
[4];
927 DPRINTF_MMU("mmu_read: reg[%d] = 0x%08" PRIx64
"\n", reg
, ret
);
930 case 5: // Turbosparc ITLB Diagnostic
931 case 6: // Turbosparc DTLB Diagnostic
932 case 7: // Turbosparc IOTLB Diagnostic
934 case 9: /* Supervisor code access */
937 ret
= ldub_code(addr
);
940 ret
= lduw_code(addr
& ~1);
944 ret
= ldl_code(addr
& ~3);
947 ret
= ldq_code(addr
& ~7);
951 case 0xa: /* User data access */
954 ret
= ldub_user(addr
);
957 ret
= lduw_user(addr
& ~1);
961 ret
= ldl_user(addr
& ~3);
964 ret
= ldq_user(addr
& ~7);
968 case 0xb: /* Supervisor data access */
971 ret
= ldub_kernel(addr
);
974 ret
= lduw_kernel(addr
& ~1);
978 ret
= ldl_kernel(addr
& ~3);
981 ret
= ldq_kernel(addr
& ~7);
985 case 0xc: /* I-cache tag */
986 case 0xd: /* I-cache data */
987 case 0xe: /* D-cache tag */
988 case 0xf: /* D-cache data */
990 case 0x20: /* MMU passthrough */
993 ret
= ldub_phys(addr
);
996 ret
= lduw_phys(addr
& ~1);
1000 ret
= ldl_phys(addr
& ~3);
1003 ret
= ldq_phys(addr
& ~7);
1007 case 0x21 ... 0x2f: /* MMU passthrough, 0x100000000 to 0xfffffffff */
1010 ret
= ldub_phys((target_phys_addr_t
)addr
1011 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
1014 ret
= lduw_phys((target_phys_addr_t
)(addr
& ~1)
1015 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
1019 ret
= ldl_phys((target_phys_addr_t
)(addr
& ~3)
1020 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
1023 ret
= ldq_phys((target_phys_addr_t
)(addr
& ~7)
1024 | ((target_phys_addr_t
)(asi
& 0xf) << 32));
1028 case 0x30: // Turbosparc secondary cache diagnostic
1029 case 0x31: // Turbosparc RAM snoop
1030 case 0x32: // Turbosparc page table descriptor diagnostic
1031 case 0x39: /* data cache diagnostic register */
1034 case 8: /* User code access, XXX */
1036 do_unassigned_access(addr
, 0, 0, asi
);
1046 ret
= (int16_t) ret
;
1049 ret
= (int32_t) ret
;
1056 dump_asi("read ", last_addr
, asi
, size
, ret
);
1061 void helper_st_asi(target_ulong addr
, uint64_t val
, int asi
, int size
)
1064 case 2: /* SuperSparc MXCC registers */
1066 case 0x01c00000: /* MXCC stream data register 0 */
1068 env
->mxccdata
[0] = val
;
1070 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1072 case 0x01c00008: /* MXCC stream data register 1 */
1074 env
->mxccdata
[1] = val
;
1076 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1078 case 0x01c00010: /* MXCC stream data register 2 */
1080 env
->mxccdata
[2] = val
;
1082 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1084 case 0x01c00018: /* MXCC stream data register 3 */
1086 env
->mxccdata
[3] = val
;
1088 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1090 case 0x01c00100: /* MXCC stream source */
1092 env
->mxccregs
[0] = val
;
1094 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1095 env
->mxccdata
[0] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) + 0);
1096 env
->mxccdata
[1] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) + 8);
1097 env
->mxccdata
[2] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) + 16);
1098 env
->mxccdata
[3] = ldq_phys((env
->mxccregs
[0] & 0xffffffffULL
) + 24);
1100 case 0x01c00200: /* MXCC stream destination */
1102 env
->mxccregs
[1] = val
;
1104 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1105 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 0, env
->mxccdata
[0]);
1106 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 8, env
->mxccdata
[1]);
1107 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 16, env
->mxccdata
[2]);
1108 stq_phys((env
->mxccregs
[1] & 0xffffffffULL
) + 24, env
->mxccdata
[3]);
1110 case 0x01c00a00: /* MXCC control register */
1112 env
->mxccregs
[3] = val
;
1114 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1116 case 0x01c00a04: /* MXCC control register */
1118 env
->mxccregs
[3] = (env
->mxccregs
[0xa] & 0xffffffff00000000ULL
) | val
;
1120 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1122 case 0x01c00e00: /* MXCC error register */
1123 // writing a 1 bit clears the error
1125 env
->mxccregs
[6] &= ~val
;
1127 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1129 case 0x01c00f00: /* MBus port address register */
1131 env
->mxccregs
[7] = val
;
1133 DPRINTF_MXCC("%08x: unimplemented access size: %d\n", addr
, size
);
1136 DPRINTF_MXCC("%08x: unimplemented address, size: %d\n", addr
, size
);
1139 DPRINTF_MXCC("asi = %d, size = %d, addr = %08x, val = %08x\n", asi
, size
, addr
, val
);
1144 case 3: /* MMU flush */
1148 mmulev
= (addr
>> 8) & 15;
1149 DPRINTF_MMU("mmu flush level %d\n", mmulev
);
1151 case 0: // flush page
1152 tlb_flush_page(env
, addr
& 0xfffff000);
1154 case 1: // flush segment (256k)
1155 case 2: // flush region (16M)
1156 case 3: // flush context (4G)
1157 case 4: // flush entire
1168 case 4: /* write MMU regs */
1170 int reg
= (addr
>> 8) & 0x1f;
1173 oldreg
= env
->mmuregs
[reg
];
1175 case 0: // Control Register
1176 env
->mmuregs
[reg
] = (env
->mmuregs
[reg
] & 0xff000000) |
1178 // Mappings generated during no-fault mode or MMU
1179 // disabled mode are invalid in normal mode
1180 if ((oldreg
& (MMU_E
| MMU_NF
| env
->mmu_bm
)) !=
1181 (env
->mmuregs
[reg
] & (MMU_E
| MMU_NF
| env
->mmu_bm
)))
1184 case 1: // Context Table Pointer Register
1185 env
->mmuregs
[reg
] = val
& env
->mmu_ctpr_mask
;
1187 case 2: // Context Register
1188 env
->mmuregs
[reg
] = val
& env
->mmu_cxr_mask
;
1189 if (oldreg
!= env
->mmuregs
[reg
]) {
1190 /* we flush when the MMU context changes because
1191 QEMU has no MMU context support */
1195 case 3: // Synchronous Fault Status Register with Clear
1196 case 4: // Synchronous Fault Address Register
1198 case 0x10: // TLB Replacement Control Register
1199 env
->mmuregs
[reg
] = val
& env
->mmu_trcr_mask
;
1201 case 0x13: // Synchronous Fault Status Register with Read and Clear
1202 env
->mmuregs
[3] = val
& env
->mmu_sfsr_mask
;
1204 case 0x14: // Synchronous Fault Address Register
1205 env
->mmuregs
[4] = val
;
1208 env
->mmuregs
[reg
] = val
;
1211 if (oldreg
!= env
->mmuregs
[reg
]) {
1212 DPRINTF_MMU("mmu change reg[%d]: 0x%08x -> 0x%08x\n", reg
, oldreg
, env
->mmuregs
[reg
]);
1219 case 5: // Turbosparc ITLB Diagnostic
1220 case 6: // Turbosparc DTLB Diagnostic
1221 case 7: // Turbosparc IOTLB Diagnostic
1223 case 0xa: /* User data access */
1226 stb_user(addr
, val
);
1229 stw_user(addr
& ~1, val
);
1233 stl_user(addr
& ~3, val
);
1236 stq_user(addr
& ~7, val
);
1240 case 0xb: /* Supervisor data access */
1243 stb_kernel(addr
, val
);
1246 stw_kernel(addr
& ~1, val
);
1250 stl_kernel(addr
& ~3, val
);
1253 stq_kernel(addr
& ~7, val
);
1257 case 0xc: /* I-cache tag */
1258 case 0xd: /* I-cache data */
1259 case 0xe: /* D-cache tag */
1260 case 0xf: /* D-cache data */
1261 case 0x10: /* I/D-cache flush page */
1262 case 0x11: /* I/D-cache flush segment */
1263 case 0x12: /* I/D-cache flush region */
1264 case 0x13: /* I/D-cache flush context */
1265 case 0x14: /* I/D-cache flush user */
1267 case 0x17: /* Block copy, sta access */
1273 uint32_t src
= val
& ~3, dst
= addr
& ~3, temp
;
1275 for (i
= 0; i
< 32; i
+= 4, src
+= 4, dst
+= 4) {
1276 temp
= ldl_kernel(src
);
1277 stl_kernel(dst
, temp
);
1281 case 0x1f: /* Block fill, stda access */
1284 // fill 32 bytes with val
1286 uint32_t dst
= addr
& 7;
1288 for (i
= 0; i
< 32; i
+= 8, dst
+= 8)
1289 stq_kernel(dst
, val
);
1292 case 0x20: /* MMU passthrough */
1296 stb_phys(addr
, val
);
1299 stw_phys(addr
& ~1, val
);
1303 stl_phys(addr
& ~3, val
);
1306 stq_phys(addr
& ~7, val
);
1311 case 0x21 ... 0x2f: /* MMU passthrough, 0x100000000 to 0xfffffffff */
1315 stb_phys((target_phys_addr_t
)addr
1316 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1319 stw_phys((target_phys_addr_t
)(addr
& ~1)
1320 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1324 stl_phys((target_phys_addr_t
)(addr
& ~3)
1325 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1328 stq_phys((target_phys_addr_t
)(addr
& ~7)
1329 | ((target_phys_addr_t
)(asi
& 0xf) << 32), val
);
1334 case 0x30: // store buffer tags or Turbosparc secondary cache diagnostic
1335 case 0x31: // store buffer data, Ross RT620 I-cache flush or
1336 // Turbosparc snoop RAM
1337 case 0x32: // store buffer control or Turbosparc page table descriptor diagnostic
1338 case 0x36: /* I-cache flash clear */
1339 case 0x37: /* D-cache flash clear */
1340 case 0x38: /* breakpoint diagnostics */
1341 case 0x4c: /* breakpoint action */
1343 case 8: /* User code access, XXX */
1344 case 9: /* Supervisor code access, XXX */
1346 do_unassigned_access(addr
, 1, 0, asi
);
1350 dump_asi("write", addr
, asi
, size
, val
);
1354 #endif /* CONFIG_USER_ONLY */
1355 #else /* TARGET_SPARC64 */
1357 #ifdef CONFIG_USER_ONLY
1358 uint64_t helper_ld_asi(target_ulong addr
, int asi
, int size
, int sign
)
1361 #if defined(DEBUG_ASI)
1362 target_ulong last_addr
= addr
;
1366 raise_exception(TT_PRIV_ACT
);
1369 case 0x80: // Primary
1370 case 0x82: // Primary no-fault
1371 case 0x88: // Primary LE
1372 case 0x8a: // Primary no-fault LE
1376 ret
= ldub_raw(addr
);
1379 ret
= lduw_raw(addr
& ~1);
1382 ret
= ldl_raw(addr
& ~3);
1386 ret
= ldq_raw(addr
& ~7);
1391 case 0x81: // Secondary
1392 case 0x83: // Secondary no-fault
1393 case 0x89: // Secondary LE
1394 case 0x8b: // Secondary no-fault LE
1401 /* Convert from little endian */
1403 case 0x88: // Primary LE
1404 case 0x89: // Secondary LE
1405 case 0x8a: // Primary no-fault LE
1406 case 0x8b: // Secondary no-fault LE
1424 /* Convert to signed number */
1431 ret
= (int16_t) ret
;
1434 ret
= (int32_t) ret
;
1441 dump_asi("read ", last_addr
, asi
, size
, ret
);
1446 void helper_st_asi(target_ulong addr
, target_ulong val
, int asi
, int size
)
1449 dump_asi("write", addr
, asi
, size
, val
);
1452 raise_exception(TT_PRIV_ACT
);
1454 /* Convert to little endian */
1456 case 0x88: // Primary LE
1457 case 0x89: // Secondary LE
1460 addr
= bswap16(addr
);
1463 addr
= bswap32(addr
);
1466 addr
= bswap64(addr
);
1476 case 0x80: // Primary
1477 case 0x88: // Primary LE
1484 stw_raw(addr
& ~1, val
);
1487 stl_raw(addr
& ~3, val
);
1491 stq_raw(addr
& ~7, val
);
1496 case 0x81: // Secondary
1497 case 0x89: // Secondary LE
1501 case 0x82: // Primary no-fault, RO
1502 case 0x83: // Secondary no-fault, RO
1503 case 0x8a: // Primary no-fault LE, RO
1504 case 0x8b: // Secondary no-fault LE, RO
1506 do_unassigned_access(addr
, 1, 0, 1);
1511 #else /* CONFIG_USER_ONLY */
1513 uint64_t helper_ld_asi(target_ulong addr
, int asi
, int size
, int sign
)
1516 #if defined(DEBUG_ASI)
1517 target_ulong last_addr
= addr
;
1520 if ((asi
< 0x80 && (env
->pstate
& PS_PRIV
) == 0)
1521 || (asi
>= 0x30 && asi
< 0x80 && !(env
->hpstate
& HS_PRIV
)))
1522 raise_exception(TT_PRIV_ACT
);
1525 case 0x10: // As if user primary
1526 case 0x18: // As if user primary LE
1527 case 0x80: // Primary
1528 case 0x82: // Primary no-fault
1529 case 0x88: // Primary LE
1530 case 0x8a: // Primary no-fault LE
1531 if ((asi
& 0x80) && (env
->pstate
& PS_PRIV
)) {
1532 if (env
->hpstate
& HS_PRIV
) {
1535 ret
= ldub_hypv(addr
);
1538 ret
= lduw_hypv(addr
& ~1);
1541 ret
= ldl_hypv(addr
& ~3);
1545 ret
= ldq_hypv(addr
& ~7);
1551 ret
= ldub_kernel(addr
);
1554 ret
= lduw_kernel(addr
& ~1);
1557 ret
= ldl_kernel(addr
& ~3);
1561 ret
= ldq_kernel(addr
& ~7);
1568 ret
= ldub_user(addr
);
1571 ret
= lduw_user(addr
& ~1);
1574 ret
= ldl_user(addr
& ~3);
1578 ret
= ldq_user(addr
& ~7);
1583 case 0x14: // Bypass
1584 case 0x15: // Bypass, non-cacheable
1585 case 0x1c: // Bypass LE
1586 case 0x1d: // Bypass, non-cacheable LE
1590 ret
= ldub_phys(addr
);
1593 ret
= lduw_phys(addr
& ~1);
1596 ret
= ldl_phys(addr
& ~3);
1600 ret
= ldq_phys(addr
& ~7);
1605 case 0x04: // Nucleus
1606 case 0x0c: // Nucleus Little Endian (LE)
1607 case 0x11: // As if user secondary
1608 case 0x19: // As if user secondary LE
1609 case 0x24: // Nucleus quad LDD 128 bit atomic
1610 case 0x2c: // Nucleus quad LDD 128 bit atomic
1611 case 0x4a: // UPA config
1612 case 0x81: // Secondary
1613 case 0x83: // Secondary no-fault
1614 case 0x89: // Secondary LE
1615 case 0x8b: // Secondary no-fault LE
1621 case 0x50: // I-MMU regs
1623 int reg
= (addr
>> 3) & 0xf;
1625 ret
= env
->immuregs
[reg
];
1628 case 0x51: // I-MMU 8k TSB pointer
1629 case 0x52: // I-MMU 64k TSB pointer
1630 case 0x55: // I-MMU data access
1633 case 0x56: // I-MMU tag read
1637 for (i
= 0; i
< 64; i
++) {
1638 // Valid, ctx match, vaddr match
1639 if ((env
->itlb_tte
[i
] & 0x8000000000000000ULL
) != 0 &&
1640 env
->itlb_tag
[i
] == addr
) {
1641 ret
= env
->itlb_tag
[i
];
1647 case 0x58: // D-MMU regs
1649 int reg
= (addr
>> 3) & 0xf;
1651 ret
= env
->dmmuregs
[reg
];
1654 case 0x5e: // D-MMU tag read
1658 for (i
= 0; i
< 64; i
++) {
1659 // Valid, ctx match, vaddr match
1660 if ((env
->dtlb_tte
[i
] & 0x8000000000000000ULL
) != 0 &&
1661 env
->dtlb_tag
[i
] == addr
) {
1662 ret
= env
->dtlb_tag
[i
];
1668 case 0x59: // D-MMU 8k TSB pointer
1669 case 0x5a: // D-MMU 64k TSB pointer
1670 case 0x5b: // D-MMU data pointer
1671 case 0x5d: // D-MMU data access
1672 case 0x48: // Interrupt dispatch, RO
1673 case 0x49: // Interrupt data receive
1674 case 0x7f: // Incoming interrupt vector, RO
1677 case 0x54: // I-MMU data in, WO
1678 case 0x57: // I-MMU demap, WO
1679 case 0x5c: // D-MMU data in, WO
1680 case 0x5f: // D-MMU demap, WO
1681 case 0x77: // Interrupt vector, WO
1683 do_unassigned_access(addr
, 0, 0, 1);
1688 /* Convert from little endian */
1690 case 0x0c: // Nucleus Little Endian (LE)
1691 case 0x18: // As if user primary LE
1692 case 0x19: // As if user secondary LE
1693 case 0x1c: // Bypass LE
1694 case 0x1d: // Bypass, non-cacheable LE
1695 case 0x88: // Primary LE
1696 case 0x89: // Secondary LE
1697 case 0x8a: // Primary no-fault LE
1698 case 0x8b: // Secondary no-fault LE
1716 /* Convert to signed number */
1723 ret
= (int16_t) ret
;
1726 ret
= (int32_t) ret
;
1733 dump_asi("read ", last_addr
, asi
, size
, ret
);
1738 void helper_st_asi(target_ulong addr
, target_ulong val
, int asi
, int size
)
1741 dump_asi("write", addr
, asi
, size
, val
);
1743 if ((asi
< 0x80 && (env
->pstate
& PS_PRIV
) == 0)
1744 || (asi
>= 0x30 && asi
< 0x80 && !(env
->hpstate
& HS_PRIV
)))
1745 raise_exception(TT_PRIV_ACT
);
1747 /* Convert to little endian */
1749 case 0x0c: // Nucleus Little Endian (LE)
1750 case 0x18: // As if user primary LE
1751 case 0x19: // As if user secondary LE
1752 case 0x1c: // Bypass LE
1753 case 0x1d: // Bypass, non-cacheable LE
1754 case 0x88: // Primary LE
1755 case 0x89: // Secondary LE
1758 addr
= bswap16(addr
);
1761 addr
= bswap32(addr
);
1764 addr
= bswap64(addr
);
1774 case 0x10: // As if user primary
1775 case 0x18: // As if user primary LE
1776 case 0x80: // Primary
1777 case 0x88: // Primary LE
1778 if ((asi
& 0x80) && (env
->pstate
& PS_PRIV
)) {
1779 if (env
->hpstate
& HS_PRIV
) {
1782 stb_hypv(addr
, val
);
1785 stw_hypv(addr
& ~1, val
);
1788 stl_hypv(addr
& ~3, val
);
1792 stq_hypv(addr
& ~7, val
);
1798 stb_kernel(addr
, val
);
1801 stw_kernel(addr
& ~1, val
);
1804 stl_kernel(addr
& ~3, val
);
1808 stq_kernel(addr
& ~7, val
);
1815 stb_user(addr
, val
);
1818 stw_user(addr
& ~1, val
);
1821 stl_user(addr
& ~3, val
);
1825 stq_user(addr
& ~7, val
);
1830 case 0x14: // Bypass
1831 case 0x15: // Bypass, non-cacheable
1832 case 0x1c: // Bypass LE
1833 case 0x1d: // Bypass, non-cacheable LE
1837 stb_phys(addr
, val
);
1840 stw_phys(addr
& ~1, val
);
1843 stl_phys(addr
& ~3, val
);
1847 stq_phys(addr
& ~7, val
);
1852 case 0x04: // Nucleus
1853 case 0x0c: // Nucleus Little Endian (LE)
1854 case 0x11: // As if user secondary
1855 case 0x19: // As if user secondary LE
1856 case 0x24: // Nucleus quad LDD 128 bit atomic
1857 case 0x2c: // Nucleus quad LDD 128 bit atomic
1858 case 0x4a: // UPA config
1859 case 0x81: // Secondary
1860 case 0x89: // Secondary LE
1868 env
->lsu
= val
& (DMMU_E
| IMMU_E
);
1869 // Mappings generated during D/I MMU disabled mode are
1870 // invalid in normal mode
1871 if (oldreg
!= env
->lsu
) {
1872 DPRINTF_MMU("LSU change: 0x%" PRIx64
" -> 0x%" PRIx64
"\n", oldreg
, env
->lsu
);
1880 case 0x50: // I-MMU regs
1882 int reg
= (addr
>> 3) & 0xf;
1885 oldreg
= env
->immuregs
[reg
];
1890 case 1: // Not in I-MMU
1897 val
= 0; // Clear SFSR
1899 case 5: // TSB access
1900 case 6: // Tag access
1904 env
->immuregs
[reg
] = val
;
1905 if (oldreg
!= env
->immuregs
[reg
]) {
1906 DPRINTF_MMU("mmu change reg[%d]: 0x%08" PRIx64
" -> 0x%08" PRIx64
"\n", reg
, oldreg
, env
->immuregs
[reg
]);
1913 case 0x54: // I-MMU data in
1917 // Try finding an invalid entry
1918 for (i
= 0; i
< 64; i
++) {
1919 if ((env
->itlb_tte
[i
] & 0x8000000000000000ULL
) == 0) {
1920 env
->itlb_tag
[i
] = env
->immuregs
[6];
1921 env
->itlb_tte
[i
] = val
;
1925 // Try finding an unlocked entry
1926 for (i
= 0; i
< 64; i
++) {
1927 if ((env
->itlb_tte
[i
] & 0x40) == 0) {
1928 env
->itlb_tag
[i
] = env
->immuregs
[6];
1929 env
->itlb_tte
[i
] = val
;
1936 case 0x55: // I-MMU data access
1938 unsigned int i
= (addr
>> 3) & 0x3f;
1940 env
->itlb_tag
[i
] = env
->immuregs
[6];
1941 env
->itlb_tte
[i
] = val
;
1944 case 0x57: // I-MMU demap
1947 case 0x58: // D-MMU regs
1949 int reg
= (addr
>> 3) & 0xf;
1952 oldreg
= env
->dmmuregs
[reg
];
1958 if ((val
& 1) == 0) {
1959 val
= 0; // Clear SFSR, Fault address
1960 env
->dmmuregs
[4] = 0;
1962 env
->dmmuregs
[reg
] = val
;
1964 case 1: // Primary context
1965 case 2: // Secondary context
1966 case 5: // TSB access
1967 case 6: // Tag access
1968 case 7: // Virtual Watchpoint
1969 case 8: // Physical Watchpoint
1973 env
->dmmuregs
[reg
] = val
;
1974 if (oldreg
!= env
->dmmuregs
[reg
]) {
1975 DPRINTF_MMU("mmu change reg[%d]: 0x%08" PRIx64
" -> 0x%08" PRIx64
"\n", reg
, oldreg
, env
->dmmuregs
[reg
]);
1982 case 0x5c: // D-MMU data in
1986 // Try finding an invalid entry
1987 for (i
= 0; i
< 64; i
++) {
1988 if ((env
->dtlb_tte
[i
] & 0x8000000000000000ULL
) == 0) {
1989 env
->dtlb_tag
[i
] = env
->dmmuregs
[6];
1990 env
->dtlb_tte
[i
] = val
;
1994 // Try finding an unlocked entry
1995 for (i
= 0; i
< 64; i
++) {
1996 if ((env
->dtlb_tte
[i
] & 0x40) == 0) {
1997 env
->dtlb_tag
[i
] = env
->dmmuregs
[6];
1998 env
->dtlb_tte
[i
] = val
;
2005 case 0x5d: // D-MMU data access
2007 unsigned int i
= (addr
>> 3) & 0x3f;
2009 env
->dtlb_tag
[i
] = env
->dmmuregs
[6];
2010 env
->dtlb_tte
[i
] = val
;
2013 case 0x5f: // D-MMU demap
2014 case 0x49: // Interrupt data receive
2017 case 0x51: // I-MMU 8k TSB pointer, RO
2018 case 0x52: // I-MMU 64k TSB pointer, RO
2019 case 0x56: // I-MMU tag read, RO
2020 case 0x59: // D-MMU 8k TSB pointer, RO
2021 case 0x5a: // D-MMU 64k TSB pointer, RO
2022 case 0x5b: // D-MMU data pointer, RO
2023 case 0x5e: // D-MMU tag read, RO
2024 case 0x48: // Interrupt dispatch, RO
2025 case 0x7f: // Incoming interrupt vector, RO
2026 case 0x82: // Primary no-fault, RO
2027 case 0x83: // Secondary no-fault, RO
2028 case 0x8a: // Primary no-fault LE, RO
2029 case 0x8b: // Secondary no-fault LE, RO
2031 do_unassigned_access(addr
, 1, 0, 1);
2035 #endif /* CONFIG_USER_ONLY */
2037 void helper_ldf_asi(target_ulong addr
, int asi
, int size
, int rd
)
2043 case 0xf0: // Block load primary
2044 case 0xf1: // Block load secondary
2045 case 0xf8: // Block load primary LE
2046 case 0xf9: // Block load secondary LE
2048 raise_exception(TT_ILL_INSN
);
2052 raise_exception(TT_UNALIGNED
);
2055 for (i
= 0; i
< 16; i
++) {
2056 *(uint32_t *)&env
->fpr
[rd
++] = helper_ld_asi(addr
, asi
& 0x8f, 4, 0);
2065 val
= helper_ld_asi(addr
, asi
, size
, 0);
2069 *((uint32_t *)&FT0
) = val
;
2072 *((int64_t *)&DT0
) = val
;
2074 #if defined(CONFIG_USER_ONLY)
2082 void helper_stf_asi(target_ulong addr
, int asi
, int size
, int rd
)
2085 target_ulong val
= 0;
2088 case 0xf0: // Block store primary
2089 case 0xf1: // Block store secondary
2090 case 0xf8: // Block store primary LE
2091 case 0xf9: // Block store secondary LE
2093 raise_exception(TT_ILL_INSN
);
2097 raise_exception(TT_UNALIGNED
);
2100 for (i
= 0; i
< 16; i
++) {
2101 val
= *(uint32_t *)&env
->fpr
[rd
++];
2102 helper_st_asi(addr
, val
, asi
& 0x8f, 4);
2114 val
= *((uint32_t *)&FT0
);
2117 val
= *((int64_t *)&DT0
);
2119 #if defined(CONFIG_USER_ONLY)
2125 helper_st_asi(addr
, val
, asi
, size
);
2128 target_ulong
helper_cas_asi(target_ulong addr
, target_ulong val1
,
2129 target_ulong val2
, uint32_t asi
)
2133 val1
&= 0xffffffffUL
;
2134 ret
= helper_ld_asi(addr
, asi
, 4, 0);
2135 ret
&= 0xffffffffUL
;
2137 helper_st_asi(addr
, val2
& 0xffffffffUL
, asi
, 4);
2141 target_ulong
helper_casx_asi(target_ulong addr
, target_ulong val1
,
2142 target_ulong val2
, uint32_t asi
)
2146 ret
= helper_ld_asi(addr
, asi
, 8, 0);
2148 helper_st_asi(addr
, val2
, asi
, 8);
2151 #endif /* TARGET_SPARC64 */
2153 #ifndef TARGET_SPARC64
2154 void helper_rett(void)
2158 if (env
->psret
== 1)
2159 raise_exception(TT_ILL_INSN
);
2162 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
2163 if (env
->wim
& (1 << cwp
)) {
2164 raise_exception(TT_WIN_UNF
);
2167 env
->psrs
= env
->psrps
;
2171 target_ulong
helper_udiv(target_ulong a
, target_ulong b
)
2176 x0
= a
| ((uint64_t) (env
->y
) << 32);
2180 raise_exception(TT_DIV_ZERO
);
2184 if (x0
> 0xffffffff) {
2193 target_ulong
helper_sdiv(target_ulong a
, target_ulong b
)
2198 x0
= a
| ((int64_t) (env
->y
) << 32);
2202 raise_exception(TT_DIV_ZERO
);
2206 if ((int32_t) x0
!= x0
) {
2208 return x0
< 0? 0x80000000: 0x7fffffff;
2215 uint64_t helper_pack64(target_ulong high
, target_ulong low
)
2217 return ((uint64_t)high
<< 32) | (uint64_t)(low
& 0xffffffff);
2221 #define ADDR(x) ((x) & 0xffffffff)
2227 void helper_std_i386(target_ulong addr
, int mem_idx
)
2229 uint64_t tmp
= ((uint64_t)env
->t1
<< 32) | (uint64_t)(env
->t2
& 0xffffffff);
2231 #if !defined(CONFIG_USER_ONLY)
2234 stq_user(ADDR(addr
), tmp
);
2237 stq_kernel(ADDR(addr
), tmp
);
2239 #ifdef TARGET_SPARC64
2241 stq_hypv(ADDR(addr
), tmp
);
2248 stq_raw(ADDR(addr
), tmp
);
2251 #endif /* __i386__ */
2253 void helper_stdf(target_ulong addr
, int mem_idx
)
2255 #if !defined(CONFIG_USER_ONLY)
2258 stfq_user(ADDR(addr
), DT0
);
2261 stfq_kernel(ADDR(addr
), DT0
);
2263 #ifdef TARGET_SPARC64
2265 stfq_hypv(ADDR(addr
), DT0
);
2272 stfq_raw(ADDR(addr
), DT0
);
2276 void helper_lddf(target_ulong addr
, int mem_idx
)
2278 #if !defined(CONFIG_USER_ONLY)
2281 DT0
= ldfq_user(ADDR(addr
));
2284 DT0
= ldfq_kernel(ADDR(addr
));
2286 #ifdef TARGET_SPARC64
2288 DT0
= ldfq_hypv(ADDR(addr
));
2295 DT0
= ldfq_raw(ADDR(addr
));
2299 #if defined(CONFIG_USER_ONLY)
2300 void helper_ldqf(target_ulong addr
)
2302 // XXX add 128 bit load
2305 u
.ll
.upper
= ldq_raw(ADDR(addr
));
2306 u
.ll
.lower
= ldq_raw(ADDR(addr
+ 8));
2310 void helper_stqf(target_ulong addr
)
2312 // XXX add 128 bit store
2316 stq_raw(ADDR(addr
), u
.ll
.upper
);
2317 stq_raw(ADDR(addr
+ 8), u
.ll
.lower
);
2323 void helper_ldfsr(void)
2327 PUT_FSR32(env
, *((uint32_t *) &FT0
));
2328 switch (env
->fsr
& FSR_RD_MASK
) {
2329 case FSR_RD_NEAREST
:
2330 rnd_mode
= float_round_nearest_even
;
2334 rnd_mode
= float_round_to_zero
;
2337 rnd_mode
= float_round_up
;
2340 rnd_mode
= float_round_down
;
2343 set_float_rounding_mode(rnd_mode
, &env
->fp_status
);
2346 void helper_stfsr(void)
2348 *((uint32_t *) &FT0
) = GET_FSR32(env
);
2351 void helper_debug(void)
2353 env
->exception_index
= EXCP_DEBUG
;
2357 #ifndef TARGET_SPARC64
2358 /* XXX: use another pointer for %iN registers to avoid slow wrapping
2360 void helper_save(void)
2364 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
2365 if (env
->wim
& (1 << cwp
)) {
2366 raise_exception(TT_WIN_OVF
);
2371 void helper_restore(void)
2375 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
2376 if (env
->wim
& (1 << cwp
)) {
2377 raise_exception(TT_WIN_UNF
);
2382 void helper_wrpsr(target_ulong new_psr
)
2384 if ((new_psr
& PSR_CWP
) >= NWINDOWS
)
2385 raise_exception(TT_ILL_INSN
);
2387 PUT_PSR(env
, new_psr
);
2390 target_ulong
helper_rdpsr(void)
2392 return GET_PSR(env
);
2396 /* XXX: use another pointer for %iN registers to avoid slow wrapping
2398 void helper_save(void)
2402 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
2403 if (env
->cansave
== 0) {
2404 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
2405 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
2406 ((env
->wstate
& 0x7) << 2)));
2408 if (env
->cleanwin
- env
->canrestore
== 0) {
2409 // XXX Clean windows without trap
2410 raise_exception(TT_CLRWIN
);
2419 void helper_restore(void)
2423 cwp
= (env
->cwp
+ 1) & (NWINDOWS
- 1);
2424 if (env
->canrestore
== 0) {
2425 raise_exception(TT_FILL
| (env
->otherwin
!= 0 ?
2426 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
2427 ((env
->wstate
& 0x7) << 2)));
2435 void helper_flushw(void)
2437 if (env
->cansave
!= NWINDOWS
- 2) {
2438 raise_exception(TT_SPILL
| (env
->otherwin
!= 0 ?
2439 (TT_WOTHER
| ((env
->wstate
& 0x38) >> 1)):
2440 ((env
->wstate
& 0x7) << 2)));
2444 void helper_saved(void)
2447 if (env
->otherwin
== 0)
2453 void helper_restored(void)
2456 if (env
->cleanwin
< NWINDOWS
- 1)
2458 if (env
->otherwin
== 0)
2464 target_ulong
helper_rdccr(void)
2466 return GET_CCR(env
);
2469 void helper_wrccr(target_ulong new_ccr
)
2471 PUT_CCR(env
, new_ccr
);
2474 // CWP handling is reversed in V9, but we still use the V8 register
2476 target_ulong
helper_rdcwp(void)
2478 return GET_CWP64(env
);
2481 void helper_wrcwp(target_ulong new_cwp
)
2483 PUT_CWP64(env
, new_cwp
);
2486 // This function uses non-native bit order
2487 #define GET_FIELD(X, FROM, TO) \
2488 ((X) >> (63 - (TO)) & ((1ULL << ((TO) - (FROM) + 1)) - 1))
2490 // This function uses the order in the manuals, i.e. bit 0 is 2^0
2491 #define GET_FIELD_SP(X, FROM, TO) \
2492 GET_FIELD(X, 63 - (TO), 63 - (FROM))
2494 target_ulong
helper_array8(target_ulong pixel_addr
, target_ulong cubesize
)
2496 return (GET_FIELD_SP(pixel_addr
, 60, 63) << (17 + 2 * cubesize
)) |
2497 (GET_FIELD_SP(pixel_addr
, 39, 39 + cubesize
- 1) << (17 + cubesize
)) |
2498 (GET_FIELD_SP(pixel_addr
, 17 + cubesize
- 1, 17) << 17) |
2499 (GET_FIELD_SP(pixel_addr
, 56, 59) << 13) |
2500 (GET_FIELD_SP(pixel_addr
, 35, 38) << 9) |
2501 (GET_FIELD_SP(pixel_addr
, 13, 16) << 5) |
2502 (((pixel_addr
>> 55) & 1) << 4) |
2503 (GET_FIELD_SP(pixel_addr
, 33, 34) << 2) |
2504 GET_FIELD_SP(pixel_addr
, 11, 12);
2507 target_ulong
helper_alignaddr(target_ulong addr
, target_ulong offset
)
2511 tmp
= addr
+ offset
;
2513 env
->gsr
|= tmp
& 7ULL;
2517 target_ulong
helper_popc(target_ulong val
)
2519 return ctpop64(val
);
2522 static inline uint64_t *get_gregset(uint64_t pstate
)
2537 static inline void change_pstate(uint64_t new_pstate
)
2539 uint64_t pstate_regs
, new_pstate_regs
;
2540 uint64_t *src
, *dst
;
2542 pstate_regs
= env
->pstate
& 0xc01;
2543 new_pstate_regs
= new_pstate
& 0xc01;
2544 if (new_pstate_regs
!= pstate_regs
) {
2545 // Switch global register bank
2546 src
= get_gregset(new_pstate_regs
);
2547 dst
= get_gregset(pstate_regs
);
2548 memcpy32(dst
, env
->gregs
);
2549 memcpy32(env
->gregs
, src
);
2551 env
->pstate
= new_pstate
;
2554 void helper_wrpstate(target_ulong new_state
)
2556 change_pstate(new_state
& 0xf3f);
2559 void helper_done(void)
2562 env
->tsptr
= &env
->ts
[env
->tl
];
2563 env
->pc
= env
->tsptr
->tpc
;
2564 env
->npc
= env
->tsptr
->tnpc
+ 4;
2565 PUT_CCR(env
, env
->tsptr
->tstate
>> 32);
2566 env
->asi
= (env
->tsptr
->tstate
>> 24) & 0xff;
2567 change_pstate((env
->tsptr
->tstate
>> 8) & 0xf3f);
2568 PUT_CWP64(env
, env
->tsptr
->tstate
& 0xff);
2571 void helper_retry(void)
2574 env
->tsptr
= &env
->ts
[env
->tl
];
2575 env
->pc
= env
->tsptr
->tpc
;
2576 env
->npc
= env
->tsptr
->tnpc
;
2577 PUT_CCR(env
, env
->tsptr
->tstate
>> 32);
2578 env
->asi
= (env
->tsptr
->tstate
>> 24) & 0xff;
2579 change_pstate((env
->tsptr
->tstate
>> 8) & 0xf3f);
2580 PUT_CWP64(env
, env
->tsptr
->tstate
& 0xff);
2584 void set_cwp(int new_cwp
)
2586 /* put the modified wrap registers at their proper location */
2587 if (env
->cwp
== (NWINDOWS
- 1))
2588 memcpy32(env
->regbase
, env
->regbase
+ NWINDOWS
* 16);
2590 /* put the wrap registers at their temporary location */
2591 if (new_cwp
== (NWINDOWS
- 1))
2592 memcpy32(env
->regbase
+ NWINDOWS
* 16, env
->regbase
);
2593 env
->regwptr
= env
->regbase
+ (new_cwp
* 16);
2594 REGWPTR
= env
->regwptr
;
2597 void cpu_set_cwp(CPUState
*env1
, int new_cwp
)
2599 CPUState
*saved_env
;
2601 target_ulong
*saved_regwptr
;
2606 saved_regwptr
= REGWPTR
;
2612 REGWPTR
= saved_regwptr
;
2616 #ifdef TARGET_SPARC64
2618 static const char * const excp_names
[0x50] = {
2619 [TT_TFAULT
] = "Instruction Access Fault",
2620 [TT_TMISS
] = "Instruction Access MMU Miss",
2621 [TT_CODE_ACCESS
] = "Instruction Access Error",
2622 [TT_ILL_INSN
] = "Illegal Instruction",
2623 [TT_PRIV_INSN
] = "Privileged Instruction",
2624 [TT_NFPU_INSN
] = "FPU Disabled",
2625 [TT_FP_EXCP
] = "FPU Exception",
2626 [TT_TOVF
] = "Tag Overflow",
2627 [TT_CLRWIN
] = "Clean Windows",
2628 [TT_DIV_ZERO
] = "Division By Zero",
2629 [TT_DFAULT
] = "Data Access Fault",
2630 [TT_DMISS
] = "Data Access MMU Miss",
2631 [TT_DATA_ACCESS
] = "Data Access Error",
2632 [TT_DPROT
] = "Data Protection Error",
2633 [TT_UNALIGNED
] = "Unaligned Memory Access",
2634 [TT_PRIV_ACT
] = "Privileged Action",
2635 [TT_EXTINT
| 0x1] = "External Interrupt 1",
2636 [TT_EXTINT
| 0x2] = "External Interrupt 2",
2637 [TT_EXTINT
| 0x3] = "External Interrupt 3",
2638 [TT_EXTINT
| 0x4] = "External Interrupt 4",
2639 [TT_EXTINT
| 0x5] = "External Interrupt 5",
2640 [TT_EXTINT
| 0x6] = "External Interrupt 6",
2641 [TT_EXTINT
| 0x7] = "External Interrupt 7",
2642 [TT_EXTINT
| 0x8] = "External Interrupt 8",
2643 [TT_EXTINT
| 0x9] = "External Interrupt 9",
2644 [TT_EXTINT
| 0xa] = "External Interrupt 10",
2645 [TT_EXTINT
| 0xb] = "External Interrupt 11",
2646 [TT_EXTINT
| 0xc] = "External Interrupt 12",
2647 [TT_EXTINT
| 0xd] = "External Interrupt 13",
2648 [TT_EXTINT
| 0xe] = "External Interrupt 14",
2649 [TT_EXTINT
| 0xf] = "External Interrupt 15",
2653 void do_interrupt(int intno
)
2656 if (loglevel
& CPU_LOG_INT
) {
2660 if (intno
< 0 || intno
>= 0x180 || (intno
> 0x4f && intno
< 0x80))
2662 else if (intno
>= 0x100)
2663 name
= "Trap Instruction";
2664 else if (intno
>= 0xc0)
2665 name
= "Window Fill";
2666 else if (intno
>= 0x80)
2667 name
= "Window Spill";
2669 name
= excp_names
[intno
];
2674 fprintf(logfile
, "%6d: %s (v=%04x) pc=%016" PRIx64
" npc=%016" PRIx64
2675 " SP=%016" PRIx64
"\n",
2678 env
->npc
, env
->regwptr
[6]);
2679 cpu_dump_state(env
, logfile
, fprintf
, 0);
2685 fprintf(logfile
, " code=");
2686 ptr
= (uint8_t *)env
->pc
;
2687 for(i
= 0; i
< 16; i
++) {
2688 fprintf(logfile
, " %02x", ldub(ptr
+ i
));
2690 fprintf(logfile
, "\n");
2696 #if !defined(CONFIG_USER_ONLY)
2697 if (env
->tl
== MAXTL
) {
2698 cpu_abort(env
, "Trap 0x%04x while trap level is MAXTL, Error state", env
->exception_index
);
2702 env
->tsptr
->tstate
= ((uint64_t)GET_CCR(env
) << 32) |
2703 ((env
->asi
& 0xff) << 24) | ((env
->pstate
& 0xf3f) << 8) |
2705 env
->tsptr
->tpc
= env
->pc
;
2706 env
->tsptr
->tnpc
= env
->npc
;
2707 env
->tsptr
->tt
= intno
;
2708 change_pstate(PS_PEF
| PS_PRIV
| PS_AG
);
2710 if (intno
== TT_CLRWIN
)
2711 set_cwp((env
->cwp
- 1) & (NWINDOWS
- 1));
2712 else if ((intno
& 0x1c0) == TT_SPILL
)
2713 set_cwp((env
->cwp
- env
->cansave
- 2) & (NWINDOWS
- 1));
2714 else if ((intno
& 0x1c0) == TT_FILL
)
2715 set_cwp((env
->cwp
+ 1) & (NWINDOWS
- 1));
2716 env
->tbr
&= ~0x7fffULL
;
2717 env
->tbr
|= ((env
->tl
> 1) ? 1 << 14 : 0) | (intno
<< 5);
2718 if (env
->tl
< MAXTL
- 1) {
2721 env
->pstate
|= PS_RED
;
2722 if (env
->tl
!= MAXTL
)
2725 env
->tsptr
= &env
->ts
[env
->tl
];
2727 env
->npc
= env
->pc
+ 4;
2728 env
->exception_index
= 0;
2732 static const char * const excp_names
[0x80] = {
2733 [TT_TFAULT
] = "Instruction Access Fault",
2734 [TT_ILL_INSN
] = "Illegal Instruction",
2735 [TT_PRIV_INSN
] = "Privileged Instruction",
2736 [TT_NFPU_INSN
] = "FPU Disabled",
2737 [TT_WIN_OVF
] = "Window Overflow",
2738 [TT_WIN_UNF
] = "Window Underflow",
2739 [TT_UNALIGNED
] = "Unaligned Memory Access",
2740 [TT_FP_EXCP
] = "FPU Exception",
2741 [TT_DFAULT
] = "Data Access Fault",
2742 [TT_TOVF
] = "Tag Overflow",
2743 [TT_EXTINT
| 0x1] = "External Interrupt 1",
2744 [TT_EXTINT
| 0x2] = "External Interrupt 2",
2745 [TT_EXTINT
| 0x3] = "External Interrupt 3",
2746 [TT_EXTINT
| 0x4] = "External Interrupt 4",
2747 [TT_EXTINT
| 0x5] = "External Interrupt 5",
2748 [TT_EXTINT
| 0x6] = "External Interrupt 6",
2749 [TT_EXTINT
| 0x7] = "External Interrupt 7",
2750 [TT_EXTINT
| 0x8] = "External Interrupt 8",
2751 [TT_EXTINT
| 0x9] = "External Interrupt 9",
2752 [TT_EXTINT
| 0xa] = "External Interrupt 10",
2753 [TT_EXTINT
| 0xb] = "External Interrupt 11",
2754 [TT_EXTINT
| 0xc] = "External Interrupt 12",
2755 [TT_EXTINT
| 0xd] = "External Interrupt 13",
2756 [TT_EXTINT
| 0xe] = "External Interrupt 14",
2757 [TT_EXTINT
| 0xf] = "External Interrupt 15",
2758 [TT_TOVF
] = "Tag Overflow",
2759 [TT_CODE_ACCESS
] = "Instruction Access Error",
2760 [TT_DATA_ACCESS
] = "Data Access Error",
2761 [TT_DIV_ZERO
] = "Division By Zero",
2762 [TT_NCP_INSN
] = "Coprocessor Disabled",
2766 void do_interrupt(int intno
)
2771 if (loglevel
& CPU_LOG_INT
) {
2775 if (intno
< 0 || intno
>= 0x100)
2777 else if (intno
>= 0x80)
2778 name
= "Trap Instruction";
2780 name
= excp_names
[intno
];
2785 fprintf(logfile
, "%6d: %s (v=%02x) pc=%08x npc=%08x SP=%08x\n",
2788 env
->npc
, env
->regwptr
[6]);
2789 cpu_dump_state(env
, logfile
, fprintf
, 0);
2795 fprintf(logfile
, " code=");
2796 ptr
= (uint8_t *)env
->pc
;
2797 for(i
= 0; i
< 16; i
++) {
2798 fprintf(logfile
, " %02x", ldub(ptr
+ i
));
2800 fprintf(logfile
, "\n");
2806 #if !defined(CONFIG_USER_ONLY)
2807 if (env
->psret
== 0) {
2808 cpu_abort(env
, "Trap 0x%02x while interrupts disabled, Error state", env
->exception_index
);
2813 cwp
= (env
->cwp
- 1) & (NWINDOWS
- 1);
2815 env
->regwptr
[9] = env
->pc
;
2816 env
->regwptr
[10] = env
->npc
;
2817 env
->psrps
= env
->psrs
;
2819 env
->tbr
= (env
->tbr
& TBR_BASE_MASK
) | (intno
<< 4);
2821 env
->npc
= env
->pc
+ 4;
2822 env
->exception_index
= 0;
2826 #if !defined(CONFIG_USER_ONLY)
2828 static void do_unaligned_access(target_ulong addr
, int is_write
, int is_user
,
2831 #define MMUSUFFIX _mmu
2832 #define ALIGNED_ONLY
2834 # define GETPC() ((void*)((unsigned long)__builtin_return_address(0) & 0x7fffffffUL))
2836 # define GETPC() (__builtin_return_address(0))
2840 #include "softmmu_template.h"
2843 #include "softmmu_template.h"
2846 #include "softmmu_template.h"
2849 #include "softmmu_template.h"
2851 static void do_unaligned_access(target_ulong addr
, int is_write
, int is_user
,
2854 #ifdef DEBUG_UNALIGNED
2855 printf("Unaligned access to 0x%x from 0x%x\n", addr
, env
->pc
);
2857 raise_exception(TT_UNALIGNED
);
2860 /* try to fill the TLB and return an exception if error. If retaddr is
2861 NULL, it means that the function was called in C code (i.e. not
2862 from generated code or from helper.c) */
2863 /* XXX: fix it to restore all registers */
2864 void tlb_fill(target_ulong addr
, int is_write
, int mmu_idx
, void *retaddr
)
2866 TranslationBlock
*tb
;
2869 CPUState
*saved_env
;
2871 /* XXX: hack to restore env in all cases, even if not called from
2874 env
= cpu_single_env
;
2876 ret
= cpu_sparc_handle_mmu_fault(env
, addr
, is_write
, mmu_idx
, 1);
2879 /* now we have a real cpu fault */
2880 pc
= (unsigned long)retaddr
;
2881 tb
= tb_find_pc(pc
);
2883 /* the PC is inside the translated code. It means that we have
2884 a virtual CPU fault */
2885 cpu_restore_state(tb
, env
, pc
, (void *)T2
);
2895 #ifndef TARGET_SPARC64
2896 void do_unassigned_access(target_phys_addr_t addr
, int is_write
, int is_exec
,
2899 CPUState
*saved_env
;
2901 /* XXX: hack to restore env in all cases, even if not called from
2904 env
= cpu_single_env
;
2905 #ifdef DEBUG_UNASSIGNED
2907 printf("Unassigned mem %s access to " TARGET_FMT_plx
" asi 0x%02x from "
2909 is_exec
? "exec" : is_write
? "write" : "read", addr
, is_asi
,
2912 printf("Unassigned mem %s access to " TARGET_FMT_plx
" from "
2914 is_exec
? "exec" : is_write
? "write" : "read", addr
, env
->pc
);
2916 if (env
->mmuregs
[3]) /* Fault status register */
2917 env
->mmuregs
[3] = 1; /* overflow (not read before another fault) */
2919 env
->mmuregs
[3] |= 1 << 16;
2921 env
->mmuregs
[3] |= 1 << 5;
2923 env
->mmuregs
[3] |= 1 << 6;
2925 env
->mmuregs
[3] |= 1 << 7;
2926 env
->mmuregs
[3] |= (5 << 2) | 2;
2927 env
->mmuregs
[4] = addr
; /* Fault address register */
2928 if ((env
->mmuregs
[0] & MMU_E
) && !(env
->mmuregs
[0] & MMU_NF
)) {
2930 raise_exception(TT_CODE_ACCESS
);
2932 raise_exception(TT_DATA_ACCESS
);
2937 void do_unassigned_access(target_phys_addr_t addr
, int is_write
, int is_exec
,
2940 #ifdef DEBUG_UNASSIGNED
2941 CPUState
*saved_env
;
2943 /* XXX: hack to restore env in all cases, even if not called from
2946 env
= cpu_single_env
;
2947 printf("Unassigned mem access to " TARGET_FMT_plx
" from " TARGET_FMT_lx
"\n",
2952 raise_exception(TT_CODE_ACCESS
);
2954 raise_exception(TT_DATA_ACCESS
);