context_vdsp.S 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2012-02-13 mojingxian First version
  9. */
  10. .global _rt_hw_interrupt_disable;
  11. .global _rt_hw_interrupt_enable;
  12. .global _interrupt_thread_switch;
  13. .extern _rt_interrupt_from_thread;
  14. .extern _rt_interrupt_to_thread;
  15. .extern _rt_thread_switch_interrupt_flag;
  16. .section/DOUBLE64 program;
  17. /*
  18. * rt_base_t rt_hw_interrupt_disable();
  19. * return value in R0.
  20. */
  21. _rt_hw_interrupt_disable:
  22. CLI R0;
  23. _rt_hw_interrupt_disable.end:
  24. NOP;
  25. NOP;
  26. NOP;
  27. RTS;
  28. /*
  29. * void rt_hw_interrupt_enable(rt_base_t level);
  30. * R0->level
  31. */
  32. _rt_hw_interrupt_enable:
  33. STI R0;
  34. _rt_hw_interrupt_enable.end:
  35. NOP;
  36. NOP;
  37. NOP;
  38. RTS;
  39. _interrupt_thread_switch:
  40. /* Save context, interrupts disabled by IPEND[4] bit */
  41. [ -- SP ] = R0;
  42. [ -- SP ] = P1;
  43. [ -- SP ] = RETS;
  44. [ -- SP ] = R1;
  45. [ -- SP ] = R2;
  46. [ -- SP ] = P0;
  47. [ -- SP ] = P2;
  48. [ -- SP ] = ASTAT;
  49. R1 = RETI; /* IPEND[4] is currently set, globally disabling interrupts */
  50. /* IPEND[4] will stay set when RETI is saved through R1 */
  51. [ -- SP ] = R1;
  52. [ -- SP ] = (R7:3, P5:3);
  53. [ -- SP ] = FP;
  54. [ -- SP ] = I0;
  55. [ -- SP ] = I1;
  56. [ -- SP ] = I2;
  57. [ -- SP ] = I3;
  58. [ -- SP ] = B0;
  59. [ -- SP ] = B1;
  60. [ -- SP ] = B2;
  61. [ -- SP ] = B3;
  62. [ -- SP ] = L0;
  63. [ -- SP ] = L1;
  64. [ -- SP ] = L2;
  65. [ -- SP ] = L3;
  66. [ -- SP ] = M0;
  67. [ -- SP ] = M1;
  68. [ -- SP ] = M2;
  69. [ -- SP ] = M3;
  70. R1.L = A0.x;
  71. [ -- SP ] = R1;
  72. R1 = A0.w;
  73. [ -- SP ] = R1;
  74. R1.L = A1.x;
  75. [ -- SP ] = R1;
  76. R1 = A1.w;
  77. [ -- SP ] = R1;
  78. [ -- SP ] = LC0;
  79. R3 = 0;
  80. LC0 = R3;
  81. [ -- SP ] = LC1;
  82. R3 = 0;
  83. LC1 = R3;
  84. [ -- SP ] = LT0;
  85. [ -- SP ] = LT1;
  86. [ -- SP ] = LB0;
  87. [ -- SP ] = LB1;
  88. /* Context save done so save SP in the TCB */
  89. P1.h = _rt_interrupt_from_thread;
  90. P1.l = _rt_interrupt_from_thread;
  91. P2 = [ P1 ];
  92. [ P2 ] = SP;
  93. /* clear rt_thread_switch_interrupt_flag to 0 */
  94. P1.h = _rt_thread_switch_interrupt_flag;
  95. P1.l = _rt_thread_switch_interrupt_flag;
  96. R0 = 0;
  97. [ P1 ] = R0;
  98. /* Get a pointer to the high ready task's TCB */
  99. P1.h = _rt_interrupt_to_thread;
  100. P1.l = _rt_interrupt_to_thread;
  101. P2 = [ P1 ];
  102. SP = [ P2 ];
  103. /* Restoring CPU context and return to task */
  104. LB1 = [ SP ++ ];
  105. LB0 = [ SP ++ ];
  106. LT1 = [ SP ++ ];
  107. LT0 = [ SP ++ ];
  108. LC1 = [ SP ++ ];
  109. LC0 = [ SP ++ ];
  110. R0 = [ SP ++ ];
  111. A1 = R0;
  112. R0 = [ SP ++ ];
  113. A1.x = R0.L;
  114. R0 = [ SP ++ ];
  115. A0 = R0;
  116. R0 = [ SP ++ ];
  117. A0.x = R0.L;
  118. M3 = [ SP ++ ];
  119. M2 = [ SP ++ ];
  120. M1 = [ SP ++ ];
  121. M0 = [ SP ++ ];
  122. L3 = [ SP ++ ];
  123. L2 = [ SP ++ ];
  124. L1 = [ SP ++ ];
  125. L0 = [ SP ++ ];
  126. B3 = [ SP ++ ];
  127. B2 = [ SP ++ ];
  128. B1 = [ SP ++ ];
  129. B0 = [ SP ++ ];
  130. I3 = [ SP ++ ];
  131. I2 = [ SP ++ ];
  132. I1 = [ SP ++ ];
  133. I0 = [ SP ++ ];
  134. FP = [ SP ++ ];
  135. (R7:3, P5:3) = [ SP ++ ];
  136. RETI = [ SP ++ ]; /* IPEND[4] will stay set when RETI popped from stack */
  137. ASTAT = [ SP ++ ];
  138. P2 = [ SP ++ ];
  139. P0 = [ SP ++ ];
  140. R2 = [ SP ++ ];
  141. R1 = [ SP ++ ];
  142. RETS = [ SP ++ ];
  143. P1 = [ SP ++ ];
  144. R0 = [ SP ++ ];
  145. _interrupt_thread_switch.end:
  146. RTI;