xref: /freebsd/lib/libc/powerpc64/gen/_setjmp.S (revision 1d386b48a555f61cb7325543adbbb5c3f3407a66)
1840b91ccSNathan Whitehorn/*-
2840b91ccSNathan Whitehorn * Copyright (c) 2002 Peter Grehan.
3840b91ccSNathan Whitehorn * All rights reserved.
4840b91ccSNathan Whitehorn *
5840b91ccSNathan Whitehorn * Redistribution and use in source and binary forms, with or without
6840b91ccSNathan Whitehorn * modification, are permitted provided that the following conditions
7840b91ccSNathan Whitehorn * are met:
8840b91ccSNathan Whitehorn * 1. Redistributions of source code must retain the above copyright
9840b91ccSNathan Whitehorn *    notice, this list of conditions and the following disclaimer.
10840b91ccSNathan Whitehorn * 2. Redistributions in binary form must reproduce the above copyright
11840b91ccSNathan Whitehorn *    notice, this list of conditions and the following disclaimer in the
12840b91ccSNathan Whitehorn *    documentation and/or other materials provided with the distribution.
13840b91ccSNathan Whitehorn *
14840b91ccSNathan Whitehorn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15840b91ccSNathan Whitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16840b91ccSNathan Whitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17840b91ccSNathan Whitehorn * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18840b91ccSNathan Whitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19840b91ccSNathan Whitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20840b91ccSNathan Whitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21840b91ccSNathan Whitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22840b91ccSNathan Whitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23840b91ccSNathan Whitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24840b91ccSNathan Whitehorn * SUCH DAMAGE.
25840b91ccSNathan Whitehorn */
26840b91ccSNathan Whitehorn/*      $NetBSD: _setjmp.S,v 1.1 1997/03/29 20:55:53 thorpej Exp $      */
27840b91ccSNathan Whitehorn
28840b91ccSNathan Whitehorn#include <machine/asm.h>
29840b91ccSNathan Whitehorn/*
30840b91ccSNathan Whitehorn * C library -- _setjmp, _longjmp
31840b91ccSNathan Whitehorn *
32840b91ccSNathan Whitehorn *      _longjmp(a,v)
33840b91ccSNathan Whitehorn * will generate a "return(v?v:1)" from the last call to
34840b91ccSNathan Whitehorn *      _setjmp(a)
35840b91ccSNathan Whitehorn * by restoring registers from the stack.
36840b91ccSNathan Whitehorn * The previous signal state is NOT restored.
37840b91ccSNathan Whitehorn *
38840b91ccSNathan Whitehorn * jmpbuf layout:
39840b91ccSNathan Whitehorn *     +------------+
40840b91ccSNathan Whitehorn *     |   unused   |
41840b91ccSNathan Whitehorn *     +------------+
42840b91ccSNathan Whitehorn *     |   unused   |
43840b91ccSNathan Whitehorn *     |            |
44840b91ccSNathan Whitehorn *     | (4 words)  |
45840b91ccSNathan Whitehorn *     |            |
46840b91ccSNathan Whitehorn *     +------------+
47840b91ccSNathan Whitehorn *     | saved regs |
48840b91ccSNathan Whitehorn *     |    ...     |
49840b91ccSNathan Whitehorn */
50840b91ccSNathan Whitehorn
51840b91ccSNathan WhitehornENTRY(_setjmp)
52840b91ccSNathan Whitehorn	mflr	%r11
53840b91ccSNathan Whitehorn	mfcr	%r12
54840b91ccSNathan Whitehorn	mr	%r10,%r1
55840b91ccSNathan Whitehorn	mr	%r9,%r2
56840b91ccSNathan Whitehorn	std	%r9,40 + 0*8(%r3)
57*1ee35324SNathan Whitehorn	stfd	%f14,40 + 23*8(%r3)
58840b91ccSNathan Whitehorn	std	%r10,40 + 1*8(%r3)
59*1ee35324SNathan Whitehorn	stfd	%f15,40 + 24*8(%r3)
60840b91ccSNathan Whitehorn	std	%r11,40 + 2*8(%r3)
61*1ee35324SNathan Whitehorn	stfd	%f16,40 + 25*8(%r3)
62840b91ccSNathan Whitehorn	std	%r12,40 + 3*8(%r3)
63*1ee35324SNathan Whitehorn	stfd	%f17,40 + 26*8(%r3)
64840b91ccSNathan Whitehorn	std	%r13,40 + 4*8(%r3)
65*1ee35324SNathan Whitehorn	stfd	%f18,40 + 27*8(%r3)
66840b91ccSNathan Whitehorn	std	%r14,40 + 5*8(%r3)
67*1ee35324SNathan Whitehorn	stfd	%f19,40 + 28*8(%r3)
68840b91ccSNathan Whitehorn	std	%r15,40 + 6*8(%r3)
69*1ee35324SNathan Whitehorn	stfd	%f20,40 + 29*8(%r3)
70840b91ccSNathan Whitehorn	std	%r16,40 + 7*8(%r3)
71*1ee35324SNathan Whitehorn	stfd	%f21,40 + 30*8(%r3)
72840b91ccSNathan Whitehorn	std	%r17,40 + 8*8(%r3)
73*1ee35324SNathan Whitehorn	stfd	%f22,40 + 31*8(%r3)
74840b91ccSNathan Whitehorn	std	%r18,40 + 9*8(%r3)
75*1ee35324SNathan Whitehorn	stfd	%f23,40 + 32*8(%r3)
76840b91ccSNathan Whitehorn	std	%r19,40 + 10*8(%r3)
77*1ee35324SNathan Whitehorn	stfd	%f24,40 + 33*8(%r3)
78840b91ccSNathan Whitehorn	std	%r20,40 + 11*8(%r3)
79*1ee35324SNathan Whitehorn	stfd	%f25,40 + 34*8(%r3)
80840b91ccSNathan Whitehorn	std	%r21,40 + 12*8(%r3)
81*1ee35324SNathan Whitehorn	stfd	%f26,40 + 35*8(%r3)
82840b91ccSNathan Whitehorn	std	%r22,40 + 13*8(%r3)
83*1ee35324SNathan Whitehorn	stfd	%f27,40 + 36*8(%r3)
84840b91ccSNathan Whitehorn	std	%r23,40 + 14*8(%r3)
85*1ee35324SNathan Whitehorn	stfd	%f28,40 + 37*8(%r3)
86840b91ccSNathan Whitehorn	std	%r24,40 + 15*8(%r3)
87*1ee35324SNathan Whitehorn	stfd	%f29,40 + 38*8(%r3)
88840b91ccSNathan Whitehorn	std	%r25,40 + 16*8(%r3)
89*1ee35324SNathan Whitehorn	stfd	%f30,40 + 39*8(%r3)
90840b91ccSNathan Whitehorn	std	%r26,40 + 17*8(%r3)
91*1ee35324SNathan Whitehorn	stfd	%f31,40 + 40*8(%r3)
92840b91ccSNathan Whitehorn	std	%r27,40 + 18*8(%r3)
93840b91ccSNathan Whitehorn	std	%r28,40 + 19*8(%r3)
94840b91ccSNathan Whitehorn	std	%r29,40 + 20*8(%r3)
95840b91ccSNathan Whitehorn	std	%r30,40 + 21*8(%r3)
96840b91ccSNathan Whitehorn	std	%r31,40 + 22*8(%r3)
97840b91ccSNathan Whitehorn	li	%r3,0
98840b91ccSNathan Whitehorn	blr
99ad9bbe98SBaptiste DaroussinEND(_setjmp)
100840b91ccSNathan Whitehorn
101840b91ccSNathan WhitehornENTRY(_longjmp)
102840b91ccSNathan Whitehorn	ld	%r9,40 + 0*8(%r3)
103*1ee35324SNathan Whitehorn	lfd	%f14,40 + 23*8(%r3)
104840b91ccSNathan Whitehorn	ld	%r10,40 + 1*8(%r3)
105*1ee35324SNathan Whitehorn	lfd	%f15,40 + 24*8(%r3)
106840b91ccSNathan Whitehorn	ld	%r11,40 + 2*8(%r3)
107*1ee35324SNathan Whitehorn	lfd	%f16,40 + 25*8(%r3)
108840b91ccSNathan Whitehorn	ld	%r12,40 + 3*8(%r3)
109*1ee35324SNathan Whitehorn	lfd	%f17,40 + 26*8(%r3)
110840b91ccSNathan Whitehorn	ld	%r14,40 + 5*8(%r3)
111*1ee35324SNathan Whitehorn	lfd	%f18,40 + 27*8(%r3)
112840b91ccSNathan Whitehorn	ld	%r15,40 + 6*8(%r3)
113*1ee35324SNathan Whitehorn	lfd	%f19,40 + 28*8(%r3)
114840b91ccSNathan Whitehorn	ld	%r16,40 + 7*8(%r3)
115*1ee35324SNathan Whitehorn	lfd	%f20,40 + 29*8(%r3)
116840b91ccSNathan Whitehorn	ld	%r17,40 + 8*8(%r3)
117*1ee35324SNathan Whitehorn	lfd	%f21,40 + 30*8(%r3)
118840b91ccSNathan Whitehorn	ld	%r18,40 + 9*8(%r3)
119*1ee35324SNathan Whitehorn	lfd	%f22,40 + 31*8(%r3)
120840b91ccSNathan Whitehorn	ld	%r19,40 + 10*8(%r3)
121*1ee35324SNathan Whitehorn	lfd	%f23,40 + 32*8(%r3)
122840b91ccSNathan Whitehorn	ld	%r20,40 + 11*8(%r3)
123*1ee35324SNathan Whitehorn	lfd	%f24,40 + 33*8(%r3)
124840b91ccSNathan Whitehorn	ld	%r21,40 + 12*8(%r3)
125*1ee35324SNathan Whitehorn	lfd	%f25,40 + 34*8(%r3)
126840b91ccSNathan Whitehorn	ld	%r22,40 + 13*8(%r3)
127*1ee35324SNathan Whitehorn	lfd	%f26,40 + 35*8(%r3)
128840b91ccSNathan Whitehorn	ld	%r23,40 + 14*8(%r3)
129*1ee35324SNathan Whitehorn	lfd	%f27,40 + 36*8(%r3)
130840b91ccSNathan Whitehorn	ld	%r24,40 + 15*8(%r3)
131*1ee35324SNathan Whitehorn	lfd	%f28,40 + 37*8(%r3)
132840b91ccSNathan Whitehorn	ld	%r25,40 + 16*8(%r3)
133*1ee35324SNathan Whitehorn	lfd	%f29,40 + 38*8(%r3)
134840b91ccSNathan Whitehorn	ld	%r26,40 + 17*8(%r3)
135*1ee35324SNathan Whitehorn	lfd	%f30,40 + 39*8(%r3)
136840b91ccSNathan Whitehorn	ld	%r27,40 + 18*8(%r3)
137*1ee35324SNathan Whitehorn	lfd	%f31,40 + 40*8(%r3)
138840b91ccSNathan Whitehorn	ld	%r28,40 + 19*8(%r3)
139840b91ccSNathan Whitehorn	ld	%r29,40 + 20*8(%r3)
140840b91ccSNathan Whitehorn	ld	%r30,40 + 21*8(%r3)
141840b91ccSNathan Whitehorn	ld	%r31,40 + 22*8(%r3)
142840b91ccSNathan Whitehorn
143840b91ccSNathan Whitehorn	mtlr	%r11
144840b91ccSNathan Whitehorn	mtcr	%r12
145840b91ccSNathan Whitehorn	mr	%r2,%r9
146840b91ccSNathan Whitehorn	mr	%r1,%r10
147840b91ccSNathan Whitehorn	or.	%r3,%r4,%r4
148840b91ccSNathan Whitehorn	bnelr
149840b91ccSNathan Whitehorn	li	%r3,1
150840b91ccSNathan Whitehorn	blr
151ad9bbe98SBaptiste DaroussinEND(_longjmp)
1528f861da9SKonstantin Belousov
1538f861da9SKonstantin Belousov	.section .note.GNU-stack,"",%progbits
154