2 * MIPS emulation helpers for qemu.
4 * Copyright (c) 2004-2005 Jocelyn Mayer
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #include "qemu/osdep.h"
22 #include "qemu/main-loop.h"
25 #include "qemu/host-utils.h"
26 #include "exec/helper-proto.h"
27 #include "exec/exec-all.h"
28 #include "exec/cpu_ldst.h"
29 #include "exec/memop.h"
30 #include "sysemu/kvm.h"
33 /*****************************************************************************/
34 /* Exceptions processing helpers */
37 void helper_raise_exception_err(CPUMIPSState
*env
, uint32_t exception
,
40 do_raise_exception_err(env
, exception
, error_code
, 0);
44 void helper_raise_exception(CPUMIPSState
*env
, uint32_t exception
)
46 do_raise_exception(env
, exception
, GETPC());
49 QEMU_NORETURN
void helper_raise_exception_debug(CPUMIPSState
*env
)
51 do_raise_exception(env
, EXCP_DEBUG
, 0);
55 void raise_exception(CPUMIPSState
*env
, uint32_t exception
)
57 do_raise_exception(env
, exception
, 0);
60 /* 64 bits arithmetic for 32 bits hosts */
61 static inline uint64_t get_HILO(CPUMIPSState
*env
)
63 return ((uint64_t)(env
->active_tc
.HI
[0]) << 32) |
64 (uint32_t)env
->active_tc
.LO
[0];
67 static inline target_ulong
set_HIT0_LO(CPUMIPSState
*env
, uint64_t HILO
)
69 env
->active_tc
.LO
[0] = (int32_t)(HILO
& 0xFFFFFFFF);
70 return env
->active_tc
.HI
[0] = (int32_t)(HILO
>> 32);
73 static inline target_ulong
set_HI_LOT0(CPUMIPSState
*env
, uint64_t HILO
)
75 target_ulong tmp
= env
->active_tc
.LO
[0] = (int32_t)(HILO
& 0xFFFFFFFF);
76 env
->active_tc
.HI
[0] = (int32_t)(HILO
>> 32);
80 /* Multiplication variants of the vr54xx. */
81 target_ulong
helper_muls(CPUMIPSState
*env
, target_ulong arg1
,
84 return set_HI_LOT0(env
, 0 - ((int64_t)(int32_t)arg1
*
85 (int64_t)(int32_t)arg2
));
88 target_ulong
helper_mulsu(CPUMIPSState
*env
, target_ulong arg1
,
91 return set_HI_LOT0(env
, 0 - (uint64_t)(uint32_t)arg1
*
92 (uint64_t)(uint32_t)arg2
);
95 target_ulong
helper_macc(CPUMIPSState
*env
, target_ulong arg1
,
98 return set_HI_LOT0(env
, (int64_t)get_HILO(env
) + (int64_t)(int32_t)arg1
*
99 (int64_t)(int32_t)arg2
);
102 target_ulong
helper_macchi(CPUMIPSState
*env
, target_ulong arg1
,
105 return set_HIT0_LO(env
, (int64_t)get_HILO(env
) + (int64_t)(int32_t)arg1
*
106 (int64_t)(int32_t)arg2
);
109 target_ulong
helper_maccu(CPUMIPSState
*env
, target_ulong arg1
,
112 return set_HI_LOT0(env
, (uint64_t)get_HILO(env
) +
113 (uint64_t)(uint32_t)arg1
* (uint64_t)(uint32_t)arg2
);
116 target_ulong
helper_macchiu(CPUMIPSState
*env
, target_ulong arg1
,
119 return set_HIT0_LO(env
, (uint64_t)get_HILO(env
) +
120 (uint64_t)(uint32_t)arg1
* (uint64_t)(uint32_t)arg2
);
123 target_ulong
helper_msac(CPUMIPSState
*env
, target_ulong arg1
,
126 return set_HI_LOT0(env
, (int64_t)get_HILO(env
) - (int64_t)(int32_t)arg1
*
127 (int64_t)(int32_t)arg2
);
130 target_ulong
helper_msachi(CPUMIPSState
*env
, target_ulong arg1
,
133 return set_HIT0_LO(env
, (int64_t)get_HILO(env
) - (int64_t)(int32_t)arg1
*
134 (int64_t)(int32_t)arg2
);
137 target_ulong
helper_msacu(CPUMIPSState
*env
, target_ulong arg1
,
140 return set_HI_LOT0(env
, (uint64_t)get_HILO(env
) -
141 (uint64_t)(uint32_t)arg1
* (uint64_t)(uint32_t)arg2
);
144 target_ulong
helper_msachiu(CPUMIPSState
*env
, target_ulong arg1
,
147 return set_HIT0_LO(env
, (uint64_t)get_HILO(env
) -
148 (uint64_t)(uint32_t)arg1
* (uint64_t)(uint32_t)arg2
);
151 target_ulong
helper_mulhi(CPUMIPSState
*env
, target_ulong arg1
,
154 return set_HIT0_LO(env
, (int64_t)(int32_t)arg1
* (int64_t)(int32_t)arg2
);
157 target_ulong
helper_mulhiu(CPUMIPSState
*env
, target_ulong arg1
,
160 return set_HIT0_LO(env
, (uint64_t)(uint32_t)arg1
*
161 (uint64_t)(uint32_t)arg2
);
164 target_ulong
helper_mulshi(CPUMIPSState
*env
, target_ulong arg1
,
167 return set_HIT0_LO(env
, 0 - (int64_t)(int32_t)arg1
*
168 (int64_t)(int32_t)arg2
);
171 target_ulong
helper_mulshiu(CPUMIPSState
*env
, target_ulong arg1
,
174 return set_HIT0_LO(env
, 0 - (uint64_t)(uint32_t)arg1
*
175 (uint64_t)(uint32_t)arg2
);
178 static inline target_ulong
bitswap(target_ulong v
)
180 v
= ((v
>> 1) & (target_ulong
)0x5555555555555555ULL
) |
181 ((v
& (target_ulong
)0x5555555555555555ULL
) << 1);
182 v
= ((v
>> 2) & (target_ulong
)0x3333333333333333ULL
) |
183 ((v
& (target_ulong
)0x3333333333333333ULL
) << 2);
184 v
= ((v
>> 4) & (target_ulong
)0x0F0F0F0F0F0F0F0FULL
) |
185 ((v
& (target_ulong
)0x0F0F0F0F0F0F0F0FULL
) << 4);
190 target_ulong
helper_dbitswap(target_ulong rt
)
196 target_ulong
helper_bitswap(target_ulong rt
)
198 return (int32_t)bitswap(rt
);
201 target_ulong
helper_rotx(target_ulong rs
, uint32_t shift
, uint32_t shiftx
,
205 uint64_t tmp0
= ((uint64_t)rs
) << 32 | ((uint64_t)rs
& 0xffffffff);
206 uint64_t tmp1
= tmp0
;
207 for (i
= 0; i
<= 46; i
++) {
215 if (stripe
!= 0 && !(i
& 0x4)) {
219 if (tmp0
& (1LL << (i
+ 16))) {
227 uint64_t tmp2
= tmp1
;
228 for (i
= 0; i
<= 38; i
++) {
237 if (tmp1
& (1LL << (i
+ 8))) {
245 uint64_t tmp3
= tmp2
;
246 for (i
= 0; i
<= 34; i
++) {
254 if (tmp2
& (1LL << (i
+ 4))) {
262 uint64_t tmp4
= tmp3
;
263 for (i
= 0; i
<= 32; i
++) {
271 if (tmp3
& (1LL << (i
+ 2))) {
279 uint64_t tmp5
= tmp4
;
280 for (i
= 0; i
<= 31; i
++) {
284 if (tmp4
& (1LL << (i
+ 1))) {
292 return (int64_t)(int32_t)(uint32_t)tmp5
;
295 #ifndef CONFIG_USER_ONLY
297 static inline hwaddr
do_translate_address(CPUMIPSState
*env
,
298 target_ulong address
,
299 int rw
, uintptr_t retaddr
)
302 CPUState
*cs
= env_cpu(env
);
304 paddr
= cpu_mips_translate_address(env
, address
, rw
);
307 cpu_loop_exit_restore(cs
, retaddr
);
313 #define HELPER_LD_ATOMIC(name, insn, almask, do_cast) \
314 target_ulong helper_##name(CPUMIPSState *env, target_ulong arg, int mem_idx) \
316 if (arg & almask) { \
317 if (!(env->hflags & MIPS_HFLAG_DM)) { \
318 env->CP0_BadVAddr = arg; \
320 do_raise_exception(env, EXCP_AdEL, GETPC()); \
322 env->CP0_LLAddr = do_translate_address(env, arg, 0, GETPC()); \
324 env->llval = do_cast cpu_##insn##_mmuidx_ra(env, arg, mem_idx, GETPC()); \
327 HELPER_LD_ATOMIC(ll
, ldl
, 0x3, (target_long
)(int32_t))
329 HELPER_LD_ATOMIC(lld
, ldq
, 0x7, (target_ulong
))
331 #undef HELPER_LD_ATOMIC
334 #ifdef TARGET_WORDS_BIGENDIAN
335 #define GET_LMASK(v) ((v) & 3)
336 #define GET_OFFSET(addr, offset) (addr + (offset))
338 #define GET_LMASK(v) (((v) & 3) ^ 3)
339 #define GET_OFFSET(addr, offset) (addr - (offset))
342 void helper_swl(CPUMIPSState
*env
, target_ulong arg1
, target_ulong arg2
,
345 cpu_stb_mmuidx_ra(env
, arg2
, (uint8_t)(arg1
>> 24), mem_idx
, GETPC());
347 if (GET_LMASK(arg2
) <= 2) {
348 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, 1), (uint8_t)(arg1
>> 16),
352 if (GET_LMASK(arg2
) <= 1) {
353 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, 2), (uint8_t)(arg1
>> 8),
357 if (GET_LMASK(arg2
) == 0) {
358 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, 3), (uint8_t)arg1
,
363 void helper_swr(CPUMIPSState
*env
, target_ulong arg1
, target_ulong arg2
,
366 cpu_stb_mmuidx_ra(env
, arg2
, (uint8_t)arg1
, mem_idx
, GETPC());
368 if (GET_LMASK(arg2
) >= 1) {
369 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, -1), (uint8_t)(arg1
>> 8),
373 if (GET_LMASK(arg2
) >= 2) {
374 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, -2), (uint8_t)(arg1
>> 16),
378 if (GET_LMASK(arg2
) == 3) {
379 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, -3), (uint8_t)(arg1
>> 24),
384 #if defined(TARGET_MIPS64)
386 * "half" load and stores. We must do the memory access inline,
387 * or fault handling won't work.
389 #ifdef TARGET_WORDS_BIGENDIAN
390 #define GET_LMASK64(v) ((v) & 7)
392 #define GET_LMASK64(v) (((v) & 7) ^ 7)
395 void helper_sdl(CPUMIPSState
*env
, target_ulong arg1
, target_ulong arg2
,
398 cpu_stb_mmuidx_ra(env
, arg2
, (uint8_t)(arg1
>> 56), mem_idx
, GETPC());
400 if (GET_LMASK64(arg2
) <= 6) {
401 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, 1), (uint8_t)(arg1
>> 48),
405 if (GET_LMASK64(arg2
) <= 5) {
406 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, 2), (uint8_t)(arg1
>> 40),
410 if (GET_LMASK64(arg2
) <= 4) {
411 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, 3), (uint8_t)(arg1
>> 32),
415 if (GET_LMASK64(arg2
) <= 3) {
416 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, 4), (uint8_t)(arg1
>> 24),
420 if (GET_LMASK64(arg2
) <= 2) {
421 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, 5), (uint8_t)(arg1
>> 16),
425 if (GET_LMASK64(arg2
) <= 1) {
426 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, 6), (uint8_t)(arg1
>> 8),
430 if (GET_LMASK64(arg2
) <= 0) {
431 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, 7), (uint8_t)arg1
,
436 void helper_sdr(CPUMIPSState
*env
, target_ulong arg1
, target_ulong arg2
,
439 cpu_stb_mmuidx_ra(env
, arg2
, (uint8_t)arg1
, mem_idx
, GETPC());
441 if (GET_LMASK64(arg2
) >= 1) {
442 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, -1), (uint8_t)(arg1
>> 8),
446 if (GET_LMASK64(arg2
) >= 2) {
447 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, -2), (uint8_t)(arg1
>> 16),
451 if (GET_LMASK64(arg2
) >= 3) {
452 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, -3), (uint8_t)(arg1
>> 24),
456 if (GET_LMASK64(arg2
) >= 4) {
457 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, -4), (uint8_t)(arg1
>> 32),
461 if (GET_LMASK64(arg2
) >= 5) {
462 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, -5), (uint8_t)(arg1
>> 40),
466 if (GET_LMASK64(arg2
) >= 6) {
467 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, -6), (uint8_t)(arg1
>> 48),
471 if (GET_LMASK64(arg2
) == 7) {
472 cpu_stb_mmuidx_ra(env
, GET_OFFSET(arg2
, -7), (uint8_t)(arg1
>> 56),
476 #endif /* TARGET_MIPS64 */
478 static const int multiple_regs
[] = { 16, 17, 18, 19, 20, 21, 22, 23, 30 };
480 void helper_lwm(CPUMIPSState
*env
, target_ulong addr
, target_ulong reglist
,
483 target_ulong base_reglist
= reglist
& 0xf;
484 target_ulong do_r31
= reglist
& 0x10;
486 if (base_reglist
> 0 && base_reglist
<= ARRAY_SIZE(multiple_regs
)) {
489 for (i
= 0; i
< base_reglist
; i
++) {
490 env
->active_tc
.gpr
[multiple_regs
[i
]] =
491 (target_long
)cpu_ldl_mmuidx_ra(env
, addr
, mem_idx
, GETPC());
497 env
->active_tc
.gpr
[31] =
498 (target_long
)cpu_ldl_mmuidx_ra(env
, addr
, mem_idx
, GETPC());
502 void helper_swm(CPUMIPSState
*env
, target_ulong addr
, target_ulong reglist
,
505 target_ulong base_reglist
= reglist
& 0xf;
506 target_ulong do_r31
= reglist
& 0x10;
508 if (base_reglist
> 0 && base_reglist
<= ARRAY_SIZE(multiple_regs
)) {
511 for (i
= 0; i
< base_reglist
; i
++) {
512 cpu_stw_mmuidx_ra(env
, addr
, env
->active_tc
.gpr
[multiple_regs
[i
]],
519 cpu_stw_mmuidx_ra(env
, addr
, env
->active_tc
.gpr
[31], mem_idx
, GETPC());
523 #if defined(TARGET_MIPS64)
524 void helper_ldm(CPUMIPSState
*env
, target_ulong addr
, target_ulong reglist
,
527 target_ulong base_reglist
= reglist
& 0xf;
528 target_ulong do_r31
= reglist
& 0x10;
530 if (base_reglist
> 0 && base_reglist
<= ARRAY_SIZE(multiple_regs
)) {
533 for (i
= 0; i
< base_reglist
; i
++) {
534 env
->active_tc
.gpr
[multiple_regs
[i
]] =
535 cpu_ldq_mmuidx_ra(env
, addr
, mem_idx
, GETPC());
541 env
->active_tc
.gpr
[31] =
542 cpu_ldq_mmuidx_ra(env
, addr
, mem_idx
, GETPC());
546 void helper_sdm(CPUMIPSState
*env
, target_ulong addr
, target_ulong reglist
,
549 target_ulong base_reglist
= reglist
& 0xf;
550 target_ulong do_r31
= reglist
& 0x10;
552 if (base_reglist
> 0 && base_reglist
<= ARRAY_SIZE(multiple_regs
)) {
555 for (i
= 0; i
< base_reglist
; i
++) {
556 cpu_stq_mmuidx_ra(env
, addr
, env
->active_tc
.gpr
[multiple_regs
[i
]],
563 cpu_stq_mmuidx_ra(env
, addr
, env
->active_tc
.gpr
[31], mem_idx
, GETPC());
569 void helper_fork(target_ulong arg1
, target_ulong arg2
)
572 * arg1 = rt, arg2 = rs
573 * TODO: store to TC register
577 target_ulong
helper_yield(CPUMIPSState
*env
, target_ulong arg
)
579 target_long arg1
= arg
;
582 /* No scheduling policy implemented. */
584 if (env
->CP0_VPEControl
& (1 << CP0VPECo_YSI
) &&
585 env
->active_tc
.CP0_TCStatus
& (1 << CP0TCSt_DT
)) {
586 env
->CP0_VPEControl
&= ~(0x7 << CP0VPECo_EXCPT
);
587 env
->CP0_VPEControl
|= 4 << CP0VPECo_EXCPT
;
588 do_raise_exception(env
, EXCP_THREAD
, GETPC());
591 } else if (arg1
== 0) {
593 /* TODO: TC underflow */
594 env
->CP0_VPEControl
&= ~(0x7 << CP0VPECo_EXCPT
);
595 do_raise_exception(env
, EXCP_THREAD
, GETPC());
597 /* TODO: Deallocate TC */
599 } else if (arg1
> 0) {
600 /* Yield qualifier inputs not implemented. */
601 env
->CP0_VPEControl
&= ~(0x7 << CP0VPECo_EXCPT
);
602 env
->CP0_VPEControl
|= 2 << CP0VPECo_EXCPT
;
603 do_raise_exception(env
, EXCP_THREAD
, GETPC());
605 return env
->CP0_YQMask
;
608 #ifndef CONFIG_USER_ONLY
610 static void r4k_mips_tlb_flush_extra(CPUMIPSState
*env
, int first
)
612 /* Discard entries from env->tlb[first] onwards. */
613 while (env
->tlb
->tlb_in_use
> first
) {
614 r4k_invalidate_tlb(env
, --env
->tlb
->tlb_in_use
, 0);
618 static inline uint64_t get_tlb_pfn_from_entrylo(uint64_t entrylo
)
620 #if defined(TARGET_MIPS64)
621 return extract64(entrylo
, 6, 54);
623 return extract64(entrylo
, 6, 24) | /* PFN */
624 (extract64(entrylo
, 32, 32) << 24); /* PFNX */
628 static void r4k_fill_tlb(CPUMIPSState
*env
, int idx
)
631 uint64_t mask
= env
->CP0_PageMask
>> (TARGET_PAGE_BITS
+ 1);
633 /* XXX: detect conflicting TLBs and raise a MCHECK exception when needed */
634 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[idx
];
635 if (env
->CP0_EntryHi
& (1 << CP0EnHi_EHINV
)) {
640 tlb
->VPN
= env
->CP0_EntryHi
& (TARGET_PAGE_MASK
<< 1);
641 #if defined(TARGET_MIPS64)
642 tlb
->VPN
&= env
->SEGMask
;
644 tlb
->ASID
= env
->CP0_EntryHi
& env
->CP0_EntryHi_ASID_mask
;
645 tlb
->MMID
= env
->CP0_MemoryMapID
;
646 tlb
->PageMask
= env
->CP0_PageMask
;
647 tlb
->G
= env
->CP0_EntryLo0
& env
->CP0_EntryLo1
& 1;
648 tlb
->V0
= (env
->CP0_EntryLo0
& 2) != 0;
649 tlb
->D0
= (env
->CP0_EntryLo0
& 4) != 0;
650 tlb
->C0
= (env
->CP0_EntryLo0
>> 3) & 0x7;
651 tlb
->XI0
= (env
->CP0_EntryLo0
>> CP0EnLo_XI
) & 1;
652 tlb
->RI0
= (env
->CP0_EntryLo0
>> CP0EnLo_RI
) & 1;
653 tlb
->PFN
[0] = (get_tlb_pfn_from_entrylo(env
->CP0_EntryLo0
) & ~mask
) << 12;
654 tlb
->V1
= (env
->CP0_EntryLo1
& 2) != 0;
655 tlb
->D1
= (env
->CP0_EntryLo1
& 4) != 0;
656 tlb
->C1
= (env
->CP0_EntryLo1
>> 3) & 0x7;
657 tlb
->XI1
= (env
->CP0_EntryLo1
>> CP0EnLo_XI
) & 1;
658 tlb
->RI1
= (env
->CP0_EntryLo1
>> CP0EnLo_RI
) & 1;
659 tlb
->PFN
[1] = (get_tlb_pfn_from_entrylo(env
->CP0_EntryLo1
) & ~mask
) << 12;
662 void r4k_helper_tlbinv(CPUMIPSState
*env
)
664 bool mi
= !!((env
->CP0_Config5
>> CP0C5_MI
) & 1);
665 uint16_t ASID
= env
->CP0_EntryHi
& env
->CP0_EntryHi_ASID_mask
;
666 uint32_t MMID
= env
->CP0_MemoryMapID
;
671 MMID
= mi
? MMID
: (uint32_t) ASID
;
672 for (idx
= 0; idx
< env
->tlb
->nb_tlb
; idx
++) {
673 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[idx
];
674 tlb_mmid
= mi
? tlb
->MMID
: (uint32_t) tlb
->ASID
;
675 if (!tlb
->G
&& tlb_mmid
== MMID
) {
679 cpu_mips_tlb_flush(env
);
682 void r4k_helper_tlbinvf(CPUMIPSState
*env
)
686 for (idx
= 0; idx
< env
->tlb
->nb_tlb
; idx
++) {
687 env
->tlb
->mmu
.r4k
.tlb
[idx
].EHINV
= 1;
689 cpu_mips_tlb_flush(env
);
692 void r4k_helper_tlbwi(CPUMIPSState
*env
)
694 bool mi
= !!((env
->CP0_Config5
>> CP0C5_MI
) & 1);
696 uint16_t ASID
= env
->CP0_EntryHi
& env
->CP0_EntryHi_ASID_mask
;
697 uint32_t MMID
= env
->CP0_MemoryMapID
;
699 bool EHINV
, G
, V0
, D0
, V1
, D1
, XI0
, XI1
, RI0
, RI1
;
703 MMID
= mi
? MMID
: (uint32_t) ASID
;
705 idx
= (env
->CP0_Index
& ~0x80000000) % env
->tlb
->nb_tlb
;
706 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[idx
];
707 VPN
= env
->CP0_EntryHi
& (TARGET_PAGE_MASK
<< 1);
708 #if defined(TARGET_MIPS64)
711 EHINV
= (env
->CP0_EntryHi
& (1 << CP0EnHi_EHINV
)) != 0;
712 G
= env
->CP0_EntryLo0
& env
->CP0_EntryLo1
& 1;
713 V0
= (env
->CP0_EntryLo0
& 2) != 0;
714 D0
= (env
->CP0_EntryLo0
& 4) != 0;
715 XI0
= (env
->CP0_EntryLo0
>> CP0EnLo_XI
) &1;
716 RI0
= (env
->CP0_EntryLo0
>> CP0EnLo_RI
) &1;
717 V1
= (env
->CP0_EntryLo1
& 2) != 0;
718 D1
= (env
->CP0_EntryLo1
& 4) != 0;
719 XI1
= (env
->CP0_EntryLo1
>> CP0EnLo_XI
) &1;
720 RI1
= (env
->CP0_EntryLo1
>> CP0EnLo_RI
) &1;
722 tlb_mmid
= mi
? tlb
->MMID
: (uint32_t) tlb
->ASID
;
724 * Discard cached TLB entries, unless tlbwi is just upgrading access
725 * permissions on the current entry.
727 if (tlb
->VPN
!= VPN
|| tlb_mmid
!= MMID
|| tlb
->G
!= G
||
728 (!tlb
->EHINV
&& EHINV
) ||
729 (tlb
->V0
&& !V0
) || (tlb
->D0
&& !D0
) ||
730 (!tlb
->XI0
&& XI0
) || (!tlb
->RI0
&& RI0
) ||
731 (tlb
->V1
&& !V1
) || (tlb
->D1
&& !D1
) ||
732 (!tlb
->XI1
&& XI1
) || (!tlb
->RI1
&& RI1
)) {
733 r4k_mips_tlb_flush_extra(env
, env
->tlb
->nb_tlb
);
736 r4k_invalidate_tlb(env
, idx
, 0);
737 r4k_fill_tlb(env
, idx
);
740 void r4k_helper_tlbwr(CPUMIPSState
*env
)
742 int r
= cpu_mips_get_random(env
);
744 r4k_invalidate_tlb(env
, r
, 1);
745 r4k_fill_tlb(env
, r
);
748 void r4k_helper_tlbp(CPUMIPSState
*env
)
750 bool mi
= !!((env
->CP0_Config5
>> CP0C5_MI
) & 1);
755 uint16_t ASID
= env
->CP0_EntryHi
& env
->CP0_EntryHi_ASID_mask
;
756 uint32_t MMID
= env
->CP0_MemoryMapID
;
760 MMID
= mi
? MMID
: (uint32_t) ASID
;
761 for (i
= 0; i
< env
->tlb
->nb_tlb
; i
++) {
762 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[i
];
763 /* 1k pages are not supported. */
764 mask
= tlb
->PageMask
| ~(TARGET_PAGE_MASK
<< 1);
765 tag
= env
->CP0_EntryHi
& ~mask
;
766 VPN
= tlb
->VPN
& ~mask
;
767 #if defined(TARGET_MIPS64)
770 tlb_mmid
= mi
? tlb
->MMID
: (uint32_t) tlb
->ASID
;
771 /* Check ASID/MMID, virtual page number & size */
772 if ((tlb
->G
== 1 || tlb_mmid
== MMID
) && VPN
== tag
&& !tlb
->EHINV
) {
778 if (i
== env
->tlb
->nb_tlb
) {
779 /* No match. Discard any shadow entries, if any of them match. */
780 for (i
= env
->tlb
->nb_tlb
; i
< env
->tlb
->tlb_in_use
; i
++) {
781 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[i
];
782 /* 1k pages are not supported. */
783 mask
= tlb
->PageMask
| ~(TARGET_PAGE_MASK
<< 1);
784 tag
= env
->CP0_EntryHi
& ~mask
;
785 VPN
= tlb
->VPN
& ~mask
;
786 #if defined(TARGET_MIPS64)
789 tlb_mmid
= mi
? tlb
->MMID
: (uint32_t) tlb
->ASID
;
790 /* Check ASID/MMID, virtual page number & size */
791 if ((tlb
->G
== 1 || tlb_mmid
== MMID
) && VPN
== tag
) {
792 r4k_mips_tlb_flush_extra(env
, i
);
797 env
->CP0_Index
|= 0x80000000;
801 static inline uint64_t get_entrylo_pfn_from_tlb(uint64_t tlb_pfn
)
803 #if defined(TARGET_MIPS64)
806 return (extract64(tlb_pfn
, 0, 24) << 6) | /* PFN */
807 (extract64(tlb_pfn
, 24, 32) << 32); /* PFNX */
811 void r4k_helper_tlbr(CPUMIPSState
*env
)
813 bool mi
= !!((env
->CP0_Config5
>> CP0C5_MI
) & 1);
814 uint16_t ASID
= env
->CP0_EntryHi
& env
->CP0_EntryHi_ASID_mask
;
815 uint32_t MMID
= env
->CP0_MemoryMapID
;
820 MMID
= mi
? MMID
: (uint32_t) ASID
;
821 idx
= (env
->CP0_Index
& ~0x80000000) % env
->tlb
->nb_tlb
;
822 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[idx
];
824 tlb_mmid
= mi
? tlb
->MMID
: (uint32_t) tlb
->ASID
;
825 /* If this will change the current ASID/MMID, flush qemu's TLB. */
826 if (MMID
!= tlb_mmid
) {
827 cpu_mips_tlb_flush(env
);
830 r4k_mips_tlb_flush_extra(env
, env
->tlb
->nb_tlb
);
833 env
->CP0_EntryHi
= 1 << CP0EnHi_EHINV
;
834 env
->CP0_PageMask
= 0;
835 env
->CP0_EntryLo0
= 0;
836 env
->CP0_EntryLo1
= 0;
838 env
->CP0_EntryHi
= mi
? tlb
->VPN
: tlb
->VPN
| tlb
->ASID
;
839 env
->CP0_MemoryMapID
= tlb
->MMID
;
840 env
->CP0_PageMask
= tlb
->PageMask
;
841 env
->CP0_EntryLo0
= tlb
->G
| (tlb
->V0
<< 1) | (tlb
->D0
<< 2) |
842 ((uint64_t)tlb
->RI0
<< CP0EnLo_RI
) |
843 ((uint64_t)tlb
->XI0
<< CP0EnLo_XI
) | (tlb
->C0
<< 3) |
844 get_entrylo_pfn_from_tlb(tlb
->PFN
[0] >> 12);
845 env
->CP0_EntryLo1
= tlb
->G
| (tlb
->V1
<< 1) | (tlb
->D1
<< 2) |
846 ((uint64_t)tlb
->RI1
<< CP0EnLo_RI
) |
847 ((uint64_t)tlb
->XI1
<< CP0EnLo_XI
) | (tlb
->C1
<< 3) |
848 get_entrylo_pfn_from_tlb(tlb
->PFN
[1] >> 12);
852 void helper_tlbwi(CPUMIPSState
*env
)
854 env
->tlb
->helper_tlbwi(env
);
857 void helper_tlbwr(CPUMIPSState
*env
)
859 env
->tlb
->helper_tlbwr(env
);
862 void helper_tlbp(CPUMIPSState
*env
)
864 env
->tlb
->helper_tlbp(env
);
867 void helper_tlbr(CPUMIPSState
*env
)
869 env
->tlb
->helper_tlbr(env
);
872 void helper_tlbinv(CPUMIPSState
*env
)
874 env
->tlb
->helper_tlbinv(env
);
877 void helper_tlbinvf(CPUMIPSState
*env
)
879 env
->tlb
->helper_tlbinvf(env
);
882 static void global_invalidate_tlb(CPUMIPSState
*env
,
897 for (idx
= 0; idx
< env
->tlb
->nb_tlb
; idx
++) {
898 tlb
= &env
->tlb
->mmu
.r4k
.tlb
[idx
];
900 (((tlb
->VPN
& ~tlb
->PageMask
) == (invMsgVPN2
& ~tlb
->PageMask
))
903 (extract64(env
->CP0_EntryHi
, 62, 2) == invMsgR
)
906 MMidMatch
= tlb
->MMID
== invMsgMMid
;
907 if ((invAll
&& (idx
> env
->CP0_Wired
)) ||
908 (VAMatch
&& invVAMMid
&& (tlb
->G
|| MMidMatch
)) ||
909 (VAMatch
&& invVA
) ||
910 (MMidMatch
&& !(tlb
->G
) && invMMid
)) {
914 cpu_mips_tlb_flush(env
);
917 void helper_ginvt(CPUMIPSState
*env
, target_ulong arg
, uint32_t type
)
919 bool invAll
= type
== 0;
920 bool invVA
= type
== 1;
921 bool invMMid
= type
== 2;
922 bool invVAMMid
= type
== 3;
923 uint32_t invMsgVPN2
= arg
& (TARGET_PAGE_MASK
<< 1);
925 uint32_t invMsgMMid
= env
->CP0_MemoryMapID
;
926 CPUState
*other_cs
= first_cpu
;
929 invMsgR
= extract64(arg
, 62, 2);
932 CPU_FOREACH(other_cs
) {
933 MIPSCPU
*other_cpu
= MIPS_CPU(other_cs
);
934 global_invalidate_tlb(&other_cpu
->env
, invMsgVPN2
, invMsgR
, invMsgMMid
,
935 invAll
, invVAMMid
, invMMid
, invVA
);
940 target_ulong
helper_di(CPUMIPSState
*env
)
942 target_ulong t0
= env
->CP0_Status
;
944 env
->CP0_Status
= t0
& ~(1 << CP0St_IE
);
948 target_ulong
helper_ei(CPUMIPSState
*env
)
950 target_ulong t0
= env
->CP0_Status
;
952 env
->CP0_Status
= t0
| (1 << CP0St_IE
);
956 static void debug_pre_eret(CPUMIPSState
*env
)
958 if (qemu_loglevel_mask(CPU_LOG_EXEC
)) {
959 qemu_log("ERET: PC " TARGET_FMT_lx
" EPC " TARGET_FMT_lx
,
960 env
->active_tc
.PC
, env
->CP0_EPC
);
961 if (env
->CP0_Status
& (1 << CP0St_ERL
)) {
962 qemu_log(" ErrorEPC " TARGET_FMT_lx
, env
->CP0_ErrorEPC
);
964 if (env
->hflags
& MIPS_HFLAG_DM
) {
965 qemu_log(" DEPC " TARGET_FMT_lx
, env
->CP0_DEPC
);
971 static void debug_post_eret(CPUMIPSState
*env
)
973 if (qemu_loglevel_mask(CPU_LOG_EXEC
)) {
974 qemu_log(" => PC " TARGET_FMT_lx
" EPC " TARGET_FMT_lx
,
975 env
->active_tc
.PC
, env
->CP0_EPC
);
976 if (env
->CP0_Status
& (1 << CP0St_ERL
)) {
977 qemu_log(" ErrorEPC " TARGET_FMT_lx
, env
->CP0_ErrorEPC
);
979 if (env
->hflags
& MIPS_HFLAG_DM
) {
980 qemu_log(" DEPC " TARGET_FMT_lx
, env
->CP0_DEPC
);
982 switch (cpu_mmu_index(env
, false)) {
996 cpu_abort(env_cpu(env
), "Invalid MMU mode!\n");
1002 static void set_pc(CPUMIPSState
*env
, target_ulong error_pc
)
1004 env
->active_tc
.PC
= error_pc
& ~(target_ulong
)1;
1006 env
->hflags
|= MIPS_HFLAG_M16
;
1008 env
->hflags
&= ~(MIPS_HFLAG_M16
);
1012 static inline void exception_return(CPUMIPSState
*env
)
1014 debug_pre_eret(env
);
1015 if (env
->CP0_Status
& (1 << CP0St_ERL
)) {
1016 set_pc(env
, env
->CP0_ErrorEPC
);
1017 env
->CP0_Status
&= ~(1 << CP0St_ERL
);
1019 set_pc(env
, env
->CP0_EPC
);
1020 env
->CP0_Status
&= ~(1 << CP0St_EXL
);
1022 compute_hflags(env
);
1023 debug_post_eret(env
);
1026 void helper_eret(CPUMIPSState
*env
)
1028 exception_return(env
);
1029 env
->CP0_LLAddr
= 1;
1033 void helper_eretnc(CPUMIPSState
*env
)
1035 exception_return(env
);
1038 void helper_deret(CPUMIPSState
*env
)
1040 debug_pre_eret(env
);
1042 env
->hflags
&= ~MIPS_HFLAG_DM
;
1043 compute_hflags(env
);
1045 set_pc(env
, env
->CP0_DEPC
);
1047 debug_post_eret(env
);
1049 #endif /* !CONFIG_USER_ONLY */
1051 static inline void check_hwrena(CPUMIPSState
*env
, int reg
, uintptr_t pc
)
1053 if ((env
->hflags
& MIPS_HFLAG_CP0
) || (env
->CP0_HWREna
& (1 << reg
))) {
1056 do_raise_exception(env
, EXCP_RI
, pc
);
1059 target_ulong
helper_rdhwr_cpunum(CPUMIPSState
*env
)
1061 check_hwrena(env
, 0, GETPC());
1062 return env
->CP0_EBase
& 0x3ff;
1065 target_ulong
helper_rdhwr_synci_step(CPUMIPSState
*env
)
1067 check_hwrena(env
, 1, GETPC());
1068 return env
->SYNCI_Step
;
1071 target_ulong
helper_rdhwr_cc(CPUMIPSState
*env
)
1073 check_hwrena(env
, 2, GETPC());
1074 #ifdef CONFIG_USER_ONLY
1075 return env
->CP0_Count
;
1077 return (int32_t)cpu_mips_get_count(env
);
1081 target_ulong
helper_rdhwr_ccres(CPUMIPSState
*env
)
1083 check_hwrena(env
, 3, GETPC());
1087 target_ulong
helper_rdhwr_performance(CPUMIPSState
*env
)
1089 check_hwrena(env
, 4, GETPC());
1090 return env
->CP0_Performance0
;
1093 target_ulong
helper_rdhwr_xnp(CPUMIPSState
*env
)
1095 check_hwrena(env
, 5, GETPC());
1096 return (env
->CP0_Config5
>> CP0C5_XNP
) & 1;
1099 void helper_pmon(CPUMIPSState
*env
, int function
)
1103 case 2: /* TODO: char inbyte(int waitflag); */
1104 if (env
->active_tc
.gpr
[4] == 0) {
1105 env
->active_tc
.gpr
[2] = -1;
1108 case 11: /* TODO: char inbyte (void); */
1109 env
->active_tc
.gpr
[2] = -1;
1113 printf("%c", (char)(env
->active_tc
.gpr
[4] & 0xFF));
1119 unsigned char *fmt
= (void *)(uintptr_t)env
->active_tc
.gpr
[4];
1126 void helper_wait(CPUMIPSState
*env
)
1128 CPUState
*cs
= env_cpu(env
);
1131 cpu_reset_interrupt(cs
, CPU_INTERRUPT_WAKE
);
1133 * Last instruction in the block, PC was updated before
1134 * - no need to recover PC and icount.
1136 raise_exception(env
, EXCP_HLT
);
1139 #if !defined(CONFIG_USER_ONLY)
1141 void mips_cpu_do_unaligned_access(CPUState
*cs
, vaddr addr
,
1142 MMUAccessType access_type
,
1143 int mmu_idx
, uintptr_t retaddr
)
1145 MIPSCPU
*cpu
= MIPS_CPU(cs
);
1146 CPUMIPSState
*env
= &cpu
->env
;
1150 if (!(env
->hflags
& MIPS_HFLAG_DM
)) {
1151 env
->CP0_BadVAddr
= addr
;
1154 if (access_type
== MMU_DATA_STORE
) {
1158 if (access_type
== MMU_INST_FETCH
) {
1159 error_code
|= EXCP_INST_NOTAVAIL
;
1163 do_raise_exception_err(env
, excp
, error_code
, retaddr
);
1166 void mips_cpu_do_transaction_failed(CPUState
*cs
, hwaddr physaddr
,
1167 vaddr addr
, unsigned size
,
1168 MMUAccessType access_type
,
1169 int mmu_idx
, MemTxAttrs attrs
,
1170 MemTxResult response
, uintptr_t retaddr
)
1172 MIPSCPU
*cpu
= MIPS_CPU(cs
);
1173 CPUMIPSState
*env
= &cpu
->env
;
1175 if (access_type
== MMU_INST_FETCH
) {
1176 do_raise_exception(env
, EXCP_IBE
, retaddr
);
1178 do_raise_exception(env
, EXCP_DBE
, retaddr
);
1181 #endif /* !CONFIG_USER_ONLY */
1185 /* Data format min and max values */
1186 #define DF_BITS(df) (1 << ((df) + 3))
1188 /* Element-by-element access macros */
1189 #define DF_ELEMENTS(df) (MSA_WRLEN / DF_BITS(df))
1191 #if !defined(CONFIG_USER_ONLY)
1192 #define MEMOP_IDX(DF) \
1193 TCGMemOpIdx oi = make_memop_idx(MO_TE | DF | MO_UNALN, \
1194 cpu_mmu_index(env, false));
1196 #define MEMOP_IDX(DF)
1199 void helper_msa_ld_b(CPUMIPSState
*env
, uint32_t wd
,
1202 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1204 #if !defined(CONFIG_USER_ONLY)
1205 #if !defined(HOST_WORDS_BIGENDIAN)
1206 pwd
->b
[0] = helper_ret_ldub_mmu(env
, addr
+ (0 << DF_BYTE
), oi
, GETPC());
1207 pwd
->b
[1] = helper_ret_ldub_mmu(env
, addr
+ (1 << DF_BYTE
), oi
, GETPC());
1208 pwd
->b
[2] = helper_ret_ldub_mmu(env
, addr
+ (2 << DF_BYTE
), oi
, GETPC());
1209 pwd
->b
[3] = helper_ret_ldub_mmu(env
, addr
+ (3 << DF_BYTE
), oi
, GETPC());
1210 pwd
->b
[4] = helper_ret_ldub_mmu(env
, addr
+ (4 << DF_BYTE
), oi
, GETPC());
1211 pwd
->b
[5] = helper_ret_ldub_mmu(env
, addr
+ (5 << DF_BYTE
), oi
, GETPC());
1212 pwd
->b
[6] = helper_ret_ldub_mmu(env
, addr
+ (6 << DF_BYTE
), oi
, GETPC());
1213 pwd
->b
[7] = helper_ret_ldub_mmu(env
, addr
+ (7 << DF_BYTE
), oi
, GETPC());
1214 pwd
->b
[8] = helper_ret_ldub_mmu(env
, addr
+ (8 << DF_BYTE
), oi
, GETPC());
1215 pwd
->b
[9] = helper_ret_ldub_mmu(env
, addr
+ (9 << DF_BYTE
), oi
, GETPC());
1216 pwd
->b
[10] = helper_ret_ldub_mmu(env
, addr
+ (10 << DF_BYTE
), oi
, GETPC());
1217 pwd
->b
[11] = helper_ret_ldub_mmu(env
, addr
+ (11 << DF_BYTE
), oi
, GETPC());
1218 pwd
->b
[12] = helper_ret_ldub_mmu(env
, addr
+ (12 << DF_BYTE
), oi
, GETPC());
1219 pwd
->b
[13] = helper_ret_ldub_mmu(env
, addr
+ (13 << DF_BYTE
), oi
, GETPC());
1220 pwd
->b
[14] = helper_ret_ldub_mmu(env
, addr
+ (14 << DF_BYTE
), oi
, GETPC());
1221 pwd
->b
[15] = helper_ret_ldub_mmu(env
, addr
+ (15 << DF_BYTE
), oi
, GETPC());
1223 pwd
->b
[0] = helper_ret_ldub_mmu(env
, addr
+ (7 << DF_BYTE
), oi
, GETPC());
1224 pwd
->b
[1] = helper_ret_ldub_mmu(env
, addr
+ (6 << DF_BYTE
), oi
, GETPC());
1225 pwd
->b
[2] = helper_ret_ldub_mmu(env
, addr
+ (5 << DF_BYTE
), oi
, GETPC());
1226 pwd
->b
[3] = helper_ret_ldub_mmu(env
, addr
+ (4 << DF_BYTE
), oi
, GETPC());
1227 pwd
->b
[4] = helper_ret_ldub_mmu(env
, addr
+ (3 << DF_BYTE
), oi
, GETPC());
1228 pwd
->b
[5] = helper_ret_ldub_mmu(env
, addr
+ (2 << DF_BYTE
), oi
, GETPC());
1229 pwd
->b
[6] = helper_ret_ldub_mmu(env
, addr
+ (1 << DF_BYTE
), oi
, GETPC());
1230 pwd
->b
[7] = helper_ret_ldub_mmu(env
, addr
+ (0 << DF_BYTE
), oi
, GETPC());
1231 pwd
->b
[8] = helper_ret_ldub_mmu(env
, addr
+ (15 << DF_BYTE
), oi
, GETPC());
1232 pwd
->b
[9] = helper_ret_ldub_mmu(env
, addr
+ (14 << DF_BYTE
), oi
, GETPC());
1233 pwd
->b
[10] = helper_ret_ldub_mmu(env
, addr
+ (13 << DF_BYTE
), oi
, GETPC());
1234 pwd
->b
[11] = helper_ret_ldub_mmu(env
, addr
+ (12 << DF_BYTE
), oi
, GETPC());
1235 pwd
->b
[12] = helper_ret_ldub_mmu(env
, addr
+ (11 << DF_BYTE
), oi
, GETPC());
1236 pwd
->b
[13] = helper_ret_ldub_mmu(env
, addr
+ (10 << DF_BYTE
), oi
, GETPC());
1237 pwd
->b
[14] = helper_ret_ldub_mmu(env
, addr
+ (9 << DF_BYTE
), oi
, GETPC());
1238 pwd
->b
[15] = helper_ret_ldub_mmu(env
, addr
+ (8 << DF_BYTE
), oi
, GETPC());
1241 #if !defined(HOST_WORDS_BIGENDIAN)
1242 pwd
->b
[0] = cpu_ldub_data(env
, addr
+ (0 << DF_BYTE
));
1243 pwd
->b
[1] = cpu_ldub_data(env
, addr
+ (1 << DF_BYTE
));
1244 pwd
->b
[2] = cpu_ldub_data(env
, addr
+ (2 << DF_BYTE
));
1245 pwd
->b
[3] = cpu_ldub_data(env
, addr
+ (3 << DF_BYTE
));
1246 pwd
->b
[4] = cpu_ldub_data(env
, addr
+ (4 << DF_BYTE
));
1247 pwd
->b
[5] = cpu_ldub_data(env
, addr
+ (5 << DF_BYTE
));
1248 pwd
->b
[6] = cpu_ldub_data(env
, addr
+ (6 << DF_BYTE
));
1249 pwd
->b
[7] = cpu_ldub_data(env
, addr
+ (7 << DF_BYTE
));
1250 pwd
->b
[8] = cpu_ldub_data(env
, addr
+ (8 << DF_BYTE
));
1251 pwd
->b
[9] = cpu_ldub_data(env
, addr
+ (9 << DF_BYTE
));
1252 pwd
->b
[10] = cpu_ldub_data(env
, addr
+ (10 << DF_BYTE
));
1253 pwd
->b
[11] = cpu_ldub_data(env
, addr
+ (11 << DF_BYTE
));
1254 pwd
->b
[12] = cpu_ldub_data(env
, addr
+ (12 << DF_BYTE
));
1255 pwd
->b
[13] = cpu_ldub_data(env
, addr
+ (13 << DF_BYTE
));
1256 pwd
->b
[14] = cpu_ldub_data(env
, addr
+ (14 << DF_BYTE
));
1257 pwd
->b
[15] = cpu_ldub_data(env
, addr
+ (15 << DF_BYTE
));
1259 pwd
->b
[0] = cpu_ldub_data(env
, addr
+ (7 << DF_BYTE
));
1260 pwd
->b
[1] = cpu_ldub_data(env
, addr
+ (6 << DF_BYTE
));
1261 pwd
->b
[2] = cpu_ldub_data(env
, addr
+ (5 << DF_BYTE
));
1262 pwd
->b
[3] = cpu_ldub_data(env
, addr
+ (4 << DF_BYTE
));
1263 pwd
->b
[4] = cpu_ldub_data(env
, addr
+ (3 << DF_BYTE
));
1264 pwd
->b
[5] = cpu_ldub_data(env
, addr
+ (2 << DF_BYTE
));
1265 pwd
->b
[6] = cpu_ldub_data(env
, addr
+ (1 << DF_BYTE
));
1266 pwd
->b
[7] = cpu_ldub_data(env
, addr
+ (0 << DF_BYTE
));
1267 pwd
->b
[8] = cpu_ldub_data(env
, addr
+ (15 << DF_BYTE
));
1268 pwd
->b
[9] = cpu_ldub_data(env
, addr
+ (14 << DF_BYTE
));
1269 pwd
->b
[10] = cpu_ldub_data(env
, addr
+ (13 << DF_BYTE
));
1270 pwd
->b
[11] = cpu_ldub_data(env
, addr
+ (12 << DF_BYTE
));
1271 pwd
->b
[12] = cpu_ldub_data(env
, addr
+ (11 << DF_BYTE
));
1272 pwd
->b
[13] = cpu_ldub_data(env
, addr
+ (10 << DF_BYTE
));
1273 pwd
->b
[14] = cpu_ldub_data(env
, addr
+ (9 << DF_BYTE
));
1274 pwd
->b
[15] = cpu_ldub_data(env
, addr
+ (8 << DF_BYTE
));
1279 void helper_msa_ld_h(CPUMIPSState
*env
, uint32_t wd
,
1282 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1284 #if !defined(CONFIG_USER_ONLY)
1285 #if !defined(HOST_WORDS_BIGENDIAN)
1286 pwd
->h
[0] = helper_ret_lduw_mmu(env
, addr
+ (0 << DF_HALF
), oi
, GETPC());
1287 pwd
->h
[1] = helper_ret_lduw_mmu(env
, addr
+ (1 << DF_HALF
), oi
, GETPC());
1288 pwd
->h
[2] = helper_ret_lduw_mmu(env
, addr
+ (2 << DF_HALF
), oi
, GETPC());
1289 pwd
->h
[3] = helper_ret_lduw_mmu(env
, addr
+ (3 << DF_HALF
), oi
, GETPC());
1290 pwd
->h
[4] = helper_ret_lduw_mmu(env
, addr
+ (4 << DF_HALF
), oi
, GETPC());
1291 pwd
->h
[5] = helper_ret_lduw_mmu(env
, addr
+ (5 << DF_HALF
), oi
, GETPC());
1292 pwd
->h
[6] = helper_ret_lduw_mmu(env
, addr
+ (6 << DF_HALF
), oi
, GETPC());
1293 pwd
->h
[7] = helper_ret_lduw_mmu(env
, addr
+ (7 << DF_HALF
), oi
, GETPC());
1295 pwd
->h
[0] = helper_ret_lduw_mmu(env
, addr
+ (3 << DF_HALF
), oi
, GETPC());
1296 pwd
->h
[1] = helper_ret_lduw_mmu(env
, addr
+ (2 << DF_HALF
), oi
, GETPC());
1297 pwd
->h
[2] = helper_ret_lduw_mmu(env
, addr
+ (1 << DF_HALF
), oi
, GETPC());
1298 pwd
->h
[3] = helper_ret_lduw_mmu(env
, addr
+ (0 << DF_HALF
), oi
, GETPC());
1299 pwd
->h
[4] = helper_ret_lduw_mmu(env
, addr
+ (7 << DF_HALF
), oi
, GETPC());
1300 pwd
->h
[5] = helper_ret_lduw_mmu(env
, addr
+ (6 << DF_HALF
), oi
, GETPC());
1301 pwd
->h
[6] = helper_ret_lduw_mmu(env
, addr
+ (5 << DF_HALF
), oi
, GETPC());
1302 pwd
->h
[7] = helper_ret_lduw_mmu(env
, addr
+ (4 << DF_HALF
), oi
, GETPC());
1305 #if !defined(HOST_WORDS_BIGENDIAN)
1306 pwd
->h
[0] = cpu_lduw_data(env
, addr
+ (0 << DF_HALF
));
1307 pwd
->h
[1] = cpu_lduw_data(env
, addr
+ (1 << DF_HALF
));
1308 pwd
->h
[2] = cpu_lduw_data(env
, addr
+ (2 << DF_HALF
));
1309 pwd
->h
[3] = cpu_lduw_data(env
, addr
+ (3 << DF_HALF
));
1310 pwd
->h
[4] = cpu_lduw_data(env
, addr
+ (4 << DF_HALF
));
1311 pwd
->h
[5] = cpu_lduw_data(env
, addr
+ (5 << DF_HALF
));
1312 pwd
->h
[6] = cpu_lduw_data(env
, addr
+ (6 << DF_HALF
));
1313 pwd
->h
[7] = cpu_lduw_data(env
, addr
+ (7 << DF_HALF
));
1315 pwd
->h
[0] = cpu_lduw_data(env
, addr
+ (3 << DF_HALF
));
1316 pwd
->h
[1] = cpu_lduw_data(env
, addr
+ (2 << DF_HALF
));
1317 pwd
->h
[2] = cpu_lduw_data(env
, addr
+ (1 << DF_HALF
));
1318 pwd
->h
[3] = cpu_lduw_data(env
, addr
+ (0 << DF_HALF
));
1319 pwd
->h
[4] = cpu_lduw_data(env
, addr
+ (7 << DF_HALF
));
1320 pwd
->h
[5] = cpu_lduw_data(env
, addr
+ (6 << DF_HALF
));
1321 pwd
->h
[6] = cpu_lduw_data(env
, addr
+ (5 << DF_HALF
));
1322 pwd
->h
[7] = cpu_lduw_data(env
, addr
+ (4 << DF_HALF
));
1327 void helper_msa_ld_w(CPUMIPSState
*env
, uint32_t wd
,
1330 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1332 #if !defined(CONFIG_USER_ONLY)
1333 #if !defined(HOST_WORDS_BIGENDIAN)
1334 pwd
->w
[0] = helper_ret_ldul_mmu(env
, addr
+ (0 << DF_WORD
), oi
, GETPC());
1335 pwd
->w
[1] = helper_ret_ldul_mmu(env
, addr
+ (1 << DF_WORD
), oi
, GETPC());
1336 pwd
->w
[2] = helper_ret_ldul_mmu(env
, addr
+ (2 << DF_WORD
), oi
, GETPC());
1337 pwd
->w
[3] = helper_ret_ldul_mmu(env
, addr
+ (3 << DF_WORD
), oi
, GETPC());
1339 pwd
->w
[0] = helper_ret_ldul_mmu(env
, addr
+ (1 << DF_WORD
), oi
, GETPC());
1340 pwd
->w
[1] = helper_ret_ldul_mmu(env
, addr
+ (0 << DF_WORD
), oi
, GETPC());
1341 pwd
->w
[2] = helper_ret_ldul_mmu(env
, addr
+ (3 << DF_WORD
), oi
, GETPC());
1342 pwd
->w
[3] = helper_ret_ldul_mmu(env
, addr
+ (2 << DF_WORD
), oi
, GETPC());
1345 #if !defined(HOST_WORDS_BIGENDIAN)
1346 pwd
->w
[0] = cpu_ldl_data(env
, addr
+ (0 << DF_WORD
));
1347 pwd
->w
[1] = cpu_ldl_data(env
, addr
+ (1 << DF_WORD
));
1348 pwd
->w
[2] = cpu_ldl_data(env
, addr
+ (2 << DF_WORD
));
1349 pwd
->w
[3] = cpu_ldl_data(env
, addr
+ (3 << DF_WORD
));
1351 pwd
->w
[0] = cpu_ldl_data(env
, addr
+ (1 << DF_WORD
));
1352 pwd
->w
[1] = cpu_ldl_data(env
, addr
+ (0 << DF_WORD
));
1353 pwd
->w
[2] = cpu_ldl_data(env
, addr
+ (3 << DF_WORD
));
1354 pwd
->w
[3] = cpu_ldl_data(env
, addr
+ (2 << DF_WORD
));
1359 void helper_msa_ld_d(CPUMIPSState
*env
, uint32_t wd
,
1362 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1363 MEMOP_IDX(DF_DOUBLE
)
1364 #if !defined(CONFIG_USER_ONLY)
1365 pwd
->d
[0] = helper_ret_ldq_mmu(env
, addr
+ (0 << DF_DOUBLE
), oi
, GETPC());
1366 pwd
->d
[1] = helper_ret_ldq_mmu(env
, addr
+ (1 << DF_DOUBLE
), oi
, GETPC());
1368 pwd
->d
[0] = cpu_ldq_data(env
, addr
+ (0 << DF_DOUBLE
));
1369 pwd
->d
[1] = cpu_ldq_data(env
, addr
+ (1 << DF_DOUBLE
));
1373 #define MSA_PAGESPAN(x) \
1374 ((((x) & ~TARGET_PAGE_MASK) + MSA_WRLEN / 8 - 1) >= TARGET_PAGE_SIZE)
1376 static inline void ensure_writable_pages(CPUMIPSState
*env
,
1381 /* FIXME: Probe the actual accesses (pass and use a size) */
1382 if (unlikely(MSA_PAGESPAN(addr
))) {
1384 probe_write(env
, addr
, 0, mmu_idx
, retaddr
);
1386 addr
= (addr
& TARGET_PAGE_MASK
) + TARGET_PAGE_SIZE
;
1387 probe_write(env
, addr
, 0, mmu_idx
, retaddr
);
1391 void helper_msa_st_b(CPUMIPSState
*env
, uint32_t wd
,
1394 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1395 int mmu_idx
= cpu_mmu_index(env
, false);
1398 ensure_writable_pages(env
, addr
, mmu_idx
, GETPC());
1399 #if !defined(CONFIG_USER_ONLY)
1400 #if !defined(HOST_WORDS_BIGENDIAN)
1401 helper_ret_stb_mmu(env
, addr
+ (0 << DF_BYTE
), pwd
->b
[0], oi
, GETPC());
1402 helper_ret_stb_mmu(env
, addr
+ (1 << DF_BYTE
), pwd
->b
[1], oi
, GETPC());
1403 helper_ret_stb_mmu(env
, addr
+ (2 << DF_BYTE
), pwd
->b
[2], oi
, GETPC());
1404 helper_ret_stb_mmu(env
, addr
+ (3 << DF_BYTE
), pwd
->b
[3], oi
, GETPC());
1405 helper_ret_stb_mmu(env
, addr
+ (4 << DF_BYTE
), pwd
->b
[4], oi
, GETPC());
1406 helper_ret_stb_mmu(env
, addr
+ (5 << DF_BYTE
), pwd
->b
[5], oi
, GETPC());
1407 helper_ret_stb_mmu(env
, addr
+ (6 << DF_BYTE
), pwd
->b
[6], oi
, GETPC());
1408 helper_ret_stb_mmu(env
, addr
+ (7 << DF_BYTE
), pwd
->b
[7], oi
, GETPC());
1409 helper_ret_stb_mmu(env
, addr
+ (8 << DF_BYTE
), pwd
->b
[8], oi
, GETPC());
1410 helper_ret_stb_mmu(env
, addr
+ (9 << DF_BYTE
), pwd
->b
[9], oi
, GETPC());
1411 helper_ret_stb_mmu(env
, addr
+ (10 << DF_BYTE
), pwd
->b
[10], oi
, GETPC());
1412 helper_ret_stb_mmu(env
, addr
+ (11 << DF_BYTE
), pwd
->b
[11], oi
, GETPC());
1413 helper_ret_stb_mmu(env
, addr
+ (12 << DF_BYTE
), pwd
->b
[12], oi
, GETPC());
1414 helper_ret_stb_mmu(env
, addr
+ (13 << DF_BYTE
), pwd
->b
[13], oi
, GETPC());
1415 helper_ret_stb_mmu(env
, addr
+ (14 << DF_BYTE
), pwd
->b
[14], oi
, GETPC());
1416 helper_ret_stb_mmu(env
, addr
+ (15 << DF_BYTE
), pwd
->b
[15], oi
, GETPC());
1418 helper_ret_stb_mmu(env
, addr
+ (7 << DF_BYTE
), pwd
->b
[0], oi
, GETPC());
1419 helper_ret_stb_mmu(env
, addr
+ (6 << DF_BYTE
), pwd
->b
[1], oi
, GETPC());
1420 helper_ret_stb_mmu(env
, addr
+ (5 << DF_BYTE
), pwd
->b
[2], oi
, GETPC());
1421 helper_ret_stb_mmu(env
, addr
+ (4 << DF_BYTE
), pwd
->b
[3], oi
, GETPC());
1422 helper_ret_stb_mmu(env
, addr
+ (3 << DF_BYTE
), pwd
->b
[4], oi
, GETPC());
1423 helper_ret_stb_mmu(env
, addr
+ (2 << DF_BYTE
), pwd
->b
[5], oi
, GETPC());
1424 helper_ret_stb_mmu(env
, addr
+ (1 << DF_BYTE
), pwd
->b
[6], oi
, GETPC());
1425 helper_ret_stb_mmu(env
, addr
+ (0 << DF_BYTE
), pwd
->b
[7], oi
, GETPC());
1426 helper_ret_stb_mmu(env
, addr
+ (15 << DF_BYTE
), pwd
->b
[8], oi
, GETPC());
1427 helper_ret_stb_mmu(env
, addr
+ (14 << DF_BYTE
), pwd
->b
[9], oi
, GETPC());
1428 helper_ret_stb_mmu(env
, addr
+ (13 << DF_BYTE
), pwd
->b
[10], oi
, GETPC());
1429 helper_ret_stb_mmu(env
, addr
+ (12 << DF_BYTE
), pwd
->b
[11], oi
, GETPC());
1430 helper_ret_stb_mmu(env
, addr
+ (11 << DF_BYTE
), pwd
->b
[12], oi
, GETPC());
1431 helper_ret_stb_mmu(env
, addr
+ (10 << DF_BYTE
), pwd
->b
[13], oi
, GETPC());
1432 helper_ret_stb_mmu(env
, addr
+ (9 << DF_BYTE
), pwd
->b
[14], oi
, GETPC());
1433 helper_ret_stb_mmu(env
, addr
+ (8 << DF_BYTE
), pwd
->b
[15], oi
, GETPC());
1436 #if !defined(HOST_WORDS_BIGENDIAN)
1437 cpu_stb_data(env
, addr
+ (0 << DF_BYTE
), pwd
->b
[0]);
1438 cpu_stb_data(env
, addr
+ (1 << DF_BYTE
), pwd
->b
[1]);
1439 cpu_stb_data(env
, addr
+ (2 << DF_BYTE
), pwd
->b
[2]);
1440 cpu_stb_data(env
, addr
+ (3 << DF_BYTE
), pwd
->b
[3]);
1441 cpu_stb_data(env
, addr
+ (4 << DF_BYTE
), pwd
->b
[4]);
1442 cpu_stb_data(env
, addr
+ (5 << DF_BYTE
), pwd
->b
[5]);
1443 cpu_stb_data(env
, addr
+ (6 << DF_BYTE
), pwd
->b
[6]);
1444 cpu_stb_data(env
, addr
+ (7 << DF_BYTE
), pwd
->b
[7]);
1445 cpu_stb_data(env
, addr
+ (8 << DF_BYTE
), pwd
->b
[8]);
1446 cpu_stb_data(env
, addr
+ (9 << DF_BYTE
), pwd
->b
[9]);
1447 cpu_stb_data(env
, addr
+ (10 << DF_BYTE
), pwd
->b
[10]);
1448 cpu_stb_data(env
, addr
+ (11 << DF_BYTE
), pwd
->b
[11]);
1449 cpu_stb_data(env
, addr
+ (12 << DF_BYTE
), pwd
->b
[12]);
1450 cpu_stb_data(env
, addr
+ (13 << DF_BYTE
), pwd
->b
[13]);
1451 cpu_stb_data(env
, addr
+ (14 << DF_BYTE
), pwd
->b
[14]);
1452 cpu_stb_data(env
, addr
+ (15 << DF_BYTE
), pwd
->b
[15]);
1454 cpu_stb_data(env
, addr
+ (7 << DF_BYTE
), pwd
->b
[0]);
1455 cpu_stb_data(env
, addr
+ (6 << DF_BYTE
), pwd
->b
[1]);
1456 cpu_stb_data(env
, addr
+ (5 << DF_BYTE
), pwd
->b
[2]);
1457 cpu_stb_data(env
, addr
+ (4 << DF_BYTE
), pwd
->b
[3]);
1458 cpu_stb_data(env
, addr
+ (3 << DF_BYTE
), pwd
->b
[4]);
1459 cpu_stb_data(env
, addr
+ (2 << DF_BYTE
), pwd
->b
[5]);
1460 cpu_stb_data(env
, addr
+ (1 << DF_BYTE
), pwd
->b
[6]);
1461 cpu_stb_data(env
, addr
+ (0 << DF_BYTE
), pwd
->b
[7]);
1462 cpu_stb_data(env
, addr
+ (15 << DF_BYTE
), pwd
->b
[8]);
1463 cpu_stb_data(env
, addr
+ (14 << DF_BYTE
), pwd
->b
[9]);
1464 cpu_stb_data(env
, addr
+ (13 << DF_BYTE
), pwd
->b
[10]);
1465 cpu_stb_data(env
, addr
+ (12 << DF_BYTE
), pwd
->b
[11]);
1466 cpu_stb_data(env
, addr
+ (11 << DF_BYTE
), pwd
->b
[12]);
1467 cpu_stb_data(env
, addr
+ (10 << DF_BYTE
), pwd
->b
[13]);
1468 cpu_stb_data(env
, addr
+ (9 << DF_BYTE
), pwd
->b
[14]);
1469 cpu_stb_data(env
, addr
+ (8 << DF_BYTE
), pwd
->b
[15]);
1474 void helper_msa_st_h(CPUMIPSState
*env
, uint32_t wd
,
1477 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1478 int mmu_idx
= cpu_mmu_index(env
, false);
1481 ensure_writable_pages(env
, addr
, mmu_idx
, GETPC());
1482 #if !defined(CONFIG_USER_ONLY)
1483 #if !defined(HOST_WORDS_BIGENDIAN)
1484 helper_ret_stw_mmu(env
, addr
+ (0 << DF_HALF
), pwd
->h
[0], oi
, GETPC());
1485 helper_ret_stw_mmu(env
, addr
+ (1 << DF_HALF
), pwd
->h
[1], oi
, GETPC());
1486 helper_ret_stw_mmu(env
, addr
+ (2 << DF_HALF
), pwd
->h
[2], oi
, GETPC());
1487 helper_ret_stw_mmu(env
, addr
+ (3 << DF_HALF
), pwd
->h
[3], oi
, GETPC());
1488 helper_ret_stw_mmu(env
, addr
+ (4 << DF_HALF
), pwd
->h
[4], oi
, GETPC());
1489 helper_ret_stw_mmu(env
, addr
+ (5 << DF_HALF
), pwd
->h
[5], oi
, GETPC());
1490 helper_ret_stw_mmu(env
, addr
+ (6 << DF_HALF
), pwd
->h
[6], oi
, GETPC());
1491 helper_ret_stw_mmu(env
, addr
+ (7 << DF_HALF
), pwd
->h
[7], oi
, GETPC());
1493 helper_ret_stw_mmu(env
, addr
+ (3 << DF_HALF
), pwd
->h
[0], oi
, GETPC());
1494 helper_ret_stw_mmu(env
, addr
+ (2 << DF_HALF
), pwd
->h
[1], oi
, GETPC());
1495 helper_ret_stw_mmu(env
, addr
+ (1 << DF_HALF
), pwd
->h
[2], oi
, GETPC());
1496 helper_ret_stw_mmu(env
, addr
+ (0 << DF_HALF
), pwd
->h
[3], oi
, GETPC());
1497 helper_ret_stw_mmu(env
, addr
+ (7 << DF_HALF
), pwd
->h
[4], oi
, GETPC());
1498 helper_ret_stw_mmu(env
, addr
+ (6 << DF_HALF
), pwd
->h
[5], oi
, GETPC());
1499 helper_ret_stw_mmu(env
, addr
+ (5 << DF_HALF
), pwd
->h
[6], oi
, GETPC());
1500 helper_ret_stw_mmu(env
, addr
+ (4 << DF_HALF
), pwd
->h
[7], oi
, GETPC());
1503 #if !defined(HOST_WORDS_BIGENDIAN)
1504 cpu_stw_data(env
, addr
+ (0 << DF_HALF
), pwd
->h
[0]);
1505 cpu_stw_data(env
, addr
+ (1 << DF_HALF
), pwd
->h
[1]);
1506 cpu_stw_data(env
, addr
+ (2 << DF_HALF
), pwd
->h
[2]);
1507 cpu_stw_data(env
, addr
+ (3 << DF_HALF
), pwd
->h
[3]);
1508 cpu_stw_data(env
, addr
+ (4 << DF_HALF
), pwd
->h
[4]);
1509 cpu_stw_data(env
, addr
+ (5 << DF_HALF
), pwd
->h
[5]);
1510 cpu_stw_data(env
, addr
+ (6 << DF_HALF
), pwd
->h
[6]);
1511 cpu_stw_data(env
, addr
+ (7 << DF_HALF
), pwd
->h
[7]);
1513 cpu_stw_data(env
, addr
+ (3 << DF_HALF
), pwd
->h
[0]);
1514 cpu_stw_data(env
, addr
+ (2 << DF_HALF
), pwd
->h
[1]);
1515 cpu_stw_data(env
, addr
+ (1 << DF_HALF
), pwd
->h
[2]);
1516 cpu_stw_data(env
, addr
+ (0 << DF_HALF
), pwd
->h
[3]);
1517 cpu_stw_data(env
, addr
+ (7 << DF_HALF
), pwd
->h
[4]);
1518 cpu_stw_data(env
, addr
+ (6 << DF_HALF
), pwd
->h
[5]);
1519 cpu_stw_data(env
, addr
+ (5 << DF_HALF
), pwd
->h
[6]);
1520 cpu_stw_data(env
, addr
+ (4 << DF_HALF
), pwd
->h
[7]);
1525 void helper_msa_st_w(CPUMIPSState
*env
, uint32_t wd
,
1528 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1529 int mmu_idx
= cpu_mmu_index(env
, false);
1532 ensure_writable_pages(env
, addr
, mmu_idx
, GETPC());
1533 #if !defined(CONFIG_USER_ONLY)
1534 #if !defined(HOST_WORDS_BIGENDIAN)
1535 helper_ret_stl_mmu(env
, addr
+ (0 << DF_WORD
), pwd
->w
[0], oi
, GETPC());
1536 helper_ret_stl_mmu(env
, addr
+ (1 << DF_WORD
), pwd
->w
[1], oi
, GETPC());
1537 helper_ret_stl_mmu(env
, addr
+ (2 << DF_WORD
), pwd
->w
[2], oi
, GETPC());
1538 helper_ret_stl_mmu(env
, addr
+ (3 << DF_WORD
), pwd
->w
[3], oi
, GETPC());
1540 helper_ret_stl_mmu(env
, addr
+ (1 << DF_WORD
), pwd
->w
[0], oi
, GETPC());
1541 helper_ret_stl_mmu(env
, addr
+ (0 << DF_WORD
), pwd
->w
[1], oi
, GETPC());
1542 helper_ret_stl_mmu(env
, addr
+ (3 << DF_WORD
), pwd
->w
[2], oi
, GETPC());
1543 helper_ret_stl_mmu(env
, addr
+ (2 << DF_WORD
), pwd
->w
[3], oi
, GETPC());
1546 #if !defined(HOST_WORDS_BIGENDIAN)
1547 cpu_stl_data(env
, addr
+ (0 << DF_WORD
), pwd
->w
[0]);
1548 cpu_stl_data(env
, addr
+ (1 << DF_WORD
), pwd
->w
[1]);
1549 cpu_stl_data(env
, addr
+ (2 << DF_WORD
), pwd
->w
[2]);
1550 cpu_stl_data(env
, addr
+ (3 << DF_WORD
), pwd
->w
[3]);
1552 cpu_stl_data(env
, addr
+ (1 << DF_WORD
), pwd
->w
[0]);
1553 cpu_stl_data(env
, addr
+ (0 << DF_WORD
), pwd
->w
[1]);
1554 cpu_stl_data(env
, addr
+ (3 << DF_WORD
), pwd
->w
[2]);
1555 cpu_stl_data(env
, addr
+ (2 << DF_WORD
), pwd
->w
[3]);
1560 void helper_msa_st_d(CPUMIPSState
*env
, uint32_t wd
,
1563 wr_t
*pwd
= &(env
->active_fpu
.fpr
[wd
].wr
);
1564 int mmu_idx
= cpu_mmu_index(env
, false);
1566 MEMOP_IDX(DF_DOUBLE
)
1567 ensure_writable_pages(env
, addr
, mmu_idx
, GETPC());
1568 #if !defined(CONFIG_USER_ONLY)
1569 helper_ret_stq_mmu(env
, addr
+ (0 << DF_DOUBLE
), pwd
->d
[0], oi
, GETPC());
1570 helper_ret_stq_mmu(env
, addr
+ (1 << DF_DOUBLE
), pwd
->d
[1], oi
, GETPC());
1572 cpu_stq_data(env
, addr
+ (0 << DF_DOUBLE
), pwd
->d
[0]);
1573 cpu_stq_data(env
, addr
+ (1 << DF_DOUBLE
), pwd
->d
[1]);
1577 void helper_cache(CPUMIPSState
*env
, target_ulong addr
, uint32_t op
)
1579 #ifndef CONFIG_USER_ONLY
1580 static const char *const type_name
[] = {
1581 "Primary Instruction",
1582 "Primary Data or Unified Primary",
1586 uint32_t cache_type
= extract32(op
, 0, 2);
1587 uint32_t cache_operation
= extract32(op
, 2, 3);
1588 target_ulong index
= addr
& 0x1fffffff;
1590 switch (cache_operation
) {
1591 case 0b010: /* Index Store Tag */
1592 memory_region_dispatch_write(env
->itc_tag
, index
, env
->CP0_TagLo
,
1593 MO_64
, MEMTXATTRS_UNSPECIFIED
);
1595 case 0b001: /* Index Load Tag */
1596 memory_region_dispatch_read(env
->itc_tag
, index
, &env
->CP0_TagLo
,
1597 MO_64
, MEMTXATTRS_UNSPECIFIED
);
1599 case 0b000: /* Index Invalidate */
1600 case 0b100: /* Hit Invalidate */
1601 case 0b110: /* Hit Writeback */
1605 qemu_log_mask(LOG_UNIMP
, "cache operation:%u (type: %s cache)\n",
1606 cache_operation
, type_name
[cache_type
]);