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)  * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #ifndef __ASM_ARC_ENTRY_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define __ASM_ARC_ENTRY_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <asm/unistd.h>		/* For NR_syscalls defination */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <asm/arcregs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <asm/processor.h>	/* For VMALLOC_START */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <asm/mmu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #ifdef CONFIG_ISA_ARCOMPACT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <asm/entry-compact.h>	/* ISA specific bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <asm/entry-arcv2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) /* Note on the LD/ST addr modes with addr reg wback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * LD.a same as LD.aw
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * LD.a    reg1, [reg2, x]  => Pre Incr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *      Eff Addr for load = [reg2 + x]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * LD.ab   reg1, [reg2, x]  => Post Incr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  *      Eff Addr for load = [reg2]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) .macro PUSH reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	st.a	\reg, [sp, -4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) .macro PUSHAX aux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	lr	r9, [\aux]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	PUSH	r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) .macro POP reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	ld.ab	\reg, [sp, 4]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) .macro POPAX aux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	POP	r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	sr	r9, [\aux]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) /*--------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)  * Helpers to save/restore Scratch Regs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53)  * used by Interrupt/Exception Prologue/Epilogue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  *-------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) .macro  SAVE_R0_TO_R12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	PUSH	r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	PUSH	r1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	PUSH	r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	PUSH	r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	PUSH	r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	PUSH	r5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	PUSH	r6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	PUSH	r7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	PUSH	r8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	PUSH	r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	PUSH	r10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	PUSH	r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	PUSH	r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) .macro RESTORE_R12_TO_R0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	POP	r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	POP	r11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	POP	r10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	POP	r9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	POP	r8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	POP	r7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	POP	r6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	POP	r5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	POP	r4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	POP	r3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	POP	r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	POP	r1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	POP	r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) /*--------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)  * Helpers to save/restore callee-saved regs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)  * used by several macros below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)  *-------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) .macro SAVE_R13_TO_R24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	PUSH	r13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	PUSH	r14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	PUSH	r15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	PUSH	r16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	PUSH	r17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	PUSH	r18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	PUSH	r19
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	PUSH	r20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	PUSH	r21
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	PUSH	r22
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	PUSH	r23
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	PUSH	r24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) .macro RESTORE_R24_TO_R13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	POP	r24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	POP	r23
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	POP	r22
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	POP	r21
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	POP	r20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	POP	r19
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	POP	r18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	POP	r17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	POP	r16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	POP	r15
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	POP	r14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	POP	r13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /*--------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  * Collect User Mode callee regs as struct callee_regs - needed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  * fork/do_signal/unaligned-access-emulation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * (By default only scratch regs are saved on entry to kernel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * Special handling for r25 if used for caching Task Pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * It would have been saved in task->thread.user_r25 already, but to keep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * the interface same it is copied into regular r25 placeholder in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  * struct callee_regs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  *-------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) .macro SAVE_CALLEE_SAVED_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	mov	r12, sp		; save SP as ref to pt_regs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	SAVE_R13_TO_R24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #ifdef CONFIG_ARC_CURR_IN_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	; Retrieve orig r25 and save it with rest of callee_regs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	ld	r12, [r12, PT_user_r25]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	PUSH	r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	PUSH	r25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*--------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)  * Save kernel Mode callee regs at the time of Contect Switch.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * Special handling for r25 if used for caching Task Pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  * Kernel simply skips saving it since it will be loaded with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  * incoming task pointer anyways
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  *-------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) .macro SAVE_CALLEE_SAVED_KERNEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	SAVE_R13_TO_R24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) #ifdef CONFIG_ARC_CURR_IN_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	sub     sp, sp, 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	PUSH	r25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /*--------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  * Opposite of SAVE_CALLEE_SAVED_KERNEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  *-------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) .macro RESTORE_CALLEE_SAVED_KERNEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #ifdef CONFIG_ARC_CURR_IN_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	add     sp, sp, 4  /* skip usual r25 placeholder */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	POP	r25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	RESTORE_R24_TO_R13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /*--------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  * Opposite of SAVE_CALLEE_SAVED_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  * ptrace tracer or unaligned-access fixup might have changed a user mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  * callee reg which is saved back to usual r25 storage location
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  *-------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) .macro RESTORE_CALLEE_SAVED_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #ifdef CONFIG_ARC_CURR_IN_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	POP	r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	POP	r25
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	RESTORE_R24_TO_R13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	; SP is back to start of pt_regs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #ifdef CONFIG_ARC_CURR_IN_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	st	r12, [sp, PT_user_r25]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /*--------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  * Super FAST Restore callee saved regs by simply re-adjusting SP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  *-------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) .macro DISCARD_CALLEE_SAVED_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	add     sp, sp, SZ_CALLEE_REGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /*-------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  * given a tsk struct, get to the base of it's kernel mode stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * tsk->thread_info is really a PAGE, whose bottom hoists stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  * which grows upwards towards thread_info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  *------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) .macro GET_TSK_STACK_BASE tsk, out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	/* Get task->thread_info (this is essentially start of a PAGE) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	ld  \out, [\tsk, TASK_THREAD_INFO]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	/* Go to end of page where stack begins (grows upwards) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	add2 \out, \out, (THREAD_SIZE)/4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  * @reg [OUT] thread_info->flags of "current"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) .macro GET_CURR_THR_INFO_FLAGS  reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	GET_CURR_THR_INFO_FROM_SP  \reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	ld  \reg, [\reg, THREAD_INFO_FLAGS]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #ifdef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) /*-------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  * Retrieve the current running task on this CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)  * 1. Determine curr CPU id.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  * 2. Use it to index into _current_task[ ]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) .macro  GET_CURR_TASK_ON_CPU   reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	GET_CPU_ID  \reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	ld.as  \reg, [@_current_task, \reg]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /*-------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * Save a new task as the "current" task on this CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  * 1. Determine curr CPU id.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)  * 2. Use it to index into _current_task[ ]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)  * Coded differently than GET_CURR_TASK_ON_CPU (which uses LD.AS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)  * because ST r0, [r1, offset] can ONLY have s9 @offset
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)  * while   LD can take s9 (4 byte insn) or LIMM (8 byte insn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .macro  SET_CURR_TASK_ON_CPU    tsk, tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	GET_CPU_ID  \tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	add2 \tmp, @_current_task, \tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	st   \tsk, [\tmp]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) #ifdef CONFIG_ARC_CURR_IN_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	mov r25, \tsk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) #else   /* Uniprocessor implementation of macros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) .macro  GET_CURR_TASK_ON_CPU    reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	ld  \reg, [@_current_task]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) .macro  SET_CURR_TASK_ON_CPU    tsk, tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	st  \tsk, [@_current_task]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) #ifdef CONFIG_ARC_CURR_IN_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	mov r25, \tsk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #endif /* SMP / UNI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) /* ------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  * Get the ptr to some field of Current Task at @off in task struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  *  -Uses r25 for Current task ptr if that is enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) #ifdef CONFIG_ARC_CURR_IN_REG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) .macro GET_CURR_TASK_FIELD_PTR  off,  reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	add \reg, r25, \off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) .macro GET_CURR_TASK_FIELD_PTR  off,  reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	GET_CURR_TASK_ON_CPU  \reg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	add \reg, \reg, \off
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) .endm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) #endif	/* CONFIG_ARC_CURR_IN_REG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) #endif  /* __ASM_ARC_ENTRY_H */