switch_to.S 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. #ifdef CONFIG_SMP
  37. mov (CPUID),a2
  38. add a2,a2
  39. add a2,a2
  40. mov (___frame,a2),d0
  41. #else /* CONFIG_SMP */
  42. mov (__frame),d0
  43. #endif /* CONFIG_SMP */
  44. mov d0,(THREAD_FRAME,a0)
  45. mov __switch_back,d0
  46. mov d0,(THREAD_PC,a0)
  47. mov sp,a2
  48. mov a2,(THREAD_SP,a0)
  49. mov a3,(THREAD_A3,a0)
  50. mov (THREAD_A3,a1),a3
  51. mov (THREAD_SP,a1),a2
  52. # switch
  53. mov a2,sp
  54. # load next context
  55. GET_THREAD_INFO a2
  56. mov a2,(__current_ti)
  57. mov (TI_task,a2),a2
  58. mov a2,(__current)
  59. #ifdef CONFIG_MN10300_CURRENT_IN_E2
  60. mov a2,e2
  61. #endif
  62. mov (THREAD_FRAME,a1),a2
  63. #ifdef CONFIG_SMP
  64. mov (CPUID),a0
  65. add a0,a0
  66. add a0,a0
  67. mov a2,(___frame,a0)
  68. #else /* CONFIG_SMP */
  69. mov a2,(__frame)
  70. #endif /* CONFIG_SMP */
  71. mov (THREAD_PC,a1),a2
  72. mov d2,d0 # for ret_from_fork
  73. mov d0,a0 # for __switch_to
  74. jmp (a2)
  75. __switch_back:
  76. and ~EPSW_NMID,epsw
  77. ret [d2,d3,a2,a3,exreg1],32