1 /* Save current context. C-SKY ABIV2 version.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <https://www.gnu.org/licenses/>. */
21 #include "ucontext_i.h"
23 /* int getcontext (ucontext_t *ucp) */
26 /* No need to save r2-r7 or a0-a3. */
29 addi a0, MCONTEXT_CSKY_R4
31 stm r4-r13, (a0) /* Save r4-r13. */
32 stw sp, (t0, MCONTEXT_CSKY_SP) /* Save sp. */
33 stw r15, (t0, MCONTEXT_CSKY_LR) /* Save lr. */
34 stw r15, (t0, MCONTEXT_CSKY_PC) /* Return to PC. */
35 addi a0, t0, MCONTEXT_CSKY_R16
36 stm r16-r31, (a0) /* Save r16-r31. */
38 stw a0, (t0, MCONTEXT_CSKY_A0) /* Return zero. */
41 stw t0, (sp, 0) /* Save t0 after "save sp". */
43 /* __sigprocmask (SIG_BLOCK, NULL, &(ucontext->uc_sigmask)) */
46 addi a2, t0, UCONTEXT_SIGMASK
48 /* Do sigprocmask syscall. */
56 lrw a3, __sigprocmask@PLT
57 ldr.w a3, (gb, a3 << 0)
67 /* Restore r15 for sigprocmask changes. */
68 ldw r15, (t0, MCONTEXT_CSKY_LR)
69 movi a0, 0 /* Return 0. */
73 weak_alias (__getcontext, getcontext)