r2300_switch.S 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * r2300_switch.S: R2300 specific task switching code.
  3. *
  4. * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
  5. * Copyright (C) 1994, 1995, 1996 by Andreas Busse
  6. *
  7. * Multi-cpu abstraction and macros for easier reading:
  8. * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
  9. *
  10. * Further modifications to make this work:
  11. * Copyright (c) 1998-2000 Harald Koerfgen
  12. */
  13. #include <asm/asm.h>
  14. #include <asm/cachectl.h>
  15. #include <asm/export.h>
  16. #include <asm/fpregdef.h>
  17. #include <asm/mipsregs.h>
  18. #include <asm/asm-offsets.h>
  19. #include <asm/regdef.h>
  20. #include <asm/stackframe.h>
  21. #include <asm/thread_info.h>
  22. #include <asm/asmmacro.h>
  23. .set mips1
  24. .align 5
  25. /*
  26. * Offset to the current process status flags, the first 32 bytes of the
  27. * stack are not used.
  28. */
  29. #define ST_OFF (_THREAD_SIZE - 32 - PT_SIZE + PT_STATUS)
  30. /*
  31. * task_struct *resume(task_struct *prev, task_struct *next,
  32. * struct thread_info *next_ti)
  33. */
  34. LEAF(resume)
  35. mfc0 t1, CP0_STATUS
  36. sw t1, THREAD_STATUS(a0)
  37. cpu_save_nonscratch a0
  38. sw ra, THREAD_REG31(a0)
  39. #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
  40. PTR_LA t8, __stack_chk_guard
  41. LONG_L t9, TASK_STACK_CANARY(a1)
  42. LONG_S t9, 0(t8)
  43. #endif
  44. /*
  45. * The order of restoring the registers takes care of the race
  46. * updating $28, $29 and kernelsp without disabling ints.
  47. */
  48. move $28, a2
  49. cpu_restore_nonscratch a1
  50. addiu t1, $28, _THREAD_SIZE - 32
  51. sw t1, kernelsp
  52. mfc0 t1, CP0_STATUS /* Do we really need this? */
  53. li a3, 0xff01
  54. and t1, a3
  55. lw a2, THREAD_STATUS(a1)
  56. nor a3, $0, a3
  57. and a2, a3
  58. or a2, t1
  59. mtc0 a2, CP0_STATUS
  60. move v0, a0
  61. jr ra
  62. END(resume)
  63. /*
  64. * Save a thread's fp context.
  65. */
  66. LEAF(_save_fp)
  67. EXPORT_SYMBOL(_save_fp)
  68. fpu_save_single a0, t1 # clobbers t1
  69. jr ra
  70. END(_save_fp)
  71. /*
  72. * Restore a thread's fp context.
  73. */
  74. LEAF(_restore_fp)
  75. fpu_restore_single a0, t1 # clobbers t1
  76. jr ra
  77. END(_restore_fp)
  78. /*
  79. * Load the FPU with signalling NANS. This bit pattern we're using has
  80. * the property that no matter whether considered as single or as double
  81. * precision represents signaling NANS.
  82. *
  83. * The value to initialize fcr31 to comes in $a0.
  84. */
  85. .set push
  86. SET_HARDFLOAT
  87. LEAF(_init_fpu)
  88. mfc0 t0, CP0_STATUS
  89. li t1, ST0_CU1
  90. or t0, t1
  91. mtc0 t0, CP0_STATUS
  92. ctc1 a0, fcr31
  93. li t0, -1
  94. mtc1 t0, $f0
  95. mtc1 t0, $f1
  96. mtc1 t0, $f2
  97. mtc1 t0, $f3
  98. mtc1 t0, $f4
  99. mtc1 t0, $f5
  100. mtc1 t0, $f6
  101. mtc1 t0, $f7
  102. mtc1 t0, $f8
  103. mtc1 t0, $f9
  104. mtc1 t0, $f10
  105. mtc1 t0, $f11
  106. mtc1 t0, $f12
  107. mtc1 t0, $f13
  108. mtc1 t0, $f14
  109. mtc1 t0, $f15
  110. mtc1 t0, $f16
  111. mtc1 t0, $f17
  112. mtc1 t0, $f18
  113. mtc1 t0, $f19
  114. mtc1 t0, $f20
  115. mtc1 t0, $f21
  116. mtc1 t0, $f22
  117. mtc1 t0, $f23
  118. mtc1 t0, $f24
  119. mtc1 t0, $f25
  120. mtc1 t0, $f26
  121. mtc1 t0, $f27
  122. mtc1 t0, $f28
  123. mtc1 t0, $f29
  124. mtc1 t0, $f30
  125. mtc1 t0, $f31
  126. jr ra
  127. END(_init_fpu)
  128. .set pop