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