1*4c5ed3b2Smatt/* $NetBSD: setjmp.S,v 1.15 2013/07/17 03:05:41 matt Exp $ */ 29f1ee9aeSthorpej 35f709618Spaulus/*- 45f709618Spaulus * Copyright (c) 1990 The Regents of the University of California. 55f709618Spaulus * All rights reserved. 65f709618Spaulus * 75f709618Spaulus * This code is derived from software contributed to Berkeley by 85f709618Spaulus * the Systems Programming Group of the University of Utah Computer 95f709618Spaulus * Science Department. 105f709618Spaulus * 115f709618Spaulus * Redistribution and use in source and binary forms, with or without 125f709618Spaulus * modification, are permitted provided that the following conditions 135f709618Spaulus * are met: 145f709618Spaulus * 1. Redistributions of source code must retain the above copyright 155f709618Spaulus * notice, this list of conditions and the following disclaimer. 165f709618Spaulus * 2. Redistributions in binary form must reproduce the above copyright 175f709618Spaulus * notice, this list of conditions and the following disclaimer in the 185f709618Spaulus * documentation and/or other materials provided with the distribution. 19eb7c1594Sagc * 3. Neither the name of the University nor the names of its contributors 205f709618Spaulus * may be used to endorse or promote products derived from this software 215f709618Spaulus * without specific prior written permission. 225f709618Spaulus * 235f709618Spaulus * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 245f709618Spaulus * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 255f709618Spaulus * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 265f709618Spaulus * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 275f709618Spaulus * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 285f709618Spaulus * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 295f709618Spaulus * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 305f709618Spaulus * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 315f709618Spaulus * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 325f709618Spaulus * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 335f709618Spaulus * SUCH DAMAGE. 345f709618Spaulus */ 355f709618Spaulus 36d0fed6c8Sthorpej#include <machine/asm.h> 37*4c5ed3b2Smatt#include "assym.h" 389f1ee9aeSthorpej 395f709618Spaulus#if defined(LIBC_SCCS) && !defined(lint) 409f1ee9aeSthorpej#if 0 419f1ee9aeSthorpej RCSID("from: @(#)setjmp.s 5.1 (Berkeley) 5/12/90") 429f1ee9aeSthorpej#else 43*4c5ed3b2Smatt RCSID("$NetBSD: setjmp.S,v 1.15 2013/07/17 03:05:41 matt Exp $") 449f1ee9aeSthorpej#endif 455f709618Spaulus#endif /* LIBC_SCCS and not lint */ 465f709618Spaulus 475f709618Spaulus/* 485f709618Spaulus * C library -- setjmp, longjmp 495f709618Spaulus * 505f709618Spaulus * longjmp(a,v) 515f709618Spaulus * will generate a "return(v)" from 525f709618Spaulus * the last call to 535f709618Spaulus * setjmp(a) 545f709618Spaulus * by restoring registers from the stack, 555f709618Spaulus * and a struct sigcontext, see <signal.h> 565f709618Spaulus */ 575f709618Spaulus 5822d2b319SchristosENTRY(__setjmp14) 5922d2b319Schristos /* Get signal stack info. Note overlay of ss_sp and ss_size! */ 6007a0a325Smatt lea -12(%sp),%sp /* sizeof(stack_t) */ 6107a0a325Smatt clrl (%sp) /* ss = NULL */ 6207a0a325Smatt movl %sp,4(%sp) /* oss = stack_t on stack */ 6329215efaSitohy jbsr PIC_PLT(_C_LABEL(__sigaltstack14)) 6422d2b319Schristos 6507a0a325Smatt movl 8(%sp),%d0 /* ss_flags */ 6622d2b319Schristos andl #1,%d0 /* extract SS_ONSTACK */ 6707a0a325Smatt lea 12(%sp),%sp /* pop stack_t */ 6822d2b319Schristos 6922d2b319Schristos /* Get pointer to jmp_buf; a sigcontext is at the beginning. */ 7007a0a325Smatt movl 4(%sp),%a0 71*4c5ed3b2Smatt movl %d0,SC_ONSTACK(%a0) /* store onstack */ 72*4c5ed3b2Smatt clrl SC___MASK13(%a0) /* unused word (old style signal mask) */ 7322d2b319Schristos 7422d2b319Schristos /* Get the signal mask. */ 75*4c5ed3b2Smatt pea SC_MASK(%a0) /* oset = &sc.sc_mask */ 7607a0a325Smatt movl #0,-(%sp) /* set = NULL */ 7707a0a325Smatt movl #0,-(%sp) /* action = 0 <ignored> */ 7822d2b319Schristos jbsr PIC_PLT(_C_LABEL(__sigprocmask14)) 7922d2b319Schristos addl #12,%sp 8022d2b319Schristos 8107a0a325Smatt movl 4(%sp),%a0 /* get jmp_buf pointer again */ 8207a0a325Smatt lea 4(%sp),%a1 /* adjust SP since we won't rts */ 83*4c5ed3b2Smatt movl %a1,SC_SP(%a0) /* save SP */ 84*4c5ed3b2Smatt movl %a6,SC_FP(%a0) /* save FP */ 85*4c5ed3b2Smatt clrl SC_AP(%a0) /* no AP */ 86*4c5ed3b2Smatt movl (%sp),SC_PC(%a0)/* save return PC */ 87*4c5ed3b2Smatt clrl SC_PS(%a0) /* clear PS */ 8822d2b319Schristos 8922d2b319Schristos /* Save remaining non-scratch regs after signal mask. */ 90*4c5ed3b2Smatt moveml #0x3CFC,SC_SIZE(%a0) 9122d2b319Schristos 923b435a73Sthorpej clrl %d0 /* return 0 */ 935f709618Spaulus rts 9494258182SmattEND(__setjmp14) 95