switch_to.S 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ###############################################################################
  2. #
  3. # MN10300 Context switch operation
  4. #
  5. # Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  6. # Written by David Howells (dhowells@redhat.com)
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public Licence
  10. # as published by the Free Software Foundation; either version
  11. # 2 of the Licence, or (at your option) any later version.
  12. #
  13. ###############################################################################
  14. #include <linux/sys.h>
  15. #include <linux/linkage.h>
  16. #include <asm/thread_info.h>
  17. #include <asm/cpu-regs.h>
  18. #ifdef CONFIG_SMP
  19. #include <proc/smp-regs.h>
  20. #endif /* CONFIG_SMP */
  21. .text
  22. ###############################################################################
  23. #
  24. # struct task_struct *__switch_to(struct thread_struct *prev,
  25. # struct thread_struct *next,
  26. # struct task_struct *prev_task)
  27. #
  28. ###############################################################################
  29. ENTRY(__switch_to)
  30. movm [d2,d3,a2,a3,exreg1],(sp)
  31. or EPSW_NMID,epsw
  32. mov (44,sp),d2
  33. mov d0,a0
  34. mov d1,a1
  35. # save prev context
  36. mov __switch_back,d0
  37. mov d0,(THREAD_PC,a0)
  38. mov sp,a2
  39. mov a2,(THREAD_SP,a0)
  40. mov a3,(THREAD_A3,a0)
  41. mov (THREAD_A3,a1),a3
  42. mov (THREAD_SP,a1),a2
  43. # switch
  44. mov a2,sp
  45. # load next context
  46. GET_THREAD_INFO a2
  47. mov a2,(__current_ti)
  48. mov (TI_task,a2),a2
  49. mov a2,(__current)
  50. #ifdef CONFIG_MN10300_CURRENT_IN_E2
  51. mov a2,e2
  52. #endif
  53. mov (THREAD_PC,a1),a2
  54. mov d2,d0 # for ret_from_fork
  55. mov d0,a0 # for __switch_to
  56. jmp (a2)
  57. __switch_back:
  58. and ~EPSW_NMID,epsw
  59. ret [d2,d3,a2,a3,exreg1],32