entry.S 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. jal deferred_smtc_ipi
  79. /* Re-arm any temporarily masked interrupts not explicitly "acked" */
  80. mfc0 v0, CP0_TCSTATUS
  81. ori v1, v0, TCSTATUS_IXMT
  82. mtc0 v1, CP0_TCSTATUS
  83. andi v0, TCSTATUS_IXMT
  84. _ehb
  85. mfc0 t0, CP0_TCCONTEXT
  86. DMT 9 # dmt t1
  87. jal mips_ihb
  88. mfc0 t2, CP0_STATUS
  89. andi t3, t0, 0xff00
  90. or t2, t2, t3
  91. mtc0 t2, CP0_STATUS
  92. _ehb
  93. andi t1, t1, VPECONTROL_TE
  94. beqz t1, 1f
  95. EMT
  96. 1:
  97. mfc0 v1, CP0_TCSTATUS
  98. /* We set IXMT above, XOR should clear it here */
  99. xori v1, v1, TCSTATUS_IXMT
  100. or v1, v0, v1
  101. mtc0 v1, CP0_TCSTATUS
  102. _ehb
  103. xor t0, t0, t3
  104. mtc0 t0, CP0_TCCONTEXT
  105. #endif /* CONFIG_MIPS_MT_SMTC */
  106. .set noat
  107. RESTORE_TEMP
  108. RESTORE_AT
  109. RESTORE_STATIC
  110. FEXPORT(restore_partial) # restore partial frame
  111. #ifdef CONFIG_TRACE_IRQFLAGS
  112. SAVE_STATIC
  113. SAVE_AT
  114. SAVE_TEMP
  115. LONG_L v0, PT_STATUS(sp)
  116. and v0, 1
  117. beqz v0, 1f
  118. jal trace_hardirqs_on
  119. b 2f
  120. 1: jal trace_hardirqs_off
  121. 2:
  122. RESTORE_TEMP
  123. RESTORE_AT
  124. RESTORE_STATIC
  125. #endif
  126. RESTORE_SOME
  127. RESTORE_SP_AND_RET
  128. .set at
  129. work_pending:
  130. andi t0, a2, _TIF_NEED_RESCHED # a2 is preloaded with TI_FLAGS
  131. beqz t0, work_notifysig
  132. work_resched:
  133. jal schedule
  134. local_irq_disable # make sure need_resched and
  135. # signals dont change between
  136. # sampling and return
  137. LONG_L a2, TI_FLAGS($28)
  138. andi t0, a2, _TIF_WORK_MASK # is there any work to be done
  139. # other than syscall tracing?
  140. beqz t0, restore_all
  141. andi t0, a2, _TIF_NEED_RESCHED
  142. bnez t0, work_resched
  143. work_notifysig: # deal with pending signals and
  144. # notify-resume requests
  145. move a0, sp
  146. li a1, 0
  147. jal do_notify_resume # a2 already loaded
  148. j resume_userspace
  149. FEXPORT(syscall_exit_work_partial)
  150. SAVE_STATIC
  151. syscall_exit_work:
  152. li t0, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
  153. and t0, a2 # a2 is preloaded with TI_FLAGS
  154. beqz t0, work_pending # trace bit set?
  155. local_irq_enable # could let do_syscall_trace()
  156. # call schedule() instead
  157. move a0, sp
  158. li a1, 1
  159. jal do_syscall_trace
  160. b resume_userspace
  161. #if defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_MIPS_MT)
  162. /*
  163. * MIPS32R2 Instruction Hazard Barrier - must be called
  164. *
  165. * For C code use the inline version named instruction_hazard().
  166. */
  167. LEAF(mips_ihb)
  168. .set mips32r2
  169. jr.hb ra
  170. nop
  171. END(mips_ihb)
  172. #endif /* CONFIG_CPU_MIPSR2 or CONFIG_MIPS_MT */