r2300_switch.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * r2300_switch.S: R2300 specific task switching code.
  4. *
  5. * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
  6. * Copyright (C) 1994, 1995, 1996 by Andreas Busse
  7. *
  8. * Multi-cpu abstraction and macros for easier reading:
  9. * Copyright (C) 1996 David S. Miller ([email protected])
  10. *
  11. * Further modifications to make this work:
  12. * Copyright (c) 1998-2000 Harald Koerfgen
  13. */
  14. #include <asm/asm.h>
  15. #include <asm/cachectl.h>
  16. #include <asm/export.h>
  17. #include <asm/fpregdef.h>
  18. #include <asm/mipsregs.h>
  19. #include <asm/asm-offsets.h>
  20. #include <asm/regdef.h>
  21. #include <asm/stackframe.h>
  22. #include <asm/thread_info.h>
  23. #include <asm/asmmacro.h>
  24. .set mips1
  25. .align 5
  26. /*
  27. * task_struct *resume(task_struct *prev, task_struct *next,
  28. * struct thread_info *next_ti)
  29. */
  30. LEAF(resume)
  31. mfc0 t1, CP0_STATUS
  32. sw t1, THREAD_STATUS(a0)
  33. cpu_save_nonscratch a0
  34. sw ra, THREAD_REG31(a0)
  35. #if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
  36. PTR_LA t8, __stack_chk_guard
  37. LONG_L t9, TASK_STACK_CANARY(a1)
  38. LONG_S t9, 0(t8)
  39. #endif
  40. /*
  41. * The order of restoring the registers takes care of the race
  42. * updating $28, $29 and kernelsp without disabling ints.
  43. */
  44. move $28, a2
  45. cpu_restore_nonscratch a1
  46. addiu t1, $28, _THREAD_SIZE - 32
  47. sw t1, kernelsp
  48. mfc0 t1, CP0_STATUS /* Do we really need this? */
  49. li a3, 0xff01
  50. and t1, a3
  51. lw a2, THREAD_STATUS(a1)
  52. nor a3, $0, a3
  53. and a2, a3
  54. or a2, t1
  55. mtc0 a2, CP0_STATUS
  56. move v0, a0
  57. jr ra
  58. END(resume)