Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / lib / libcr / alpha / gen / setjmp.S
1 /*      $NetBSD: setjmp.S,v 1.3 1997/12/05 02:06:27 thorpej Exp $       */
2
3 /*
4  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
5  * All rights reserved.
6  *
7  * Author: Chris G. Demetriou
8  * 
9  * Permission to use, copy, modify and distribute this software and
10  * its documentation is hereby granted, provided that both the copyright
11  * notice and this permission notice appear in all copies of the
12  * software, derivative works or modified versions, and any portions
13  * thereof, and that both notices appear in supporting documentation.
14  * 
15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 
16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 
17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18  * 
19  * Carnegie Mellon requests users of this software to return to
20  *
21  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22  *  School of Computer Science
23  *  Carnegie Mellon University
24  *  Pittsburgh PA 15213-3890
25  *
26  * any improvements or extensions that they make and grant Carnegie the
27  * rights to redistribute these changes.
28  *
29  * $FreeBSD: src/lib/libc/alpha/gen/setjmp.S,v 1.11.2.3 2002/11/13 06:08:44 fjoe Exp $
30  * $DragonFly: src/lib/libcr/alpha/gen/Attic/setjmp.S,v 1.2 2003/06/17 04:26:41 dillon Exp $
31  */
32
33 #include "SYS.h"
34
35 /*
36  * C library -- setjmp, longjmp
37  *
38  *      longjmp(a,v)
39  * will generate a "return(v)" from
40  * the last call to
41  *      setjmp(a)
42  * by restoring registers from the stack,
43  * and the previous signal state.
44  */
45
46         .set    noreorder
47
48 LEAF(setjmp, 1)
49         LDGP(pv)
50         stq     ra, (2 * 8)(a0)                 /* sc_pc = return address */
51         stq     s0, (( 9 + 4) * 8)(a0)          /* saved bits of sc_regs */
52         stq     s1, ((10 + 4) * 8)(a0)
53         stq     s2, ((11 + 4) * 8)(a0)
54         stq     s3, ((12 + 4) * 8)(a0)
55         stq     s4, ((13 + 4) * 8)(a0)
56         stq     s5, ((14 + 4) * 8)(a0)
57         stq     s6, ((15 + 4) * 8)(a0)
58         stq     ra, ((26 + 4) * 8)(a0)
59         stq     t12,((27 + 4) * 8)(a0)
60         stq     sp, ((30 + 4) * 8)(a0)
61
62         /*
63          * get signal information
64          */
65         mov     a0, s0                          /* squirrel away ptr to sc */
66
67         /* see what's blocked */
68         lda     a2, (71 * 8)(a0)                /* oset: sc_reserved */
69         mov     zero, a1                        /* set:  NULL */
70         addq    a1, 1, a0                       /* how:  SIG_BLOCK */
71         PCALL(sigprocmask)                      /* see what's blocked */
72
73         lda     sp, -24(sp)                     /* sizeof struct sigaltstack */
74         mov     zero, a0
75         mov     sp, a1
76         CALL(sigaltstack)
77         ldl     t0, 16(sp)                      /* offset of ss_flags */
78         lda     sp, 24(sp)                      /* sizeof struct sigaltstack */
79         ldq     ra, ((26 + 4) * 8)(s0)          /* restore return address */
80         blt     v0, botch                       /* check for error */
81         and     t0, 0x1, t0                     /* get SA_ONSTACK flag */
82         stq     t0, (0 * 8)(s0)                 /* and save it in sc_onstack */
83         /*
84          * Restore old s0 and a0, and continue saving registers
85          */
86         mov     s0, a0
87         ldq     s0, (( 9 + 4) * 8)(a0)
88
89         ldiq    t0, 0xacedbade                  /* sigcontext magic number */
90         stq     t0, ((31 + 4) * 8)(a0)          /* magic in sc_regs[31] */
91         /* Too bad we can't check if we actually used FP */
92         ldiq    t0, 1
93         stq     t0, (36 * 8)(a0)                /* say we've used FP.  */
94         stt     fs0, ((2 + 37) * 8)(a0)         /* saved bits of sc_fpregs */
95         stt     fs1, ((3 + 37) * 8)(a0)
96         stt     fs2, ((4 + 37) * 8)(a0)
97         stt     fs3, ((5 + 37) * 8)(a0)
98         stt     fs4, ((6 + 37) * 8)(a0)
99         stt     fs5, ((7 + 37) * 8)(a0)
100         stt     fs6, ((8 + 37) * 8)(a0)
101         stt     fs7, ((9 + 37) * 8)(a0)
102         mf_fpcr ft0                             /* get FP control reg */
103         stt     ft0, (69 * 8)(a0)               /* and store it in sc_fpcr */
104         stq     zero, (70 * 8)(a0)              /* FP software control XXX */
105         stq     zero, (71 * 8)(a0)              /* sc_reserved[0] */
106         stq     zero, (72 * 8)(a0)              /* sc_reserved[1] */
107         stq     zero, (73 * 8)(a0)              /* sc_xxx[0] */
108         stq     zero, (74 * 8)(a0)              /* sc_xxx[1] */
109         stq     zero, (75 * 8)(a0)              /* sc_xxx[2] */
110         stq     zero, (76 * 8)(a0)              /* sc_xxx[3] */
111         stq     zero, (77 * 8)(a0)              /* sc_xxx[4] */
112         stq     zero, (78 * 8)(a0)              /* sc_xxx[5] */
113         stq     zero, (79 * 8)(a0)              /* sc_xxx[6] */
114         stq     zero, (80 * 8)(a0)              /* sc_xxx[7] */
115
116         mov     zero, v0                        /* return zero */
117         RET
118 END(setjmp)
119
120 #ifdef _THREAD_SAFE
121 LEAF(__longjmp, 2)
122 #else
123 XLEAF(__longjmp, 2)
124 LEAF(longjmp, 2)
125 #endif
126         LDGP(pv)
127         stq     a1, (( 0 + 4) * 8)(a0)          /* save return value */
128         CALL(sigreturn)                         /* use sigreturn to return */
129
130 botch:
131         CALL(longjmperror)
132         CALL(abort)
133         RET                                     /* "can't" get here... */
134 #ifdef _THREAD_SAFE
135 END(__longjmp)
136 #else
137 END(longjmp)
138 #endif