1 /* Save current context.
2 Copyright (C) 2009 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Maciej W. Rozycki <macro@codesourcery.com>.
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.
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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
22 #include <sys/fpregdef.h>
23 #include <sys/regdef.h>
25 #include "ucontext_i.h"
27 /* int getcontext (ucontext_t *ucp) */
33 LOCALSZ = 1 /* save gp */
34 # if _MIPS_SIM != _ABIO32
38 FRAMESZ = ((LOCALSZ * SZREG) + ALSZ) & ALMASK
39 GPOFF = FRAMESZ - (1 * SZREG)
41 NESTED (__getcontext, FRAMESZ, ra)
51 # if _MIPS_SIM != _ABIO32
56 PTR_ADDIU sp, -FRAMESZ
57 SETUP_GP64 (GPOFF, __getcontext)
64 #endif /* ! __PIC__ */
73 /* Store a magic flag. */
75 REG_S v1, (0 * SZREG + MCONTEXT_GREGS)(a0) /* zero */
77 REG_S s0, (16 * SZREG + MCONTEXT_GREGS)(a0)
78 REG_S s1, (17 * SZREG + MCONTEXT_GREGS)(a0)
79 REG_S s2, (18 * SZREG + MCONTEXT_GREGS)(a0)
80 REG_S s3, (19 * SZREG + MCONTEXT_GREGS)(a0)
81 REG_S s4, (20 * SZREG + MCONTEXT_GREGS)(a0)
82 REG_S s5, (21 * SZREG + MCONTEXT_GREGS)(a0)
83 REG_S s6, (22 * SZREG + MCONTEXT_GREGS)(a0)
84 REG_S s7, (23 * SZREG + MCONTEXT_GREGS)(a0)
85 #if ! defined (__PIC__) || _MIPS_SIM != _ABIO32
86 REG_S _GP, (28 * SZREG + MCONTEXT_GREGS)(a0)
88 REG_S _SP, (29 * SZREG + MCONTEXT_GREGS)(a0)
89 REG_S fp, (30 * SZREG + MCONTEXT_GREGS)(a0)
90 REG_S ra, (31 * SZREG + MCONTEXT_GREGS)(a0)
91 REG_S ra, MCONTEXT_PC(a0)
93 #ifdef __mips_hard_float
94 # if _MIPS_SIM == _ABI64
95 s.d fs0, (24 * SZREG + MCONTEXT_FPREGS)(a0)
96 s.d fs1, (25 * SZREG + MCONTEXT_FPREGS)(a0)
97 s.d fs2, (26 * SZREG + MCONTEXT_FPREGS)(a0)
98 s.d fs3, (27 * SZREG + MCONTEXT_FPREGS)(a0)
99 s.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(a0)
100 s.d fs5, (29 * SZREG + MCONTEXT_FPREGS)(a0)
101 s.d fs6, (30 * SZREG + MCONTEXT_FPREGS)(a0)
102 s.d fs7, (31 * SZREG + MCONTEXT_FPREGS)(a0)
104 # else /* _MIPS_SIM != _ABI64 */
105 s.d fs0, (20 * SZREG + MCONTEXT_FPREGS)(a0)
106 s.d fs1, (22 * SZREG + MCONTEXT_FPREGS)(a0)
107 s.d fs2, (24 * SZREG + MCONTEXT_FPREGS)(a0)
108 s.d fs3, (26 * SZREG + MCONTEXT_FPREGS)(a0)
109 s.d fs4, (28 * SZREG + MCONTEXT_FPREGS)(a0)
110 s.d fs5, (30 * SZREG + MCONTEXT_FPREGS)(a0)
112 # endif /* _MIPS_SIM != _ABI64 */
115 sw v1, MCONTEXT_FPC_CSR(a0)
116 #endif /* __mips_hard_float */
118 /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8) */
120 PTR_ADDU a2, a0, UCONTEXT_SIGMASK
124 li v0, SYS_ify (rt_sigprocmask)
130 PTR_ADDIU sp, FRAMESZ
137 PTR_LA t9, JUMPTARGET (__syscall_error)
139 PTR_ADDIU sp, FRAMESZ
142 #else /* ! __PIC__ */
144 j JUMPTARGET (__syscall_error)
145 #endif /* ! __PIC__ */
146 PSEUDO_END (__getcontext)
148 weak_alias (__getcontext, getcontext)