1 /* Save current context and install the given one.
2 Copyright (C) 2008-2015 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, see
18 <http://www.gnu.org/licenses/>. */
23 #include "ucontext_i.h"
26 /* int __swapcontext (ucontext_t *oucp, const ucontext_t *ucp);
28 Saves the machine context in oucp such that when it is activated,
29 it appears as if __swapcontext() returned again, restores the
30 machine context in ucp and thereby resumes execution in that
33 This implementation is intended to be used for *synchronous* context
34 switches only. Therefore, it does not have to save anything
35 other than the PRESERVED state. */
40 st %g0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_PSR]
42 st %o0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_PC]
44 st %o0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_NPC]
46 st %o1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_Y]
47 st %g1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G1]
48 st %g2, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G2]
49 st %g3, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G3]
50 st %g4, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G4]
51 st %g5, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G5]
52 st %g6, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G6]
53 st %g7, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G7]
54 st %g0, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O0]
55 st %i1, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O1]
56 st %i2, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O2]
57 st %i3, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O3]
58 st %i4, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O4]
59 st %i5, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O5]
60 st %i6, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O6]
61 st %i7, [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O7]
62 st %g0, [%i0 + UC_MCONTEXT + MC_GWINS]
63 stb %g0, [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_EN]
64 st %g0, [%i0 + UC_MCONTEXT + MC_XRS + XRS_ID]
65 st %g0, [%i0 + UC_MCONTEXT + MC_XRS + XRS_PTR]
68 add %i1, UC_SIGMASK, %o1
69 add %i0, UC_SIGMASK, %o2
71 mov __NR_rt_sigprocmask, %g1
75 ldub [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_EN], %g1
79 ld [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_FSR], %fsr
80 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D0], %f0
81 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D2], %f2
82 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D4], %f4
83 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D6], %f6
84 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D8], %f8
85 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D10], %f10
86 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D12], %f12
87 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D14], %f14
88 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D16], %f16
89 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D18], %f18
90 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D20], %f20
91 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D22], %f22
92 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D24], %f24
93 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D26], %f26
94 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D28], %f28
95 ldd [%i0 + UC_MCONTEXT + MC_FPREGS + FPU_D30], %f30
97 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_Y], %g1
99 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G2], %g2
100 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G3], %g3
101 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G4], %g4
102 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G5], %g5
103 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G6], %g6
104 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_G7], %g7
105 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O1], %i1
106 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O2], %i2
107 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O3], %i3
108 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O4], %i4
109 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O5], %i5
110 ld [%i0 + UC_MCONTEXT + MC_GREGS + GREG_O6], %i6
112 ld [%o0 + UC_MCONTEXT + MC_GREGS + GREG_O7], %o7
113 ld [%o0 + UC_MCONTEXT + MC_GREGS + GREG_PC], %g1
115 ld [%o0 + UC_MCONTEXT + MC_GREGS + GREG_O0], %o0
118 weak_alias (__swapcontext, swapcontext)