VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100  1) /* SPDX-License-Identifier: GPL-2.0 */
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  2) #include "libgcc.h"
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  3) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  4) 	;; This function also computes the remainder and stores it in er3.
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  5) 	.global	__udivsi3
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  6) __udivsi3:
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  7) 	mov.w	A1E,A1E		; denominator top word 0?
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  8) 	bne	DenHighNonZero
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900  9) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 10) 	; do it the easy way, see page 107 in manual
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 11) 	mov.w	A0E,A2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 12) 	extu.l	A2P
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 13) 	divxu.w	A1,A2P
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 14) 	mov.w	A2E,A0E
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 15) 	divxu.w	A1,A0P
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 16) 	mov.w	A0E,A3
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 17) 	mov.w	A2,A0E
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 18) 	extu.l	A3P
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 19) 	rts
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 20) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 21) 	; er0 = er0 / er1
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 22) 	; er3 = er0 % er1
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 23) 	; trashes er1 er2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 24) 	; expects er1 >= 2^16
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 25) DenHighNonZero:
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 26) 	mov.l	er0,er3
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 27) 	mov.l	er1,er2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 28) #ifdef CONFIG_CPU_H8300H
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 29) divmod_L21:
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 30) 	shlr.l	er0
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 31) 	shlr.l	er2		; make divisor < 2^16
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 32) 	mov.w	e2,e2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 33) 	bne	divmod_L21
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 34) #else
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 35) 	shlr.l	#2,er2		; make divisor < 2^16
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 36) 	mov.w	e2,e2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 37) 	beq	divmod_L22A
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 38) divmod_L21:
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 39) 	shlr.l	#2,er0
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 40) divmod_L22:
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 41) 	shlr.l	#2,er2		; make divisor < 2^16
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 42) 	mov.w	e2,e2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 43) 	bne	divmod_L21
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 44) divmod_L22A:
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 45) 	rotxl.w	r2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 46) 	bcs	divmod_L23
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 47) 	shlr.l	er0
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 48) 	bra	divmod_L24
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 49) divmod_L23:
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 50) 	rotxr.w	r2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 51) 	shlr.l	#2,er0
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 52) divmod_L24:
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 53) #endif
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 54) 	;; At this point,
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 55) 	;;  er0 contains shifted dividend
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 56) 	;;  er1 contains divisor
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 57) 	;;  er2 contains shifted divisor
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 58) 	;;  er3 contains dividend, later remainder
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 59) 	divxu.w	r2,er0		; r0 now contains the approximate quotient (AQ)
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 60) 	extu.l	er0
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 61) 	beq	divmod_L25
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 62) 	subs	#1,er0		; er0 = AQ - 1
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 63) 	mov.w	e1,r2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 64) 	mulxu.w	r0,er2		; er2 = upper (AQ - 1) * divisor
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 65) 	sub.w	r2,e3		; dividend - 65536 * er2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 66) 	mov.w	r1,r2
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 67) 	mulxu.w	r0,er2		; compute er3 = remainder (tentative)
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 68) 	sub.l	er2,er3		; er3 = dividend - (AQ - 1) * divisor
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 69) divmod_L25:
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 70) 	cmp.l	er1,er3		; is divisor < remainder?
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 71) 	blo	divmod_L26
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 72) 	adds	#1,er0
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 73) 	sub.l	er1,er3		; correct the remainder
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 74) divmod_L26:
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 75) 	rts
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 76) 
a71a29de4c2f9 (Yoshinori Sato     2015-01-28 02:48:15 +0900 77) 	.end