1/*- 2 * Copyright (c) 2016 Justin Hibbits 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26/* $NetBSD: _setjmp.S,v 1.1 1997/03/29 20:55:53 thorpej Exp $ */ 27 28#include <machine/asm.h> 29/* 30 * C library -- _setjmp, _longjmp 31 * 32 * _longjmp(a,v) 33 * will generate a "return(v?v:1)" from the last call to 34 * _setjmp(a) 35 * by restoring registers from the stack. 36 * The previous signal state is NOT restored. 37 * 38 * jmpbuf layout: 39 * +------------+ 40 * | unused | 41 * +------------+ 42 * | unused | 43 * | | 44 * | (4 words) | 45 * | | 46 * +------------+ 47 * | saved regs | 48 * | ... | 49 */ 50 51ENTRY(_setjmp) 52 mflr %r11 53 mfcr %r12 54 evstdd %r1,24+0*8(%r3) 55 evstdd %r2,24+1*8(%r3) 56 evstdd %r11,24+2*8(%r3) 57 evstdd %r12,24+3*8(%r3) 58 evstdd %r13,24+4*8(%r3) 59 evstdd %r14,24+5*8(%r3) 60 evstdd %r15,24+6*8(%r3) 61 evstdd %r16,24+7*8(%r3) 62 evstdd %r17,24+8*8(%r3) 63 evstdd %r18,24+9*8(%r3) 64 evstdd %r19,24+10*8(%r3) 65 evstdd %r20,24+11*8(%r3) 66 evstdd %r21,24+12*8(%r3) 67 evstdd %r22,24+13*8(%r3) 68 evstdd %r23,24+14*8(%r3) 69 evstdd %r24,24+15*8(%r3) 70 evstdd %r25,24+16*8(%r3) 71 evstdd %r26,24+17*8(%r3) 72 evstdd %r27,24+18*8(%r3) 73 evstdd %r28,24+19*8(%r3) 74 evstdd %r29,24+20*8(%r3) 75 evstdd %r30,24+21*8(%r3) 76 evstdd %r31,24+22*8(%r3) 77 78 li %r3,0 79 blr 80END(_setjmp) 81 82ENTRY(_longjmp) 83 evldd %r1,24+0*8(%r3) 84 evldd %r2,24+1*8(%r3) 85 evldd %r11,24+2*8(%r3) 86 evldd %r12,24+3*8(%r3) 87 evldd %r13,24+4*8(%r3) 88 evldd %r14,24+5*8(%r3) 89 evldd %r15,24+6*8(%r3) 90 evldd %r16,24+7*8(%r3) 91 evldd %r17,24+8*8(%r3) 92 evldd %r18,24+9*8(%r3) 93 evldd %r19,24+10*8(%r3) 94 evldd %r20,24+11*8(%r3) 95 evldd %r21,24+12*8(%r3) 96 evldd %r22,24+13*8(%r3) 97 evldd %r23,24+14*8(%r3) 98 evldd %r24,24+15*8(%r3) 99 evldd %r25,24+16*8(%r3) 100 evldd %r26,24+17*8(%r3) 101 evldd %r27,24+18*8(%r3) 102 evldd %r28,24+19*8(%r3) 103 evldd %r29,24+20*8(%r3) 104 evldd %r30,24+21*8(%r3) 105 evldd %r31,24+22*8(%r3) 106 107 mtlr %r11 108 mtcr %r12 109 or. %r3,%r4,%r4 110 bnelr 111 li %r3,1 112 blr 113END(_longjmp) 114 115 .section .note.GNU-stack,"",%progbits 116