entry.S 5.8 KB

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