]>
Commit | Line | Data |
---|---|---|
5bccf609 | 1 | /* Get current user context. |
04277e02 | 2 | Copyright (C) 2008-2019 Free Software Foundation, Inc. |
5bccf609 CD |
3 | This file is part of the GNU C Library. |
4 | Contributed by Helge Deller <deller@gmx.de>, 2008. | |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
7 | modify it under the terms of the GNU Lesser General Public | |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public | |
ab84e3ff PE |
17 | License along with the GNU C Library. If not, see |
18 | <http://www.gnu.org/licenses/>. */ | |
5bccf609 CD |
19 | |
20 | #include <sysdep.h> | |
21 | ||
22 | #include "ucontext_i.h" | |
23 | ||
24 | ||
131fafa7 | 25 | /* Trampoline function. Non-standard calling ABI. */ |
5bccf609 CD |
26 | /* Can not use ENTRY(__getcontext_ret) here. */ |
27 | .type __getcontext_ret, @function | |
28 | .hidden __getcontext_ret | |
29 | __getcontext_ret: | |
30 | .proc | |
31 | .callinfo FRAME=0,NO_CALLS | |
131fafa7 CD |
32 | /* r26-r23 contain original r3-r6, but because setcontext |
33 | does not reload r3-r6 (it's using them as temporaries) | |
34 | we must save them elsewhere and swap them back in. */ | |
5bccf609 CD |
35 | copy %r23, %r3 |
36 | copy %r24, %r4 | |
37 | copy %r25, %r5 | |
38 | copy %r26, %r6 | |
131fafa7 | 39 | /* r20 contains original return pointer. */ |
5bccf609 CD |
40 | bv 0(%r20) |
41 | copy %r0, %ret0 | |
42 | .procend | |
43 | .size __getcontext_ret, .-__getcontext_ret | |
44 | ||
45 | ||
46 | ENTRY(__getcontext) | |
47 | /* Save the registers. */ | |
48 | stw %r0, oR0(%r26) | |
49 | stw %r1, oR1(%r26) | |
50 | /* stw %r2, oR2(%r26) - used for trampoline. */ | |
51 | stw %r3, oR3(%r26) | |
52 | stw %r4, oR4(%r26) | |
53 | stw %r5, oR5(%r26) | |
54 | stw %r6, oR6(%r26) | |
55 | stw %r7, oR7(%r26) | |
56 | stw %r8, oR8(%r26) | |
57 | stw %r9, oR9(%r26) | |
58 | stw %r10, oR10(%r26) | |
59 | stw %r11, oR11(%r26) | |
60 | stw %r12, oR12(%r26) | |
61 | stw %r13, oR13(%r26) | |
62 | stw %r14, oR14(%r26) | |
63 | stw %r15, oR15(%r26) | |
64 | stw %r16, oR16(%r26) | |
65 | stw %r17, oR17(%r26) | |
66 | stw %r18, oR18(%r26) | |
67 | stw %r19, oR19(%r26) | |
68 | /* stw %r20, oR20(%r26) - used for trampoline. */ | |
69 | stw %r21, oR21(%r26) | |
70 | stw %r22, oR22(%r26) | |
71 | /* stw %r23, oR23(%r26) - used for trampoline. */ | |
72 | /* stw %r24, oR24(%r26) - used for trampoline. */ | |
73 | /* stw %r25, oR25(%r26) - used for trampoline. */ | |
74 | /* stw %r26, oR26(%r26) - used for trampoline. */ | |
75 | stw %r27, oR27(%r26) | |
76 | stw %r28, oR28(%r26) | |
77 | stw %r29, oR29(%r26) | |
131fafa7 | 78 | stw %sp, oR30(%r26) |
5bccf609 CD |
79 | stw %r31, oR31(%r26) |
80 | ||
81 | stw %r0, oUC_FLAGS(%r26) | |
82 | /* stw %r0, oUC_LINK(%r26) - Do not overwrite. */ | |
131fafa7 | 83 | stw %sp, oSS_SP(%r26) |
5bccf609 CD |
84 | stw %r0, oSS_FLAGS(%r26) |
85 | stw %r0, oSS_SIZE(%r26) | |
86 | ||
87 | stw %r0, oSC_FLAGS(%r26) | |
88 | ||
89 | stw %r0, oIASQ0(%r26) | |
90 | stw %r0, oIASQ1(%r26) | |
91 | stw %r0, oIAOQ0(%r26) | |
92 | stw %r0, oIAOQ1(%r26) | |
93 | stw %r0, oSAR(%r26) /* used as flag in swapcontext(). */ | |
94 | ||
95 | ||
96 | /* Store floating-point regs. */ | |
97 | ldo oFPREGS0(%r26),%r1 | |
98 | fstds,ma %fr0, 8(%r1) | |
99 | fstds,ma %fr1, 8(%r1) | |
100 | fstds,ma %fr2, 8(%r1) | |
101 | fstds,ma %fr3, 8(%r1) | |
102 | fstds,ma %fr4, 8(%r1) | |
103 | fstds,ma %fr5, 8(%r1) | |
104 | fstds,ma %fr6, 8(%r1) | |
105 | fstds,ma %fr7, 8(%r1) | |
106 | fstds,ma %fr8, 8(%r1) | |
107 | fstds,ma %fr9, 8(%r1) | |
108 | fstds,ma %fr10, 8(%r1) | |
109 | fstds,ma %fr11, 8(%r1) | |
110 | fstds,ma %fr12, 8(%r1) | |
111 | fstds,ma %fr13, 8(%r1) | |
112 | fstds,ma %fr14, 8(%r1) | |
113 | fstds,ma %fr15, 8(%r1) | |
114 | fstds,ma %fr16, 8(%r1) | |
115 | fstds,ma %fr17, 8(%r1) | |
116 | fstds,ma %fr18, 8(%r1) | |
117 | fstds,ma %fr19, 8(%r1) | |
118 | fstds,ma %fr20, 8(%r1) | |
119 | fstds,ma %fr21, 8(%r1) | |
120 | fstds,ma %fr22, 8(%r1) | |
121 | fstds,ma %fr23, 8(%r1) | |
122 | fstds,ma %fr24, 8(%r1) | |
123 | fstds,ma %fr25, 8(%r1) | |
124 | fstds,ma %fr26, 8(%r1) | |
125 | fstds,ma %fr27, 8(%r1) | |
126 | fstds,ma %fr28, 8(%r1) | |
127 | fstds,ma %fr29, 8(%r1) | |
128 | fstds,ma %fr30, 8(%r1) | |
129 | fstds %fr31, 0(%r1) | |
130 | ||
131 | /* Prologue */ | |
8da92e72 JDA |
132 | stw %r2, -20(%sp) |
133 | .cfi_offset 2, -20 | |
131fafa7 | 134 | stwm %r4, 64(%sp) |
ce1917d0 JDA |
135 | .cfi_def_cfa_offset -64 |
136 | .cfi_offset 4, 0 | |
5bccf609 | 137 | #ifdef PIC |
131fafa7 | 138 | stw %r19, -32(%sp) |
ce1917d0 | 139 | .cfi_offset 19, 32 |
5bccf609 CD |
140 | #endif |
141 | ||
142 | /* Set up the trampoline registers. | |
143 | r20, r23, r24, r25, r26 and r2 are clobbered | |
144 | by call to getcontext() anyway. Reuse them. */ | |
145 | stw %r2, oR20(%r26) | |
146 | stw %r3, oR23(%r26) | |
147 | stw %r4, oR24(%r26) | |
148 | stw %r5, oR25(%r26) | |
149 | stw %r6, oR26(%r26) | |
388784cf JDA |
150 | #ifdef PIC |
151 | addil LT%__getcontext_ret, %r19 | |
152 | ldw RT%__getcontext_ret(%r1), %r1 | |
153 | #else | |
5bccf609 CD |
154 | ldil L%__getcontext_ret, %r1 |
155 | ldo R%__getcontext_ret(%r1), %r1 | |
388784cf | 156 | #endif |
5bccf609 CD |
157 | stw %r1, oR2(%r26) |
158 | ||
159 | /* Save the current signal mask. */ | |
160 | /* sigprocmask(SIG_BLOCK, NULL, &ucp->uc_sigmask); */ | |
161 | ldo oSIGMASK(%r26), %r24 | |
162 | copy %r0, %r25 | |
3785b31c | 163 | bl __sigprocmask, %r2 |
5bccf609 CD |
164 | ldi SIG_BLOCK, %r26 |
165 | ||
166 | /* Epilogue */ | |
131fafa7 | 167 | ldw -84(%sp), %r2 |
5bccf609 | 168 | #ifdef PIC |
cc407f4e | 169 | ldw -32(%sp), %r19 |
5bccf609 CD |
170 | #endif |
171 | bv %r0(%r2) | |
131fafa7 | 172 | ldwm -64(%sp), %r4 |
5bccf609 CD |
173 | END(__getcontext) |
174 | ||
175 | weak_alias (__getcontext, getcontext) |