getcontext.S 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. /* sigprocmask clobbered r0; point it back at the VFP/iWMMXt
  39. save area inside ucontext_t (uc_regspace[]) before storing
  40. any coprocessor state there. */
  41. add r0, r4, #UCONTEXT_REGSPACE
  42. #if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
  43. # ifdef __VFP_FP__
  44. /* Store the VFP registers. */
  45. /* Following instruction is fstmiax ip!, {d8-d15}. */
  46. stc p11, cr8, [r0], #64
  47. /* Store the floating-point status register. */
  48. /* Following instruction is fmrx r2, fpscr. */
  49. mrc p10, 7, r1, cr1, cr0, 0
  50. str r1, [r0], #4
  51. # endif
  52. #endif
  53. #ifdef __IWMMXT__
  54. /* Save the call-preserved iWMMXt registers. */
  55. /* Following instructions are wstrd wr10, [r0], #8 (etc.) */
  56. stcl p1, cr10, [r0], #8
  57. stcl p1, cr11, [r0], #8
  58. stcl p1, cr12, [r0], #8
  59. stcl p1, cr13, [r0], #8
  60. stcl p1, cr14, [r0], #8
  61. stcl p1, cr15, [r0], #8
  62. #endif
  63. /* Restore the clobbered R4 and LR. */
  64. ldr r14, [r4, #MCONTEXT_ARM_LR]
  65. ldr r4, [r4, #MCONTEXT_ARM_R4]
  66. mov r0, #0
  67. DO_RET(r14)
  68. END(__getcontext)
  69. weak_alias(__getcontext, getcontext)