Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / unix / sysv / linux / arm / getcontext.S
blobb8b7b202b85175d4983f4ba1dccd5fd879a6ae62
1 /* Copyright (C) 2012-2014 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
18 #include <sysdep.h>
19 #include <rtld-global-offsets.h>
21 #include "ucontext_i.h"
23         .syntax unified
24         .text
26 /* int getcontext (ucontext_t *ucp) */
28 ENTRY(__getcontext)
29         /* No need to save r0-r3, d0-d7, or d16-d31.  */
30         add     r1, r0, #MCONTEXT_ARM_R4
31         stmia   r1, {r4-r11}
33         /* Save R13 separately as Thumb can't STM it.  */
34         str     r13, [r0, #MCONTEXT_ARM_SP]
35         str     r14, [r0, #MCONTEXT_ARM_LR]
36         /* Return to LR */
37         str     r14, [r0, #MCONTEXT_ARM_PC]
38         /* Return zero */
39         mov     r2, #0
40         str     r2, [r0, #MCONTEXT_ARM_R0]
42         /* Save ucontext_t * across the next call.  */
43         mov     r4, r0
45         /* __sigprocmask(SIG_BLOCK, NULL, &(ucontext->uc_sigmask)) */
46         mov     r0, #SIG_BLOCK
47         mov     r1, #0
48         add     r2, r4, #UCONTEXT_SIGMASK
49         bl      PLTJMP(__sigprocmask)
51         /* Store FP regs.  Much of the FP code is copied from arm/setjmp.S.  */
53 #ifdef PIC
54         ldr     r2, 1f
55         ldr     r1, .Lrtld_global_ro
56 0:      add     r2, pc, r2
57         ldr     r2, [r2, r1]
58         ldr     r2, [r2, #RTLD_GLOBAL_RO_DL_HWCAP_OFFSET]
59 #else
60         ldr     r2, .Lhwcap
61         ldr     r2, [r2, #0]
62 #endif
64         add     r0, r4, #UCONTEXT_REGSPACE
66 #ifdef __SOFTFP__
67         tst     r2, #HWCAP_ARM_VFP
68         beq     .Lno_vfp
69 #endif
71         /* Store the VFP registers.
72            Don't use VFP instructions directly because this code
73            is used in non-VFP multilibs.  */
74         /* Following instruction is vstmia r0!, {d8-d15}.  */
75         stc     p11, cr8, [r0], #64
76         /* Store the floating-point status register.  */
77         /* Following instruction is vmrs r1, fpscr.  */
78         mrc     p10, 7, r1, cr1, cr0, 0
79         str     r1, [r0], #4
80 .Lno_vfp:
82         tst     r2, #HWCAP_ARM_IWMMXT
83         beq     .Lno_iwmmxt
85         /* Save the call-preserved iWMMXt registers.  */
86         /* Following instructions are wstrd wr10, [r0], #8 (etc.)  */
87         stcl    p1, cr10, [r0], #8
88         stcl    p1, cr11, [r0], #8
89         stcl    p1, cr12, [r0], #8
90         stcl    p1, cr13, [r0], #8
91         stcl    p1, cr14, [r0], #8
92         stcl    p1, cr15, [r0], #8
93 .Lno_iwmmxt:
95         /* Restore the clobbered R4 and LR.  */
96         ldr     r14, [r4, #MCONTEXT_ARM_LR]
97         ldr     r4, [r4, #MCONTEXT_ARM_R4]
99         mov     r0, #0
101         DO_RET(r14)
103 END(__getcontext)
105 #ifdef PIC
106 1:      .long   _GLOBAL_OFFSET_TABLE_ - 0b - PC_OFS
107 .Lrtld_global_ro:
108         .long   C_SYMBOL_NAME(_rtld_global_ro)(GOT)
109 #else
110 .Lhwcap:
111         .long   C_SYMBOL_NAME(_dl_hwcap)
112 #endif
115 weak_alias(__getcontext, getcontext)