xref: /openbmc/linux/arch/csky/include/asm/switch_to.h (revision d0034a7a4ac7fae708146ac0059b9c47a1543f0d)
1*e9564df7SGuo Ren /* SPDX-License-Identifier: GPL-2.0 */
2*e9564df7SGuo Ren 
3*e9564df7SGuo Ren #ifndef __ASM_CSKY_SWITCH_TO_H
4*e9564df7SGuo Ren #define __ASM_CSKY_SWITCH_TO_H
5*e9564df7SGuo Ren 
6*e9564df7SGuo Ren #include <linux/thread_info.h>
7*e9564df7SGuo Ren #ifdef CONFIG_CPU_HAS_FPU
8*e9564df7SGuo Ren #include <abi/fpu.h>
__switch_to_fpu(struct task_struct * prev,struct task_struct * next)9*e9564df7SGuo Ren static inline void __switch_to_fpu(struct task_struct *prev,
10*e9564df7SGuo Ren 				   struct task_struct *next)
11*e9564df7SGuo Ren {
12*e9564df7SGuo Ren 	save_to_user_fp(&prev->thread.user_fp);
13*e9564df7SGuo Ren 	restore_from_user_fp(&next->thread.user_fp);
14*e9564df7SGuo Ren }
15*e9564df7SGuo Ren #else
__switch_to_fpu(struct task_struct * prev,struct task_struct * next)16*e9564df7SGuo Ren static inline void __switch_to_fpu(struct task_struct *prev,
17*e9564df7SGuo Ren 				   struct task_struct *next)
18*e9564df7SGuo Ren {}
19*e9564df7SGuo Ren #endif
20*e9564df7SGuo Ren 
21*e9564df7SGuo Ren /*
22*e9564df7SGuo Ren  * Context switching is now performed out-of-line in switch_to.S
23*e9564df7SGuo Ren  */
24*e9564df7SGuo Ren extern struct task_struct *__switch_to(struct task_struct *,
25*e9564df7SGuo Ren 				       struct task_struct *);
26*e9564df7SGuo Ren 
27*e9564df7SGuo Ren #define switch_to(prev, next, last)					\
28*e9564df7SGuo Ren 	do {								\
29*e9564df7SGuo Ren 		struct task_struct *__prev = (prev);			\
30*e9564df7SGuo Ren 		struct task_struct *__next = (next);			\
31*e9564df7SGuo Ren 		__switch_to_fpu(__prev, __next);			\
32*e9564df7SGuo Ren 		((last) = __switch_to((prev), (next)));			\
33*e9564df7SGuo Ren 	} while (0)
34*e9564df7SGuo Ren 
35*e9564df7SGuo Ren #endif /* __ASM_CSKY_SWITCH_TO_H */
36