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-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  linux/arch/arm/lib/findbit.S
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  Copyright (C) 1995-2000 Russell King
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * 16th March 2001 - John Ripley <jripley@sonicblue.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *   Fixed so that "size" is an exclusive not an inclusive quantity.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *   All users of these functions expect exclusive sizes, and may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *   also call with zero size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * Reworked by rmk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <asm/assembler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)                 .text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * Purpose  : Find a 'zero' bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * Prototype: int find_first_zero_bit(void *addr, unsigned int maxbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) ENTRY(_find_first_zero_bit_le)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 		teq	r1, #0	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 		beq	3f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		mov	r2, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  ARM(		ldrb	r3, [r0, r2, lsr #3]	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  THUMB(		lsr	r3, r2, #3		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  THUMB(		ldrb	r3, [r0, r3]		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		eors	r3, r3, #0xff		@ invert bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		bne	.L_found		@ any now set - found zero bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		add	r2, r2, #8		@ next bit pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 2:		cmp	r2, r1			@ any more?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		blo	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 3:		mov	r0, r1			@ no free bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) ENDPROC(_find_first_zero_bit_le)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * Purpose  : Find next 'zero' bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) ENTRY(_find_next_zero_bit_le)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		teq	r1, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		beq	3b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		ands	ip, r2, #7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		beq	1b			@ If new byte, goto old routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)  ARM(		ldrb	r3, [r0, r2, lsr #3]	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)  THUMB(		lsr	r3, r2, #3		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49)  THUMB(		ldrb	r3, [r0, r3]		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		eor	r3, r3, #0xff		@ now looking for a 1 bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		movs	r3, r3, lsr ip		@ shift off unused bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		bne	.L_found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		orr	r2, r2, #7		@ if zero, then no bits here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		add	r2, r2, #1		@ align bit pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		b	2b			@ loop for next bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) ENDPROC(_find_next_zero_bit_le)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * Purpose  : Find a 'one' bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * Prototype: int find_first_bit(const unsigned long *addr, unsigned int maxbit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) ENTRY(_find_first_bit_le)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		teq	r1, #0	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		beq	3f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		mov	r2, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  ARM(		ldrb	r3, [r0, r2, lsr #3]	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  THUMB(		lsr	r3, r2, #3		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  THUMB(		ldrb	r3, [r0, r3]		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		movs	r3, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		bne	.L_found		@ any now set - found zero bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		add	r2, r2, #8		@ next bit pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 2:		cmp	r2, r1			@ any more?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		blo	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 3:		mov	r0, r1			@ no free bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) ENDPROC(_find_first_bit_le)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * Purpose  : Find next 'one' bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) ENTRY(_find_next_bit_le)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		teq	r1, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		beq	3b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		ands	ip, r2, #7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		beq	1b			@ If new byte, goto old routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  ARM(		ldrb	r3, [r0, r2, lsr #3]	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  THUMB(		lsr	r3, r2, #3		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  THUMB(		ldrb	r3, [r0, r3]		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		movs	r3, r3, lsr ip		@ shift off unused bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		bne	.L_found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		orr	r2, r2, #7		@ if zero, then no bits here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		add	r2, r2, #1		@ align bit pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		b	2b			@ loop for next bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) ENDPROC(_find_next_bit_le)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) #ifdef __ARMEB__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) ENTRY(_find_first_zero_bit_be)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		teq	r1, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		beq	3f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		mov	r2, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 1:		eor	r3, r2, #0x18		@ big endian byte ordering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  ARM(		ldrb	r3, [r0, r3, lsr #3]	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  THUMB(		lsr	r3, #3			)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  THUMB(		ldrb	r3, [r0, r3]		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		eors	r3, r3, #0xff		@ invert bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		bne	.L_found		@ any now set - found zero bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		add	r2, r2, #8		@ next bit pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 2:		cmp	r2, r1			@ any more?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		blo	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 3:		mov	r0, r1			@ no free bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) ENDPROC(_find_first_zero_bit_be)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) ENTRY(_find_next_zero_bit_be)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		teq	r1, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		beq	3b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		ands	ip, r2, #7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		beq	1b			@ If new byte, goto old routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		eor	r3, r2, #0x18		@ big endian byte ordering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  ARM(		ldrb	r3, [r0, r3, lsr #3]	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  THUMB(		lsr	r3, #3			)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  THUMB(		ldrb	r3, [r0, r3]		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		eor	r3, r3, #0xff		@ now looking for a 1 bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		movs	r3, r3, lsr ip		@ shift off unused bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		bne	.L_found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		orr	r2, r2, #7		@ if zero, then no bits here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		add	r2, r2, #1		@ align bit pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		b	2b			@ loop for next bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) ENDPROC(_find_next_zero_bit_be)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) ENTRY(_find_first_bit_be)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		teq	r1, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		beq	3f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		mov	r2, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 1:		eor	r3, r2, #0x18		@ big endian byte ordering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)  ARM(		ldrb	r3, [r0, r3, lsr #3]	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)  THUMB(		lsr	r3, #3			)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)  THUMB(		ldrb	r3, [r0, r3]		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		movs	r3, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		bne	.L_found		@ any now set - found zero bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		add	r2, r2, #8		@ next bit pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 2:		cmp	r2, r1			@ any more?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		blo	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 3:		mov	r0, r1			@ no free bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) ENDPROC(_find_first_bit_be)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) ENTRY(_find_next_bit_be)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		teq	r1, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		beq	3b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		ands	ip, r2, #7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		beq	1b			@ If new byte, goto old routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		eor	r3, r2, #0x18		@ big endian byte ordering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)  ARM(		ldrb	r3, [r0, r3, lsr #3]	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)  THUMB(		lsr	r3, #3			)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  THUMB(		ldrb	r3, [r0, r3]		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		movs	r3, r3, lsr ip		@ shift off unused bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		bne	.L_found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		orr	r2, r2, #7		@ if zero, then no bits here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 		add	r2, r2, #1		@ align bit pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		b	2b			@ loop for next bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) ENDPROC(_find_next_bit_be)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)  * One or more bits in the LSB of r3 are assumed to be set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) .L_found:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #if __LINUX_ARM_ARCH__ >= 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		rsb	r0, r3, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		and	r3, r3, r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		clz	r3, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		rsb	r3, r3, #31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		add	r0, r2, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		tst	r3, #0x0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		addeq	r2, r2, #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		movne	r3, r3, lsl #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		tst	r3, #0x30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		addeq	r2, r2, #2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		movne	r3, r3, lsl #2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		tst	r3, #0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		addeq	r2, r2, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		mov	r0, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		cmp	r1, r0			@ Clamp to maxbit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		movlo	r0, r1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)