Home | History | Annotate | Line # | Download | only in gen
__setjmp14.S revision 1.5
      1  1.5     matt /* $NetBSD: __setjmp14.S,v 1.5 2011/06/12 05:44:36 matt Exp $ */
      2  1.1  thorpej 
      3  1.1  thorpej /*
      4  1.1  thorpej  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
      5  1.1  thorpej  * All rights reserved.
      6  1.1  thorpej  *
      7  1.1  thorpej  * Author: Chris G. Demetriou
      8  1.1  thorpej  *
      9  1.1  thorpej  * Permission to use, copy, modify and distribute this software and
     10  1.1  thorpej  * its documentation is hereby granted, provided that both the copyright
     11  1.1  thorpej  * notice and this permission notice appear in all copies of the
     12  1.1  thorpej  * software, derivative works or modified versions, and any portions
     13  1.1  thorpej  * thereof, and that both notices appear in supporting documentation.
     14  1.1  thorpej  *
     15  1.1  thorpej  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  1.1  thorpej  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  1.1  thorpej  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  1.1  thorpej  *
     19  1.1  thorpej  * Carnegie Mellon requests users of this software to return to
     20  1.1  thorpej  *
     21  1.1  thorpej  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  1.1  thorpej  *  School of Computer Science
     23  1.1  thorpej  *  Carnegie Mellon University
     24  1.1  thorpej  *  Pittsburgh PA 15213-3890
     25  1.1  thorpej  *
     26  1.1  thorpej  * any improvements or extensions that they make and grant Carnegie the
     27  1.1  thorpej  * rights to redistribute these changes.
     28  1.1  thorpej  */
     29  1.1  thorpej 
     30  1.1  thorpej #include <machine/asm.h>
     31  1.4     matt #include "assym.h"
     32  1.1  thorpej 
     33  1.1  thorpej /*
     34  1.1  thorpej  * C library -- setjmp, longjmp
     35  1.1  thorpej  *
     36  1.1  thorpej  *	longjmp(a,v)
     37  1.1  thorpej  * will generate a "return(v)" from
     38  1.1  thorpej  * the last call to
     39  1.1  thorpej  *	setjmp(a)
     40  1.1  thorpej  * by restoring registers from the stack,
     41  1.1  thorpej  * and the previous signal state.
     42  1.1  thorpej  */
     43  1.1  thorpej 
     44  1.1  thorpej 	.set	noreorder
     45  1.1  thorpej 
     46  1.1  thorpej LEAF(__setjmp14, 1)
     47  1.1  thorpej 	LDGP(pv)
     48  1.4     matt 	stq	ra, SC_PC(a0)			/* sc_pc = return address */
     49  1.4     matt 	stq	s0, (SC_REGS+_REG_S0)(a0)	/* saved bits of sc_regs */
     50  1.4     matt 	stq	s1, (SC_REGS+_REG_S1)(a0)
     51  1.4     matt 	stq	s2, (SC_REGS+_REG_S2)(a0)
     52  1.4     matt 	stq	s3, (SC_REGS+_REG_S3)(a0)
     53  1.4     matt 	stq	s4, (SC_REGS+_REG_S4)(a0)
     54  1.4     matt 	stq	s5, (SC_REGS+_REG_S5)(a0)
     55  1.4     matt 	stq	s6, (SC_REGS+_REG_S6)(a0)
     56  1.4     matt 	stq	ra, (SC_REGS+_REG_RA)(a0)
     57  1.4     matt 	stq	sp, (SC_REGS+_REG_SP)(a0)
     58  1.1  thorpej 
     59  1.1  thorpej 	/*
     60  1.1  thorpej 	 * get signal information
     61  1.1  thorpej 	 */
     62  1.1  thorpej 	mov	a0, s0				/* squirrel away ptr to sc */
     63  1.1  thorpej 
     64  1.1  thorpej 	/* see what's blocked */
     65  1.1  thorpej 	mov	zero, a0			/* how (insignificant) */
     66  1.1  thorpej 	mov	zero, a1			/* set (NULL) */
     67  1.4     matt 	lda	a2, SC_MASK(s0)			/* point to mask in sc */
     68  1.1  thorpej 	CALL(__sigprocmask14)
     69  1.1  thorpej 
     70  1.1  thorpej 	lda	sp, -24(sp)			/* sizeof struct sigaltstack */
     71  1.1  thorpej 	mov	zero, a0
     72  1.1  thorpej 	mov	sp, a1
     73  1.1  thorpej 	CALL(__sigaltstack14)
     74  1.1  thorpej 	ldl	t0, 16(sp)			/* offset of ss_flags */
     75  1.1  thorpej 	lda	sp, 24(sp)			/* sizeof struct sigaltstack */
     76  1.4     matt 	ldq	ra, (SC_REGS+_REG_RA)(s0)	/* restore return address */
     77  1.1  thorpej 	blt	v0, botch			/* check for error */
     78  1.1  thorpej 	and	t0, 0x1, t0			/* get SA_ONSTACK flag */
     79  1.4     matt 	stq	t0, SC_ONSTACK(s0)		/* and save it in sc_onstack */
     80  1.1  thorpej 	/*
     81  1.1  thorpej 	 * Restore old s0 and a0, and continue saving registers
     82  1.1  thorpej 	 */
     83  1.1  thorpej 	mov	s0, a0
     84  1.4     matt 	ldq	s0, (SC_REGS+_REG_S0)(a0)
     85  1.1  thorpej 
     86  1.1  thorpej 	ldiq	t0, 0xacedbade			/* sigcontext magic number */
     87  1.4     matt 	stq	t0, (SC_REGS+_REG_UNIQUE)(a0)	/* magic in sc_regs[31] */
     88  1.1  thorpej 	/* Too bad we can't check if we actually used FP */
     89  1.1  thorpej 	ldiq	t0, 1
     90  1.4     matt 	stq	t0, SC_OWNEDFP(a0)		/* say we've used FP.  */
     91  1.4     matt 	stt	fs0, (2*8 + SC_FPREGS)(a0)	/* saved bits of sc_fpregs */
     92  1.4     matt 	stt	fs1, (3*8 + SC_FPREGS)(a0)
     93  1.4     matt 	stt	fs2, (4*8 + SC_FPREGS)(a0)
     94  1.4     matt 	stt	fs3, (5*8 + SC_FPREGS)(a0)
     95  1.4     matt 	stt	fs4, (6*8 + SC_FPREGS)(a0)
     96  1.4     matt 	stt	fs5, (7*8 + SC_FPREGS)(a0)
     97  1.4     matt 	stt	fs6, (8*8 + SC_FPREGS)(a0)
     98  1.4     matt 	stt	fs7, (9*8 + SC_FPREGS)(a0)
     99  1.5     matt 	excb					/* required 4.7.8.1 Alpha ARM */
    100  1.1  thorpej 	mf_fpcr	ft0				/* get FP control reg */
    101  1.5     matt 	excb					/* required 4.7.8.1 Alpha ARM */
    102  1.4     matt 	stt	ft0, SC_FPCR(a0)		/* and store it in sc_fpcr */
    103  1.4     matt 	stq	zero, SC_FP_CONTROL(a0)		/* FP software control XXX */
    104  1.4     matt 	stq	zero, (SC_RESERVED + 0*8)(a0)	/* sc_reserved[0] */
    105  1.4     matt 	stq	zero, (SC_RESERVED + 1*8)(a0)	/* sc_reserved[1] */
    106  1.4     matt 	stq	zero, (SC_XXX + 0*8)(a0)	/* sc_xxx[0] */
    107  1.4     matt 	stq	zero, (SC_XXX + 1*8)(a0)	/* sc_xxx[1] */
    108  1.4     matt 	stq	zero, (SC_XXX + 2*8)(a0)	/* sc_xxx[2] */
    109  1.4     matt 	stq	zero, (SC_XXX + 3*8)(a0)	/* sc_xxx[3] */
    110  1.4     matt 	stq	zero, (SC_XXX + 4*8)(a0)	/* sc_xxx[4] */
    111  1.4     matt 	stq	zero, (SC_XXX + 5*8)(a0)	/* sc_xxx[5] */
    112  1.4     matt 	stq	zero, (SC_XXX + 6*8)(a0)	/* sc_xxx[6] */
    113  1.4     matt 	stq	zero, (SC_XXX + 7*8)(a0)	/* sc_xxx[7] */
    114  1.1  thorpej 
    115  1.1  thorpej 	mov	zero, v0			/* return zero */
    116  1.1  thorpej 	RET
    117  1.1  thorpej botch:
    118  1.1  thorpej 	CALL(abort)
    119  1.1  thorpej 	RET					/* "can't" get here... */
    120  1.4     matt END(__setjmp14)
    121