1*0a6a1f1dSLionel Sambuc/* $NetBSD: __setjmp14.S,v 1.7 2014/01/23 03:08:50 christos Exp $ */ 22fe8fb19SBen Gras 32fe8fb19SBen Gras/* 42fe8fb19SBen Gras * Copyright (c) 1994, 1995 Carnegie-Mellon University. 52fe8fb19SBen Gras * All rights reserved. 62fe8fb19SBen Gras * 72fe8fb19SBen Gras * Author: Chris G. Demetriou 82fe8fb19SBen Gras * 92fe8fb19SBen Gras * Permission to use, copy, modify and distribute this software and 102fe8fb19SBen Gras * its documentation is hereby granted, provided that both the copyright 112fe8fb19SBen Gras * notice and this permission notice appear in all copies of the 122fe8fb19SBen Gras * software, derivative works or modified versions, and any portions 132fe8fb19SBen Gras * thereof, and that both notices appear in supporting documentation. 142fe8fb19SBen Gras * 152fe8fb19SBen Gras * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 162fe8fb19SBen Gras * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 172fe8fb19SBen Gras * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 182fe8fb19SBen Gras * 192fe8fb19SBen Gras * Carnegie Mellon requests users of this software to return to 202fe8fb19SBen Gras * 212fe8fb19SBen Gras * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 222fe8fb19SBen Gras * School of Computer Science 232fe8fb19SBen Gras * Carnegie Mellon University 242fe8fb19SBen Gras * Pittsburgh PA 15213-3890 252fe8fb19SBen Gras * 262fe8fb19SBen Gras * any improvements or extensions that they make and grant Carnegie the 272fe8fb19SBen Gras * rights to redistribute these changes. 282fe8fb19SBen Gras */ 292fe8fb19SBen Gras 302fe8fb19SBen Gras#include <machine/asm.h> 312fe8fb19SBen Gras#include "assym.h" 322fe8fb19SBen Gras 332fe8fb19SBen Gras/* 342fe8fb19SBen Gras * C library -- setjmp, longjmp 352fe8fb19SBen Gras * 362fe8fb19SBen Gras * longjmp(a,v) 372fe8fb19SBen Gras * will generate a "return(v)" from 382fe8fb19SBen Gras * the last call to 392fe8fb19SBen Gras * setjmp(a) 402fe8fb19SBen Gras * by restoring registers from the stack, 412fe8fb19SBen Gras * and the previous signal state. 422fe8fb19SBen Gras */ 432fe8fb19SBen Gras 442fe8fb19SBen Gras .set noreorder 452fe8fb19SBen Gras 462fe8fb19SBen GrasLEAF(__setjmp14, 1) 472fe8fb19SBen Gras LDGP(pv) 482fe8fb19SBen Gras stq ra, SC_PC(a0) /* sc_pc = return address */ 492fe8fb19SBen Gras stq s0, (SC_REGS+_REG_S0)(a0) /* saved bits of sc_regs */ 502fe8fb19SBen Gras stq s1, (SC_REGS+_REG_S1)(a0) 512fe8fb19SBen Gras stq s2, (SC_REGS+_REG_S2)(a0) 522fe8fb19SBen Gras stq s3, (SC_REGS+_REG_S3)(a0) 532fe8fb19SBen Gras stq s4, (SC_REGS+_REG_S4)(a0) 542fe8fb19SBen Gras stq s5, (SC_REGS+_REG_S5)(a0) 552fe8fb19SBen Gras stq s6, (SC_REGS+_REG_S6)(a0) 562fe8fb19SBen Gras stq ra, (SC_REGS+_REG_RA)(a0) 572fe8fb19SBen Gras stq sp, (SC_REGS+_REG_SP)(a0) 5884d9c625SLionel Sambuc stq gp, (SC_REGS+_REG_GP)(a0) 592fe8fb19SBen Gras 602fe8fb19SBen Gras /* 612fe8fb19SBen Gras * get signal information 622fe8fb19SBen Gras */ 632fe8fb19SBen Gras mov a0, s0 /* squirrel away ptr to sc */ 642fe8fb19SBen Gras 652fe8fb19SBen Gras /* see what's blocked */ 662fe8fb19SBen Gras mov zero, a0 /* how (insignificant) */ 672fe8fb19SBen Gras mov zero, a1 /* set (NULL) */ 682fe8fb19SBen Gras lda a2, SC_MASK(s0) /* point to mask in sc */ 692fe8fb19SBen Gras CALL(__sigprocmask14) 702fe8fb19SBen Gras 712fe8fb19SBen Gras lda sp, -24(sp) /* sizeof struct sigaltstack */ 722fe8fb19SBen Gras mov zero, a0 732fe8fb19SBen Gras mov sp, a1 742fe8fb19SBen Gras CALL(__sigaltstack14) 752fe8fb19SBen Gras ldl t0, 16(sp) /* offset of ss_flags */ 762fe8fb19SBen Gras lda sp, 24(sp) /* sizeof struct sigaltstack */ 772fe8fb19SBen Gras ldq ra, (SC_REGS+_REG_RA)(s0) /* restore return address */ 782fe8fb19SBen Gras blt v0, botch /* check for error */ 792fe8fb19SBen Gras and t0, 0x1, t0 /* get SA_ONSTACK flag */ 802fe8fb19SBen Gras stq t0, SC_ONSTACK(s0) /* and save it in sc_onstack */ 812fe8fb19SBen Gras /* 822fe8fb19SBen Gras * Restore old s0 and a0, and continue saving registers 832fe8fb19SBen Gras */ 842fe8fb19SBen Gras mov s0, a0 852fe8fb19SBen Gras ldq s0, (SC_REGS+_REG_S0)(a0) 862fe8fb19SBen Gras 87*0a6a1f1dSLionel Sambuc ldq t0, magic /* sigcontext magic number */ 882fe8fb19SBen Gras stq t0, (SC_REGS+_REG_UNIQUE)(a0) /* magic in sc_regs[31] */ 892fe8fb19SBen Gras /* Too bad we can't check if we actually used FP */ 902fe8fb19SBen Gras ldiq t0, 1 912fe8fb19SBen Gras stq t0, SC_OWNEDFP(a0) /* say we've used FP. */ 922fe8fb19SBen Gras stt fs0, (2*8 + SC_FPREGS)(a0) /* saved bits of sc_fpregs */ 932fe8fb19SBen Gras stt fs1, (3*8 + SC_FPREGS)(a0) 942fe8fb19SBen Gras stt fs2, (4*8 + SC_FPREGS)(a0) 952fe8fb19SBen Gras stt fs3, (5*8 + SC_FPREGS)(a0) 962fe8fb19SBen Gras stt fs4, (6*8 + SC_FPREGS)(a0) 972fe8fb19SBen Gras stt fs5, (7*8 + SC_FPREGS)(a0) 982fe8fb19SBen Gras stt fs6, (8*8 + SC_FPREGS)(a0) 992fe8fb19SBen Gras stt fs7, (9*8 + SC_FPREGS)(a0) 100e415d488SLionel Sambuc excb /* required 4.7.8.1 Alpha ARM */ 1012fe8fb19SBen Gras mf_fpcr ft0 /* get FP control reg */ 102e415d488SLionel Sambuc excb /* required 4.7.8.1 Alpha ARM */ 1032fe8fb19SBen Gras stt ft0, SC_FPCR(a0) /* and store it in sc_fpcr */ 1042fe8fb19SBen Gras stq zero, SC_FP_CONTROL(a0) /* FP software control XXX */ 1052fe8fb19SBen Gras stq zero, (SC_RESERVED + 0*8)(a0) /* sc_reserved[0] */ 1062fe8fb19SBen Gras stq zero, (SC_RESERVED + 1*8)(a0) /* sc_reserved[1] */ 1072fe8fb19SBen Gras stq zero, (SC_XXX + 0*8)(a0) /* sc_xxx[0] */ 1082fe8fb19SBen Gras stq zero, (SC_XXX + 1*8)(a0) /* sc_xxx[1] */ 1092fe8fb19SBen Gras stq zero, (SC_XXX + 2*8)(a0) /* sc_xxx[2] */ 1102fe8fb19SBen Gras stq zero, (SC_XXX + 3*8)(a0) /* sc_xxx[3] */ 1112fe8fb19SBen Gras stq zero, (SC_XXX + 4*8)(a0) /* sc_xxx[4] */ 1122fe8fb19SBen Gras stq zero, (SC_XXX + 5*8)(a0) /* sc_xxx[5] */ 1132fe8fb19SBen Gras stq zero, (SC_XXX + 6*8)(a0) /* sc_xxx[6] */ 1142fe8fb19SBen Gras stq zero, (SC_XXX + 7*8)(a0) /* sc_xxx[7] */ 1152fe8fb19SBen Gras 1162fe8fb19SBen Gras mov zero, v0 /* return zero */ 1172fe8fb19SBen Gras RET 1182fe8fb19SBen Grasbotch: 1192fe8fb19SBen Gras CALL(abort) 1202fe8fb19SBen Gras RET /* "can't" get here... */ 121*0a6a1f1dSLionel Sambucmagic: 122*0a6a1f1dSLionel Sambuc .quad 0xacedbade /* sigcontext magic number */ 1232fe8fb19SBen GrasEND(__setjmp14) 124