#ifdef __mips_n32
#undef _MIPS_SZPTR
#define _MIPS_SZPTR 64
#endif
#include <mips/asm.h>
RCSID("$NetBSD: cache_r4k_subr.S,v 1.3 2017/04/27 19:40:55 skrll Exp $")
#include <mips/cache_r4k.h>
#ifndef LINE_SHIFT
#error LINE_SHIFT undefined
#endif
#ifdef __mips_o32
.set mips32
#else
.set mips3
#endif
#define LINE_SIZE (1 << LINE_SHIFT)
#ifdef __STDC__
#define _CONCAT3(a,b,c) a ## _ ## b ## _ ## c
#define _CONCAT4(a,b,c,d) a ## _ ## b ## _ ## c ## _ ## d
#else
#define _CONCAT3(a,b,c) a_b_c
#define _CONCAT4(a,b,c,d) a_b_c_d
#endif
#define _OPNAME(a,b,c) _CONCAT3(a,b,c)
#define _OPNAME32(a,b,c) _CONCAT4(a,b,32lines,c)
#ifndef OPNAME
#define OPNAME is not defined!
#endif
#ifndef OPNAME32
#define OPNAME32 is not defined!
#endif
STATIC_LEAF_NOPROFILE(OPNAME(doop))
.set push
.set noreorder
and v1, a0, LINE_SIZE - 1 # get offset in cache line
xor a0, v1 # align start to cache line
PTR_ADDU a1, v1 # add offset to size
PTR_ADDU a1, LINE_SIZE - 1 # size is now rounded
PTR_SRL t0, a1, LINE_SHIFT # get # of cache lines
beqz t0, 3f # bail if t0 is 0 (no lines)
PTR_SRL v0, t0, 5 # v0 = # of (32x lines)
beqz v0, 2f # must have < 32 sets
nop # delay slot
move ta0, ra # save return address
1:
jalr t9 # do 32 cache ops (31..0)
PTR_ADDU v0, -1 # decrement 32x set count
bnez v0, 1b # do next 32x set if > 0
PTR_ADDU a0, 32*LINE_SIZE # adjust address by 32 lines
andi t0, 31 # t0 = # of lines left
beqz t0, 3f # no more to do?
move ra, ta0 # restore return address
2:
PTR_SLL t0, INT_SCALESHIFT # shift to instruction index
PTR_ADDU t9, 32 << INT_SCALESHIFT # point to end of table
PTR_SUBU t9, t0 # backup N cacheops
jr t9 # and do them.
nop
3:
jr ra
nop
.set pop
END(OPNAME(doop))
#ifdef WANT_ICACHE_OPS
LEAF_NOPROFILE(OPNAME(icache_index_inv))
PTR_LA t9, OPNAME32(icache_index_inv) # get address of first op
b OPNAME(doop)
END(OPNAME(icache_index_inv))
LEAF_NOPROFILE(OPNAME(icache_hit_inv))
PTR_LA t9, OPNAME32(icache_hit_inv) # get address of first op
b OPNAME(doop)
END(OPNAME(icache_hit_inv))
#endif
#ifdef WANT_PDCACHE_OPS
LEAF_NOPROFILE(OPNAME(pdcache_index_wb_inv))
PTR_LA t9, OPNAME32(pdcache_index_wb_inv) # get address of first op
b OPNAME(doop)
END(OPNAME(pdcache_index_wb_inv))
LEAF_NOPROFILE(OPNAME(pdcache_hit_inv))
PTR_LA t9, OPNAME32(pdcache_hit_inv) # get address of first op
b OPNAME(doop)
END(OPNAME(pdcache_hit_inv))
LEAF_NOPROFILE(OPNAME(pdcache_hit_wb_inv))
PTR_LA t9, OPNAME32(pdcache_hit_wb_inv) # get address of first op
b OPNAME(doop)
END(OPNAME(pdcache_hit_wb_inv))
LEAF_NOPROFILE(OPNAME(pdcache_hit_wb))
PTR_LA t9, OPNAME32(pdcache_hit_wb) # get address of first op
b OPNAME(doop)
END(OPNAME(pdcache_hit_wb))
#endif
#ifdef WANT_SDCACHE_OPS
LEAF_NOPROFILE(OPNAME(sdcache_index_wb_inv))
PTR_LA t9, OPNAME32(sdcache_index_wb_inv) # get address of first op
b OPNAME(doop)
END(OPNAME(sdcache_index_wb_inv))
LEAF_NOPROFILE(OPNAME(sdcache_hit_inv))
PTR_LA t9, OPNAME32(sdcache_hit_inv) # get address of first op
b OPNAME(doop)
END(OPNAME(sdcache_hit_inv))
LEAF_NOPROFILE(OPNAME(sdcache_hit_wb_inv))
PTR_LA t9, OPNAME32(sdcache_hit_wb_inv) # get address of first op
b OPNAME(doop)
END(OPNAME(sdcache_hit_wb_inv))
LEAF_NOPROFILE(OPNAME(sdcache_hit_wb))
PTR_LA t9, OPNAME32(sdcache_hit_wb) # get address of first op
b OPNAME(doop)
END(OPNAME(sdcache_hit_wb))
#endif
.macro emitops name, op, start=31
.ifeq \start - 31
.p2align 4
STATIC_LEAF_NOPROFILE(\name)
.endif
cache \op, (\start*LINE_SIZE)(a0)
.ifgt \start
emitops \name, \op, "(\start-1)"
.else
j ra
sync
END(\name)
.endif
.endm
.set noreorder
#ifdef WANT_ICACHE_OPS
emitops OPNAME32(icache_index_inv), CACHE_R4K_I|CACHEOP_R4K_INDEX_INV
emitops OPNAME32(icache_hit_inv), CACHE_R4K_I|CACHEOP_R4K_HIT_INV
#endif
#ifdef WANT_PDCACHE_OPS
emitops OPNAME32(pdcache_index_wb_inv), CACHE_R4K_D|CACHEOP_R4K_INDEX_WB_INV
emitops OPNAME32(pdcache_hit_inv), CACHE_R4K_D|CACHEOP_R4K_HIT_INV
emitops OPNAME32(pdcache_hit_wb_inv), CACHE_R4K_D|CACHEOP_R4K_HIT_WB_INV
emitops OPNAME32(pdcache_hit_wb), CACHE_R4K_D|CACHEOP_R4K_HIT_WB
#endif
#ifdef WANT_SDCACHE_OPS
emitops OPNAME32(sdcache_index_wb_inv), CACHE_R4K_SD|CACHEOP_R4K_INDEX_WB_INV
emitops OPNAME32(sdcache_hit_inv), CACHE_R4K_SD|CACHEOP_R4K_HIT_INV
emitops OPNAME32(sdcache_hit_wb_inv), CACHE_R4K_SD|CACHEOP_R4K_HIT_WB_INV
emitops OPNAME32(sdcache_hit_wb), CACHE_R4K_SD|CACHEOP_R4K_HIT_WB
#endif