entry.S 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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_enter
  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_leave
  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. movel %sp@(PT_OFF_ORIG_D0),%d0
  65. movel %sp,%d1 /* get thread_info pointer */
  66. andl #-THREAD_SIZE,%d1
  67. movel %d1,%a2
  68. btst #(TIF_SYSCALL_TRACE%8),%a2@(TI_FLAGS+(31-TIF_SYSCALL_TRACE)/8)
  69. jne do_trace
  70. cmpl #NR_syscalls,%d0
  71. jcc badsys
  72. lsl #2,%d0
  73. lea sys_call_table,%a0
  74. movel %a0@(%d0), %a0
  75. jbsr %a0@
  76. movel %d0,%sp@(PT_OFF_D0) /* save the return value*/
  77. ret_from_exception:
  78. btst #5,%sp@(PT_OFF_SR) /* check if returning to kernel*/
  79. jeq Luser_return /* if so, skip resched, signals*/
  80. Lkernel_return:
  81. RESTORE_ALL
  82. Luser_return:
  83. /* only allow interrupts when we are really the last one on the*/
  84. /* kernel stack, otherwise stack overflow can occur during*/
  85. /* heavy interrupt load*/
  86. andw #ALLOWINT,%sr
  87. movel %sp,%d1 /* get thread_info pointer */
  88. andl #-THREAD_SIZE,%d1
  89. movel %d1,%a2
  90. 1:
  91. move %a2@(TI_FLAGS),%d1 /* thread_info->flags */
  92. jne Lwork_to_do
  93. RESTORE_ALL
  94. Lwork_to_do:
  95. movel %a2@(TI_FLAGS),%d1 /* thread_info->flags */
  96. btst #TIF_NEED_RESCHED,%d1
  97. jne reschedule
  98. Lsignal_return:
  99. subql #4,%sp /* dummy return address*/
  100. SAVE_SWITCH_STACK
  101. pea %sp@(SWITCH_STACK_SIZE)
  102. bsrw do_signal
  103. addql #4,%sp
  104. RESTORE_SWITCH_STACK
  105. addql #4,%sp
  106. jra 1b
  107. /*
  108. * This is the main interrupt handler, responsible for calling do_IRQ()
  109. */
  110. inthandler:
  111. SAVE_ALL
  112. movew %sp@(PT_OFF_FORMATVEC), %d0
  113. and.l #0x3ff, %d0
  114. lsr.l #0x02, %d0
  115. movel %sp,%sp@-
  116. movel %d0,%sp@- /* put vector # on stack*/
  117. jbsr do_IRQ /* process the IRQ*/
  118. 3: addql #8,%sp /* pop parameters off stack*/
  119. bra ret_from_interrupt
  120. ret_from_interrupt:
  121. jeq 1f
  122. 2:
  123. RESTORE_ALL
  124. 1:
  125. moveb %sp@(PT_OFF_SR), %d0
  126. and #7, %d0
  127. jhi 2b
  128. /* check if we need to do software interrupts */
  129. movel irq_stat+CPUSTAT_SOFTIRQ_PENDING,%d0
  130. jeq ret_from_exception
  131. pea ret_from_exception
  132. jra do_softirq
  133. /*
  134. * Handler for uninitialized and spurious interrupts.
  135. */
  136. bad_interrupt:
  137. addql #1,num_spurious
  138. rte
  139. /*
  140. * Beware - when entering resume, prev (the current task) is
  141. * in a0, next (the new task) is in a1,so don't change these
  142. * registers until their contents are no longer needed.
  143. */
  144. ENTRY(resume)
  145. movel %a0,%d1 /* save prev thread in d1 */
  146. movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
  147. movel %usp,%a2 /* save usp */
  148. movel %a2,%a0@(TASK_THREAD+THREAD_USP)
  149. SAVE_SWITCH_STACK
  150. movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
  151. movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
  152. RESTORE_SWITCH_STACK
  153. movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore user stack */
  154. movel %a0,%usp
  155. movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
  156. rts