Update copyright notices with scripts/update-copyrights
[glibc.git] / ports / sysdeps / unix / sysv / linux / m68k / m680x0 / setcontext.S
blob9242c55e87206ee56997710c2f4f9fef2fe3c4b5
1 /* Install given context.
2    Copyright (C) 2012-2014 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    <http://www.gnu.org/licenses/>.  */
19 #include <sysdep.h>
21 #include "ucontext_i.h"
23 ENTRY(__setcontext)
24         /* Load address of the context data structure.  */
25         move.l  4(%sp), %a0
27         /* Get the current signal mask.  Note that we preserve D2/D3 in case
28            the system call fails and we return from the function with an
29            error.  */
30         move.l  %d3, -(%sp)
31         cfi_adjust_cfa_offset (4)
32         cfi_rel_offset (%d3, 0)
33         move.l  %d2, -(%sp)
34         cfi_adjust_cfa_offset (4)
35         cfi_rel_offset (%d2, 0)
36         clr.l   %d3
37         lea     oSIGMASK(%a0), %a1
38         move.l  %a1, %d2
39         move.l  #SIG_SETMASK, %d1
40         move.l  #__NR_sigprocmask, %d0
41         trap    #0
42         cmp.l   #-4095, %d0             /* Check %d0 for error.  */
43         jcs     0f
44         move.l  (%sp)+, %d2
45         cfi_adjust_cfa_offset (-4)
46         cfi_restore (d2)
47         move.l  (%sp)+, %d3
48         cfi_adjust_cfa_offset (-4)
49         cfi_restore (d3)
50         jra     SYSCALL_ERROR_LABEL     /* Jump to error handler if error.  */
52 0:      /* Load the new stack pointer.  */
53         move.l  oSP(%a0), %sp
54         cfi_def_cfa (%a0, 0)
55         cfi_offset (%d2, oGREGS+2*4)
56         cfi_offset (%d3, oGREGS+3*4)
57         cfi_offset (%d4, oGREGS+4*4)
58         cfi_offset (%d5, oGREGS+5*4)
59         cfi_offset (%d6, oGREGS+6*4)
60         cfi_offset (%d7, oGREGS+7*4)
61         cfi_offset (%a2, oGREGS+10*4)
62         cfi_offset (%a3, oGREGS+11*4)
63         cfi_offset (%a4, oGREGS+12*4)
64         cfi_offset (%a5, oGREGS+13*4)
65         cfi_offset (%a6, oGREGS+14*4)
66         cfi_offset (%fp2, oFP2+0*12)
67         cfi_offset (%fp3, oFP2+1*12)
68         cfi_offset (%fp4, oFP2+2*12)
69         cfi_offset (%fp5, oFP2+3*12)
70         cfi_offset (%fp6, oFP2+4*12)
71         cfi_offset (%fp7, oFP2+5*12)
72         cfi_offset (%pc, oPC)
74         /* Load the values of all the preserved registers (except SP).  */
75         movem.l oGREGS+2*4(%a0), %d2-%d7
76         movem.l oGREGS+10*4(%a0), %a2-%a6
77         fmovem.l oFPREGS(%a0), %fpsr/%fpcr/%fpiar
78         fmovem.x oFP2(%a0), %fp2-%fp7
79         clr.l   %d0
81         /* Fetch the address to return to.  */
82         movl    oPC(%a0), %a1
84         /* End FDE here, we fall into another context.  */
85         cfi_endproc
86         cfi_startproc
87         cfi_register (%pc, %a1)
89         jmp     (%a1)
91         cfi_offset (%pc, -4)
92 PSEUDO_END(__setcontext)
94 weak_alias (__setcontext, setcontext)