ctx_sw_asm.S 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  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. * Vineetg: Aug 2009
  9. * -Moved core context switch macro out of entry.S into this file.
  10. * -This is the more "natural" hand written assembler
  11. */
  12. #include <asm/entry.h> /* For the SAVE_* macros */
  13. #include <asm/asm-offsets.h>
  14. #include <asm/linkage.h>
  15. ;################### Low Level Context Switch ##########################
  16. .section .sched.text,"ax",@progbits
  17. .align 4
  18. .global __switch_to
  19. .type __switch_to, @function
  20. __switch_to:
  21. /* Save regs on kernel mode stack of task */
  22. st.a blink, [sp, -4]
  23. st.a fp, [sp, -4]
  24. SAVE_CALLEE_SAVED_KERNEL
  25. /* Save the now KSP in task->thread.ksp */
  26. st.as sp, [r0, (TASK_THREAD + THREAD_KSP)/4]
  27. /*
  28. * Return last task in r0 (return reg)
  29. * On ARC, Return reg = First Arg reg = r0.
  30. * Since we already have last task in r0,
  31. * don't need to do anything special to return it
  32. */
  33. /* hardware memory barrier */
  34. sync
  35. /*
  36. * switch to new task, contained in r1
  37. * Temp reg r3 is required to get the ptr to store val
  38. */
  39. SET_CURR_TASK_ON_CPU r1, r3
  40. /* reload SP with kernel mode stack pointer in task->thread.ksp */
  41. ld.as sp, [r1, (TASK_THREAD + THREAD_KSP)/4]
  42. /* restore the registers */
  43. RESTORE_CALLEE_SAVED_KERNEL
  44. ld.ab fp, [sp, 4]
  45. ld.ab blink, [sp, 4]
  46. j [blink]
  47. ARC_EXIT __switch_to