setcontext.S 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Copyright (C) 2012 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <sysdep.h>
  15. #include "ucontext_i.h"
  16. .syntax unified
  17. .text
  18. /* int setcontext (const ucontext_t *ucp) */
  19. ENTRY(__setcontext)
  20. mov r4, r0
  21. #if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
  22. # ifdef __VFP_FP__
  23. /* Following instruction is vldmia r0!, {d8-d15}. */
  24. ldc p11, cr8, [r0], #64
  25. /* Restore the floating-point status register. */
  26. ldr r1, [r0], #4
  27. /* Following instruction is fmxr fpscr, r1. */
  28. mcr p10, 7, r1, cr1, cr0, 0
  29. # endif
  30. #endif
  31. #ifdef __IWMMXT__
  32. /* Restore the call-preserved iWMMXt registers. */
  33. /* Following instructions are wldrd wr10, [r0], #8 (etc.) */
  34. ldcl p1, cr10, [r0], #8
  35. ldcl p1, cr11, [r0], #8
  36. ldcl p1, cr12, [r0], #8
  37. ldcl p1, cr13, [r0], #8
  38. ldcl p1, cr14, [r0], #8
  39. ldcl p1, cr15, [r0], #8
  40. #endif
  41. /* Now bring back the signal status. */
  42. mov r0, #SIG_SETMASK
  43. add r1, r4, #UCONTEXT_SIGMASK
  44. mov r2, #0
  45. bl PLTJMP(sigprocmask)
  46. /* Loading r0-r3 makes makecontext easier. */
  47. add r14, r4, #MCONTEXT_ARM_R0
  48. ldmia r14, {r0-r11}
  49. ldr r13, [r14, #(MCONTEXT_ARM_SP - MCONTEXT_ARM_R0)]
  50. add r14, r14, #(MCONTEXT_ARM_LR - MCONTEXT_ARM_R0)
  51. ldmia r14, {r14, pc}
  52. END(setcontext)
  53. weak_alias(__setcontext, setcontext)
  54. /* Called when a makecontext() context returns. Start the
  55. context in R4 or fall through to exit(). */
  56. ENTRY(__startcontext)
  57. movs r0, r4
  58. bne PLTJMP(__setcontext)
  59. @ New context was 0 - exit
  60. b PLTJMP(_exit)
  61. END(__startcontext)