entry.S 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. * entry.S -- non-mmu 68000 interrupt and exception entry points
  3. *
  4. * Copyright (C) 1991, 1992 Linus Torvalds
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file README.legal in the main directory of this archive
  8. * for more details.
  9. *
  10. * Linux/m68k support by Hamish Macdonald
  11. */
  12. #include <linux/linkage.h>
  13. #include <asm/thread_info.h>
  14. #include <asm/unistd.h>
  15. #include <asm/errno.h>
  16. #include <asm/setup.h>
  17. #include <asm/traps.h>
  18. #include <asm/asm-offsets.h>
  19. #include <asm/entry.h>
  20. .text
  21. .globl system_call
  22. .globl resume
  23. .globl ret_from_exception
  24. .globl sys_call_table
  25. .globl bad_interrupt
  26. .globl inthandler1
  27. .globl inthandler2
  28. .globl inthandler3
  29. .globl inthandler4
  30. .globl inthandler5
  31. .globl inthandler6
  32. .globl inthandler7
  33. badsys:
  34. movel #-ENOSYS,%sp@(PT_OFF_D0)
  35. jra ret_from_exception
  36. do_trace:
  37. movel #-ENOSYS,%sp@(PT_OFF_D0) /* needed for strace*/
  38. subql #4,%sp
  39. SAVE_SWITCH_STACK
  40. jbsr syscall_trace_enter
  41. RESTORE_SWITCH_STACK
  42. addql #4,%sp
  43. addql #1,%d0
  44. jeq ret_from_exception
  45. movel %sp@(PT_OFF_ORIG_D0),%d1
  46. movel #-ENOSYS,%d0
  47. cmpl #NR_syscalls,%d1
  48. jcc 1f
  49. lsl #2,%d1
  50. lea sys_call_table, %a0
  51. jbsr %a0@(%d1)
  52. 1: movel %d0,%sp@(PT_OFF_D0) /* save the return value */
  53. subql #4,%sp /* dummy return address */
  54. SAVE_SWITCH_STACK
  55. jbsr syscall_trace_leave
  56. RESTORE_SWITCH_STACK
  57. addql #4,%sp
  58. jra ret_from_exception
  59. ENTRY(system_call)
  60. SAVE_ALL_SYS
  61. /* save top of frame*/
  62. pea %sp@
  63. jbsr set_esp0
  64. addql #4,%sp
  65. movel %sp@(PT_OFF_ORIG_D0),%d0
  66. movel %sp,%d1 /* get thread_info pointer */
  67. andl #-THREAD_SIZE,%d1
  68. movel %d1,%a2
  69. btst #(TIF_SYSCALL_TRACE%8),%a2@(TINFO_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
  70. jne do_trace
  71. cmpl #NR_syscalls,%d0
  72. jcc badsys
  73. lsl #2,%d0
  74. lea sys_call_table,%a0
  75. movel %a0@(%d0), %a0
  76. jbsr %a0@
  77. movel %d0,%sp@(PT_OFF_D0) /* save the return value*/
  78. ret_from_exception:
  79. btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/
  80. jeq Luser_return /* if so, skip resched, signals*/
  81. Lkernel_return:
  82. RESTORE_ALL
  83. Luser_return:
  84. /* only allow interrupts when we are really the last one on the*/
  85. /* kernel stack, otherwise stack overflow can occur during*/
  86. /* heavy interrupt load*/
  87. andw #ALLOWINT,%sr
  88. movel %sp,%d1 /* get thread_info pointer */
  89. andl #-THREAD_SIZE,%d1
  90. movel %d1,%a2
  91. 1:
  92. move %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
  93. jne Lwork_to_do
  94. RESTORE_ALL
  95. Lwork_to_do:
  96. movel %a2@(TINFO_FLAGS),%d1 /* thread_info->flags */
  97. btst #TIF_NEED_RESCHED,%d1
  98. jne reschedule
  99. Lsignal_return:
  100. subql #4,%sp /* dummy return address*/
  101. SAVE_SWITCH_STACK
  102. pea %sp@(SWITCH_STACK_SIZE)
  103. bsrw do_notify_resume
  104. addql #4,%sp
  105. RESTORE_SWITCH_STACK
  106. addql #4,%sp
  107. jra 1b
  108. /*
  109. * This is the main interrupt handler, responsible for calling process_int()
  110. */
  111. inthandler1:
  112. SAVE_ALL_INT
  113. movew %sp@(PT_OFF_FORMATVEC), %d0
  114. and #0x3ff, %d0
  115. movel %sp,%sp@-
  116. movel #65,%sp@- /* put vector # on stack*/
  117. jbsr process_int /* process the IRQ*/
  118. 3: addql #8,%sp /* pop parameters off stack*/
  119. bra ret_from_exception
  120. inthandler2:
  121. SAVE_ALL_INT
  122. movew %sp@(PT_OFF_FORMATVEC), %d0
  123. and #0x3ff, %d0
  124. movel %sp,%sp@-
  125. movel #66,%sp@- /* put vector # on stack*/
  126. jbsr process_int /* process the IRQ*/
  127. 3: addql #8,%sp /* pop parameters off stack*/
  128. bra ret_from_exception
  129. inthandler3:
  130. SAVE_ALL_INT
  131. movew %sp@(PT_OFF_FORMATVEC), %d0
  132. and #0x3ff, %d0
  133. movel %sp,%sp@-
  134. movel #67,%sp@- /* put vector # on stack*/
  135. jbsr process_int /* process the IRQ*/
  136. 3: addql #8,%sp /* pop parameters off stack*/
  137. bra ret_from_exception
  138. inthandler4:
  139. SAVE_ALL_INT
  140. movew %sp@(PT_OFF_FORMATVEC), %d0
  141. and #0x3ff, %d0
  142. movel %sp,%sp@-
  143. movel #68,%sp@- /* put vector # on stack*/
  144. jbsr process_int /* process the IRQ*/
  145. 3: addql #8,%sp /* pop parameters off stack*/
  146. bra ret_from_exception
  147. inthandler5:
  148. SAVE_ALL_INT
  149. movew %sp@(PT_OFF_FORMATVEC), %d0
  150. and #0x3ff, %d0
  151. movel %sp,%sp@-
  152. movel #69,%sp@- /* put vector # on stack*/
  153. jbsr process_int /* process the IRQ*/
  154. 3: addql #8,%sp /* pop parameters off stack*/
  155. bra ret_from_exception
  156. inthandler6:
  157. SAVE_ALL_INT
  158. movew %sp@(PT_OFF_FORMATVEC), %d0
  159. and #0x3ff, %d0
  160. movel %sp,%sp@-
  161. movel #70,%sp@- /* put vector # on stack*/
  162. jbsr process_int /* process the IRQ*/
  163. 3: addql #8,%sp /* pop parameters off stack*/
  164. bra ret_from_exception
  165. inthandler7:
  166. SAVE_ALL_INT
  167. movew %sp@(PT_OFF_FORMATVEC), %d0
  168. and #0x3ff, %d0
  169. movel %sp,%sp@-
  170. movel #71,%sp@- /* put vector # on stack*/
  171. jbsr process_int /* process the IRQ*/
  172. 3: addql #8,%sp /* pop parameters off stack*/
  173. bra ret_from_exception
  174. inthandler:
  175. SAVE_ALL_INT
  176. movew %sp@(PT_OFF_FORMATVEC), %d0
  177. and #0x3ff, %d0
  178. movel %sp,%sp@-
  179. movel %d0,%sp@- /* put vector # on stack*/
  180. jbsr process_int /* process the IRQ*/
  181. 3: addql #8,%sp /* pop parameters off stack*/
  182. bra ret_from_exception
  183. /*
  184. * Handler for uninitialized and spurious interrupts.
  185. */
  186. ENTRY(bad_interrupt)
  187. addql #1,irq_err_count
  188. rte
  189. /*
  190. * Beware - when entering resume, prev (the current task) is
  191. * in a0, next (the new task) is in a1, so don't change these
  192. * registers until their contents are no longer needed.
  193. */
  194. ENTRY(resume)
  195. movel %a0,%d1 /* save prev thread in d1 */
  196. movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
  197. SAVE_SWITCH_STACK
  198. movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
  199. movel %usp,%a3 /* save usp */
  200. movel %a3,%a0@(TASK_THREAD+THREAD_USP)
  201. movel %a1@(TASK_THREAD+THREAD_USP),%a3 /* restore user stack */
  202. movel %a3,%usp
  203. movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
  204. RESTORE_SWITCH_STACK
  205. movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
  206. rts