]>
Commit | Line | Data |
---|---|---|
688903eb | 1 | /* Copyright (C) 2011-2018 Free Software Foundation, Inc. |
63d143a2 CM |
2 | This file is part of the GNU C Library. |
3 | Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. | |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
ab84e3ff PE |
16 | License along with the GNU C Library. If not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
63d143a2 CM |
18 | |
19 | #include <sysdep.h> | |
20 | #include <arch/abi.h> | |
21 | ||
22 | #include "ucontext_i.h" | |
23 | ||
24 | /* int getcontext (ucontext_t *ucp) */ | |
25 | ||
26 | .text | |
27 | ENTRY (__getcontext) | |
28 | FEEDBACK_ENTER(__getcontext) | |
29 | ||
30 | /* Save the callee-saved GPRs. There's no need to save the | |
31 | caller-saved GPRs since the eventual setcontext() or | |
32 | swapcontext() will assume those registers are all dead. | |
33 | Save value "1" to uc_flags to later recognize getcontext(). */ | |
34 | { movei r11, 1; ADDI_PTR r10, r0, UC_FLAGS_OFFSET } | |
0adc5f38 | 35 | { ST_PTR r10, r11; addli r10, r0, UC_REG(30) } |
8d2d239c AZ |
36 | { st r10, r30; ADDI_PTR r10, r10, REGSIZE } |
37 | { st r10, r31; ADDI_PTR r10, r10, REGSIZE } | |
38 | { st r10, r32; ADDI_PTR r10, r10, REGSIZE } | |
39 | { st r10, r33; ADDI_PTR r10, r10, REGSIZE } | |
40 | { st r10, r34; ADDI_PTR r10, r10, REGSIZE } | |
41 | { st r10, r35; ADDI_PTR r10, r10, REGSIZE } | |
42 | { st r10, r36; ADDI_PTR r10, r10, REGSIZE } | |
43 | { st r10, r37; ADDI_PTR r10, r10, REGSIZE } | |
44 | { st r10, r38; ADDI_PTR r10, r10, REGSIZE } | |
45 | { st r10, r39; ADDI_PTR r10, r10, REGSIZE } | |
46 | { st r10, r40; ADDI_PTR r10, r10, REGSIZE } | |
47 | { st r10, r41; ADDI_PTR r10, r10, REGSIZE } | |
48 | { st r10, r42; ADDI_PTR r10, r10, REGSIZE } | |
49 | { st r10, r43; ADDI_PTR r10, r10, REGSIZE } | |
50 | { st r10, r44; ADDI_PTR r10, r10, REGSIZE } | |
51 | { st r10, r45; ADDI_PTR r10, r10, REGSIZE } | |
52 | { st r10, r46; ADDI_PTR r10, r10, REGSIZE } | |
53 | { st r10, r47; ADDI_PTR r10, r10, REGSIZE } | |
54 | { st r10, r48; ADDI_PTR r10, r10, REGSIZE } | |
55 | { st r10, r49; ADDI_PTR r10, r10, REGSIZE } | |
56 | { st r10, r50; ADDI_PTR r10, r10, REGSIZE } | |
57 | { st r10, r51; ADDI_PTR r10, r10, REGSIZE } | |
58 | { st r10, r52; ADDI_PTR r10, r10, REGSIZE } | |
59 | { st r10, tp; ADDI_PTR r10, r10, REGSIZE } | |
60 | { st r10, sp; ADDI_PTR r10, r10, REGSIZE } | |
61 | { st r10, lr; ADDI_PTR r10, r10, REGSIZE } | |
63d143a2 CM |
62 | lnk r11 /* Point PC at the "jrp lr" instruction. */ |
63 | addli r11, r11, .Lreturn - . | |
8d2d239c | 64 | { st r10, r11; ADDI_PTR r10, r10, REGSIZE } |
63d143a2 CM |
65 | mfspr r11, INTERRUPT_CRITICAL_SECTION |
66 | { | |
8d2d239c | 67 | st r10, r11 |
63d143a2 CM |
68 | movei r1, 0 |
69 | } | |
70 | ||
71 | /* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG / 8) */ | |
72 | { | |
73 | movei r3, _NSIG / 8 | |
74 | addli r2, r0, UC_SIGMASK_OFFSET | |
75 | } | |
76 | { | |
77 | movei r0, SIG_BLOCK | |
78 | moveli TREG_SYSCALL_NR_NAME, __NR_rt_sigprocmask | |
79 | } | |
80 | swint1 | |
8d2d239c | 81 | bnez r1, .Lsyscall_error |
63d143a2 CM |
82 | |
83 | .Lreturn: | |
84 | { | |
85 | movei r0, 0 | |
86 | jrp lr | |
87 | } | |
88 | ||
89 | .Lsyscall_error: | |
90 | j SYSCALL_ERROR_NAME | |
91 | ||
92 | END (__getcontext) | |
93 | .hidden __getcontext | |
94 | ||
95 | weak_alias (__getcontext, getcontext) |