1840b91ccSNathan Whitehorn/*- 2840b91ccSNathan Whitehorn * Copyright (c) 2002 Peter Grehan. 3840b91ccSNathan Whitehorn * All rights reserved. 4840b91ccSNathan Whitehorn * 5840b91ccSNathan Whitehorn * Redistribution and use in source and binary forms, with or without 6840b91ccSNathan Whitehorn * modification, are permitted provided that the following conditions 7840b91ccSNathan Whitehorn * are met: 8840b91ccSNathan Whitehorn * 1. Redistributions of source code must retain the above copyright 9840b91ccSNathan Whitehorn * notice, this list of conditions and the following disclaimer. 10840b91ccSNathan Whitehorn * 2. Redistributions in binary form must reproduce the above copyright 11840b91ccSNathan Whitehorn * notice, this list of conditions and the following disclaimer in the 12840b91ccSNathan Whitehorn * documentation and/or other materials provided with the distribution. 13840b91ccSNathan Whitehorn * 14840b91ccSNathan Whitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15840b91ccSNathan Whitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16840b91ccSNathan Whitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17840b91ccSNathan Whitehorn * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18840b91ccSNathan Whitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19840b91ccSNathan Whitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20840b91ccSNathan Whitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21840b91ccSNathan Whitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22840b91ccSNathan Whitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23840b91ccSNathan Whitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24840b91ccSNathan Whitehorn * SUCH DAMAGE. 25840b91ccSNathan Whitehorn */ 26840b91ccSNathan Whitehorn/* $NetBSD: setjmp.S,v 1.3 1998/10/03 12:30:38 tsubai Exp $ */ 27840b91ccSNathan Whitehorn 28840b91ccSNathan Whitehorn#include <machine/asm.h> 29840b91ccSNathan Whitehorn#include <sys/syscall.h> 30840b91ccSNathan Whitehorn 31840b91ccSNathan Whitehorn/* 32840b91ccSNathan Whitehorn * C library -- setjmp, longjmp 33840b91ccSNathan Whitehorn * 34840b91ccSNathan Whitehorn * longjmp(a,v) 35840b91ccSNathan Whitehorn * will generate a "return(v?v:1)" from the last call to 36840b91ccSNathan Whitehorn * setjmp(a) 37840b91ccSNathan Whitehorn * by restoring registers from the stack. 38840b91ccSNathan Whitehorn * The previous signal state is restored. 39840b91ccSNathan Whitehorn * 40840b91ccSNathan Whitehorn * jmpbuf layout: 41840b91ccSNathan Whitehorn * +------------+ 42840b91ccSNathan Whitehorn * | unused | 43840b91ccSNathan Whitehorn * +------------+ 44840b91ccSNathan Whitehorn * | sig state | 45840b91ccSNathan Whitehorn * | | 46840b91ccSNathan Whitehorn * | (4 words) | 47840b91ccSNathan Whitehorn * | | 48840b91ccSNathan Whitehorn * +------------+ 49840b91ccSNathan Whitehorn * | saved regs | 50840b91ccSNathan Whitehorn * | ... | 51840b91ccSNathan Whitehorn */ 52840b91ccSNathan Whitehorn 53840b91ccSNathan WhitehornENTRY(setjmp) 54840b91ccSNathan Whitehorn mr %r6,%r3 55840b91ccSNathan Whitehorn li %r3,1 /* SIG_BLOCK, but doesn't matter */ 56840b91ccSNathan Whitehorn /* since set == NULL */ 57840b91ccSNathan Whitehorn li %r4,0 /* set = NULL */ 58840b91ccSNathan Whitehorn mr %r5,%r6 /* &oset */ 59840b91ccSNathan Whitehorn addi %r5,%r5,4 60840b91ccSNathan Whitehorn li %r0, SYS_sigprocmask /*sigprocmask(SIG_BLOCK, NULL, &oset)*/ 61840b91ccSNathan Whitehorn sc /*assume no error XXX */ 62840b91ccSNathan Whitehorn mflr %r11 /* r11 <- link reg */ 63840b91ccSNathan Whitehorn mfcr %r12 /* r12 <- condition reg */ 64840b91ccSNathan Whitehorn mr %r10,%r1 /* r10 <- stackptr */ 65840b91ccSNathan Whitehorn mr %r9,%r2 /* r9 <- global ptr */ 66840b91ccSNathan Whitehorn 67840b91ccSNathan Whitehorn std %r9,40 + 0*8(%r6) 68*1ee35324SNathan Whitehorn stfd %f14,40 + 23*8(%r6) 69840b91ccSNathan Whitehorn std %r10,40 + 1*8(%r6) 70*1ee35324SNathan Whitehorn stfd %f15,40 + 24*8(%r6) 71840b91ccSNathan Whitehorn std %r11,40 + 2*8(%r6) 72*1ee35324SNathan Whitehorn stfd %f16,40 + 25*8(%r6) 73840b91ccSNathan Whitehorn std %r12,40 + 3*8(%r6) 74*1ee35324SNathan Whitehorn stfd %f17,40 + 26*8(%r6) 75840b91ccSNathan Whitehorn std %r13,40 + 4*8(%r6) 76*1ee35324SNathan Whitehorn stfd %f18,40 + 27*8(%r6) 77840b91ccSNathan Whitehorn std %r14,40 + 5*8(%r6) 78*1ee35324SNathan Whitehorn stfd %f19,40 + 28*8(%r6) 79840b91ccSNathan Whitehorn std %r15,40 + 6*8(%r6) 80*1ee35324SNathan Whitehorn stfd %f20,40 + 29*8(%r6) 81840b91ccSNathan Whitehorn std %r16,40 + 7*8(%r6) 82*1ee35324SNathan Whitehorn stfd %f21,40 + 30*8(%r6) 83840b91ccSNathan Whitehorn std %r17,40 + 8*8(%r6) 84*1ee35324SNathan Whitehorn stfd %f22,40 + 31*8(%r6) 85840b91ccSNathan Whitehorn std %r18,40 + 9*8(%r6) 86*1ee35324SNathan Whitehorn stfd %f23,40 + 32*8(%r6) 87840b91ccSNathan Whitehorn std %r19,40 + 10*8(%r6) 88*1ee35324SNathan Whitehorn stfd %f24,40 + 33*8(%r6) 89840b91ccSNathan Whitehorn std %r20,40 + 11*8(%r6) 90*1ee35324SNathan Whitehorn stfd %f25,40 + 34*8(%r6) 91840b91ccSNathan Whitehorn std %r21,40 + 12*8(%r6) 92*1ee35324SNathan Whitehorn stfd %f26,40 + 35*8(%r6) 93840b91ccSNathan Whitehorn std %r22,40 + 13*8(%r6) 94*1ee35324SNathan Whitehorn stfd %f27,40 + 36*8(%r6) 95840b91ccSNathan Whitehorn std %r23,40 + 14*8(%r6) 96*1ee35324SNathan Whitehorn stfd %f28,40 + 37*8(%r6) 97840b91ccSNathan Whitehorn std %r24,40 + 15*8(%r6) 98*1ee35324SNathan Whitehorn stfd %f29,40 + 38*8(%r6) 99840b91ccSNathan Whitehorn std %r25,40 + 16*8(%r6) 100*1ee35324SNathan Whitehorn stfd %f30,40 + 39*8(%r6) 101840b91ccSNathan Whitehorn std %r26,40 + 17*8(%r6) 102*1ee35324SNathan Whitehorn stfd %f31,40 + 40*8(%r6) 103840b91ccSNathan Whitehorn std %r27,40 + 18*8(%r6) 104840b91ccSNathan Whitehorn std %r28,40 + 19*8(%r6) 105840b91ccSNathan Whitehorn std %r29,40 + 20*8(%r6) 106840b91ccSNathan Whitehorn std %r30,40 + 21*8(%r6) 107840b91ccSNathan Whitehorn std %r31,40 + 22*8(%r6) 108840b91ccSNathan Whitehorn 109*1ee35324SNathan Whitehorn /* XXX Altivec regs */ 110*1ee35324SNathan Whitehorn 111840b91ccSNathan Whitehorn li %r3,0 /* return (0) */ 112840b91ccSNathan Whitehorn blr 113ad9bbe98SBaptiste DaroussinEND(setjmp) 114840b91ccSNathan Whitehorn 11554558cdcSAndreas Tobler WEAK_REFERENCE(__longjmp, longjmp) 116840b91ccSNathan WhitehornENTRY(__longjmp) 117840b91ccSNathan Whitehorn ld %r9,40 + 0*8(%r3) 118*1ee35324SNathan Whitehorn lfd %f14,40 + 23*8(%r3) 119840b91ccSNathan Whitehorn ld %r10,40 + 1*8(%r3) 120*1ee35324SNathan Whitehorn lfd %f15,40 + 24*8(%r3) 121840b91ccSNathan Whitehorn ld %r11,40 + 2*8(%r3) 122*1ee35324SNathan Whitehorn lfd %f16,40 + 25*8(%r3) 123840b91ccSNathan Whitehorn ld %r12,40 + 3*8(%r3) 124*1ee35324SNathan Whitehorn lfd %f17,40 + 26*8(%r3) 125840b91ccSNathan Whitehorn ld %r14,40 + 5*8(%r3) 126*1ee35324SNathan Whitehorn lfd %f18,40 + 27*8(%r3) 127840b91ccSNathan Whitehorn ld %r15,40 + 6*8(%r3) 128*1ee35324SNathan Whitehorn lfd %f19,40 + 28*8(%r3) 129840b91ccSNathan Whitehorn ld %r16,40 + 7*8(%r3) 130*1ee35324SNathan Whitehorn lfd %f20,40 + 29*8(%r3) 131840b91ccSNathan Whitehorn ld %r17,40 + 8*8(%r3) 132*1ee35324SNathan Whitehorn lfd %f21,40 + 30*8(%r3) 133840b91ccSNathan Whitehorn ld %r18,40 + 9*8(%r3) 134*1ee35324SNathan Whitehorn lfd %f22,40 + 31*8(%r3) 135840b91ccSNathan Whitehorn ld %r19,40 + 10*8(%r3) 136*1ee35324SNathan Whitehorn lfd %f23,40 + 32*8(%r3) 137840b91ccSNathan Whitehorn ld %r20,40 + 11*8(%r3) 138*1ee35324SNathan Whitehorn lfd %f24,40 + 33*8(%r3) 139840b91ccSNathan Whitehorn ld %r21,40 + 12*8(%r3) 140*1ee35324SNathan Whitehorn lfd %f25,40 + 34*8(%r3) 141840b91ccSNathan Whitehorn ld %r22,40 + 13*8(%r3) 142*1ee35324SNathan Whitehorn lfd %f26,40 + 35*8(%r3) 143840b91ccSNathan Whitehorn ld %r23,40 + 14*8(%r3) 144*1ee35324SNathan Whitehorn lfd %f27,40 + 36*8(%r3) 145840b91ccSNathan Whitehorn ld %r24,40 + 15*8(%r3) 146*1ee35324SNathan Whitehorn lfd %f28,40 + 37*8(%r3) 147840b91ccSNathan Whitehorn ld %r25,40 + 16*8(%r3) 148*1ee35324SNathan Whitehorn lfd %f29,40 + 38*8(%r3) 149840b91ccSNathan Whitehorn ld %r26,40 + 17*8(%r3) 150*1ee35324SNathan Whitehorn lfd %f30,40 + 39*8(%r3) 151840b91ccSNathan Whitehorn ld %r27,40 + 18*8(%r3) 152*1ee35324SNathan Whitehorn lfd %f31,40 + 40*8(%r3) 153840b91ccSNathan Whitehorn ld %r28,40 + 19*8(%r3) 154840b91ccSNathan Whitehorn ld %r29,40 + 20*8(%r3) 155840b91ccSNathan Whitehorn ld %r30,40 + 21*8(%r3) 156840b91ccSNathan Whitehorn ld %r31,40 + 22*8(%r3) 157840b91ccSNathan Whitehorn mr %r6,%r4 /* save val param */ 158840b91ccSNathan Whitehorn mtlr %r11 /* r11 -> link reg */ 159840b91ccSNathan Whitehorn mtcr %r12 /* r12 -> condition reg */ 160840b91ccSNathan Whitehorn mr %r2,%r9 /* r9 -> global ptr */ 161840b91ccSNathan Whitehorn mr %r1,%r10 /* r10 -> stackptr */ 162840b91ccSNathan Whitehorn mr %r4,%r3 163840b91ccSNathan Whitehorn li %r3,3 /* SIG_SETMASK */ 164840b91ccSNathan Whitehorn addi %r4,%r4,4 /* &set */ 165840b91ccSNathan Whitehorn li %r5,0 /* oset = NULL */ 166840b91ccSNathan Whitehorn li %r0,SYS_sigprocmask /* sigprocmask(SIG_SET, &set, NULL) */ 167840b91ccSNathan Whitehorn sc /* assume no error XXX */ 168840b91ccSNathan Whitehorn or. %r3,%r6,%r6 169840b91ccSNathan Whitehorn bnelr 170840b91ccSNathan Whitehorn li %r3,1 171840b91ccSNathan Whitehorn blr 172ad9bbe98SBaptiste DaroussinEND(__longjmp) 173840b91ccSNathan Whitehorn 1748f861da9SKonstantin Belousov .section .note.GNU-stack,"",%progbits 175