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