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: sigsetjmp.S,v 1.4 1998/10/03 12:30:38 tsubai Exp $ */ 27840b91ccSNathan Whitehorn 28840b91ccSNathan Whitehorn#include <machine/asm.h> 29840b91ccSNathan Whitehorn/* 30840b91ccSNathan Whitehorn * C library -- sigsetjmp, siglongjmp 31840b91ccSNathan Whitehorn * 32840b91ccSNathan Whitehorn * siglongjmp(a,v) 33840b91ccSNathan Whitehorn * will generate a "return(v?v:1)" from the last call to 34840b91ccSNathan Whitehorn * sigsetjmp(a, savemask) 35840b91ccSNathan Whitehorn * by restoring registers from the stack. 36840b91ccSNathan Whitehorn * The previous signal state is restored if savemask is non-zero 37840b91ccSNathan Whitehorn * 38840b91ccSNathan Whitehorn * jmpbuf layout: 39840b91ccSNathan Whitehorn * +------------+ 40840b91ccSNathan Whitehorn * | savemask | 41840b91ccSNathan Whitehorn * +------------+ 42840b91ccSNathan Whitehorn * | sig state | 43840b91ccSNathan Whitehorn * | | 44840b91ccSNathan Whitehorn * | (4 words) | 45840b91ccSNathan Whitehorn * | | 46840b91ccSNathan Whitehorn * +------------+ 47840b91ccSNathan Whitehorn * | saved regs | 48840b91ccSNathan Whitehorn * | ... | 49840b91ccSNathan Whitehorn */ 50840b91ccSNathan Whitehorn 51840b91ccSNathan Whitehorn 52840b91ccSNathan Whitehorn#include <sys/syscall.h> 53840b91ccSNathan Whitehorn 54840b91ccSNathan WhitehornENTRY(sigsetjmp) 55840b91ccSNathan Whitehorn mr %r6,%r3 56840b91ccSNathan Whitehorn stw %r4,0(%r3) 57840b91ccSNathan Whitehorn or. %r7,%r4,%r4 58840b91ccSNathan Whitehorn beq 1f 59840b91ccSNathan Whitehorn li %r3,1 /* SIG_BLOCK, but doesn't matter */ 60840b91ccSNathan Whitehorn /* since set == NULL */ 61840b91ccSNathan Whitehorn li %r4,0 /* set = NULL */ 62840b91ccSNathan Whitehorn mr %r5,%r6 /* &oset */ 63840b91ccSNathan Whitehorn addi %r5,%r5,4 64840b91ccSNathan Whitehorn li %r0, SYS_sigprocmask /* sigprocmask(SIG_BLOCK, NULL, &oset)*/ 65840b91ccSNathan Whitehorn sc /* assume no error XXX */ 66840b91ccSNathan Whitehorn1: 67840b91ccSNathan Whitehorn mflr %r11 68840b91ccSNathan Whitehorn mfcr %r12 69840b91ccSNathan Whitehorn mr %r10,%r1 70840b91ccSNathan Whitehorn mr %r9,%r2 71840b91ccSNathan Whitehorn 72840b91ccSNathan Whitehorn std %r9,40 + 0*8(%r6) 73*1ee35324SNathan Whitehorn stfd %f14,40 + 23*8(%r6) 74840b91ccSNathan Whitehorn std %r10,40 + 1*8(%r6) 75*1ee35324SNathan Whitehorn stfd %f15,40 + 24*8(%r6) 76840b91ccSNathan Whitehorn std %r11,40 + 2*8(%r6) 77*1ee35324SNathan Whitehorn stfd %f16,40 + 25*8(%r6) 78840b91ccSNathan Whitehorn std %r12,40 + 3*8(%r6) 79*1ee35324SNathan Whitehorn stfd %f17,40 + 26*8(%r6) 80840b91ccSNathan Whitehorn std %r13,40 + 4*8(%r6) 81*1ee35324SNathan Whitehorn stfd %f18,40 + 27*8(%r6) 82840b91ccSNathan Whitehorn std %r14,40 + 5*8(%r6) 83*1ee35324SNathan Whitehorn stfd %f19,40 + 28*8(%r6) 84840b91ccSNathan Whitehorn std %r15,40 + 6*8(%r6) 85*1ee35324SNathan Whitehorn stfd %f20,40 + 29*8(%r6) 86840b91ccSNathan Whitehorn std %r16,40 + 7*8(%r6) 87*1ee35324SNathan Whitehorn stfd %f21,40 + 30*8(%r6) 88840b91ccSNathan Whitehorn std %r17,40 + 8*8(%r6) 89*1ee35324SNathan Whitehorn stfd %f22,40 + 31*8(%r6) 90840b91ccSNathan Whitehorn std %r18,40 + 9*8(%r6) 91*1ee35324SNathan Whitehorn stfd %f23,40 + 32*8(%r6) 92840b91ccSNathan Whitehorn std %r19,40 + 10*8(%r6) 93*1ee35324SNathan Whitehorn stfd %f24,40 + 33*8(%r6) 94840b91ccSNathan Whitehorn std %r20,40 + 11*8(%r6) 95*1ee35324SNathan Whitehorn stfd %f25,40 + 34*8(%r6) 96840b91ccSNathan Whitehorn std %r21,40 + 12*8(%r6) 97*1ee35324SNathan Whitehorn stfd %f26,40 + 35*8(%r6) 98840b91ccSNathan Whitehorn std %r22,40 + 13*8(%r6) 99*1ee35324SNathan Whitehorn stfd %f27,40 + 36*8(%r6) 100840b91ccSNathan Whitehorn std %r23,40 + 14*8(%r6) 101*1ee35324SNathan Whitehorn stfd %f28,40 + 37*8(%r6) 102840b91ccSNathan Whitehorn std %r24,40 + 15*8(%r6) 103*1ee35324SNathan Whitehorn stfd %f29,40 + 38*8(%r6) 104840b91ccSNathan Whitehorn std %r25,40 + 16*8(%r6) 105*1ee35324SNathan Whitehorn stfd %f30,40 + 39*8(%r6) 106840b91ccSNathan Whitehorn std %r26,40 + 17*8(%r6) 107*1ee35324SNathan Whitehorn stfd %f31,40 + 40*8(%r6) 108840b91ccSNathan Whitehorn std %r27,40 + 18*8(%r6) 109840b91ccSNathan Whitehorn std %r28,40 + 19*8(%r6) 110840b91ccSNathan Whitehorn std %r29,40 + 20*8(%r6) 111840b91ccSNathan Whitehorn std %r30,40 + 21*8(%r6) 112840b91ccSNathan Whitehorn std %r31,40 + 22*8(%r6) 113840b91ccSNathan Whitehorn 114840b91ccSNathan Whitehorn li %r3,0 115840b91ccSNathan Whitehorn blr 116ad9bbe98SBaptiste DaroussinEND(sigsetjmp) 117840b91ccSNathan Whitehorn 118840b91ccSNathan WhitehornENTRY(siglongjmp) 119840b91ccSNathan Whitehorn ld %r9,40 + 0*8(%r3) 120*1ee35324SNathan Whitehorn lfd %f14,40 + 23*8(%r3) 121840b91ccSNathan Whitehorn ld %r10,40 + 1*8(%r3) 122*1ee35324SNathan Whitehorn lfd %f15,40 + 24*8(%r3) 123840b91ccSNathan Whitehorn ld %r11,40 + 2*8(%r3) 124*1ee35324SNathan Whitehorn lfd %f16,40 + 25*8(%r3) 125840b91ccSNathan Whitehorn ld %r12,40 + 3*8(%r3) 126*1ee35324SNathan Whitehorn lfd %f17,40 + 26*8(%r3) 127840b91ccSNathan Whitehorn ld %r14,40 + 5*8(%r3) 128*1ee35324SNathan Whitehorn lfd %f18,40 + 27*8(%r3) 129840b91ccSNathan Whitehorn ld %r15,40 + 6*8(%r3) 130*1ee35324SNathan Whitehorn lfd %f19,40 + 28*8(%r3) 131840b91ccSNathan Whitehorn ld %r16,40 + 7*8(%r3) 132*1ee35324SNathan Whitehorn lfd %f20,40 + 29*8(%r3) 133840b91ccSNathan Whitehorn ld %r17,40 + 8*8(%r3) 134*1ee35324SNathan Whitehorn lfd %f21,40 + 30*8(%r3) 135840b91ccSNathan Whitehorn ld %r18,40 + 9*8(%r3) 136*1ee35324SNathan Whitehorn lfd %f22,40 + 31*8(%r3) 137840b91ccSNathan Whitehorn ld %r19,40 + 10*8(%r3) 138*1ee35324SNathan Whitehorn lfd %f23,40 + 32*8(%r3) 139840b91ccSNathan Whitehorn ld %r20,40 + 11*8(%r3) 140*1ee35324SNathan Whitehorn lfd %f24,40 + 33*8(%r3) 141840b91ccSNathan Whitehorn ld %r21,40 + 12*8(%r3) 142*1ee35324SNathan Whitehorn lfd %f25,40 + 34*8(%r3) 143840b91ccSNathan Whitehorn ld %r22,40 + 13*8(%r3) 144*1ee35324SNathan Whitehorn lfd %f26,40 + 35*8(%r3) 145840b91ccSNathan Whitehorn ld %r23,40 + 14*8(%r3) 146*1ee35324SNathan Whitehorn lfd %f27,40 + 36*8(%r3) 147840b91ccSNathan Whitehorn ld %r24,40 + 15*8(%r3) 148*1ee35324SNathan Whitehorn lfd %f28,40 + 37*8(%r3) 149840b91ccSNathan Whitehorn ld %r25,40 + 16*8(%r3) 150*1ee35324SNathan Whitehorn lfd %f29,40 + 38*8(%r3) 151840b91ccSNathan Whitehorn ld %r26,40 + 17*8(%r3) 152*1ee35324SNathan Whitehorn lfd %f30,40 + 39*8(%r3) 153840b91ccSNathan Whitehorn ld %r27,40 + 18*8(%r3) 154*1ee35324SNathan Whitehorn lfd %f31,40 + 40*8(%r3) 155840b91ccSNathan Whitehorn ld %r28,40 + 19*8(%r3) 156840b91ccSNathan Whitehorn ld %r29,40 + 20*8(%r3) 157840b91ccSNathan Whitehorn ld %r30,40 + 21*8(%r3) 158840b91ccSNathan Whitehorn ld %r31,40 + 22*8(%r3) 159840b91ccSNathan Whitehorn 160840b91ccSNathan Whitehorn lwz %r7,0(%r3) 161840b91ccSNathan Whitehorn mr %r6,%r4 162840b91ccSNathan Whitehorn mtlr %r11 163840b91ccSNathan Whitehorn mtcr %r12 164840b91ccSNathan Whitehorn mr %r2,%r9 165840b91ccSNathan Whitehorn mr %r1,%r10 166840b91ccSNathan Whitehorn or. %r7,%r7,%r7 167840b91ccSNathan Whitehorn beq 1f 168840b91ccSNathan Whitehorn mr %r4,%r3 169840b91ccSNathan Whitehorn li %r3,3 /* SIG_SETMASK */ 170840b91ccSNathan Whitehorn addi %r4,%r4,4 /* &set */ 171840b91ccSNathan Whitehorn li %r5,0 /* oset = NULL */ 172840b91ccSNathan Whitehorn li %r0,SYS_sigprocmask /* sigprocmask(SIG_SET, &set, NULL) */ 173840b91ccSNathan Whitehorn sc /* assume no error XXX */ 174840b91ccSNathan Whitehorn1: 175840b91ccSNathan Whitehorn or. %r3,%r6,%r6 176840b91ccSNathan Whitehorn bnelr 177840b91ccSNathan Whitehorn li %r3,1 178840b91ccSNathan Whitehorn blr 179ad9bbe98SBaptiste DaroussinEND(siglongjmp) 1808f861da9SKonstantin Belousov 1818f861da9SKonstantin Belousov .section .note.GNU-stack,"",%progbits 182