__setjmp14.S revision 1.1 1 /* $NetBSD: __setjmp14.S,v 1.1 1998/09/29 03:01:37 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 (at) 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
30 #include <machine/asm.h>
31
32 /*
33 * C library -- setjmp, longjmp
34 *
35 * longjmp(a,v)
36 * will generate a "return(v)" from
37 * the last call to
38 * setjmp(a)
39 * by restoring registers from the stack,
40 * and the previous signal state.
41 */
42
43 .set noreorder
44
45 LEAF(__setjmp14, 1)
46 LDGP(pv)
47 stq ra, (2 * 8)(a0) /* sc_pc = return address */
48 stq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */
49 stq s1, ((10 + 4) * 8)(a0)
50 stq s2, ((11 + 4) * 8)(a0)
51 stq s3, ((12 + 4) * 8)(a0)
52 stq s4, ((13 + 4) * 8)(a0)
53 stq s5, ((14 + 4) * 8)(a0)
54 stq s6, ((15 + 4) * 8)(a0)
55 stq ra, ((26 + 4) * 8)(a0)
56 stq sp, ((30 + 4) * 8)(a0)
57
58 /*
59 * get signal information
60 */
61 mov a0, s0 /* squirrel away ptr to sc */
62
63 /* see what's blocked */
64 mov zero, a0 /* how (insignificant) */
65 mov zero, a1 /* set (NULL) */
66 lda a2, 648(s0) /* point to mask in sc */
67 CALL(__sigprocmask14)
68
69 lda sp, -24(sp) /* sizeof struct sigaltstack */
70 mov zero, a0
71 mov sp, a1
72 CALL(__sigaltstack14)
73 ldl t0, 16(sp) /* offset of ss_flags */
74 lda sp, 24(sp) /* sizeof struct sigaltstack */
75 ldq ra, ((26 + 4) * 8)(s0) /* restore return address */
76 blt v0, botch /* check for error */
77 and t0, 0x1, t0 /* get SA_ONSTACK flag */
78 stq t0, (0 * 8)(s0) /* and save it in sc_onstack */
79 /*
80 * Restore old s0 and a0, and continue saving registers
81 */
82 mov s0, a0
83 ldq s0, (( 9 + 4) * 8)(a0)
84
85 ldiq t0, 0xacedbade /* sigcontext magic number */
86 stq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */
87 /* Too bad we can't check if we actually used FP */
88 ldiq t0, 1
89 stq t0, (36 * 8)(a0) /* say we've used FP. */
90 stt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */
91 stt fs1, ((3 + 37) * 8)(a0)
92 stt fs2, ((4 + 37) * 8)(a0)
93 stt fs3, ((5 + 37) * 8)(a0)
94 stt fs4, ((6 + 37) * 8)(a0)
95 stt fs5, ((7 + 37) * 8)(a0)
96 stt fs6, ((8 + 37) * 8)(a0)
97 stt fs7, ((9 + 37) * 8)(a0)
98 mf_fpcr ft0 /* get FP control reg */
99 stt ft0, (69 * 8)(a0) /* and store it in sc_fpcr */
100 stq zero, (70 * 8)(a0) /* FP software control XXX */
101 stq zero, (71 * 8)(a0) /* sc_reserved[0] */
102 stq zero, (72 * 8)(a0) /* sc_reserved[1] */
103 stq zero, (73 * 8)(a0) /* sc_xxx[0] */
104 stq zero, (74 * 8)(a0) /* sc_xxx[1] */
105 stq zero, (75 * 8)(a0) /* sc_xxx[2] */
106 stq zero, (76 * 8)(a0) /* sc_xxx[3] */
107 stq zero, (77 * 8)(a0) /* sc_xxx[4] */
108 stq zero, (78 * 8)(a0) /* sc_xxx[5] */
109 stq zero, (79 * 8)(a0) /* sc_xxx[6] */
110 stq zero, (80 * 8)(a0) /* sc_xxx[7] */
111
112 mov zero, v0 /* return zero */
113 RET
114 END(__setjmp14)
115
116 LEAF(__longjmp14, 2)
117 LDGP(pv)
118 stq a1, (( 0 + 4) * 8)(a0) /* save return value */
119 CALL(__sigreturn14) /* use sigreturn to return */
120
121 botch:
122 CALL(longjmperror)
123 CALL(abort)
124 RET /* "can't" get here... */
125 END(__longjmp14)
126