setcontext.S 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. /* Point r0 at the VFP/iWMMXt save area (uc_regspace[]) before
  22. restoring any coprocessor state. Without this r0 still points
  23. at the start of ucontext_t and we would read uc_flags etc. */
  24. add r0, r0, #UCONTEXT_REGSPACE
  25. #if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
  26. # ifdef __VFP_FP__
  27. /* Following instruction is vldmia r0!, {d8-d15}. */
  28. ldc p11, cr8, [r0], #64
  29. /* Restore the floating-point status register. */
  30. ldr r1, [r0], #4
  31. /* Following instruction is fmxr fpscr, r1. */
  32. mcr p10, 7, r1, cr1, cr0, 0
  33. # endif
  34. #endif
  35. #ifdef __IWMMXT__
  36. /* Restore the call-preserved iWMMXt registers. */
  37. /* Following instructions are wldrd wr10, [r0], #8 (etc.) */
  38. ldcl p1, cr10, [r0], #8
  39. ldcl p1, cr11, [r0], #8
  40. ldcl p1, cr12, [r0], #8
  41. ldcl p1, cr13, [r0], #8
  42. ldcl p1, cr14, [r0], #8
  43. ldcl p1, cr15, [r0], #8
  44. #endif
  45. /* Now bring back the signal status. */
  46. mov r0, #SIG_SETMASK
  47. add r1, r4, #UCONTEXT_SIGMASK
  48. mov r2, #0
  49. bl PLTJMP(sigprocmask)
  50. /* Loading r0-r3 makes makecontext easier. */
  51. add r14, r4, #MCONTEXT_ARM_R0
  52. ldmia r14, {r0-r11}
  53. ldr r13, [r14, #(MCONTEXT_ARM_SP - MCONTEXT_ARM_R0)]
  54. add r14, r14, #(MCONTEXT_ARM_LR - MCONTEXT_ARM_R0)
  55. ldmia r14, {r14, pc}
  56. END(setcontext)
  57. weak_alias(__setcontext, setcontext)
  58. /* Called when a makecontext() context returns. Start the
  59. context in R4 or fall through to exit(). */
  60. ENTRY(__startcontext)
  61. movs r0, r4
  62. bne PLTJMP(__setcontext)
  63. @ New context was 0 - exit
  64. b PLTJMP(_exit)
  65. END(__startcontext)