switch_to.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* MN10300 task switching definitions
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public Licence
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the Licence, or (at your option) any later version.
  10. */
  11. #ifndef _ASM_SWITCH_TO_H
  12. #define _ASM_SWITCH_TO_H
  13. #include <asm/barrier.h>
  14. struct task_struct;
  15. struct thread_struct;
  16. #if !defined(CONFIG_LAZY_SAVE_FPU)
  17. struct fpu_state_struct;
  18. extern asmlinkage void fpu_save(struct fpu_state_struct *);
  19. #define switch_fpu(prev, next) \
  20. do { \
  21. if ((prev)->thread.fpu_flags & THREAD_HAS_FPU) { \
  22. (prev)->thread.fpu_flags &= ~THREAD_HAS_FPU; \
  23. (prev)->thread.uregs->epsw &= ~EPSW_FE; \
  24. fpu_save(&(prev)->thread.fpu_state); \
  25. } \
  26. } while (0)
  27. #else
  28. #define switch_fpu(prev, next) do {} while (0)
  29. #endif
  30. /* context switching is now performed out-of-line in switch_to.S */
  31. extern asmlinkage
  32. struct task_struct *__switch_to(struct thread_struct *prev,
  33. struct thread_struct *next,
  34. struct task_struct *prev_task);
  35. #define switch_to(prev, next, last) \
  36. do { \
  37. switch_fpu(prev, next); \
  38. current->thread.wchan = (u_long) __builtin_return_address(0); \
  39. (last) = __switch_to(&(prev)->thread, &(next)->thread, (prev)); \
  40. mb(); \
  41. current->thread.wchan = 0; \
  42. } while (0)
  43. #endif /* _ASM_SWITCH_TO_H */