entry.S 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1994 - 2000, 2001, 2003 Ralf Baechle
  7. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  8. * Copyright (C) 2001 MIPS Technologies, Inc.
  9. */
  10. #include <asm/asm.h>
  11. #include <asm/asmmacro.h>
  12. #include <asm/regdef.h>
  13. #include <asm/mipsregs.h>
  14. #include <asm/stackframe.h>
  15. #include <asm/isadep.h>
  16. #include <asm/thread_info.h>
  17. #include <asm/war.h>
  18. #ifdef CONFIG_MIPS_MT_SMTC
  19. #include <asm/mipsmtregs.h>
  20. #endif
  21. #ifndef CONFIG_PREEMPT
  22. .macro preempt_stop
  23. local_irq_disable
  24. .endm
  25. #define resume_kernel restore_all
  26. #endif
  27. .text
  28. .align 5
  29. FEXPORT(ret_from_irq)
  30. LONG_S s0, TI_REGS($28)
  31. #ifdef CONFIG_PREEMPT
  32. FEXPORT(ret_from_exception)
  33. #else
  34. b _ret_from_irq
  35. FEXPORT(ret_from_exception)
  36. preempt_stop
  37. #endif
  38. FEXPORT(_ret_from_irq)
  39. LONG_L t0, PT_STATUS(sp) # returning to kernel mode?
  40. andi t0, t0, KU_USER
  41. beqz t0, resume_kernel
  42. resume_userspace:
  43. local_irq_disable # make sure we dont miss an
  44. # interrupt setting need_resched
  45. # between sampling and return
  46. LONG_L a2, TI_FLAGS($28) # current->work
  47. andi t0, a2, _TIF_WORK_MASK # (ignoring syscall_trace)
  48. bnez t0, work_pending
  49. j restore_all
  50. #ifdef CONFIG_PREEMPT
  51. resume_kernel:
  52. local_irq_disable
  53. lw t0, TI_PRE_COUNT($28)
  54. bnez t0, restore_all
  55. need_resched:
  56. LONG_L t0, TI_FLAGS($28)
  57. andi t1, t0, _TIF_NEED_RESCHED
  58. beqz t1, restore_all
  59. LONG_L t0, PT_STATUS(sp) # Interrupts off?
  60. andi t0, 1
  61. beqz t0, restore_all
  62. jal preempt_schedule_irq
  63. b need_resched
  64. #endif
  65. FEXPORT(ret_from_fork)
  66. jal schedule_tail # a0 = struct task_struct *prev
  67. FEXPORT(syscall_exit)
  68. local_irq_disable # make sure need_resched and
  69. # signals dont change between
  70. # sampling and return
  71. LONG_L a2, TI_FLAGS($28) # current->work
  72. li t0, _TIF_ALLWORK_MASK
  73. and t0, a2, t0
  74. bnez t0, syscall_exit_work
  75. FEXPORT(restore_all) # restore full frame
  76. #ifdef CONFIG_MIPS_MT_SMTC
  77. /* Detect and execute deferred IPI "interrupts" */
  78. LONG_L s0, TI_REGS($28)
  79. LONG_S sp, TI_REGS($28)
  80. jal deferred_smtc_ipi
  81. LONG_S s0, TI_REGS($28)
  82. /* Re-arm any temporarily masked interrupts not explicitly "acked" */
  83. mfc0 v0, CP0_TCSTATUS
  84. ori v1, v0, TCSTATUS_IXMT
  85. mtc0 v1, CP0_TCSTATUS
  86. andi v0, TCSTATUS_IXMT
  87. _ehb
  88. mfc0 t0, CP0_TCCONTEXT
  89. DMT 9 # dmt t1
  90. jal mips_ihb
  91. mfc0 t2, CP0_STATUS
  92. andi t3, t0, 0xff00
  93. or t2, t2, t3
  94. mtc0 t2, CP0_STATUS
  95. _ehb
  96. andi t1, t1, VPECONTROL_TE
  97. beqz t1, 1f
  98. EMT
  99. 1:
  100. mfc0 v1, CP0_TCSTATUS
  101. /* We set IXMT above, XOR should clear it here */
  102. xori v1, v1, TCSTATUS_IXMT
  103. or v1, v0, v1
  104. mtc0 v1, CP0_TCSTATUS
  105. _ehb
  106. xor t0, t0, t3
  107. mtc0 t0, CP0_TCCONTEXT
  108. #endif /* CONFIG_MIPS_MT_SMTC */
  109. .set noat
  110. RESTORE_TEMP
  111. RESTORE_AT
  112. RESTORE_STATIC
  113. FEXPORT(restore_partial) # restore partial frame
  114. #ifdef CONFIG_TRACE_IRQFLAGS
  115. SAVE_STATIC
  116. SAVE_AT
  117. SAVE_TEMP
  118. LONG_L v0, PT_STATUS(sp)
  119. and v0, 1
  120. beqz v0, 1f
  121. jal trace_hardirqs_on
  122. b 2f
  123. 1: jal trace_hardirqs_off
  124. 2:
  125. RESTORE_TEMP
  126. RESTORE_AT
  127. RESTORE_STATIC
  128. #endif
  129. RESTORE_SOME
  130. RESTORE_SP_AND_RET
  131. .set at
  132. work_pending:
  133. andi t0, a2, _TIF_NEED_RESCHED # a2 is preloaded with TI_FLAGS
  134. beqz t0, work_notifysig
  135. work_resched:
  136. jal schedule
  137. local_irq_disable # make sure need_resched and
  138. # signals dont change between
  139. # sampling and return
  140. LONG_L a2, TI_FLAGS($28)
  141. andi t0, a2, _TIF_WORK_MASK # is there any work to be done
  142. # other than syscall tracing?
  143. beqz t0, restore_all
  144. andi t0, a2, _TIF_NEED_RESCHED
  145. bnez t0, work_resched
  146. work_notifysig: # deal with pending signals and
  147. # notify-resume requests
  148. move a0, sp
  149. li a1, 0
  150. jal do_notify_resume # a2 already loaded
  151. j resume_userspace
  152. FEXPORT(syscall_exit_work_partial)
  153. SAVE_STATIC
  154. syscall_exit_work:
  155. li t0, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
  156. and t0, a2 # a2 is preloaded with TI_FLAGS
  157. beqz t0, work_pending # trace bit set?
  158. local_irq_enable # could let do_syscall_trace()
  159. # call schedule() instead
  160. move a0, sp
  161. li a1, 1
  162. jal do_syscall_trace
  163. b resume_userspace
  164. #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_MIPS_MT)
  165. /*
  166. * MIPS32R2 Instruction Hazard Barrier - must be called
  167. *
  168. * For C code use the inline version named instruction_hazard().
  169. */
  170. LEAF(mips_ihb)
  171. .set mips32r2
  172. jr.hb ra
  173. nop
  174. END(mips_ihb)
  175. #endif /* CONFIG_CPU_MIPSR2 or CONFIG_MIPS_MT */