getcontext.S 2.3 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 getcontext (ucontext_t *ucp) */
  19. ENTRY(__getcontext)
  20. /* No need to save r0-r3, d0-d7, or d16-d31. */
  21. add r1, r0, #MCONTEXT_ARM_R4
  22. stmia r1, {r4-r11}
  23. /* Save R13 separately as Thumb can't STM it. */
  24. str r13, [r0, #MCONTEXT_ARM_SP]
  25. str r14, [r0, #MCONTEXT_ARM_LR]
  26. /* Return to LR */
  27. str r14, [r0, #MCONTEXT_ARM_PC]
  28. /* Return zero */
  29. mov r2, #0
  30. str r2, [r0, #MCONTEXT_ARM_R0]
  31. /* Save ucontext_t * across the next call. */
  32. mov r4, r0
  33. /* __sigprocmask(SIG_BLOCK, NULL, &(ucontext->uc_sigmask)) */
  34. mov r0, #SIG_BLOCK
  35. mov r1, #0
  36. add r2, r4, #UCONTEXT_SIGMASK
  37. bl PLTJMP(sigprocmask)
  38. #if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
  39. # ifdef __VFP_FP__
  40. /* Store the VFP registers. */
  41. /* Following instruction is fstmiax ip!, {d8-d15}. */
  42. stc p11, cr8, [r0], #64
  43. /* Store the floating-point status register. */
  44. /* Following instruction is fmrx r2, fpscr. */
  45. mrc p10, 7, r1, cr1, cr0, 0
  46. str r1, [r0], #4
  47. # endif
  48. #endif
  49. #ifdef __IWMMXT__
  50. /* Save the call-preserved iWMMXt registers. */
  51. /* Following instructions are wstrd wr10, [r0], #8 (etc.) */
  52. stcl p1, cr10, [r0], #8
  53. stcl p1, cr11, [r0], #8
  54. stcl p1, cr12, [r0], #8
  55. stcl p1, cr13, [r0], #8
  56. stcl p1, cr14, [r0], #8
  57. stcl p1, cr15, [r0], #8
  58. #endif
  59. /* Restore the clobbered R4 and LR. */
  60. ldr r14, [r4, #MCONTEXT_ARM_LR]
  61. ldr r4, [r4, #MCONTEXT_ARM_R4]
  62. mov r0, #0
  63. DO_RET(r14)
  64. END(__getcontext)
  65. weak_alias(__getcontext, getcontext)