1/* $OpenBSD: setjmp.S,v 1.9 2008/05/21 19:42:07 miod Exp $ */ 2/* kernel version of this file, does not have signal goop */ 3/* int setjmp(jmp_buf env) */ 4 5/* 6 * Copyright (c) 1996 Dale Rahn. 7 * All rights reserved. 8 * 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include <machine/asm.h> 32#define JMP_r1 0x04 33#define JMP_r14 0x08 34#define JMP_r15 0x0c 35#define JMP_r16 0x10 36#define JMP_r17 0x14 37#define JMP_r18 0x18 38#define JMP_r19 0x1c 39#define JMP_r20 0x20 40#define JMP_r21 0x24 41#define JMP_r22 0x28 42#define JMP_r23 0x2c 43#define JMP_r24 0x30 44#define JMP_r25 0x34 45#define JMP_r26 0x38 46#define JMP_r27 0x3c 47#define JMP_r28 0x40 48#define JMP_r29 0x44 49#define JMP_r30 0x48 50#define JMP_r31 0x4c 51#define JMP_lr 0x50 52#define JMP_cr 0x54 53#define JMP_ctr 0x58 54#define JMP_xer 0x5c 55#define JMP_sig 0x60 56 57 58ENTRY(_C_LABEL(setjmp)) 59 stw %r31, JMP_r31(%r3) 60 /* r1, r14-r30 */ 61 stw %r1, JMP_r1 (%r3) 62 stw %r14, JMP_r14(%r3) 63 stw %r15, JMP_r15(%r3) 64 stw %r16, JMP_r16(%r3) 65 stw %r17, JMP_r17(%r3) 66 stw %r18, JMP_r18(%r3) 67 stw %r19, JMP_r19(%r3) 68 stw %r20, JMP_r20(%r3) 69 stw %r21, JMP_r21(%r3) 70 stw %r22, JMP_r22(%r3) 71 stw %r23, JMP_r23(%r3) 72 stw %r24, JMP_r24(%r3) 73 stw %r25, JMP_r25(%r3) 74 stw %r26, JMP_r26(%r3) 75 stw %r27, JMP_r27(%r3) 76 stw %r28, JMP_r28(%r3) 77 stw %r29, JMP_r29(%r3) 78 stw %r30, JMP_r30(%r3) 79 /* cr, lr, ctr, xer */ 80 mfcr %r0 81 stw %r0, JMP_cr(%r3) 82 mflr %r0 83 stw %r0, JMP_lr(%r3) 84 mfctr %r0 85 stw %r0, JMP_ctr(%r3) 86 mfxer %r0 87 stw %r0, JMP_xer(%r3) 88 /* f14-f31, fpscr */ 89 li %r3, 0 90 blr 91 92 93ENTRY(_C_LABEL(longjmp)) 94 lwz %r31, JMP_r31(%r3) 95 /* r1, r14-r30 */ 96 lwz %r1, JMP_r1 (%r3) 97 lwz %r14, JMP_r14(%r3) 98 lwz %r15, JMP_r15(%r3) 99 lwz %r16, JMP_r16(%r3) 100 lwz %r17, JMP_r17(%r3) 101 lwz %r18, JMP_r18(%r3) 102 lwz %r19, JMP_r19(%r3) 103 lwz %r20, JMP_r20(%r3) 104 lwz %r21, JMP_r21(%r3) 105 lwz %r22, JMP_r22(%r3) 106 lwz %r23, JMP_r23(%r3) 107 lwz %r24, JMP_r24(%r3) 108 lwz %r25, JMP_r25(%r3) 109 lwz %r26, JMP_r26(%r3) 110 lwz %r27, JMP_r27(%r3) 111 lwz %r28, JMP_r28(%r3) 112 lwz %r29, JMP_r29(%r3) 113 lwz %r30, JMP_r30(%r3) 114 /* cr, lr, ctr, xer */ 115 lwz %r0, JMP_cr(%r3) 116 mtcr %r0 117 lwz %r0, JMP_lr(%r3) 118 mtlr %r0 119 lwz %r0, JMP_ctr(%r3) 120 mtctr %r0 121 lwz %r0, JMP_xer(%r3) 122 mtxer %r0 123 /* f14-f31, fpscr */ 124 li %r3, 1 125 blr 126