/*-1* Copyright (c) 2002 Peter Grehan.2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/25/* $NetBSD: sigsetjmp.S,v 1.4 1998/10/03 12:30:38 tsubai Exp $ */2627#include <machine/asm.h>28/*29* C library -- sigsetjmp, siglongjmp30*31* siglongjmp(a,v)32* will generate a "return(v?v:1)" from the last call to33* sigsetjmp(a, savemask)34* by restoring registers from the stack.35* The previous signal state is restored if savemask is non-zero36*37* jmpbuf layout:38* +------------+39* | savemask |40* +------------+41* | sig state |42* | |43* | (4 words) |44* | |45* +------------+46* | saved regs |47* | ... |48*/495051#include <sys/syscall.h>5253ENTRY(sigsetjmp)54mr %r6,%r355stw %r4,0(%r3)56or. %r7,%r4,%r457beq 1f58li %r3,1 /* SIG_BLOCK, but doesn't matter */59/* since set == NULL */60li %r4,0 /* set = NULL */61mr %r5,%r6 /* &oset */62addi %r5,%r5,463li %r0, SYS_sigprocmask /* sigprocmask(SIG_BLOCK, NULL, &oset)*/64sc /* assume no error XXX */651:66mflr %r1167mfcr %r1268mr %r10,%r169mr %r9,%r270stmw %r9,20(%r6)7172/* FPRs */73stfd %f14,112+0*8(%r6)74stfd %f15,112+1*8(%r6)75stfd %f16,112+2*8(%r6)76stfd %f17,112+3*8(%r6)77stfd %f18,112+4*8(%r6)78stfd %f19,112+5*8(%r6)79stfd %f20,112+6*8(%r6)80stfd %f21,112+7*8(%r6)81stfd %f22,112+8*8(%r6)82stfd %f23,112+9*8(%r6)83stfd %f24,112+10*8(%r6)84stfd %f25,112+11*8(%r6)85stfd %f26,112+12*8(%r6)86stfd %f27,112+13*8(%r6)87stfd %f28,112+14*8(%r6)88stfd %f29,112+15*8(%r6)89stfd %f30,112+16*8(%r6)90stfd %f31,112+17*8(%r6)9192li %r3,093blr94END(sigsetjmp)9596ENTRY(siglongjmp)97lmw %r9,20(%r3)9899/* FPRs */100lfd %f14,112+0*8(%r3)101lfd %f15,112+1*8(%r3)102lfd %f16,112+2*8(%r3)103lfd %f17,112+3*8(%r3)104lfd %f18,112+4*8(%r3)105lfd %f19,112+5*8(%r3)106lfd %f20,112+6*8(%r3)107lfd %f21,112+7*8(%r3)108lfd %f22,112+8*8(%r3)109lfd %f23,112+9*8(%r3)110lfd %f24,112+10*8(%r3)111lfd %f25,112+11*8(%r3)112lfd %f26,112+12*8(%r3)113lfd %f27,112+13*8(%r3)114lfd %f28,112+14*8(%r3)115lfd %f29,112+15*8(%r3)116lfd %f30,112+16*8(%r3)117lfd %f31,112+17*8(%r3)118119lwz %r7,0(%r3)120mr %r6,%r4121mtlr %r11122mtcr %r12123mr %r1,%r10124or. %r7,%r7,%r7125beq 1f126mr %r4,%r3127li %r3,3 /* SIG_SETMASK */128addi %r4,%r4,4 /* &set */129li %r5,0 /* oset = NULL */130li %r0,SYS_sigprocmask /* sigprocmask(SIG_SET, &set, NULL) */131sc /* assume no error XXX */1321:133or. %r3,%r6,%r6134bnelr135li %r3,1136blr137END(siglongjmp)138139.section .note.GNU-stack,"",%progbits140141142