/*-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 */6566std %r9,40 + 0*8(%r6)67stfd %f14,40 + 23*8(%r6)68std %r10,40 + 1*8(%r6)69stfd %f15,40 + 24*8(%r6)70std %r11,40 + 2*8(%r6)71stfd %f16,40 + 25*8(%r6)72std %r12,40 + 3*8(%r6)73stfd %f17,40 + 26*8(%r6)74std %r13,40 + 4*8(%r6)75stfd %f18,40 + 27*8(%r6)76std %r14,40 + 5*8(%r6)77stfd %f19,40 + 28*8(%r6)78std %r15,40 + 6*8(%r6)79stfd %f20,40 + 29*8(%r6)80std %r16,40 + 7*8(%r6)81stfd %f21,40 + 30*8(%r6)82std %r17,40 + 8*8(%r6)83stfd %f22,40 + 31*8(%r6)84std %r18,40 + 9*8(%r6)85stfd %f23,40 + 32*8(%r6)86std %r19,40 + 10*8(%r6)87stfd %f24,40 + 33*8(%r6)88std %r20,40 + 11*8(%r6)89stfd %f25,40 + 34*8(%r6)90std %r21,40 + 12*8(%r6)91stfd %f26,40 + 35*8(%r6)92std %r22,40 + 13*8(%r6)93stfd %f27,40 + 36*8(%r6)94std %r23,40 + 14*8(%r6)95stfd %f28,40 + 37*8(%r6)96std %r24,40 + 15*8(%r6)97stfd %f29,40 + 38*8(%r6)98std %r25,40 + 16*8(%r6)99stfd %f30,40 + 39*8(%r6)100std %r26,40 + 17*8(%r6)101stfd %f31,40 + 40*8(%r6)102std %r27,40 + 18*8(%r6)103std %r28,40 + 19*8(%r6)104std %r29,40 + 20*8(%r6)105std %r30,40 + 21*8(%r6)106std %r31,40 + 22*8(%r6)107108/* XXX Altivec regs */109110li %r3,0 /* return (0) */111blr112END(setjmp)113114WEAK_REFERENCE(__longjmp, longjmp)115ENTRY(__longjmp)116ld %r9,40 + 0*8(%r3)117lfd %f14,40 + 23*8(%r3)118ld %r10,40 + 1*8(%r3)119lfd %f15,40 + 24*8(%r3)120ld %r11,40 + 2*8(%r3)121lfd %f16,40 + 25*8(%r3)122ld %r12,40 + 3*8(%r3)123lfd %f17,40 + 26*8(%r3)124ld %r14,40 + 5*8(%r3)125lfd %f18,40 + 27*8(%r3)126ld %r15,40 + 6*8(%r3)127lfd %f19,40 + 28*8(%r3)128ld %r16,40 + 7*8(%r3)129lfd %f20,40 + 29*8(%r3)130ld %r17,40 + 8*8(%r3)131lfd %f21,40 + 30*8(%r3)132ld %r18,40 + 9*8(%r3)133lfd %f22,40 + 31*8(%r3)134ld %r19,40 + 10*8(%r3)135lfd %f23,40 + 32*8(%r3)136ld %r20,40 + 11*8(%r3)137lfd %f24,40 + 33*8(%r3)138ld %r21,40 + 12*8(%r3)139lfd %f25,40 + 34*8(%r3)140ld %r22,40 + 13*8(%r3)141lfd %f26,40 + 35*8(%r3)142ld %r23,40 + 14*8(%r3)143lfd %f27,40 + 36*8(%r3)144ld %r24,40 + 15*8(%r3)145lfd %f28,40 + 37*8(%r3)146ld %r25,40 + 16*8(%r3)147lfd %f29,40 + 38*8(%r3)148ld %r26,40 + 17*8(%r3)149lfd %f30,40 + 39*8(%r3)150ld %r27,40 + 18*8(%r3)151lfd %f31,40 + 40*8(%r3)152ld %r28,40 + 19*8(%r3)153ld %r29,40 + 20*8(%r3)154ld %r30,40 + 21*8(%r3)155ld %r31,40 + 22*8(%r3)156mr %r6,%r4 /* save val param */157mtlr %r11 /* r11 -> link reg */158mtcr %r12 /* r12 -> condition reg */159mr %r2,%r9 /* r9 -> global ptr */160mr %r1,%r10 /* r10 -> stackptr */161mr %r4,%r3162li %r3,3 /* SIG_SETMASK */163addi %r4,%r4,4 /* &set */164li %r5,0 /* oset = NULL */165li %r0,SYS_sigprocmask /* sigprocmask(SIG_SET, &set, NULL) */166sc /* assume no error XXX */167or. %r3,%r6,%r6168bnelr169li %r3,1170blr171END(__longjmp)172173.section .note.GNU-stack,"",%progbits174175176