]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/arm/setcontext.S
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / arm / setcontext.S
1 /* Copyright (C) 2012 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
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.
8
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.
13
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/>.  */
17
18 #include <sysdep.h>
19
20 #include "ucontext_i.h"
21
22         .syntax unified
23         .text
24
25 /* int setcontext (const ucontext_t *ucp) */
26
27 ENTRY(__setcontext)
28         mov     r4, r0
29
30 #if defined __UCLIBC_HAS_FLOATS__ && ! defined __UCLIBC_HAS_SOFT_FLOAT__
31 # ifdef __VFP_FP__
32         /* Following instruction is vldmia r0!, {d8-d15}.  */
33         ldc     p11, cr8, [r0], #64
34         /* Restore the floating-point status register.  */
35         ldr     r1, [r0], #4
36         /* Following instruction is fmxr fpscr, r1.  */
37         mcr     p10, 7, r1, cr1, cr0, 0
38 # endif
39 #endif
40
41 #ifdef __IWMMXT__
42         /* Restore the call-preserved iWMMXt registers.  */
43         /* Following instructions are wldrd wr10, [r0], #8 (etc.)  */
44         ldcl    p1, cr10, [r0], #8
45         ldcl    p1, cr11, [r0], #8
46         ldcl    p1, cr12, [r0], #8
47         ldcl    p1, cr13, [r0], #8
48         ldcl    p1, cr14, [r0], #8
49         ldcl    p1, cr15, [r0], #8
50 #endif
51
52         /* Now bring back the signal status.  */
53         mov     r0, #SIG_SETMASK
54         add     r1, r4, #UCONTEXT_SIGMASK
55         mov     r2, #0
56         bl      PLTJMP(sigprocmask)
57
58         /* Loading r0-r3 makes makecontext easier.  */
59         add     r14, r4, #MCONTEXT_ARM_R0
60         ldmia   r14, {r0-r11}
61         ldr     r13, [r14, #(MCONTEXT_ARM_SP - MCONTEXT_ARM_R0)]
62         add     r14, r14, #(MCONTEXT_ARM_LR - MCONTEXT_ARM_R0)
63         ldmia   r14, {r14, pc}
64
65 END(setcontext)
66 weak_alias(__setcontext, setcontext)
67
68         /* Called when a makecontext() context returns.  Start the
69            context in R4 or fall through to exit().  */
70 ENTRY(__startcontext)
71         movs    r0, r4
72         bne     PLTJMP(__setcontext)
73
74         @ New context was 0 - exit
75         b       PLTJMP(_exit)
76 END(__startcontext)