Home | History | Annotate | Line # | Download | only in gen
setjmp.S revision 1.7
      1  1.7  christos /*	$NetBSD: setjmp.S,v 1.7 2005/10/16 17:15:38 christos Exp $	*/
      2  1.1       eeh 
      3  1.1       eeh /*
      4  1.1       eeh  * Copyright (c) 1992, 1993
      5  1.1       eeh  *	The Regents of the University of California.  All rights reserved.
      6  1.1       eeh  *
      7  1.1       eeh  * This software was developed by the Computer Systems Engineering group
      8  1.1       eeh  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      9  1.1       eeh  * contributed to Berkeley.
     10  1.1       eeh  *
     11  1.1       eeh  * Redistribution and use in source and binary forms, with or without
     12  1.1       eeh  * modification, are permitted provided that the following conditions
     13  1.1       eeh  * are met:
     14  1.1       eeh  * 1. Redistributions of source code must retain the above copyright
     15  1.1       eeh  *    notice, this list of conditions and the following disclaimer.
     16  1.1       eeh  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.1       eeh  *    notice, this list of conditions and the following disclaimer in the
     18  1.1       eeh  *    documentation and/or other materials provided with the distribution.
     19  1.5       agc  * 3. Neither the name of the University nor the names of its contributors
     20  1.1       eeh  *    may be used to endorse or promote products derived from this software
     21  1.1       eeh  *    without specific prior written permission.
     22  1.1       eeh  *
     23  1.1       eeh  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  1.1       eeh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.1       eeh  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.1       eeh  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  1.1       eeh  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.1       eeh  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.1       eeh  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.1       eeh  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.1       eeh  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.1       eeh  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.1       eeh  * SUCH DAMAGE.
     34  1.1       eeh  *
     35  1.1       eeh  * from: Header: setjmp.s,v 1.2 92/06/25 03:18:43 torek Exp
     36  1.1       eeh  */
     37  1.1       eeh 
     38  1.3       eeh #define _LOCORE
     39  1.1       eeh #include <machine/asm.h>
     40  1.3       eeh #include <machine/frame.h>
     41  1.1       eeh #if defined(LIBC_SCCS) && !defined(lint)
     42  1.1       eeh #if 0
     43  1.1       eeh 	.asciz "@(#)setjmp.s	8.1 (Berkeley) 6/4/93"
     44  1.1       eeh #else
     45  1.7  christos 	RCSID("$NetBSD: setjmp.S,v 1.7 2005/10/16 17:15:38 christos Exp $")
     46  1.1       eeh #endif
     47  1.1       eeh #endif /* LIBC_SCCS and not lint */
     48  1.1       eeh 
     49  1.1       eeh /*
     50  1.7  christos  * C library -- setjmp
     51  1.1       eeh  *
     52  1.7  christos  *	__longjmp14(a,v)
     53  1.1       eeh  * will generate a "return(v)" from
     54  1.1       eeh  * the last call to
     55  1.1       eeh  *	setjmp(a)
     56  1.1       eeh  * by restoring registers from the stack,
     57  1.1       eeh  * and a struct sigcontext, see <signal.h>
     58  1.1       eeh  */
     59  1.1       eeh 
     60  1.1       eeh #include "SYS.h"
     61  1.1       eeh 
     62  1.7  christos 	.register %g2,#ignore
     63  1.7  christos 	.register %g3,#ignore
     64  1.7  christos 	.register %g6,#ignore
     65  1.7  christos 
     66  1.7  christos ENTRY(__setjmp14)
     67  1.7  christos 	save	%sp, -CC64FSZ, %sp
     68  1.7  christos 
     69  1.7  christos 	/* save globals into locals */
     70  1.7  christos 	mov	%g1, %l1
     71  1.7  christos 	mov	%g2, %l2
     72  1.7  christos 	mov	%g3, %l3
     73  1.7  christos 	mov	%g4, %l4
     74  1.7  christos 	mov	%g5, %l5
     75  1.7  christos 	mov	%g6, %l6
     76  1.7  christos 	mov	%g7, %l7
     77  1.7  christos 
     78  1.7  christos #ifdef PIC
     79  1.7  christos 	PIC_PROLOGUE(%i1, %o4)
     80  1.7  christos #endif
     81  1.7  christos 
     82  1.7  christos 	/* now get sigmask and onstack flag */
     83  1.7  christos 	add	%i0, 0x38, %o2		/* build sigcontext in [%o2]->sc.sc_mask */
     84  1.3       eeh 	mov	1, %o0			/* SIG_BLOCK */
     85  1.7  christos 					/* sigprocmask(SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)a) */
     86  1.7  christos #ifdef PIC
     87  1.7  christos #ifdef BIGPIC
     88  1.7  christos 	set	_C_LABEL(__sigprocmask14), %o4
     89  1.7  christos 	ldx	[%i1 + %o4], %g2
     90  1.7  christos #else
     91  1.7  christos 	ldx	[%i1 + _C_LABEL(__sigprocmask14)], %g2
     92  1.7  christos #endif
     93  1.7  christos 	call	%g2
     94  1.7  christos #else
     95  1.7  christos 	call	_C_LABEL(__sigprocmask14)
     96  1.7  christos #endif
     97  1.7  christos 	 clr	%o1
     98  1.7  christos 
     99  1.3       eeh 	clr	%o0			/* sigstack(NULL, &foo) */
    100  1.7  christos #ifdef PIC
    101  1.7  christos #ifdef BIGPIC
    102  1.7  christos 	set	_C_LABEL(__sigaltstack14), %o4
    103  1.7  christos 	ldx	[%i1 + %o4], %g2
    104  1.7  christos #else
    105  1.7  christos 	ldx	[%i1 + _C_LABEL(__sigaltstack14)], %g2
    106  1.7  christos #endif
    107  1.7  christos 	call	%g2
    108  1.7  christos #else
    109  1.7  christos 	call	_C_LABEL(__sigaltstack14)
    110  1.7  christos #endif
    111  1.7  christos 	 add	%i0, 8, %o1		/* (foo being part of the sigcontext we're overwriting) */
    112  1.3       eeh 
    113  1.7  christos 	lduw	[%i0 + 8 + 0x10], %o0	/* foo.ss_flags */
    114  1.7  christos 	and	%o0, 1, %o1		/* onstack = foo.ss_flags & SS_ONSTACK; */
    115  1.7  christos 	st	%o1, [%i0 + 0x00]	/* sc.sc_onstack = current onstack; */
    116  1.7  christos 
    117  1.7  christos 	/* store essential state */
    118  1.7  christos 	stx	%fp, [%i0 + 0x08]	/* sc.sc_sp = sp */
    119  1.7  christos 	add	%i7, 8, %o0
    120  1.7  christos 	stx	%o0, [%i0 + 0x10]	/* sc.sc_pc = return_pc */
    121  1.7  christos 	add	%i7, 12, %o0
    122  1.7  christos 	stx	%o0, [%i0 + 0x18]	/* sc.sc_npc = return_pc + 4 */
    123  1.7  christos 	stx	%g0, [%i0 + 0x20]	/* sc.sc_tstate = (clean ccr) */
    124  1.7  christos 	stx	%l1, [%i0 + 0x28]	/* sc.sc_g1 */
    125  1.7  christos 	stx	%l2, [%i0 + 0x30]	/* sc.sc_o0, set in longjmp, use as %g2 */
    126  1.7  christos 	/* 0x38 */			/* sc.sc_mask was already saved above */
    127  1.7  christos 
    128  1.7  christos 	/* save additional registers needed to fill a complete mcontext */
    129  1.7  christos 	stx	%l3, [%i0 + 0x40]
    130  1.7  christos 	stx	%l4, [%i0 + 0x48]
    131  1.7  christos 	stx	%l5, [%i0 + 0x50]
    132  1.7  christos 	stx	%l6, [%i0 + 0x58]
    133  1.7  christos 	stx	%l7, [%i0 + 0x60]
    134  1.1       eeh 
    135  1.7  christos 	ret				/* return 0 */
    136  1.7  christos 	 restore %g0, 0, %o0
    137