]>
Commit | Line | Data |
---|---|---|
d4697bc9 | 1 | /* Copyright (C) 2011-2014 Free Software Foundation, Inc. |
63d143a2 CM |
2 | This file is part of the GNU C Library. |
3 | Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
ab84e3ff PE |
16 | License along with the GNU C Library. If not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
63d143a2 CM |
18 | |
19 | #include <sysdep.h> | |
20 | ||
21 | #include "ucontext_i.h" | |
22 | ||
23 | /* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */ | |
24 | ||
25 | .text | |
26 | ENTRY (__swapcontext) | |
27 | FEEDBACK_ENTER(__swapcontext) | |
28 | /* Set up a frame and save r0 and r1. */ | |
29 | { | |
30 | ST sp, lr | |
31 | ADDI_PTR r11, sp, -(3 * REGSIZE) | |
32 | move r10, sp | |
33 | } | |
0adc5f38 CM |
34 | ADDI_PTR sp, sp, -(4 * REGSIZE) |
35 | cfi_def_cfa_offset (4 * REGSIZE) | |
63d143a2 CM |
36 | cfi_offset (lr, 0) |
37 | { | |
38 | ST r11, r10 | |
0adc5f38 | 39 | ADDI_PTR r10, sp, (2 * REGSIZE) |
63d143a2 CM |
40 | } |
41 | { | |
42 | ST r10, r0 | |
0adc5f38 | 43 | ADDI_PTR r10, sp, (3 * REGSIZE) |
63d143a2 | 44 | } |
63d143a2 CM |
45 | ST r10, r1 |
46 | ||
47 | /* Save the current context. */ | |
48 | jal __getcontext | |
5556231d | 49 | |
63d143a2 CM |
50 | /* Tear down the frame and restore r0, r1, and lr. */ |
51 | { | |
52 | BNEZ r0, .Lerror | |
53 | ADDI_PTR r1, sp, 3 * REGSIZE | |
54 | } | |
55 | { | |
56 | LD r1, r1 | |
57 | ADDI_PTR r0, sp, 2 * REGSIZE | |
58 | } | |
59 | { | |
60 | LD r0, r0 | |
61 | ADDI_PTR sp, sp, 4 * REGSIZE | |
62 | } | |
63 | cfi_def_cfa_offset (0) | |
64 | { | |
65 | LD lr, sp | |
66 | ADDLI_PTR r10, r0, UC_REG(54) | |
67 | } | |
68 | ||
69 | /* Update the stored sp and lr. */ | |
70 | { | |
71 | ST r10, sp | |
72 | ADDLI_PTR r10, r0, UC_REG(55) | |
73 | } | |
74 | ST r10, lr | |
75 | ||
76 | /* Tail-call setcontext to finish up. */ | |
77 | { | |
78 | move r0, r1 | |
79 | j __setcontext | |
80 | } | |
81 | ||
82 | .Lerror: | |
0adc5f38 CM |
83 | ADDI_PTR sp, sp, 4 * REGSIZE |
84 | cfi_def_cfa_offset (0) | |
85 | LD lr, sp | |
63d143a2 CM |
86 | jrp lr |
87 | END (__swapcontext) | |
88 | ||
89 | weak_alias (__swapcontext, swapcontext) |