18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef __ASM_CSKY_SWITCH_TO_H
58c2ecf20Sopenharmony_ci#define __ASM_CSKY_SWITCH_TO_H
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/thread_info.h>
88c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_HAS_FPU
98c2ecf20Sopenharmony_ci#include <abi/fpu.h>
108c2ecf20Sopenharmony_cistatic inline void __switch_to_fpu(struct task_struct *prev,
118c2ecf20Sopenharmony_ci				   struct task_struct *next)
128c2ecf20Sopenharmony_ci{
138c2ecf20Sopenharmony_ci	save_to_user_fp(&prev->thread.user_fp);
148c2ecf20Sopenharmony_ci	restore_from_user_fp(&next->thread.user_fp);
158c2ecf20Sopenharmony_ci}
168c2ecf20Sopenharmony_ci#else
178c2ecf20Sopenharmony_cistatic inline void __switch_to_fpu(struct task_struct *prev,
188c2ecf20Sopenharmony_ci				   struct task_struct *next)
198c2ecf20Sopenharmony_ci{}
208c2ecf20Sopenharmony_ci#endif
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/*
238c2ecf20Sopenharmony_ci * Context switching is now performed out-of-line in switch_to.S
248c2ecf20Sopenharmony_ci */
258c2ecf20Sopenharmony_ciextern struct task_struct *__switch_to(struct task_struct *,
268c2ecf20Sopenharmony_ci				       struct task_struct *);
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define switch_to(prev, next, last)					\
298c2ecf20Sopenharmony_ci	do {								\
308c2ecf20Sopenharmony_ci		struct task_struct *__prev = (prev);			\
318c2ecf20Sopenharmony_ci		struct task_struct *__next = (next);			\
328c2ecf20Sopenharmony_ci		__switch_to_fpu(__prev, __next);			\
338c2ecf20Sopenharmony_ci		((last) = __switch_to((prev), (next)));			\
348c2ecf20Sopenharmony_ci	} while (0)
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#endif /* __ASM_CSKY_SWITCH_TO_H */
37