1 /* Save current context.
2 Copyright (C) 2008 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by David S. Miller <davem@davemloft.net>, 2008.
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, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 #include "ucontext_i.h"
25 /* int __getcontext (ucontext_t *ucp)
27 Saves the machine context in UCP such that when it is activated,
28 it appears as if __getcontext() returned again.
30 This implementation is intended to be used for *synchronous* context
31 switches only. Therefore, it does not have to save anything
32 other than the PRESERVED state. */
37 st %g0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_PSR]
39 /* In reality, we only use the GREG_PC value when setting
40 or swapping contexts. But we fill in NPC for completeness. */
42 st %o0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_PC]
44 st %o0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_NPC]
47 st %o1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_Y]
49 st %g1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G1]
50 st %g2, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G2]
51 st %g3, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G3]
52 st %g4, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G4]
53 st %g5, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G5]
54 st %g6, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G6]
55 st %g7, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G7]
59 add %i0, UC_SIGMASK, %o2
61 mov __NR_rt_sigprocmask, %g1
64 /* Zero, success, return value. */
65 st %g0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O0]
66 st %i1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O1]
67 st %i2, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O2]
68 st %i3, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O3]
69 st %i4, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O4]
70 st %i5, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O5]
71 st %i6, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O6]
72 st %i7, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O7]
74 st %g0, [%i0 + UC_MCONTEXT + MC_GWINS]
76 /* Do not save FPU state, it is volatile across calls. */
77 stb %g0, [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_EN]
79 st %g0, [%i0 + UC_MCONTEXT + MC_XRS + XRS_ID]
80 st %g0, [%i0 + UC_MCONTEXT + MC_XRS + XRS_PTR]
85 weak_alias (__getcontext, getcontext)