getcontext.S 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Save current context.
  2. Copyright (C) 2009-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library. If not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include "ucontext-macros.h"
  16. /* int getcontext (ucontext_t *ucp) */
  17. .text
  18. LEAF (__getcontext)
  19. SAVE_INT_REG (ra, 0, a0)
  20. SAVE_INT_REG (ra, 1, a0)
  21. SAVE_INT_REG (sp, 2, a0)
  22. SAVE_INT_REG (s0, 8, a0)
  23. SAVE_INT_REG (s1, 9, a0)
  24. SAVE_INT_REG (x0, 10, a0) /* return 0 by overwriting a0. */
  25. SAVE_INT_REG (s2, 18, a0)
  26. SAVE_INT_REG (s3, 19, a0)
  27. SAVE_INT_REG (s4, 20, a0)
  28. SAVE_INT_REG (s5, 21, a0)
  29. SAVE_INT_REG (s6, 22, a0)
  30. SAVE_INT_REG (s7, 23, a0)
  31. SAVE_INT_REG (s8, 24, a0)
  32. SAVE_INT_REG (s9, 25, a0)
  33. SAVE_INT_REG (s10, 26, a0)
  34. SAVE_INT_REG (s11, 27, a0)
  35. #ifndef __riscv_float_abi_soft
  36. frsr a1
  37. SAVE_FP_REG (fs0, 8, a0)
  38. SAVE_FP_REG (fs1, 9, a0)
  39. SAVE_FP_REG (fs2, 18, a0)
  40. SAVE_FP_REG (fs3, 19, a0)
  41. SAVE_FP_REG (fs4, 20, a0)
  42. SAVE_FP_REG (fs5, 21, a0)
  43. SAVE_FP_REG (fs6, 22, a0)
  44. SAVE_FP_REG (fs7, 23, a0)
  45. SAVE_FP_REG (fs8, 24, a0)
  46. SAVE_FP_REG (fs9, 25, a0)
  47. SAVE_FP_REG (fs10, 26, a0)
  48. SAVE_FP_REG (fs11, 27, a0)
  49. sw a1, MCONTEXT_FSR(a0)
  50. #endif /* __riscv_float_abi_soft */
  51. /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
  52. li a3, _NSIG8
  53. add a2, a0, UCONTEXT_SIGMASK
  54. mv a1, zero
  55. li a0, SIG_BLOCK
  56. li a7, SYS_ify (rt_sigprocmask)
  57. scall
  58. bltz a0, 99f
  59. ret
  60. 99: j __syscall_error
  61. PSEUDO_END (__getcontext)
  62. weak_alias (__getcontext, getcontext)