]>
Commit | Line | Data |
---|---|---|
ff347533 | 1 | /* Save current context. |
d4697bc9 | 2 | Copyright (C) 2009-2014 Free Software Foundation, Inc. |
ff347533 JM |
3 | This file is part of the GNU C Library. |
4 | Contributed by Maciej W. Rozycki <macro@codesourcery.com>. | |
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/>. */ | |
ff347533 JM |
19 | |
20 | #include <sysdep.h> | |
21 | #include <sys/asm.h> | |
22 | #include <sys/fpregdef.h> | |
23 | #include <sys/regdef.h> | |
24 | ||
25 | #include "ucontext_i.h" | |
26 | ||
27 | /* int getcontext (ucontext_t *ucp) */ | |
28 | ||
29 | .text | |
43301bd3 | 30 | .set nomips16 |
ff347533 JM |
31 | LOCALSZ = 0 |
32 | MASK = 0x00000000 | |
33 | #ifdef __PIC__ | |
34 | LOCALSZ = 1 /* save gp */ | |
35 | # if _MIPS_SIM != _ABIO32 | |
36 | MASK = 0x10000000 | |
37 | # endif | |
38 | #endif | |
39 | FRAMESZ = ((LOCALSZ * SZREG) + ALSZ) & ALMASK | |
40 | GPOFF = FRAMESZ - (1 * SZREG) | |
41 | ||
42 | NESTED (__getcontext, FRAMESZ, ra) | |
43 | .mask MASK, 0 | |
44 | .fmask 0x00000000, 0 | |
45 | ||
46 | #ifdef __PIC__ | |
47 | SETUP_GP | |
48 | ||
49 | move a2, sp | |
50 | # define _SP a2 | |
51 | ||
52 | # if _MIPS_SIM != _ABIO32 | |
53 | move a3, gp | |
54 | # define _GP a3 | |
55 | # endif | |
56 | ||
57 | PTR_ADDIU sp, -FRAMESZ | |
aea7a9b9 JM |
58 | cfi_adjust_cfa_offset (FRAMESZ) |
59 | SETUP_GP64_STACK (GPOFF, __getcontext) | |
ff347533 JM |
60 | SAVE_GP (GPOFF) |
61 | ||
62 | #else /* ! __PIC__ */ | |
63 | # define _SP sp | |
64 | # define _GP gp | |
65 | ||
66 | #endif /* ! __PIC__ */ | |
67 | ||
68 | #ifdef PROF | |
69 | .set noat | |
70 | move AT, ra | |
71 | jal _mcount | |
72 | .set at | |
73 | #endif | |
74 | ||
75 | /* Store a magic flag. */ | |
76 | li v1, 1 | |
77 | REG_S v1, (0 * SZREG + MCONTEXT_GREGS)(a0) /* zero */ | |
78 | ||
79 | REG_S s0, (16 * SZREG + MCONTEXT_GREGS)(a0) | |
80 | REG_S s1, (17 * SZREG + MCONTEXT_GREGS)(a0) | |
81 | REG_S s2, (18 * SZREG + MCONTEXT_GREGS)(a0) | |
82 | REG_S s3, (19 * SZREG + MCONTEXT_GREGS)(a0) | |
83 | REG_S s4, (20 * SZREG + MCONTEXT_GREGS)(a0) | |
84 | REG_S s5, (21 * SZREG + MCONTEXT_GREGS)(a0) | |
85 | REG_S s6, (22 * SZREG + MCONTEXT_GREGS)(a0) | |
86 | REG_S s7, (23 * SZREG + MCONTEXT_GREGS)(a0) | |
87 | #if ! defined (__PIC__) || _MIPS_SIM != _ABIO32 | |
88 | REG_S _GP, (28 * SZREG + MCONTEXT_GREGS)(a0) | |
89 | #endif | |
90 | REG_S _SP, (29 * SZREG + MCONTEXT_GREGS)(a0) | |
91 | REG_S fp, (30 * SZREG + MCONTEXT_GREGS)(a0) | |
92 | REG_S ra, (31 * SZREG + MCONTEXT_GREGS)(a0) | |
93 | REG_S ra, MCONTEXT_PC(a0) | |
94 | ||
95 | #ifdef __mips_hard_float | |
96 | # if _MIPS_SIM == _ABI64 | |
97 | s.d fs0, (24 * SZREG + MCONTEXT_FPREGS)(a0) | |
98 | s.d fs1, (25 * SZREG + MCONTEXT_FPREGS)(a0) | |
99 | s.d fs2, (26 * SZREG + MCONTEXT_FPREGS)(a0) | |
100 | s.d fs3, (27 * SZREG + MCONTEXT_FPREGS)(a0) | |
101 | s.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(a0) | |
102 | s.d fs5, (29 * SZREG + MCONTEXT_FPREGS)(a0) | |
103 | s.d fs6, (30 * SZREG + MCONTEXT_FPREGS)(a0) | |
104 | s.d fs7, (31 * SZREG + MCONTEXT_FPREGS)(a0) | |
105 | ||
106 | # else /* _MIPS_SIM != _ABI64 */ | |
107 | s.d fs0, (20 * SZREG + MCONTEXT_FPREGS)(a0) | |
108 | s.d fs1, (22 * SZREG + MCONTEXT_FPREGS)(a0) | |
109 | s.d fs2, (24 * SZREG + MCONTEXT_FPREGS)(a0) | |
110 | s.d fs3, (26 * SZREG + MCONTEXT_FPREGS)(a0) | |
111 | s.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(a0) | |
112 | s.d fs5, (30 * SZREG + MCONTEXT_FPREGS)(a0) | |
113 | ||
114 | # endif /* _MIPS_SIM != _ABI64 */ | |
115 | ||
116 | cfc1 v1, fcr31 | |
117 | sw v1, MCONTEXT_FPC_CSR(a0) | |
118 | #endif /* __mips_hard_float */ | |
119 | ||
120 | /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */ | |
121 | li a3, _NSIG8 | |
122 | PTR_ADDU a2, a0, UCONTEXT_SIGMASK | |
123 | move a1, zero | |
124 | li a0, SIG_BLOCK | |
125 | ||
126 | li v0, SYS_ify (rt_sigprocmask) | |
127 | syscall | |
128 | bnez a3, 99f | |
aea7a9b9 | 129 | cfi_remember_state |
ff347533 JM |
130 | |
131 | #ifdef __PIC__ | |
aea7a9b9 | 132 | RESTORE_GP64_STACK |
ff347533 | 133 | PTR_ADDIU sp, FRAMESZ |
aea7a9b9 | 134 | cfi_adjust_cfa_offset (-FRAMESZ) |
ff347533 JM |
135 | #endif |
136 | move v0, zero | |
137 | jr ra | |
138 | ||
139 | 99: | |
aea7a9b9 | 140 | cfi_restore_state |
ff347533 JM |
141 | #ifdef __PIC__ |
142 | PTR_LA t9, JUMPTARGET (__syscall_error) | |
aea7a9b9 | 143 | RESTORE_GP64_STACK |
ff347533 | 144 | PTR_ADDIU sp, FRAMESZ |
aea7a9b9 | 145 | cfi_adjust_cfa_offset (-FRAMESZ) |
ff347533 JM |
146 | jr t9 |
147 | ||
148 | #else /* ! __PIC__ */ | |
149 | ||
150 | j JUMPTARGET (__syscall_error) | |
151 | #endif /* ! __PIC__ */ | |
152 | PSEUDO_END (__getcontext) | |
153 | ||
154 | weak_alias (__getcontext, getcontext) |