Home | History | Annotate | Line # | Download | only in gen
compat__setjmp.S revision 1.1.50.1
      1  1.1.50.1       tls /* $NetBSD: compat__setjmp.S,v 1.1.50.1 2014/08/20 00:02:13 tls Exp $ */
      2       1.1  drochner 
      3       1.1  drochner /*
      4       1.1  drochner  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
      5       1.1  drochner  * All rights reserved.
      6       1.1  drochner  *
      7       1.1  drochner  * Author: Chris G. Demetriou
      8       1.1  drochner  *
      9       1.1  drochner  * Permission to use, copy, modify and distribute this software and
     10       1.1  drochner  * its documentation is hereby granted, provided that both the copyright
     11       1.1  drochner  * notice and this permission notice appear in all copies of the
     12       1.1  drochner  * software, derivative works or modified versions, and any portions
     13       1.1  drochner  * thereof, and that both notices appear in supporting documentation.
     14       1.1  drochner  *
     15       1.1  drochner  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16       1.1  drochner  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17       1.1  drochner  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18       1.1  drochner  *
     19       1.1  drochner  * Carnegie Mellon requests users of this software to return to
     20       1.1  drochner  *
     21       1.1  drochner  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22       1.1  drochner  *  School of Computer Science
     23       1.1  drochner  *  Carnegie Mellon University
     24       1.1  drochner  *  Pittsburgh PA 15213-3890
     25       1.1  drochner  *
     26       1.1  drochner  * any improvements or extensions that they make and grant Carnegie the
     27       1.1  drochner  * rights to redistribute these changes.
     28       1.1  drochner  */
     29       1.1  drochner 
     30       1.1  drochner #include <machine/asm.h>
     31       1.1  drochner 
     32       1.1  drochner /*
     33       1.1  drochner  * C library -- _setjmp, _longjmp
     34       1.1  drochner  *
     35       1.1  drochner  *	_longjmp(a,v)
     36       1.1  drochner  * will generate a "return(v)" from
     37       1.1  drochner  * the last call to
     38       1.1  drochner  *	_setjmp(a)
     39       1.1  drochner  * by restoring registers from the stack,
     40       1.1  drochner  * The previous signal state is NOT restored.
     41       1.1  drochner  */
     42       1.1  drochner 
     43       1.1  drochner 	.set	noreorder
     44       1.1  drochner 
     45       1.1  drochner LEAF(_setjmp, 1)
     46       1.1  drochner 	LDGP(pv)
     47       1.1  drochner 	stq	ra, (2 * 8)(a0)			/* sc_pc = return address */
     48       1.1  drochner 	stq	s0, (( 9 + 4) * 8)(a0)		/* saved bits of sc_regs */
     49       1.1  drochner 	stq	s1, ((10 + 4) * 8)(a0)
     50       1.1  drochner 	stq	s2, ((11 + 4) * 8)(a0)
     51       1.1  drochner 	stq	s3, ((12 + 4) * 8)(a0)
     52       1.1  drochner 	stq	s4, ((13 + 4) * 8)(a0)
     53       1.1  drochner 	stq	s5, ((14 + 4) * 8)(a0)
     54       1.1  drochner 	stq	s6, ((15 + 4) * 8)(a0)
     55       1.1  drochner 	stq	ra, ((26 + 4) * 8)(a0)
     56       1.1  drochner 	stq	sp, ((30 + 4) * 8)(a0)
     57  1.1.50.1       tls 	ldq	t0, magic			/* sigcontext magic number */
     58       1.1  drochner 	stq	t0, ((31 + 4) * 8)(a0)		/* magic in sc_regs[31] */
     59       1.1  drochner 	/* Too bad we can't check if we actually used FP */
     60       1.1  drochner 	ldiq	t0, 1
     61       1.1  drochner 	stq	t0, (36 * 8)(a0)		/* say we've used FP.  */
     62       1.1  drochner 	stt	fs0, ((2 + 37) * 8)(a0)		/* saved bits of sc_fpregs */
     63       1.1  drochner 	stt	fs1, ((3 + 37) * 8)(a0)
     64       1.1  drochner 	stt	fs2, ((4 + 37) * 8)(a0)
     65       1.1  drochner 	stt	fs3, ((5 + 37) * 8)(a0)
     66       1.1  drochner 	stt	fs4, ((6 + 37) * 8)(a0)
     67       1.1  drochner 	stt	fs5, ((7 + 37) * 8)(a0)
     68       1.1  drochner 	stt	fs6, ((8 + 37) * 8)(a0)
     69       1.1  drochner 	stt	fs7, ((9 + 37) * 8)(a0)
     70       1.1  drochner 	mf_fpcr ft0				/* get FP control reg */
     71       1.1  drochner 	stt	ft0, (69 * 8)(a0)		/* and store it in sc_fpcr */
     72       1.1  drochner 	stq	zero, (70 * 8)(a0)		/* FP software control XXX */
     73       1.1  drochner 	stq	zero, (71 * 8)(a0)		/* sc_reserved[0] */
     74       1.1  drochner 	stq	zero, (72 * 8)(a0)		/* sc_reserved[1] */
     75       1.1  drochner 	stq	zero, (73 * 8)(a0)		/* sc_xxx[0] */
     76       1.1  drochner 	stq	zero, (74 * 8)(a0)		/* sc_xxx[1] */
     77       1.1  drochner 	stq	zero, (75 * 8)(a0)		/* sc_xxx[2] */
     78       1.1  drochner 	stq	zero, (76 * 8)(a0)		/* sc_xxx[3] */
     79       1.1  drochner 	stq	zero, (77 * 8)(a0)		/* sc_xxx[4] */
     80       1.1  drochner 	stq	zero, (78 * 8)(a0)		/* sc_xxx[5] */
     81       1.1  drochner 	stq	zero, (79 * 8)(a0)		/* sc_xxx[6] */
     82       1.1  drochner 	stq	zero, (80 * 8)(a0)		/* sc_xxx[7] */
     83       1.1  drochner 
     84       1.1  drochner 	mov	zero, v0			/* return zero */
     85       1.1  drochner 	RET
     86  1.1.50.1       tls magic:
     87  1.1.50.1       tls 	.quad 0xacedbadd
     88       1.1  drochner END(_setjmp)
     89       1.1  drochner 
     90       1.1  drochner LEAF(_longjmp, 2)
     91       1.1  drochner 	LDGP(pv)
     92       1.1  drochner 	ldq	t0, ((31 + 4) * 8)(a0)		/* magic in sc_regs[31] */
     93  1.1.50.1       tls 	ldq	t1, magic			/* sigcontext magic number */
     94       1.1  drochner 	cmpeq	t0, t1, t0
     95       1.1  drochner 	beq	t0, botch			/* If the magic was bad, punt */
     96       1.1  drochner 
     97       1.1  drochner 	ldq	ra, (2 * 8)(a0)			/* sc_pc = return address */
     98       1.1  drochner 	ldq	s0, (( 9 + 4) * 8)(a0)		/* saved bits of sc_regs */
     99       1.1  drochner 	ldq	s1, ((10 + 4) * 8)(a0)
    100       1.1  drochner 	ldq	s2, ((11 + 4) * 8)(a0)
    101       1.1  drochner 	ldq	s3, ((12 + 4) * 8)(a0)
    102       1.1  drochner 	ldq	s4, ((13 + 4) * 8)(a0)
    103       1.1  drochner 	ldq	s5, ((14 + 4) * 8)(a0)
    104       1.1  drochner 	ldq	s6, ((15 + 4) * 8)(a0)
    105       1.1  drochner 	/* ldq	ra, ((26 + 4) * 8)(a0)		set above */
    106       1.1  drochner 	ldq	sp, ((30 + 4) * 8)(a0)
    107       1.1  drochner 	ldt	fs0, ((2 + 37) * 8)(a0)		/* saved bits of sc_fpregs */
    108       1.1  drochner 	ldt	fs1, ((3 + 37) * 8)(a0)
    109       1.1  drochner 	ldt	fs2, ((4 + 37) * 8)(a0)
    110       1.1  drochner 	ldt	fs3, ((5 + 37) * 8)(a0)
    111       1.1  drochner 	ldt	fs4, ((6 + 37) * 8)(a0)
    112       1.1  drochner 	ldt	fs5, ((7 + 37) * 8)(a0)
    113       1.1  drochner 	ldt	fs6, ((8 + 37) * 8)(a0)
    114       1.1  drochner 	ldt	fs7, ((9 + 37) * 8)(a0)
    115       1.1  drochner 	ldt	ft0, (69 * 8)(a0)		/* get sc_fpcr */
    116       1.1  drochner 	mt_fpcr	ft0				/* and restore it. */
    117       1.1  drochner 
    118       1.1  drochner 	mov	a1, v0				/* return second arg */
    119       1.1  drochner 	RET
    120       1.1  drochner 
    121       1.1  drochner botch:
    122       1.1  drochner 	CALL(longjmperror)
    123       1.1  drochner 	CALL(abort)
    124       1.1  drochner 	RET					/* "can't" get here... */
    125       1.1  drochner END(_longjmp)
    126