entry.S 5.6 KB

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