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