]>
Commit | Line | Data |
---|---|---|
76e95c88 UD |
1 | /* Save current context. |
2 | Copyright (C) 2005 Free Software Foundation, Inc. | |
3 | This file is part of the GNU C Library. | |
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 | |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
19 | ||
20 | #include <sysdep.h> | |
21 | ||
22 | #include "ucontext_i.h" | |
23 | ||
24 | /* int __getcontext (ucontext_t *uc); */ | |
25 | ||
26 | .text | |
27 | .align 5 | |
28 | cfi_startproc | |
29 | ENTRY(__getcontext) | |
30 | ||
31 | /* Return value of getcontext. R0 is the only register whose | |
32 | value is not preserved. */ | |
33 | mov #0, r0 | |
34 | mov.l r0, @(oR0,r4) | |
35 | mov.l r1, @(oR1,r4) | |
36 | mov.l r2, @(oR2,r4) | |
37 | mov.l r3, @(oR3,r4) | |
38 | mov.l r4, @(oR4,r4) | |
39 | mov.l r5, @(oR5,r4) | |
40 | mov.l r6, @(oR6,r4) | |
41 | mov.l r7, @(oR7,r4) | |
42 | mov r4, r0 | |
43 | add #(oMACL+4), r0 | |
44 | sts.l macl, @-r0 | |
45 | sts.l mach, @-r0 | |
46 | stc.l gbr, @-r0 | |
47 | ||
48 | /* Save T flag to SR. */ | |
49 | movt r1 | |
50 | mov.l r1, @-r0 | |
51 | sts.l pr, @-r0 | |
52 | ||
53 | /* The return address of getcontext is the restart pc. */ | |
54 | sts.l pr, @-r0 | |
55 | ||
56 | mov.l r15, @-r0 | |
57 | mov.l r14, @-r0 | |
58 | mov.l r13, @-r0 | |
59 | mov.l r12, @-r0 | |
60 | mov.l r11, @-r0 | |
61 | mov.l r10, @-r0 | |
62 | mov.l r9, @-r0 | |
63 | mov.l r8, @-r0 | |
64 | ||
65 | mov r4, r0 | |
66 | /* We need 2 add instruction because oFPUL+4 > 127. */ | |
67 | add #124,r0 | |
68 | add #(oFPUL+4-124),r0 | |
69 | sts.l fpul, @-r0 | |
70 | sts.l fpscr, @-r0 | |
71 | frchg | |
72 | fmov.s fr15, @-r0 | |
73 | fmov.s fr14, @-r0 | |
74 | fmov.s fr13, @-r0 | |
75 | fmov.s fr12, @-r0 | |
76 | fmov.s fr11, @-r0 | |
77 | fmov.s fr10, @-r0 | |
78 | fmov.s fr9, @-r0 | |
79 | fmov.s fr8, @-r0 | |
80 | fmov.s fr7, @-r0 | |
81 | fmov.s fr6, @-r0 | |
82 | fmov.s fr5, @-r0 | |
83 | fmov.s fr4, @-r0 | |
84 | fmov.s fr3, @-r0 | |
85 | fmov.s fr2, @-r0 | |
86 | fmov.s fr1, @-r0 | |
87 | fmov.s fr0, @-r0 | |
88 | frchg | |
89 | fmov.s fr15, @-r0 | |
90 | fmov.s fr14, @-r0 | |
91 | fmov.s fr13, @-r0 | |
92 | fmov.s fr12, @-r0 | |
93 | fmov.s fr11, @-r0 | |
94 | fmov.s fr10, @-r0 | |
95 | fmov.s fr9, @-r0 | |
96 | fmov.s fr8, @-r0 | |
97 | fmov.s fr7, @-r0 | |
98 | fmov.s fr6, @-r0 | |
99 | fmov.s fr5, @-r0 | |
100 | fmov.s fr4, @-r0 | |
101 | fmov.s fr3, @-r0 | |
102 | fmov.s fr2, @-r0 | |
103 | fmov.s fr1, @-r0 | |
104 | fmov.s fr0, @-r0 | |
105 | ||
106 | /* sigprocmask (SIG_BLOCK, NULL, &uc->uc_sigmask). */ | |
107 | mov r4, r6 | |
108 | /* We need 2 add instruction because oSIGMASK > 127. */ | |
109 | add #(oSIGMASK/2), r6 | |
110 | add #(oSIGMASK/2), r6 | |
111 | mov #SIG_BLOCK, r4 | |
112 | mov #0, r5 | |
113 | mov #+SYS_ify(sigprocmask), r3 | |
114 | trapa #0x13 | |
115 | mov r0, r1 | |
116 | mov #-12, r2 | |
117 | shad r2, r1 | |
118 | not r1, r1 // r1=0 means r0 = -1 to -4095 | |
119 | tst r1, r1 // i.e. error in linux | |
120 | bf .Lgetcontext_end | |
121 | .Lsyscall_error: | |
122 | SYSCALL_ERROR_HANDLER | |
123 | .Lgetcontext_end: | |
124 | /* All done, return 0 for success. */ | |
125 | mov #0, r0 | |
126 | .Lpseudo_end: | |
127 | rts | |
128 | nop | |
129 | ||
130 | cfi_endproc | |
131 | PSEUDO_END(__getcontext) | |
132 | ||
133 | weak_alias (__getcontext, getcontext) |