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