changelog shortlog tags branches changeset file revisions annotate raw help

Mercurial > hg > plan9front / sys/src/9/bcm64/cache.v8.s

revision 7199: ba62683c0e2d
     1.1new file mode 100644
     1.2--- /dev/null
     1.3+++ b/sys/src/9/bcm64/cache.v8.s
     1.4@@ -0,0 +1,212 @@
     1.5+#include "sysreg.h"
     1.6+
     1.7+#undef	SYSREG
     1.8+#define	SYSREG(op0,op1,Cn,Cm,op2)	SPR(((op0)<<19|(op1)<<16|(Cn)<<12|(Cm)<<8|(op2)<<5))
     1.9+
    1.10+/*
    1.11+ * instruction cache operations
    1.12+ */
    1.13+TEXT cacheiinvse(SB), 1, $-4
    1.14+	MOVWU	len+8(FP), R2
    1.15+	ADD	R0, R2
    1.16+
    1.17+	MRS	DAIF, R11
    1.18+	MSR	$0x2, DAIFSet
    1.19+	MOVWU	$1, R10
    1.20+	MSR	R10, CSSELR_EL1
    1.21+	ISB	$SY
    1.22+	MRS	CCSIDR_EL1, R4
    1.23+
    1.24+	ANDW	$7, R4
    1.25+	ADDW	$4, R4		// log2(linelen)
    1.26+	LSL	R4, R10
    1.27+	LSR	R4, R0
    1.28+	LSL	R4, R0
    1.29+
    1.30+_iinvse:
    1.31+	IC	R0, 3,7,5,1	// IVAU
    1.32+	ADD	R10, R0
    1.33+	CMP	R0, R2
    1.34+	BGT	_iinvse
    1.35+	DSB	$NSH
    1.36+	ISB	$SY
    1.37+	MSR	R11, DAIF
    1.38+	RETURN
    1.39+
    1.40+TEXT cacheiinv(SB), 1, $-4
    1.41+	IC	R0, 0,7,5,0	// IALLU
    1.42+	DSB	$NSH
    1.43+	ISB	$SY
    1.44+	RETURN
    1.45+
    1.46+TEXT cacheuwbinv(SB), 1, $0
    1.47+	BL	cachedwbinv(SB)
    1.48+	BL	cacheiinv(SB)
    1.49+	RETURN
    1.50+
    1.51+/*
    1.52+ * data cache operations
    1.53+ */
    1.54+TEXT cachedwbse(SB), 1, $-4
    1.55+	MOV	LR, R29
    1.56+	BL	cachedva<>(SB)
    1.57+TEXT dccvac(SB), 1, $-4
    1.58+	DC	R0, 3,7,10,1	// CVAC
    1.59+	RETURN
    1.60+
    1.61+TEXT cacheduwbse(SB), 1, $-4
    1.62+	MOV	LR, R29
    1.63+	BL	cachedva<>(SB)
    1.64+TEXT dccvau(SB), 1, $-4
    1.65+	DC	R0, 3,7,11,1	// CVAU
    1.66+	RETURN
    1.67+
    1.68+TEXT cachedinvse(SB), 1, $-4
    1.69+	MOV	LR, R29
    1.70+	BL	cachedva<>(SB)
    1.71+TEXT dcivac(SB), 1, $-4
    1.72+	DC	R0, 0,7,6,1	// IVAC
    1.73+	RETURN
    1.74+
    1.75+TEXT cachedwbinvse(SB), 1, $-4
    1.76+	MOV	LR, R29
    1.77+	BL	cachedva<>(SB)
    1.78+TEXT dccivac(SB), 1, $-4
    1.79+	DC	R0, 3,7,14,1	// CIVAC
    1.80+	RETURN
    1.81+
    1.82+TEXT cachedva<>(SB), 1, $-4
    1.83+	MOV	LR, R1
    1.84+	MOVWU	len+8(FP), R2
    1.85+	ADD	R0, R2
    1.86+
    1.87+	MRS	DAIF, R11
    1.88+	MSR	$0x2, DAIFSet
    1.89+	MOVWU	$0, R10
    1.90+	MSR	R10, CSSELR_EL1
    1.91+	ISB	$SY
    1.92+	MRS	CCSIDR_EL1, R4
    1.93+
    1.94+	ANDW	$7, R4
    1.95+	ADDW	$4, R4		// log2(linelen)
    1.96+	MOVWU	$1, R10
    1.97+	LSL	R4, R10
    1.98+	LSR	R4, R0
    1.99+	LSL	R4, R0
   1.100+
   1.101+	DSB	$SY
   1.102+	ISB	$SY
   1.103+_cachedva:
   1.104+	BL	(R1)
   1.105+	ADD	R10, R0
   1.106+	CMP	R0, R2
   1.107+	BGT	_cachedva
   1.108+	DSB	$SY
   1.109+	ISB	$SY
   1.110+	MSR	R11, DAIF
   1.111+	RET	R29
   1.112+
   1.113+/*
   1.114+ * l1 cache operations
   1.115+ */
   1.116+TEXT cachedwb(SB), 1, $-4
   1.117+	MOVWU	$0, R0
   1.118+_cachedwb:
   1.119+	MOV	LR, R29
   1.120+	BL	cachedsw<>(SB)
   1.121+TEXT dccsw(SB), 1, $-4
   1.122+	DC	R0, 0,7,10,2	// CSW
   1.123+	RETURN
   1.124+
   1.125+TEXT cachedinv(SB), 1, $-4
   1.126+	MOVWU	$0, R0
   1.127+_cachedinv:
   1.128+	MOV	LR, R29
   1.129+	BL	cachedsw<>(SB)
   1.130+TEXT dcisw(SB), 1, $-4
   1.131+	DC	R0, 0,7,6,2	// ISW
   1.132+	RETURN
   1.133+
   1.134+TEXT cachedwbinv(SB), 1, $-4
   1.135+	MOVWU	$0, R0
   1.136+_cachedwbinv:
   1.137+	MOV	LR, R29
   1.138+	BL	cachedsw<>(SB)
   1.139+TEXT dccisw(SB), 1, $-4
   1.140+	DC	R0, 0,7,14,2	// CISW
   1.141+	RETURN
   1.142+
   1.143+/*
   1.144+ * l2 cache operations
   1.145+ */
   1.146+TEXT l2cacheuwb(SB), 1, $-4
   1.147+	MOVWU	$1, R0
   1.148+	B	_cachedwb
   1.149+TEXT l2cacheuinv(SB), 1, $-4
   1.150+	MOVWU	$1, R0
   1.151+	B	_cachedinv
   1.152+TEXT l2cacheuwbinv(SB), 1, $-4
   1.153+	MOVWU	$1, R0
   1.154+	B	_cachedwbinv
   1.155+
   1.156+TEXT cachesize(SB), 1, $-4
   1.157+	MRS	DAIF, R11
   1.158+	MSR	$0x2, DAIFSet
   1.159+	MSR	R0, CSSELR_EL1
   1.160+	ISB	$SY
   1.161+	MRS	CCSIDR_EL1, R0
   1.162+	MSR	R11, DAIF
   1.163+	RETURN
   1.164+
   1.165+TEXT cachedsw<>(SB), 1, $-4
   1.166+	MOV	LR, R1
   1.167+
   1.168+	MRS	DAIF, R11
   1.169+	MSR	$0x2, DAIFSet
   1.170+	ADDW	R0, R0, R8
   1.171+	MSR	R8, CSSELR_EL1
   1.172+	ISB	$SY
   1.173+	MRS	CCSIDR_EL1, R4
   1.174+
   1.175+	LSR	$3, R4, R7
   1.176+	ANDW	$1023, R7	// lastway
   1.177+	ADDW	$1, R7, R5	// #ways
   1.178+
   1.179+	LSR	$13, R4, R2
   1.180+	ANDW	$32767, R2	// lastset
   1.181+	ADDW	$1, R2		// #sets
   1.182+
   1.183+	ANDW	$7, R4
   1.184+	ADDW	$4, R4		// log2(linelen)
   1.185+
   1.186+	MOVWU	$32, R3		// wayshift = 32 - log2(#ways)
   1.187+_countlog2ways:
   1.188+	CBZ	R7, _loop	// lastway == 0?
   1.189+	LSR	$1, R7		// lastway >>= 1
   1.190+	SUB	$1, R3		// wayshift--
   1.191+	B _countlog2ways
   1.192+_loop:
   1.193+	DSB	$SY
   1.194+	ISB	$SY
   1.195+_nextway:
   1.196+	MOVWU	$0, R6		// set
   1.197+_nextset:
   1.198+	LSL	R3, R7, R0	// way<<wayshift
   1.199+	LSL	R4, R6, R9	// set<<log2(linelen)
   1.200+	ORRW	R8, R0		// level
   1.201+	ORRW	R9, R0		// setway
   1.202+
   1.203+	BL	(R1)		// op(setway)
   1.204+
   1.205+	ADDW	$1, R6		// set++
   1.206+	CMPW	R2, R6
   1.207+	BLT	_nextset
   1.208+
   1.209+	ADDW	$1, R7		// way++
   1.210+	CMPW	R5, R7
   1.211+	BLT	_nextway
   1.212+
   1.213+	DSB	$SY
   1.214+	ISB	$SY
   1.215+	MSR	R11, DAIF
   1.216+	RET	R29