switch_to.h 982 B

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