switch_to.S 914 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <asm/sysreg.h>
  9. .text
  10. .global __switch_to
  11. .type __switch_to, @function
  12. /* Switch thread context from "prev" to "next", returning "last"
  13. * r12 : prev
  14. * r11 : &prev->thread + 1
  15. * r10 : &next->thread
  16. */
  17. __switch_to:
  18. stm --r11, r0,r1,r2,r3,r4,r5,r6,r7,sp,lr
  19. mfsr r9, SYSREG_SR
  20. st.w --r11, r9
  21. ld.w r8, r10++
  22. /*
  23. * schedule() may have been called from a mode with a different
  24. * set of registers. Make sure we don't lose anything here.
  25. */
  26. pushm r10,r12
  27. mtsr SYSREG_SR, r8
  28. frs /* flush the return stack */
  29. sub pc, -2 /* flush the pipeline */
  30. popm r10,r12
  31. ldm r10++, r0,r1,r2,r3,r4,r5,r6,r7,sp,pc
  32. .size __switch_to, . - __switch_to