entry.S 4.1 KB

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