setcontext.S 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (C) 2016-2017 Andes Technology, Inc.
  3. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  4. */
  5. #include <sysdep.h>
  6. #include "ucontext_i.h"
  7. ENTRY(__setcontext)
  8. move $r4, $r0
  9. #ifdef __NDS32_ABI_2FP_PLUS__
  10. addi $r0, $r4, UCONTEXT_FDREGS
  11. /* Case switch for $r20 as $fpcfg.freg. */
  12. beqz $r20, .LCFG0 /* Branch if $fpcfg.freg = 0b00. */
  13. xori $r15, $r20, #0b10
  14. beqz $r15, .LCFG2 /* Branch if $fpcfg.freg = 0b10. */
  15. srli $r20, $r20, #0b01
  16. beqz $r20, .LCFG1 /* Branch if $fpcfg.freg = 0b01. */
  17. /* Fall-through if $fpcfg.freg = 0b11. */
  18. .LCFG3:
  19. fldi $fd31, [$r0 + 248]
  20. fldi $fd30, [$r0 + 240]
  21. fldi $fd29, [$r0 + 232]
  22. fldi $fd28, [$r0 + 224]
  23. fldi $fd27, [$r0 + 216]
  24. fldi $fd26, [$r0 + 208]
  25. fldi $fd25, [$r0 + 200]
  26. fldi $fd24, [$r0 + 192]
  27. .LCFG2:
  28. fldi $fd10, [$r0 + 80]
  29. fldi $fd9, [$r0 + 72]
  30. fldi $fd8, [$r0 + 64]
  31. .LCFG1:
  32. fldi $fd7, [$r0 + 56]
  33. fldi $fd6, [$r0 + 48]
  34. fldi $fd5, [$r0 + 40]
  35. fldi $fd4, [$r0 + 32]
  36. .LCFG0:
  37. fldi $fd3, [$r0 + 24]
  38. /*save fpcsr*/
  39. lwi $r1, [$r0 + 0x100]
  40. fmtcsr $r1
  41. #endif /* __NDS32_ABI_2FP_PLUS__ */
  42. /* sigprocmask (SIG_BLOCK, &sc->sc_mask, NULL). */
  43. move $r0, SIG_SETMASK
  44. addi $r1, $r4, UCONTEXT_SIGMASK
  45. move $r2, 0
  46. move $r3, _NSIG8
  47. syscall SYS_ify(rt_sigprocmask)
  48. bnez $r0, 1f
  49. move $r0, $r4
  50. addi $r15, $r4, UCONTEXT_GREGS + 4
  51. lmw.bim $r1, [$r15], $r14
  52. addi $r15, $r15, 4
  53. lmw.bim $r16, [$r15], $r25, #0xf
  54. lwi $r15, [$r0 + UCONTEXT_PC]
  55. push $r1
  56. cfi_adjust_cfa_offset (4)
  57. move $r1, $r0
  58. lwi $r0, [$r1 + UCONTEXT_GREGS]
  59. pop $r1
  60. cfi_adjust_cfa_offset (-4)
  61. jr $r15
  62. 1:
  63. move $r0, -1
  64. ret
  65. END(__setcontext)
  66. weak_alias (__setcontext, setcontext)
  67. libc_hidden_def(__setcontext)
  68. ENTRY (__startcontext)
  69. move $r0, $r6
  70. beqz $r0, 1f
  71. jal HIDDEN_JUMPTARGET(__setcontext)
  72. 1:
  73. move $r0, 0
  74. j HIDDEN_JUMPTARGET(exit)
  75. END (__startcontext)