context_iar.S 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * File : context.asm
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2010-04-09 fify the first version
  13. * 2010-04-19 fify rewrite rt_hw_interrupt_disable/enable fuction
  14. * 2010-04-20 fify move peripheral ISR to bsp/interrupts.s34
  15. *
  16. * For : Renesas M16C
  17. * Toolchain : IAR's EW for M16C v3.401
  18. */
  19. RSEG CSTACK
  20. RSEG ISTACK
  21. RSEG CODE(1)
  22. EXTERN rt_thread_switch_interrupt_flag
  23. EXTERN rt_interrupt_from_thread
  24. EXTERN rt_interrupt_to_thread
  25. PUBLIC rt_hw_interrupt_disable
  26. PUBLIC rt_hw_interrupt_enable
  27. PUBLIC rt_hw_context_switch_to
  28. PUBLIC rt_hw_context_switch
  29. PUBLIC rt_hw_context_switch_interrupt
  30. PUBLIC os_context_switch
  31. rt_hw_interrupt_disable:
  32. STC FLG, R0 ;fify 20100419
  33. FCLR I
  34. RTS
  35. rt_hw_interrupt_enable:
  36. LDC R0, FLG ;fify 20100419
  37. RTS
  38. .EVEN
  39. os_context_switch:
  40. PUSHM R0,R1,R2,R3,A0,A1,SB,FB
  41. MOV.W rt_interrupt_from_thread, A0
  42. STC ISP, [A0]
  43. MOV.W rt_interrupt_to_thread, A0
  44. LDC [A0], ISP
  45. POPM R0,R1,R2,R3,A0,A1,SB,FB ; Restore registers from the new task's stack
  46. REIT ; Return from interrup
  47. /*
  48. * void rt_hw_context_switch_to(rt_uint32 to);
  49. * r0 --> to
  50. * this fucntion is used to perform the first thread switch
  51. */
  52. rt_hw_context_switch_to:
  53. MOV.W R0, A0
  54. LDC [A0], ISP
  55. POPM R0,R1,R2,R3,A0,A1,SB,FB
  56. REIT
  57. rt_hw_context_switch:
  58. MOV.W R0, rt_interrupt_from_thread
  59. MOV.W R1, rt_interrupt_to_thread
  60. INT #0 ;software interrupt 0
  61. RTS
  62. rt_hw_context_switch_interrupt:
  63. CMP.W #1, rt_thread_switch_interrupt_flag
  64. JEQ jump
  65. MOV.W #1, rt_thread_switch_interrupt_flag
  66. MOV.W R0, rt_interrupt_from_thread
  67. jump
  68. MOV.W R1, rt_interrupt_to_thread
  69. RTS
  70. END