Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * arch/alpha/lib/strchr.S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Contributed by Richard Henderson (rth@tamu.edu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Return the address of a given character within a null-terminated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * string, or null if it is not found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <asm/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <asm/regdef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 	.set noreorder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 	.set noat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	.align 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	.globl strchr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	.ent strchr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) strchr:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	.frame sp, 0, ra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	.prologue 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	zapnot	a1, 1, a1	# e0    : zero extend the search character
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	ldq_u   t0, 0(a0)	# .. e1 : load first quadword
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	sll	a1, 8, t5	# e0    : replicate the search character
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	andnot  a0, 7, v0	# .. e1 : align our loop pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	or	t5, a1, a1	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	lda	t4, -1		# .. e1 : build garbage mask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	sll	a1, 16, t5	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	cmpbge  zero, t0, t2	# .. e1 : bits set iff byte == zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	mskqh	t4, a0, t4	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	or	t5, a1, a1	# .. e1 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	sll	a1, 32, t5	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	cmpbge	zero, t4, t4	# .. e1 : bits set iff byte is garbage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	or	t5, a1, a1	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	xor	t0, a1, t1	# .. e1 : make bytes == c zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	cmpbge  zero, t1, t3	# e0    : bits set iff byte == c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	or	t2, t3, t0	# e1    : bits set iff char match or zero match
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	andnot	t0, t4, t0	# e0    : clear garbage bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	bne	t0, $found	# .. e1 (zdb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) $loop:	ldq	t0, 8(v0)	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	addq	v0, 8, v0	# .. e1 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	nop			# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	xor	t0, a1, t1	# .. e1 (ev5 data stall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	cmpbge	zero, t0, t2	# e0    : bits set iff byte == 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	cmpbge	zero, t1, t3	# .. e1 : bits set iff byte == c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	or	t2, t3, t0	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	beq	t0, $loop	# .. e1 (zdb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) $found:	negq    t0, t1		# e0    : clear all but least set bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	and     t0, t1, t0	# e1 (stall)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	and	t0, t3, t1	# e0    : bit set iff byte was the char
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	beq	t1, $retnull	# .. e1 (zdb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	and     t0, 0xf0, t2	# e0    : binary search for that set bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	and	t0, 0xcc, t3	# .. e1 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	and	t0, 0xaa, t4	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	cmovne	t2, 4, t2	# .. e1 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	cmovne	t3, 2, t3	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	cmovne	t4, 1, t4	# .. e1 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	addq	t2, t3, t2	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	addq	v0, t4, v0	# .. e1 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	addq	v0, t2, v0	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	ret			# .. e1 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) $retnull:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	mov	zero, v0	# e0    :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	ret			# .. e1 :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 	.end strchr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	EXPORT_SYMBOL(strchr)