switch_to.h 866 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (C) 2004 Microtronix Datacom Ltd.
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. */
  8. #ifndef _ASM_NIOS2_SWITCH_TO_H
  9. #define _ASM_NIOS2_SWITCH_TO_H
  10. /*
  11. * switch_to(n) should switch tasks to task ptr, first checking that
  12. * ptr isn't the current task, in which case it does nothing. This
  13. * also clears the TS-flag if the task we switched to has used the
  14. * math co-processor latest.
  15. */
  16. #define switch_to(prev, next, last) \
  17. { \
  18. void *_last; \
  19. __asm__ __volatile__ ( \
  20. "mov r4, %1\n" \
  21. "mov r5, %2\n" \
  22. "call resume\n" \
  23. "mov %0,r4\n" \
  24. : "=r" (_last) \
  25. : "r" (prev), "r" (next) \
  26. : "r4", "r5", "r7", "r8", "ra"); \
  27. (last) = _last; \
  28. }
  29. #endif /* _ASM_NIOS2_SWITCH_TO_H */