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