setjmp.S revision 67117
1/* $NetBSD: setjmp.S,v 1.3 1997/12/05 02:06:27 thorpej Exp $ */ 2/* $FreeBSD: head/lib/libc/ia64/gen/setjmp.S 67117 2000-10-14 17:01:12Z dfr $ */ 3 4/* 5 * Copyright (c) 1994, 1995 Carnegie-Mellon University. 6 * All rights reserved. 7 * 8 * Author: Chris G. Demetriou 9 * 10 * Permission to use, copy, modify and distribute this software and 11 * its documentation is hereby granted, provided that both the copyright 12 * notice and this permission notice appear in all copies of the 13 * software, derivative works or modified versions, and any portions 14 * thereof, and that both notices appear in supporting documentation. 15 * 16 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 17 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 18 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 19 * 20 * Carnegie Mellon requests users of this software to return to 21 * 22 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 23 * School of Computer Science 24 * Carnegie Mellon University 25 * Pittsburgh PA 15213-3890 26 * 27 * any improvements or extensions that they make and grant Carnegie the 28 * rights to redistribute these changes. 29 * 30 * $FreeBSD: head/lib/libc/ia64/gen/setjmp.S 67117 2000-10-14 17:01:12Z dfr $ 31 */ 32 33#include "SYS.h" 34 35/* 36 * C library -- setjmp, longjmp 37 * 38 * longjmp(a,v) 39 * will generate a "return(v)" from 40 * the last call to 41 * setjmp(a) 42 * by restoring registers from the stack, 43 * and the previous signal state. 44 */ 45 46ENTRY(setjmp, 1) 47#if 0 48 LDGP(pv) 49 stq ra, (2 * 8)(a0) /* sc_pc = return address */ 50 stq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */ 51 stq s1, ((10 + 4) * 8)(a0) 52 stq s2, ((11 + 4) * 8)(a0) 53 stq s3, ((12 + 4) * 8)(a0) 54 stq s4, ((13 + 4) * 8)(a0) 55 stq s5, ((14 + 4) * 8)(a0) 56 stq s6, ((15 + 4) * 8)(a0) 57 stq ra, ((26 + 4) * 8)(a0) 58 stq sp, ((30 + 4) * 8)(a0) 59 60 /* 61 * get signal information 62 */ 63 mov a0, s0 /* squirrel away ptr to sc */ 64 65 /* see what's blocked */ 66 lda a2, (71 * 8)(a0) /* oset: sc_reserved */ 67 mov zero, a1 /* set: NULL */ 68 addq a1, 1, a0 /* how: SIG_BLOCK */ 69 PCALL(sigprocmask) /* see what's blocked */ 70 71 lda sp, -24(sp) /* sizeof struct sigaltstack */ 72 mov zero, a0 73 mov sp, a1 74 PCALL(sigaltstack) 75 ldl t0, 16(sp) /* offset of ss_flags */ 76 lda sp, 24(sp) /* sizeof struct sigaltstack */ 77 ldq ra, ((26 + 4) * 8)(s0) /* restore return address */ 78 blt v0, botch /* check for error */ 79 and t0, 0x1, t0 /* get SA_ONSTACK flag */ 80 stq t0, (0 * 8)(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, (( 9 + 4) * 8)(a0) 86 87 ldiq t0, 0xacedbade /* sigcontext magic number */ 88 stq t0, ((31 + 4) * 8)(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, (36 * 8)(a0) /* say we've used FP. */ 92 stt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */ 93 stt fs1, ((3 + 37) * 8)(a0) 94 stt fs2, ((4 + 37) * 8)(a0) 95 stt fs3, ((5 + 37) * 8)(a0) 96 stt fs4, ((6 + 37) * 8)(a0) 97 stt fs5, ((7 + 37) * 8)(a0) 98 stt fs6, ((8 + 37) * 8)(a0) 99 stt fs7, ((9 + 37) * 8)(a0) 100 mf_fpcr ft0 /* get FP control reg */ 101 stt ft0, (69 * 8)(a0) /* and store it in sc_fpcr */ 102 stq zero, (70 * 8)(a0) /* FP software control XXX */ 103 stq zero, (71 * 8)(a0) /* sc_reserved[0] */ 104 stq zero, (72 * 8)(a0) /* sc_reserved[1] */ 105 stq zero, (73 * 8)(a0) /* sc_xxx[0] */ 106 stq zero, (74 * 8)(a0) /* sc_xxx[1] */ 107 stq zero, (75 * 8)(a0) /* sc_xxx[2] */ 108 stq zero, (76 * 8)(a0) /* sc_xxx[3] */ 109 stq zero, (77 * 8)(a0) /* sc_xxx[4] */ 110 stq zero, (78 * 8)(a0) /* sc_xxx[5] */ 111 stq zero, (79 * 8)(a0) /* sc_xxx[6] */ 112 stq zero, (80 * 8)(a0) /* sc_xxx[7] */ 113 114 mov zero, v0 /* return zero */ 115 RET 116#endif 117END(setjmp) 118 119#ifdef _THREAD_SAFE 120ENTRY(__longjmp, 2) 121#else 122XENTRY(__longjmp) 123ENTRY(longjmp, 2) 124#endif 125#if 0 126 LDGP(pv) 127 stq a1, (( 0 + 4) * 8)(a0) /* save return value */ 128 PCALL(sigreturn) /* use sigreturn to return */ 129 130botch: 131 CALL(longjmperror) 132 CALL(abort) 133 RET /* "can't" get here... */ 134#endif 135#ifdef _THREAD_SAFE 136END(__longjmp) 137#else 138END(longjmp) 139#endif 140