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/config.h>
  15. #include <linux/sys.h>
  16. #include <linux/linkage.h>
  17. #include <asm/thread_info.h>
  18. #include <asm/unistd.h>
  19. #include <asm/errno.h>
  20. #include <asm/setup.h>
  21. #include <asm/segment.h>
  22. #include <asm/traps.h>
  23. #include <asm/asm-offsets.h>
  24. #include <asm/entry.h>
  25. .text
  26. .globl system_call
  27. .globl resume
  28. .globl ret_from_exception
  29. .globl ret_from_signal
  30. .globl sys_call_table
  31. .globl ret_from_interrupt
  32. .globl bad_interrupt
  33. .globl inthandler
  34. badsys:
  35. movel #-ENOSYS,%sp@(PT_D0)
  36. jra ret_from_exception
  37. do_trace:
  38. movel #-ENOSYS,%sp@(PT_D0) /* needed for strace*/
  39. subql #4,%sp
  40. SAVE_SWITCH_STACK
  41. jbsr syscall_trace
  42. RESTORE_SWITCH_STACK
  43. addql #4,%sp
  44. movel %sp@(PT_ORIG_D0),%d1
  45. movel #-ENOSYS,%d0
  46. cmpl #NR_syscalls,%d1
  47. jcc 1f
  48. lsl #2,%d1
  49. lea sys_call_table, %a0
  50. jbsr %a0@(%d1)
  51. 1: movel %d0,%sp@(PT_D0) /* save the return value */
  52. subql #4,%sp /* dummy return address */
  53. SAVE_SWITCH_STACK
  54. jbsr syscall_trace
  55. ret_from_signal:
  56. RESTORE_SWITCH_STACK
  57. addql #4,%sp
  58. jra ret_from_exception
  59. ENTRY(system_call)
  60. SAVE_ALL
  61. /* save top of frame*/
  62. pea %sp@
  63. jbsr set_esp0
  64. addql #4,%sp
  65. btst #PF_TRACESYS_BIT,%a2@(TASK_FLAGS+PF_TRACESYS_OFF)
  66. jne do_trace
  67. cmpl #NR_syscalls,%d0
  68. jcc badsys
  69. lsl #2,%d0
  70. lea sys_call_table,%a0
  71. movel %a0@(%d0), %a0
  72. jbsr %a0@
  73. movel %d0,%sp@(PT_D0) /* save the return value*/
  74. ret_from_exception:
  75. btst #5,%sp@(PT_SR) /* check if returning to kernel*/
  76. jeq Luser_return /* if so, skip resched, signals*/
  77. Lkernel_return:
  78. RESTORE_ALL
  79. Luser_return:
  80. /* only allow interrupts when we are really the last one on the*/
  81. /* kernel stack, otherwise stack overflow can occur during*/
  82. /* heavy interrupt load*/
  83. andw #ALLOWINT,%sr
  84. movel %sp,%d1 /* get thread_info pointer */
  85. andl #-THREAD_SIZE,%d1
  86. movel %d1,%a2
  87. move %a2@(TI_FLAGS),%d1 /* thread_info->flags */
  88. andl #_TIF_WORK_MASK,%d1
  89. jne Lwork_to_do
  90. RESTORE_ALL
  91. Lwork_to_do:
  92. movel %a2@(TI_FLAGS),%d1 /* thread_info->flags */
  93. btst #TIF_NEED_RESCHED,%d1
  94. jne reschedule
  95. Lsignal_return:
  96. subql #4,%sp /* dummy return address*/
  97. SAVE_SWITCH_STACK
  98. pea %sp@(SWITCH_STACK_SIZE)
  99. clrl %sp@-
  100. bsrw do_signal
  101. addql #8,%sp
  102. RESTORE_SWITCH_STACK
  103. addql #4,%sp
  104. Lreturn:
  105. RESTORE_ALL
  106. /*
  107. * This is the main interrupt handler, responsible for calling process_int()
  108. */
  109. inthandler:
  110. SAVE_ALL
  111. addql #1,local_irq_count /* put exception # in d0*/
  112. movew %sp@(PT_VECTOR), %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 process_int /* process the IRQ*/
  118. 3: addql #8,%sp /* pop parameters off stack*/
  119. bra ret_from_interrupt
  120. ret_from_interrupt:
  121. subql #1,local_irq_count
  122. jeq 1f
  123. 2:
  124. RESTORE_ALL
  125. 1:
  126. moveb %sp@(PT_SR), %d0
  127. and #7, %d0
  128. jhi 2b
  129. /* check if we need to do software interrupts */
  130. movel irq_stat+CPUSTAT_SOFTIRQ_PENDING,%d0
  131. jeq ret_from_exception
  132. pea ret_from_exception
  133. jra do_softirq
  134. /*
  135. * Handler for uninitialized and spurious interrupts.
  136. */
  137. bad_interrupt:
  138. addql #1,num_spurious
  139. rte
  140. /*
  141. * Beware - when entering resume, prev (the current task) is
  142. * in a0, next (the new task) is in a1,so don't change these
  143. * registers until their contents are no longer needed.
  144. */
  145. ENTRY(resume)
  146. movel %a0,%d1 /* save prev thread in d1 */
  147. movew %sr,%a0@(TASK_THREAD+THREAD_SR) /* save sr */
  148. movel %usp,%a2 /* save usp */
  149. movel %a2,%a0@(TASK_THREAD+THREAD_USP)
  150. SAVE_SWITCH_STACK
  151. movel %sp,%a0@(TASK_THREAD+THREAD_KSP) /* save kernel stack */
  152. movel %a1@(TASK_THREAD+THREAD_KSP),%sp /* restore new thread stack */
  153. RESTORE_SWITCH_STACK
  154. movel %a1@(TASK_THREAD+THREAD_USP),%a0 /* restore user stack */
  155. movel %a0,%usp
  156. movew %a1@(TASK_THREAD+THREAD_SR),%sr /* restore thread status reg */
  157. rts