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