entry.S 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. andl #_TIF_WORK_MASK,%d1
  97. jne Lwork_to_do
  98. RESTORE_ALL
  99. Lwork_to_do:
  100. movel %a2@(TI_FLAGS),%d1 /* thread_info->flags */
  101. btst #TIF_NEED_RESCHED,%d1
  102. jne reschedule
  103. Lsignal_return:
  104. subql #4,%sp /* dummy return address*/
  105. SAVE_SWITCH_STACK
  106. pea %sp@(SWITCH_STACK_SIZE)
  107. bsrw do_signal
  108. addql #4,%sp
  109. RESTORE_SWITCH_STACK
  110. addql #4,%sp
  111. jra 1b
  112. /*
  113. * This is the main interrupt handler, responsible for calling process_int()
  114. */
  115. inthandler1:
  116. SAVE_ALL
  117. movew %sp@(PT_OFF_FORMATVEC), %d0
  118. and #0x3ff, %d0
  119. movel %sp,%sp@-
  120. movel #65,%sp@- /* put vector # on stack*/
  121. jbsr process_int /* process the IRQ*/
  122. 3: addql #8,%sp /* pop parameters off stack*/
  123. bra ret_from_interrupt
  124. inthandler2:
  125. SAVE_ALL
  126. movew %sp@(PT_OFF_FORMATVEC), %d0
  127. and #0x3ff, %d0
  128. movel %sp,%sp@-
  129. movel #66,%sp@- /* put vector # on stack*/
  130. jbsr process_int /* process the IRQ*/
  131. 3: addql #8,%sp /* pop parameters off stack*/
  132. bra ret_from_interrupt
  133. inthandler3:
  134. SAVE_ALL
  135. movew %sp@(PT_OFF_FORMATVEC), %d0
  136. and #0x3ff, %d0
  137. movel %sp,%sp@-
  138. movel #67,%sp@- /* put vector # on stack*/
  139. jbsr process_int /* process the IRQ*/
  140. 3: addql #8,%sp /* pop parameters off stack*/
  141. bra ret_from_interrupt
  142. inthandler4:
  143. SAVE_ALL
  144. movew %sp@(PT_OFF_FORMATVEC), %d0
  145. and #0x3ff, %d0
  146. movel %sp,%sp@-
  147. movel #68,%sp@- /* put vector # on stack*/
  148. jbsr process_int /* process the IRQ*/
  149. 3: addql #8,%sp /* pop parameters off stack*/
  150. bra ret_from_interrupt
  151. inthandler5:
  152. SAVE_ALL
  153. movew %sp@(PT_OFF_FORMATVEC), %d0
  154. and #0x3ff, %d0
  155. movel %sp,%sp@-
  156. movel #69,%sp@- /* put vector # on stack*/
  157. jbsr process_int /* process the IRQ*/
  158. 3: addql #8,%sp /* pop parameters off stack*/
  159. bra ret_from_interrupt
  160. inthandler6:
  161. SAVE_ALL
  162. movew %sp@(PT_OFF_FORMATVEC), %d0
  163. and #0x3ff, %d0
  164. movel %sp,%sp@-
  165. movel #70,%sp@- /* put vector # on stack*/
  166. jbsr process_int /* process the IRQ*/
  167. 3: addql #8,%sp /* pop parameters off stack*/
  168. bra ret_from_interrupt
  169. inthandler7:
  170. SAVE_ALL
  171. movew %sp@(PT_OFF_FORMATVEC), %d0
  172. and #0x3ff, %d0
  173. movel %sp,%sp@-
  174. movel #71,%sp@- /* put vector # on stack*/
  175. jbsr process_int /* process the IRQ*/
  176. 3: addql #8,%sp /* pop parameters off stack*/
  177. bra ret_from_interrupt
  178. inthandler:
  179. SAVE_ALL
  180. movew %sp@(PT_OFF_FORMATVEC), %d0
  181. and #0x3ff, %d0
  182. movel %sp,%sp@-
  183. movel %d0,%sp@- /* put vector # on stack*/
  184. jbsr process_int /* process the IRQ*/
  185. 3: addql #8,%sp /* pop parameters off stack*/
  186. bra ret_from_interrupt
  187. ret_from_interrupt:
  188. jeq 1f
  189. 2:
  190. RESTORE_ALL
  191. 1:
  192. moveb %sp@(PT_OFF_SR), %d0
  193. and #7, %d0
  194. jhi 2b
  195. /* check if we need to do software interrupts */
  196. jeq ret_from_exception
  197. pea ret_from_exception
  198. jra do_softirq
  199. /*
  200. * Handler for uninitialized and spurious interrupts.
  201. */
  202. ENTRY(bad_interrupt)
  203. addql #1,num_spurious
  204. rte
  205. /*
  206. * Beware - when entering resume, prev (the current task) is
  207. * in a0, next (the new task) is in a1,so don't change these
  208. * registers until their contents are no longer needed.
  209. */
  210. ENTRY(resume)
  211. movel %a0,%d1 /* save prev thread in d1 */
  212. movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
  213. movel %usp,%a2 /* save usp */
  214. movel %a2,%a0@(TASK_THREAD+THREAD_USP)
  215. SAVE_SWITCH_STACK
  216. movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
  217. movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
  218. RESTORE_SWITCH_STACK
  219. movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore user stack */
  220. movel %a0,%usp
  221. movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
  222. rts