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