/*-1* Copyright (c) 2016 Justin Hibbits2* 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: setjmp.S,v 1.3 1998/10/03 12:30:38 tsubai Exp $ */2627#include <machine/asm.h>28#include <sys/syscall.h>2930/*31* C library -- setjmp, longjmp32*33* longjmp(a,v)34* will generate a "return(v?v:1)" from the last call to35* setjmp(a)36* by restoring registers from the stack.37* The previous signal state is restored.38*39* jmpbuf layout:40* +------------+41* | unused |42* +------------+43* | sig state |44* | |45* | (4 words) |46* | |47* +------------+48* | saved regs |49* | ... |50*/5152ENTRY(setjmp)53mr %r6,%r354li %r3,1 /* SIG_BLOCK, but doesn't matter */55/* since set == NULL */56li %r4,0 /* set = NULL */57mr %r5,%r6 /* &oset */58addi %r5,%r5,459li %r0, SYS_sigprocmask /*sigprocmask(SIG_BLOCK, NULL, &oset)*/60sc /*assume no error XXX */61mflr %r11 /* r11 <- link reg */62mfcr %r12 /* r12 <- condition reg */63mr %r10,%r1 /* r10 <- stackptr */64mr %r9,%r2 /* r9 <- global ptr */65evstdd %r9,24+0*8(%r6)66evstdd %r10,24+1*8(%r6)67evstdd %r11,24+2*8(%r6)68evstdd %r12,24+3*8(%r6)69evstdd %r13,24+4*8(%r6)70evstdd %r14,24+5*8(%r6)71evstdd %r15,24+6*8(%r6)72evstdd %r16,24+7*8(%r6)73evstdd %r17,24+8*8(%r6)74evstdd %r18,24+9*8(%r6)75evstdd %r19,24+10*8(%r6)76evstdd %r20,24+11*8(%r6)77evstdd %r21,24+12*8(%r6)78evstdd %r22,24+13*8(%r6)79evstdd %r23,24+14*8(%r6)80evstdd %r24,24+15*8(%r6)81evstdd %r25,24+16*8(%r6)82evstdd %r26,24+17*8(%r6)83evstdd %r27,24+18*8(%r6)84evstdd %r28,24+19*8(%r6)85evstdd %r29,24+20*8(%r6)86evstdd %r30,24+21*8(%r6)87evstdd %r31,24+22*8(%r6)8889li %r3,0 /* return (0) */90blr91END(setjmp)9293WEAK_REFERENCE(CNAME(__longjmp), longjmp)94ENTRY(__longjmp)95evldd %r9,24+0*8(%r3)96evldd %r10,24+1*8(%r3)97evldd %r11,24+2*8(%r3)98evldd %r12,24+3*8(%r3)99evldd %r13,24+4*8(%r3)100evldd %r14,24+5*8(%r3)101evldd %r15,24+6*8(%r3)102evldd %r16,24+7*8(%r3)103evldd %r17,24+8*8(%r3)104evldd %r18,24+9*8(%r3)105evldd %r19,24+10*8(%r3)106evldd %r20,24+11*8(%r3)107evldd %r21,24+12*8(%r3)108evldd %r22,24+13*8(%r3)109evldd %r23,24+14*8(%r3)110evldd %r24,24+15*8(%r3)111evldd %r25,24+16*8(%r3)112evldd %r26,24+17*8(%r3)113evldd %r27,24+18*8(%r3)114evldd %r28,24+19*8(%r3)115evldd %r29,24+20*8(%r3)116evldd %r30,24+21*8(%r3)117evldd %r31,24+22*8(%r3)118119mr %r6,%r4 /* save val param */120mtlr %r11 /* r11 -> link reg */121mtcr %r12 /* r12 -> condition reg */122mr %r1,%r10 /* r10 -> stackptr */123mr %r4,%r3124li %r3,3 /* SIG_SETMASK */125addi %r4,%r4,4 /* &set */126li %r5,0 /* oset = NULL */127li %r0,SYS_sigprocmask /* sigprocmask(SIG_SET, &set, NULL) */128sc /* assume no error XXX */129or. %r3,%r6,%r6130bnelr131li %r3,1132blr133END(__longjmp)134135.section .note.GNU-stack,"",%progbits136137138