194614Sobrien/*
294614Sobrien * Copyright (c) 1992, 1993
394614Sobrien *	The Regents of the University of California.  All rights reserved.
494614Sobrien *
594614Sobrien * This software was developed by the Computer Systems Engineering group
694614Sobrien * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
794614Sobrien * contributed to Berkeley.
894614Sobrien *
994614Sobrien * Redistribution and use in source and binary forms, with or without
1094614Sobrien * modification, are permitted provided that the following conditions
1194614Sobrien * are met:
1294614Sobrien * 1. Redistributions of source code must retain the above copyright
1394614Sobrien *    notice, this list of conditions and the following disclaimer.
1494614Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1594614Sobrien *    notice, this list of conditions and the following disclaimer in the
1694614Sobrien *    documentation and/or other materials provided with the distribution.
1794614Sobrien * 4. Neither the name of the University nor the names of its contributors
1894614Sobrien *    may be used to endorse or promote products derived from this software
1994614Sobrien *    without specific prior written permission.
2094614Sobrien *
2194614Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2294614Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2394614Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2494614Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2594614Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2694614Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2794614Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2894614Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2994614Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3094614Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3194614Sobrien * SUCH DAMAGE.
3294614Sobrien *
3394614Sobrien *	$Header: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp
3494614Sobrien */
3594614Sobrien
3694614Sobrien#if defined(LIBC_SCCS) && !defined(lint)
3794614Sobrien#if 0
3894614Sobrien	.asciz "@(#)_setjmp.s	8.1 (Berkeley) 6/4/93"
3994614Sobrien#else
4094614Sobrien	RCSID("$NetBSD: _setjmp.S,v 1.4 1998/10/08 02:27:59 eeh Exp $")
4194614Sobrien#endif
4294614Sobrien#endif /* LIBC_SCCS and not lint */
4394614Sobrien
4494614Sobrien#include <machine/asm.h>
4594614Sobrien__FBSDID("$FreeBSD$");
4694614Sobrien
4794614Sobrien#define	_JB_FP		0x0
4894614Sobrien#define	_JB_PC		0x8
4994614Sobrien#define	_JB_SP		0x10
5094614Sobrien
5194614Sobrien	.register %g2,#ignore
5294614Sobrien	.register %g3,#ignore
5394614Sobrien
5494614Sobrien/*
5594614Sobrien * C library -- setjmp, longjmp
5694614Sobrien *
5794614Sobrien *	longjmp(a,v)
5894614Sobrien * will generate a "return(v?v:1)" from
5994614Sobrien * the last call to
6094614Sobrien *	setjmp(a)
6194614Sobrien * by restoring the previous context.
6294614Sobrien */
6394614Sobrien
6499536SjakeENTRY(_setjmp)
6594614Sobrien	stx	%sp, [%o0 + _JB_SP]
6694614Sobrien	stx	%o7, [%o0 + _JB_PC]
6794614Sobrien	stx	%fp, [%o0 + _JB_FP]
6894614Sobrien	retl
6994614Sobrien	 clr	%o0
7099536SjakeEND(_setjmp)
7194614Sobrien
7299536SjakeENTRY(_longjmp)
7394614Sobrien	mov	1, %g1
7494614Sobrien	movrnz	%o1, %o1, %g1
7594614Sobrien	mov	%o0, %g2
7694614Sobrien	ldx	[%g2 + _JB_FP], %g3
7794614Sobrien1:	cmp	%fp, %g3
7894614Sobrien	bl,a	1b
7994614Sobrien	 restore
8094614Sobrien	be,a	2f
8194614Sobrien	 ldx	[%g2 + _JB_SP], %o0
8294614Sobrien
8394614Sobrien.Lbotch:
8494614Sobrien	illtrap
8594614Sobrien
8694614Sobrien2:	cmp	%o0, %sp
8794614Sobrien	bge,a	3f
8894614Sobrien	 mov	%o0, %sp
8994614Sobrien	b,a	.Lbotch
9094614Sobrien	 nop
9194614Sobrien3:	ldx	[%g2 + _JB_PC], %o7
9294614Sobrien	retl
9394614Sobrien	 mov	%g1, %o0
9499536SjakeEND(_longjmp)
95