Move all files into ports/ subdirectory in preparation for merge with glibc
[glibc.git] / ports / sysdeps / unix / sysv / linux / arm / getcontext.S
blob116d6e8f357518696ed4220f45c161d2bd5b20b8
1 /* Copyright (C) 2012 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
44         
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)
50         
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         tst     r2, #HWCAP_ARM_VFP
67         beq     Lno_vfp
69         /* Store the VFP registers.
70            Don't use VFP instructions directly because this code
71            is used in non-VFP multilibs.  */
72         /* Following instruction is vstmia r0!, {d8-d15}.  */
73         stc     p11, cr8, [r0], #64
74         /* Store the floating-point status register.  */
75         /* Following instruction is vmrs r1, fpscr.  */
76         mrc     p10, 7, r1, cr1, cr0, 0
77         str     r1, [r0], #4
78 Lno_vfp:
80         tst     r2, #HWCAP_ARM_IWMMXT
81         beq     Lno_iwmmxt
83         /* Save the call-preserved iWMMXt registers.  */
84         /* Following instructions are wstrd wr10, [r0], #8 (etc.)  */
85         stcl    p1, cr10, [r0], #8
86         stcl    p1, cr11, [r0], #8
87         stcl    p1, cr12, [r0], #8
88         stcl    p1, cr13, [r0], #8
89         stcl    p1, cr14, [r0], #8
90         stcl    p1, cr15, [r0], #8
91 Lno_iwmmxt:
93         /* Restore the clobbered R4 and LR.  */
94         ldr     r14, [r4, #MCONTEXT_ARM_LR]
95         ldr     r4, [r4, #MCONTEXT_ARM_R4]
97         mov     r0, #0
99         DO_RET(r14)
101 END(__getcontext)
103 #ifdef PIC
104 1:      .long   _GLOBAL_OFFSET_TABLE_ - 0b - 8
105 Lrtld_global_ro:
106         .long   C_SYMBOL_NAME(_rtld_global_ro)(GOT)
107 #else
108 Lhwcap:
109         .long   C_SYMBOL_NAME(_dl_hwcap)
110 #endif
113 weak_alias(__getcontext, getcontext)