1
0

context_gcc.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * File : context_gcc.S
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2013, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2013-7-14 Peng Fan sep6200 implementation
  23. */
  24. /**
  25. * \addtogroup sep6200
  26. */
  27. /*@{*/
  28. #define NOINT 0xc0
  29. /*
  30. * rt_base_t rt_hw_interrupt_disable();
  31. */
  32. .globl rt_hw_interrupt_disable
  33. .type rt_hw_interrupt_disable, %function
  34. rt_hw_interrupt_disable:
  35. stw.w r1, [sp-], #4
  36. mov r0, asr
  37. or r1, r0, #NOINT
  38. mov.a asr, r1
  39. ldw.w r1, [sp]+, #4
  40. mov pc, lr
  41. /*
  42. * void rt_hw_interrupt_enable(rt_base_t level);
  43. */
  44. .globl rt_hw_interrupt_enable
  45. .type rt_hw_interrupt_disable, %function
  46. rt_hw_interrupt_enable:
  47. mov.a asr, r0
  48. mov pc, lr
  49. /*
  50. * void rt_hw_context_switch(rt_uint32 from, rt_uint32 to);
  51. * r0 --> from
  52. * r1 --> to
  53. */
  54. .globl rt_hw_context_switch
  55. .type rt_hw_interrupt_disable, %function
  56. rt_hw_context_switch:
  57. stm.w (lr), [sp-]
  58. stm.w (r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, lr), [sp-]
  59. stm.w (r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15), [sp-]
  60. mov r4, asr
  61. stm.w (r4), [sp-]
  62. mov r4, bsr
  63. stm.w (r4), [sp-]
  64. stw sp, [r0+]
  65. ldw sp, [r1+]
  66. ldm.w (r4), [sp]+
  67. mov.a bsr,r4
  68. ldm.w (r4), [sp]+
  69. mov.a asr, r4
  70. ldm.w (r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15), [sp]+
  71. ldm.w (r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, lr, pc), [sp]+
  72. /*
  73. * void rt_hw_context_switch_to(rt_uint32 to);
  74. * r0 --> to
  75. */
  76. .globl rt_hw_context_switch_to
  77. rt_hw_context_switch_to:
  78. ldw sp, [r0+]
  79. ldm.w (r4), [sp]+
  80. mov.a bsr, r4
  81. ldm.w (r4), [sp]+
  82. mov.a asr, r4
  83. ldm.w (r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15), [sp]+
  84. ldm.w (r16, r17, r18, r19, r20, r21, r22, r23, r24, r25, r26, r27, r28, lr, pc), [sp]+
  85. /*
  86. * void rt_hw_context_switch_interrupt(rt_uint32 from, rt_uint32 to);
  87. */
  88. .globl rt_thread_switch_interrupt_flag
  89. .globl rt_interrupt_from_thread
  90. .globl rt_interrupt_to_thread
  91. .globl rt_hw_context_switch_interrupt
  92. rt_hw_context_switch_interrupt:
  93. ldw r2, =rt_thread_switch_interrupt_flag
  94. ldw r3, [r2+]
  95. cmpsub.a r3, #1
  96. beq _reswitch
  97. mov r3, #1
  98. stw r3, [r2+]
  99. ldw r2, =rt_interrupt_from_thread
  100. stw r0, [r2+]
  101. _reswitch:
  102. ldw r2, =rt_interrupt_to_thread
  103. stw r1, [r2+]
  104. mov pc, lr