/*-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: 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 */65stmw %r9,20(%r6)6667/* FPRs */68stfd %f14,112+0*8(%r6)69stfd %f15,112+1*8(%r6)70stfd %f16,112+2*8(%r6)71stfd %f17,112+3*8(%r6)72stfd %f18,112+4*8(%r6)73stfd %f19,112+5*8(%r6)74stfd %f20,112+6*8(%r6)75stfd %f21,112+7*8(%r6)76stfd %f22,112+8*8(%r6)77stfd %f23,112+9*8(%r6)78stfd %f24,112+10*8(%r6)79stfd %f25,112+11*8(%r6)80stfd %f26,112+12*8(%r6)81stfd %f27,112+13*8(%r6)82stfd %f28,112+14*8(%r6)83stfd %f29,112+15*8(%r6)84stfd %f30,112+16*8(%r6)85stfd %f31,112+17*8(%r6)8687li %r3,0 /* return (0) */88blr89END(setjmp)9091WEAK_REFERENCE(CNAME(__longjmp), longjmp)92ENTRY(__longjmp)93lmw %r9,20(%r3) /* restore regs */9495/* FPRs */96lfd %f14,112+0*8(%r3)97lfd %f15,112+1*8(%r3)98lfd %f16,112+2*8(%r3)99lfd %f17,112+3*8(%r3)100lfd %f18,112+4*8(%r3)101lfd %f19,112+5*8(%r3)102lfd %f20,112+6*8(%r3)103lfd %f21,112+7*8(%r3)104lfd %f22,112+8*8(%r3)105lfd %f23,112+9*8(%r3)106lfd %f24,112+10*8(%r3)107lfd %f25,112+11*8(%r3)108lfd %f26,112+12*8(%r3)109lfd %f27,112+13*8(%r3)110lfd %f28,112+14*8(%r3)111lfd %f29,112+15*8(%r3)112lfd %f30,112+16*8(%r3)113lfd %f31,112+17*8(%r3)114115mr %r6,%r4 /* save val param */116mtlr %r11 /* r11 -> link reg */117mtcr %r12 /* r12 -> condition reg */118mr %r1,%r10 /* r10 -> stackptr */119mr %r4,%r3120li %r3,3 /* SIG_SETMASK */121addi %r4,%r4,4 /* &set */122li %r5,0 /* oset = NULL */123li %r0,SYS_sigprocmask /* sigprocmask(SIG_SET, &set, NULL) */124sc /* assume no error XXX */125or. %r3,%r6,%r6126bnelr127li %r3,1128blr129END(__longjmp)130131.section .note.GNU-stack,"",%progbits132133134