entry.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 <linux/config.h>
  11. #include <asm/asm.h>
  12. #include <asm/asmmacro.h>
  13. #include <asm/regdef.h>
  14. #include <asm/mipsregs.h>
  15. #include <asm/stackframe.h>
  16. #include <asm/isadep.h>
  17. #include <asm/thread_info.h>
  18. #include <asm/war.h>
  19. #ifdef CONFIG_PREEMPT
  20. .macro preempt_stop
  21. .endm
  22. #else
  23. .macro preempt_stop
  24. local_irq_disable
  25. .endm
  26. #define resume_kernel restore_all
  27. #endif
  28. .text
  29. .align 5
  30. FEXPORT(ret_from_exception)
  31. preempt_stop
  32. FEXPORT(ret_from_irq)
  33. LONG_L t0, PT_STATUS(sp) # returning to kernel mode?
  34. andi t0, t0, KU_USER
  35. beqz t0, resume_kernel
  36. resume_userspace:
  37. local_irq_disable # make sure we dont miss an
  38. # interrupt setting need_resched
  39. # between sampling and return
  40. LONG_L a2, TI_FLAGS($28) # current->work
  41. andi t0, a2, _TIF_WORK_MASK # (ignoring syscall_trace)
  42. bnez t0, work_pending
  43. j restore_all
  44. #ifdef CONFIG_PREEMPT
  45. resume_kernel:
  46. lw t0, TI_PRE_COUNT($28)
  47. bnez t0, restore_all
  48. need_resched:
  49. LONG_L t0, TI_FLAGS($28)
  50. andi t1, t0, _TIF_NEED_RESCHED
  51. beqz t1, restore_all
  52. LONG_L t0, PT_STATUS(sp) # Interrupts off?
  53. andi t0, 1
  54. beqz t0, restore_all
  55. li t0, PREEMPT_ACTIVE
  56. sw t0, TI_PRE_COUNT($28)
  57. local_irq_enable
  58. jal schedule
  59. sw zero, TI_PRE_COUNT($28)
  60. local_irq_disable
  61. b need_resched
  62. #endif
  63. FEXPORT(ret_from_fork)
  64. jal schedule_tail # a0 = task_t *prev
  65. FEXPORT(syscall_exit)
  66. local_irq_disable # make sure need_resched and
  67. # signals dont change between
  68. # sampling and return
  69. LONG_L a2, TI_FLAGS($28) # current->work
  70. li t0, _TIF_ALLWORK_MASK
  71. and t0, a2, t0
  72. bnez t0, syscall_exit_work
  73. FEXPORT(restore_all) # restore full frame
  74. .set noat
  75. RESTORE_TEMP
  76. RESTORE_AT
  77. RESTORE_STATIC
  78. FEXPORT(restore_partial) # restore partial frame
  79. RESTORE_SOME
  80. RESTORE_SP_AND_RET
  81. .set at
  82. work_pending:
  83. andi t0, a2, _TIF_NEED_RESCHED # a2 is preloaded with TI_FLAGS
  84. beqz t0, work_notifysig
  85. work_resched:
  86. jal schedule
  87. local_irq_disable # make sure need_resched and
  88. # signals dont change between
  89. # sampling and return
  90. LONG_L a2, TI_FLAGS($28)
  91. andi t0, a2, _TIF_WORK_MASK # is there any work to be done
  92. # other than syscall tracing?
  93. beqz t0, restore_all
  94. andi t0, a2, _TIF_NEED_RESCHED
  95. bnez t0, work_resched
  96. work_notifysig: # deal with pending signals and
  97. # notify-resume requests
  98. move a0, sp
  99. li a1, 0
  100. jal do_notify_resume # a2 already loaded
  101. j restore_all
  102. FEXPORT(syscall_exit_work_partial)
  103. SAVE_STATIC
  104. syscall_exit_work:
  105. li t0, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
  106. and t0, a2 # a2 is preloaded with TI_FLAGS
  107. beqz t0, work_pending # trace bit set?
  108. local_irq_enable # could let do_syscall_trace()
  109. # call schedule() instead
  110. move a0, sp
  111. li a1, 1
  112. jal do_syscall_trace
  113. b resume_userspace
  114. /*
  115. * Common spurious interrupt handler.
  116. */
  117. LEAF(spurious_interrupt)
  118. /*
  119. * Someone tried to fool us by sending an interrupt but we
  120. * couldn't find a cause for it.
  121. */
  122. PTR_LA t1, irq_err_count
  123. #ifdef CONFIG_SMP
  124. 1: ll t0, (t1)
  125. addiu t0, 1
  126. sc t0, (t1)
  127. #if R10000_LLSC_WAR
  128. beqzl t0, 1b
  129. #else
  130. beqz t0, 1b
  131. #endif
  132. #else
  133. lw t0, (t1)
  134. addiu t0, 1
  135. sw t0, (t1)
  136. #endif
  137. j ret_from_irq
  138. END(spurious_interrupt)