entry.S 6.2 KB

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