1/* $FreeBSD$ */ 2/* from: NetBSD: setjmp.S,v 1.1 1998/01/27 15:13:12 sakamoto Exp $ */ 3/* from: OpenBSD: setjmp.S,v 1.2 1996/12/28 06:22:18 rahnds Exp */ 4/* kernel version of this file, does not have signal goop */ 5/* int setjmp(jmp_buf env) */ 6 7#define _ASM 8#include <asm/types.h> 9 10#ifdef __powerpc64__ 11#if !defined(PPC64_ELF_ABI_v2) && !defined(PPC64_ELF_ABI_v1) 12#if defined(_CALL_ELF) && _CALL_ELF == 2 13#define PPC64_ELF_ABI_v2 14#endif /* _CALL_ELF */ 15#endif /* PPC64_ELF_ABI_ */ 16#endif /* __powerpc64__ */ 17 18#ifdef __powerpc64__ 19#define LD_REG ld 20#define ST_REG std 21#define REGWIDTH 8 22#else 23#define LD_REG lwz 24#define ST_REG stw 25#define REGWIDTH 4 26#endif /* __powerpc64__ */ 27 28#define JMP_r1 1*REGWIDTH 29#define JMP_r2 2*REGWIDTH 30#define JMP_r14 3*REGWIDTH 31#define JMP_r15 4*REGWIDTH 32#define JMP_r16 5*REGWIDTH 33#define JMP_r17 6*REGWIDTH 34#define JMP_r18 7*REGWIDTH 35#define JMP_r19 8*REGWIDTH 36#define JMP_r20 9*REGWIDTH 37#define JMP_r21 10*REGWIDTH 38#define JMP_r22 11*REGWIDTH 39#define JMP_r23 12*REGWIDTH 40#define JMP_r24 13*REGWIDTH 41#define JMP_r25 14*REGWIDTH 42#define JMP_r26 15*REGWIDTH 43#define JMP_r27 16*REGWIDTH 44#define JMP_r28 17*REGWIDTH 45#define JMP_r29 18*REGWIDTH 46#define JMP_r30 19*REGWIDTH 47#define JMP_r31 20*REGWIDTH 48#define JMP_lr 21*REGWIDTH 49#define JMP_cr 22*REGWIDTH 50#define JMP_ctr 23*REGWIDTH 51#define JMP_xer 24*REGWIDTH 52 53#ifdef __powerpc64__ 54#ifdef PPC64_ELF_ABI_v2 55 56#define ENTRY(name) \ 57 .balign 2 ; \ 58 .type name,@function; \ 59 .weak name; \ 60name: 61 62#else /* PPC64_ELF_ABI_v1 */ 63 64#define XGLUE(a,b) a##b 65#define GLUE(a,b) XGLUE(a,b) 66#define ENTRY(name) \ 67 .balign 2 ; \ 68 .weak name; \ 69 .weak GLUE(.,name); \ 70 .pushsection ".opd","aw"; \ 71name: \ 72 .quad GLUE(.,name); \ 73 .quad .TOC.@tocbase; \ 74 .quad 0; \ 75 .popsection; \ 76 .type GLUE(.,name),@function; \ 77GLUE(.,name): 78 79#endif /* PPC64_ELF_ABI_v2 */ 80 81#else /* 32-bit */ 82 83#define ENTRY(name) \ 84 .text; \ 85 .p2align 4; \ 86 .weak name; \ 87 .type name,@function; \ 88name: 89 90#endif /* __powerpc64__ */ 91 92 93ENTRY(setjmp) 94 ST_REG 31, JMP_r31(3) 95 /* r1, r2, r14-r30 */ 96 ST_REG 1, JMP_r1 (3) 97 ST_REG 2, JMP_r2 (3) 98 ST_REG 14, JMP_r14(3) 99 ST_REG 15, JMP_r15(3) 100 ST_REG 16, JMP_r16(3) 101 ST_REG 17, JMP_r17(3) 102 ST_REG 18, JMP_r18(3) 103 ST_REG 19, JMP_r19(3) 104 ST_REG 20, JMP_r20(3) 105 ST_REG 21, JMP_r21(3) 106 ST_REG 22, JMP_r22(3) 107 ST_REG 23, JMP_r23(3) 108 ST_REG 24, JMP_r24(3) 109 ST_REG 25, JMP_r25(3) 110 ST_REG 26, JMP_r26(3) 111 ST_REG 27, JMP_r27(3) 112 ST_REG 28, JMP_r28(3) 113 ST_REG 29, JMP_r29(3) 114 ST_REG 30, JMP_r30(3) 115 /* cr, lr, ctr, xer */ 116 mfcr 0 117 ST_REG 0, JMP_cr(3) 118 mflr 0 119 ST_REG 0, JMP_lr(3) 120 mfctr 0 121 ST_REG 0, JMP_ctr(3) 122 mfxer 0 123 ST_REG 0, JMP_xer(3) 124 /* f14-f31, fpscr */ 125 li 3, 0 126 blr 127 128ENTRY(longjmp) 129 LD_REG 31, JMP_r31(3) 130 /* r1, r2, r14-r30 */ 131 LD_REG 1, JMP_r1 (3) 132 LD_REG 2, JMP_r2 (3) 133 LD_REG 14, JMP_r14(3) 134 LD_REG 15, JMP_r15(3) 135 LD_REG 16, JMP_r16(3) 136 LD_REG 17, JMP_r17(3) 137 LD_REG 18, JMP_r18(3) 138 LD_REG 19, JMP_r19(3) 139 LD_REG 20, JMP_r20(3) 140 LD_REG 21, JMP_r21(3) 141 LD_REG 22, JMP_r22(3) 142 LD_REG 23, JMP_r23(3) 143 LD_REG 24, JMP_r24(3) 144 LD_REG 25, JMP_r25(3) 145 LD_REG 26, JMP_r26(3) 146 LD_REG 27, JMP_r27(3) 147 LD_REG 28, JMP_r28(3) 148 LD_REG 29, JMP_r29(3) 149 LD_REG 30, JMP_r30(3) 150 /* cr, lr, ctr, xer */ 151 LD_REG 0, JMP_cr(3) 152 mtcr 0 153 LD_REG 0, JMP_lr(3) 154 mtlr 0 155 LD_REG 0, JMP_ctr(3) 156 mtctr 0 157 LD_REG 0, JMP_xer(3) 158 mtxer 0 159 /* f14-f31, fpscr */ 160 mr 3, 4 161 blr 162 163#ifdef __ELF__ 164.section .note.GNU-stack,"",%progbits 165#endif 166