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)  * Copyright (C) 2008 Google, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * This software is licensed under the terms of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * License version 2, as published by the Free Software Foundation, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * may be copied, distributed, and modified under those terms.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <asm/assembler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 		.text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 		.global fiq_glue_end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 		/* fiq stack: r0-r15,cpsr,spsr of interrupted mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) ENTRY(fiq_glue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		/* store pc, cpsr from previous mode, reserve space for spsr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		mrs	r12, spsr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		sub	lr, lr, #4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		subs	r10, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		bne	nested_fiq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 		str	r12, [sp, #-8]!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		str	lr, [sp, #-4]!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 		/* store r8-r14 from previous mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 		sub	sp, sp, #(7 * 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	ARM(	stmia	sp, {r8-r14}^	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 		/* store r0-r7 from previous mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		stmfd	sp!, {r0-r7}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		/* setup func(data,regs) arguments */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		mov	r0, r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		mov	r1, sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		mov	r3, r8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		mov	r7, sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		/* Get sp and lr from non-user modes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		and	r4, r12, #MODE_MASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		cmp	r4, #USR_MODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		beq	fiq_from_usr_mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		mov	r7, sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		orr	r4, r4, #(PSR_I_BIT | PSR_F_BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		msr	cpsr_c, r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	THUMB(	add	r7, r7, #(4 * 8)	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	THUMB(	stmia	r7, {r8-r12}		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	THUMB(	sub	r7, r7, #(4 * 8)	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		str	sp, [r7, #(4 * 13)]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		str	lr, [r7, #(4 * 14)]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		mrs	r5, spsr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		str	r5, [r7, #(4 * 17)]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		cmp	r4, #(SVC_MODE | PSR_I_BIT | PSR_F_BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		/* use fiq stack if we reenter this mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	THUMB(	subne	r6, r7, #(4 * 3)	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	THUMB(	movne	sp, r6			)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	ARM(	subne	sp, r7, #(4 * 3)	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) fiq_from_usr_mode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	THUMB(	mov	r6, #(SVC_MODE | PSR_I_BIT | PSR_F_BIT)		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	THUMB(	msr	cpsr_c, r6					)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	ARM(	msr	cpsr_c, #(SVC_MODE | PSR_I_BIT | PSR_F_BIT)	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		mov	r2, sp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	THUMB(	sub	r6, r7, #12	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	THUMB(	mov	sp, r6		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	ARM(	sub	sp, r7, #12	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		stmfd	sp!, {r2, ip, lr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		/* call func(data,regs) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		blx	r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		ldmfd	sp, {r2, ip, lr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		mov	sp, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		/* restore/discard saved state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		cmp	r4, #USR_MODE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		beq	fiq_from_usr_mode_exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		msr	cpsr_c, r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		ldr	sp, [r7, #(4 * 13)]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		ldr	lr, [r7, #(4 * 14)]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		msr	spsr_cxsf, r5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) fiq_from_usr_mode_exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	THUMB(	mov	r6, #(FIQ_MODE | PSR_I_BIT | PSR_F_BIT)		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	THUMB(	msr	cpsr_c, r6					)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	ARM(	msr	cpsr_c, #(FIQ_MODE | PSR_I_BIT | PSR_F_BIT)	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		ldmfd	sp!, {r0-r7}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		ldr	lr, [sp, #(4 * 7)]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		ldr	r12, [sp, #(4 * 8)]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		add	sp, sp, #(10 * 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) exit_fiq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		msr	spsr_cxsf, r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		add	r10, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		cmp	r11, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		moveqs	pc, lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		bx	r11 /* jump to custom fiq return function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) nested_fiq:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		orr	r12, r12, #(PSR_F_BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		b	exit_fiq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) fiq_glue_end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) ENTRY(fiq_glue_setup) /* func, data, sp, smc call number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		stmfd		sp!, {r4}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		mrs		r4, cpsr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	THUMB(	mov		r6, #(FIQ_MODE | PSR_I_BIT | PSR_F_BIT)		)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	THUMB(	msr		cpsr_c, r6					)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	ARM(	msr		cpsr_c, #(FIQ_MODE | PSR_I_BIT | PSR_F_BIT)	)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		movs		r8, r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		mov		r9, r1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		mov		sp, r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		mov		r11, r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		moveq		r10, #0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		movne		r10, #1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		msr		cpsr_c, r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		ldmfd		sp!, {r4}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		bx		lr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)