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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * linux/arch/arm/lib/lib1funcs.S: Optimized ARM division routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Author: Nicolas Pitre <nico@fluxnic.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *   - contributed to gcc-3.4 on Sep 30, 2003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *   - adapted for the Linux kernel on Oct 2, 2003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) /* Copyright 1995, 1996, 1998, 1999, 2000, 2003 Free Software Foundation, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) This file is free software; you can redistribute it and/or modify it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) under the terms of the GNU General Public License as published by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) Free Software Foundation; either version 2, or (at your option) any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) In addition to the permissions in the GNU General Public License, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) Free Software Foundation gives you unlimited permission to link the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) compiled version of this file into combinations with other programs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) and to distribute those combinations without any restriction coming
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) from the use of this file.  (The General Public License restrictions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) do apply in other respects; for example, they cover modification of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) the file, and distribution when not linked into a combine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) executable.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) This file is distributed in the hope that it will be useful, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) along with this program; see the file COPYING.  If not, write to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) the Free Software Foundation, 59 Temple Place - Suite 330,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) Boston, MA 02111-1307, USA.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #include <asm/assembler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #include <asm/unwind.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) .macro ARM_DIV_BODY dividend, divisor, result, curbit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #if __LINUX_ARM_ARCH__ >= 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	clz	\curbit, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	clz	\result, \dividend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	sub	\result, \curbit, \result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	mov	\curbit, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	mov	\divisor, \divisor, lsl \result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	mov	\curbit, \curbit, lsl \result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	mov	\result, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	@ Initially shift the divisor left 3 bits if possible,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	@ set curbit accordingly.  This allows for curbit to be located
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	@ at the left end of each 4 bit nibbles in the division loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	@ to save one loop in most cases.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	tst	\divisor, #0xe0000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	moveq	\divisor, \divisor, lsl #3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	moveq	\curbit, #8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	movne	\curbit, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	@ Unless the divisor is very big, shift it up in multiples of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	@ four bits, since this is the amount of unwinding in the main
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	@ division loop.  Continue shifting until the divisor is 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	@ larger than the dividend.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 1:	cmp	\divisor, #0x10000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	cmplo	\divisor, \dividend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	movlo	\divisor, \divisor, lsl #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	movlo	\curbit, \curbit, lsl #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	blo	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	@ For very big divisors, we must shift it a bit at a time, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	@ we will be in danger of overflowing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 1:	cmp	\divisor, #0x80000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	cmplo	\divisor, \dividend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	movlo	\divisor, \divisor, lsl #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	movlo	\curbit, \curbit, lsl #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	blo	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	mov	\result, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	@ Division loop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 1:	cmp	\dividend, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	subhs	\dividend, \dividend, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	orrhs	\result,   \result,   \curbit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	cmp	\dividend, \divisor,  lsr #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	subhs	\dividend, \dividend, \divisor, lsr #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	orrhs	\result,   \result,   \curbit,  lsr #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	cmp	\dividend, \divisor,  lsr #2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	subhs	\dividend, \dividend, \divisor, lsr #2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	orrhs	\result,   \result,   \curbit,  lsr #2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	cmp	\dividend, \divisor,  lsr #3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	subhs	\dividend, \dividend, \divisor, lsr #3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	orrhs	\result,   \result,   \curbit,  lsr #3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	cmp	\dividend, #0			@ Early termination?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	movsne	\curbit,   \curbit,  lsr #4	@ No, any more bits to do?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	movne	\divisor,  \divisor, lsr #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	bne	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .macro ARM_DIV2_ORDER divisor, order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #if __LINUX_ARM_ARCH__ >= 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	clz	\order, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	rsb	\order, \order, #31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	cmp	\divisor, #(1 << 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	movhs	\divisor, \divisor, lsr #16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	movhs	\order, #16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	movlo	\order, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	cmp	\divisor, #(1 << 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	movhs	\divisor, \divisor, lsr #8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	addhs	\order, \order, #8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	cmp	\divisor, #(1 << 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	movhs	\divisor, \divisor, lsr #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	addhs	\order, \order, #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	cmp	\divisor, #(1 << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	addhi	\order, \order, #3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	addls	\order, \order, \divisor, lsr #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) .macro ARM_MOD_BODY dividend, divisor, order, spare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #if __LINUX_ARM_ARCH__ >= 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	clz	\order, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	clz	\spare, \dividend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	sub	\order, \order, \spare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	mov	\divisor, \divisor, lsl \order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	mov	\order, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	@ Unless the divisor is very big, shift it up in multiples of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	@ four bits, since this is the amount of unwinding in the main
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	@ division loop.  Continue shifting until the divisor is 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	@ larger than the dividend.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 1:	cmp	\divisor, #0x10000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	cmplo	\divisor, \dividend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	movlo	\divisor, \divisor, lsl #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	addlo	\order, \order, #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	blo	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	@ For very big divisors, we must shift it a bit at a time, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	@ we will be in danger of overflowing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 1:	cmp	\divisor, #0x80000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	cmplo	\divisor, \dividend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	movlo	\divisor, \divisor, lsl #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	addlo	\order, \order, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	blo	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	@ Perform all needed subtractions to keep only the reminder.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	@ Do comparisons in batch of 4 first.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	subs	\order, \order, #3		@ yes, 3 is intended here
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	blt	2f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 1:	cmp	\dividend, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	subhs	\dividend, \dividend, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	cmp	\dividend, \divisor,  lsr #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	subhs	\dividend, \dividend, \divisor, lsr #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	cmp	\dividend, \divisor,  lsr #2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	subhs	\dividend, \dividend, \divisor, lsr #2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	cmp	\dividend, \divisor,  lsr #3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	subhs	\dividend, \dividend, \divisor, lsr #3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	cmp	\dividend, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	mov	\divisor, \divisor, lsr #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	subsge	\order, \order, #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	bge	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	tst	\order, #3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	teqne	\dividend, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	beq	5f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	@ Either 1, 2 or 3 comparison/subtractions are left.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 2:	cmn	\order, #2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	blt	4f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	beq	3f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	cmp	\dividend, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	subhs	\dividend, \dividend, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	mov	\divisor,  \divisor,  lsr #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 3:	cmp	\dividend, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	subhs	\dividend, \dividend, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	mov	\divisor,  \divisor,  lsr #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 4:	cmp	\dividend, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	subhs	\dividend, \dividend, \divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 5:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) #ifdef CONFIG_ARM_PATCH_IDIV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	.align	3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) ENTRY(__udivsi3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) ENTRY(__aeabi_uidiv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) UNWIND(.fnstart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	subs	r2, r1, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	reteq	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	bcc	Ldiv0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	cmp	r0, r1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	bls	11f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	tst	r1, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	beq	12f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	ARM_DIV_BODY r0, r1, r2, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	mov	r0, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 11:	moveq	r0, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	movne	r0, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 12:	ARM_DIV2_ORDER r1, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	mov	r0, r0, lsr r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) UNWIND(.fnend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) ENDPROC(__udivsi3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) ENDPROC(__aeabi_uidiv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) ENTRY(__umodsi3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) UNWIND(.fnstart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	subs	r2, r1, #1			@ compare divisor with 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	bcc	Ldiv0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	cmpne	r0, r1				@ compare dividend with divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	moveq   r0, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	tsthi	r1, r2				@ see if divisor is power of 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	andeq	r0, r0, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	retls	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	ARM_MOD_BODY r0, r1, r2, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) UNWIND(.fnend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) ENDPROC(__umodsi3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) #ifdef CONFIG_ARM_PATCH_IDIV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	.align 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) ENTRY(__divsi3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) ENTRY(__aeabi_idiv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) UNWIND(.fnstart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	cmp	r1, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	eor	ip, r0, r1			@ save the sign of the result.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	beq	Ldiv0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	rsbmi	r1, r1, #0			@ loops below use unsigned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	subs	r2, r1, #1			@ division by 1 or -1 ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	beq	10f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	movs	r3, r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	rsbmi	r3, r0, #0			@ positive dividend value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	cmp	r3, r1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	bls	11f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	tst	r1, r2				@ divisor is power of 2 ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	beq	12f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	ARM_DIV_BODY r3, r1, r0, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	cmp	ip, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	rsbmi	r0, r0, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 10:	teq	ip, r0				@ same sign ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	rsbmi	r0, r0, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 11:	movlo	r0, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	moveq	r0, ip, asr #31
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	orreq	r0, r0, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 12:	ARM_DIV2_ORDER r1, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	cmp	ip, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	mov	r0, r3, lsr r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	rsbmi	r0, r0, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) UNWIND(.fnend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) ENDPROC(__divsi3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) ENDPROC(__aeabi_idiv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) ENTRY(__modsi3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) UNWIND(.fnstart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	cmp	r1, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	beq	Ldiv0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	rsbmi	r1, r1, #0			@ loops below use unsigned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	movs	ip, r0				@ preserve sign of dividend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	rsbmi	r0, r0, #0			@ if negative make positive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	subs	r2, r1, #1			@ compare divisor with 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	cmpne	r0, r1				@ compare dividend with divisor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	moveq	r0, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	tsthi	r1, r2				@ see if divisor is power of 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	andeq	r0, r0, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	bls	10f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	ARM_MOD_BODY r0, r1, r2, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 10:	cmp	ip, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	rsbmi	r0, r0, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) UNWIND(.fnend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) ENDPROC(__modsi3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) #ifdef CONFIG_AEABI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) ENTRY(__aeabi_uidivmod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) UNWIND(.fnstart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) UNWIND(.save {r0, r1, ip, lr}	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	stmfd	sp!, {r0, r1, ip, lr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	bl	__aeabi_uidiv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	ldmfd	sp!, {r1, r2, ip, lr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	mul	r3, r0, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	sub	r1, r1, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) UNWIND(.fnend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) ENDPROC(__aeabi_uidivmod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) ENTRY(__aeabi_idivmod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) UNWIND(.fnstart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) UNWIND(.save {r0, r1, ip, lr}	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	stmfd	sp!, {r0, r1, ip, lr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	bl	__aeabi_idiv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	ldmfd	sp!, {r1, r2, ip, lr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	mul	r3, r0, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	sub	r1, r1, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	ret	lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) UNWIND(.fnend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) ENDPROC(__aeabi_idivmod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) Ldiv0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) UNWIND(.fnstart)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) UNWIND(.pad #4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) UNWIND(.save {lr})
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	str	lr, [sp, #-8]!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	bl	__div0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	mov	r0, #0			@ About as wrong as it could be.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	ldr	pc, [sp], #8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) UNWIND(.fnend)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) ENDPROC(Ldiv0)