gdbinvalicache.s 832 Bytes
#include <asm.h>
#include <regdef.h>
#include <R4300.h>

/*
 * gdbInvalICache(void *addr, int nbytes)
 */
LEAF(gdbInvalICache)
#ifndef __sgi__
	.set mips3
#endif
	blez	a1,2f			# If nbytes <= 0, bail
	li	t3,ICACHE_SIZE
	bgeu	a1,t3,3f		# Is nbytes >= I-Cache size?
	move	t0,a0
	addu	t1,a0,a1
	bgeu	t0,t1,2f		# (Check for address wrap)
	subu	t1,ICACHE_LINESIZE
	andi	t2,t0,ICACHE_LINEMASK
	subu	t0,t2
1:
	.set	noreorder
	cache	CACH_PI|C_HINV,0(t0)	# If not, use hit invalidate
	bltu	t0,t1,1b		#  only on given range
	addu	t0,ICACHE_LINESIZE
	.set	reorder
2:
	j	ra
3:
	li	t0,K0BASE
	addu	t1,t0,t3
	subu	t1,ICACHE_LINESIZE
4:
	.set	noreorder
	cache	CACH_PI|C_IINV,0(t0)	# If so, use index invalidate on
	bltu	t0,t1,4b		#  entire cache
	addu	t0,ICACHE_LINESIZE
	.set	reorder

	j	ra
#ifndef __sgi__
	.set mips0
#endif
	END(gdbInvalICache)