switch_to.S 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. .text
  19. ###############################################################################
  20. #
  21. # struct task_struct *__switch_to(struct thread_struct *prev,
  22. # struct thread_struct *next,
  23. # struct task_struct *prev_task)
  24. #
  25. ###############################################################################
  26. ENTRY(__switch_to)
  27. movm [d2,d3,a2,a3,exreg1],(sp)
  28. or EPSW_NMID,epsw
  29. mov (44,sp),d2
  30. mov d0,a0
  31. mov d1,a1
  32. # save prev context
  33. mov (__frame),d0
  34. mov d0,(THREAD_FRAME,a0)
  35. mov __switch_back,d0
  36. mov d0,(THREAD_PC,a0)
  37. mov sp,a2
  38. mov a2,(THREAD_SP,a0)
  39. mov a3,(THREAD_A3,a0)
  40. mov (THREAD_A3,a1),a3
  41. mov (THREAD_SP,a1),a2
  42. # switch
  43. mov a2,sp
  44. # load next context
  45. GET_THREAD_INFO a2
  46. mov a2,(__current_ti)
  47. mov (TI_task,a2),a2
  48. mov a2,(__current)
  49. #ifdef CONFIG_MN10300_CURRENT_IN_E2
  50. mov a2,e2
  51. #endif
  52. mov (THREAD_FRAME,a1),a2
  53. mov a2,(__frame)
  54. mov (THREAD_PC,a1),a2
  55. mov d2,d0 # for ret_from_fork
  56. mov d0,a0 # for __switch_to
  57. jmp (a2)
  58. __switch_back:
  59. and ~EPSW_NMID,epsw
  60. ret [d2,d3,a2,a3,exreg1],32