entry.S 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * linux/arch/m68knommu/platform/68360/entry.S
  3. *
  4. * Copyright (C) 1991, 1992 Linus Torvalds
  5. * Copyright (C) 2001 SED Systems, a Division of Calian Ltd.
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file README.legal in the main directory of this archive
  9. * for more details.
  10. *
  11. * Linux/m68k support by Hamish Macdonald
  12. * M68360 Port by SED Systems, and Lineo.
  13. */
  14. #include <linux/sys.h>
  15. #include <linux/linkage.h>
  16. #include <asm/thread_info.h>
  17. #include <asm/unistd.h>
  18. #include <asm/errno.h>
  19. #include <asm/setup.h>
  20. #include <asm/segment.h>
  21. #include <asm/traps.h>
  22. #include <asm/asm-offsets.h>
  23. #include <asm/entry.h>
  24. .text
  25. .globl system_call
  26. .globl resume
  27. .globl ret_from_exception
  28. .globl ret_from_signal
  29. .globl sys_call_table
  30. .globl ret_from_interrupt
  31. .globl bad_interrupt
  32. .globl inthandler
  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
  41. RESTORE_SWITCH_STACK
  42. addql #4,%sp
  43. movel %sp@(PT_OFF_ORIG_D0),%d1
  44. movel #-ENOSYS,%d0
  45. cmpl #NR_syscalls,%d1
  46. jcc 1f
  47. lsl #2,%d1
  48. lea sys_call_table, %a0
  49. jbsr %a0@(%d1)
  50. 1: movel %d0,%sp@(PT_OFF_D0) /* save the return value */
  51. subql #4,%sp /* dummy return address */
  52. SAVE_SWITCH_STACK
  53. jbsr syscall_trace
  54. ret_from_signal:
  55. RESTORE_SWITCH_STACK
  56. addql #4,%sp
  57. jra ret_from_exception
  58. ENTRY(system_call)
  59. SAVE_ALL
  60. /* save top of frame*/
  61. pea %sp@
  62. jbsr set_esp0
  63. addql #4,%sp
  64. btst #PF_TRACESYS_BIT,%a2@(TASK_FLAGS+PF_TRACESYS_OFF)
  65. jne do_trace
  66. cmpl #NR_syscalls,%d0
  67. jcc badsys
  68. lsl #2,%d0
  69. lea sys_call_table,%a0
  70. movel %a0@(%d0), %a0
  71. jbsr %a0@
  72. movel %d0,%sp@(PT_OFF_D0) /* save the return value*/
  73. ret_from_exception:
  74. btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/
  75. jeq Luser_return /* if so, skip resched, signals*/
  76. Lkernel_return:
  77. RESTORE_ALL
  78. Luser_return:
  79. /* only allow interrupts when we are really the last one on the*/
  80. /* kernel stack, otherwise stack overflow can occur during*/
  81. /* heavy interrupt load*/
  82. andw #ALLOWINT,%sr
  83. movel %sp,%d1 /* get thread_info pointer */
  84. andl #-THREAD_SIZE,%d1
  85. movel %d1,%a2
  86. move %a2@(TI_FLAGS),%d1 /* thread_info->flags */
  87. andl #_TIF_WORK_MASK,%d1
  88. jne Lwork_to_do
  89. RESTORE_ALL
  90. Lwork_to_do:
  91. movel %a2@(TI_FLAGS),%d1 /* thread_info->flags */
  92. btst #TIF_NEED_RESCHED,%d1
  93. jne reschedule
  94. Lsignal_return:
  95. subql #4,%sp /* dummy return address*/
  96. SAVE_SWITCH_STACK
  97. pea %sp@(SWITCH_STACK_SIZE)
  98. clrl %sp@-
  99. bsrw do_signal
  100. addql #8,%sp
  101. RESTORE_SWITCH_STACK
  102. addql #4,%sp
  103. Lreturn:
  104. RESTORE_ALL
  105. /*
  106. * This is the main interrupt handler, responsible for calling do_IRQ()
  107. */
  108. inthandler:
  109. SAVE_ALL
  110. movew %sp@(PT_OFF_VECTOR), %d0
  111. and.l #0x3ff, %d0
  112. lsr.l #0x02, %d0
  113. movel %sp,%sp@-
  114. movel %d0,%sp@- /* put vector # on stack*/
  115. jbsr do_IRQ /* process the IRQ*/
  116. 3: addql #8,%sp /* pop parameters off stack*/
  117. bra ret_from_interrupt
  118. ret_from_interrupt:
  119. jeq 1f
  120. 2:
  121. RESTORE_ALL
  122. 1:
  123. moveb %sp@(PT_OFF_SR), %d0
  124. and #7, %d0
  125. jhi 2b
  126. /* check if we need to do software interrupts */
  127. movel irq_stat+CPUSTAT_SOFTIRQ_PENDING,%d0
  128. jeq ret_from_exception
  129. pea ret_from_exception
  130. jra do_softirq
  131. /*
  132. * Handler for uninitialized and spurious interrupts.
  133. */
  134. bad_interrupt:
  135. addql #1,num_spurious
  136. rte
  137. /*
  138. * Beware - when entering resume, prev (the current task) is
  139. * in a0, next (the new task) is in a1,so don't change these
  140. * registers until their contents are no longer needed.
  141. */
  142. ENTRY(resume)
  143. movel %a0,%d1 /* save prev thread in d1 */
  144. movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
  145. movel %usp,%a2 /* save usp */
  146. movel %a2,%a0@(TASK_THREAD+THREAD_USP)
  147. SAVE_SWITCH_STACK
  148. movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
  149. movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
  150. RESTORE_SWITCH_STACK
  151. movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore user stack */
  152. movel %a0,%usp
  153. movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
  154. rts