xref: /freebsd/lib/libc/powerpc64/gen/sigsetjmp.S (revision 8f861da99cb9865b2f1ef6098ad074150f368c23)
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: sigsetjmp.S,v 1.4 1998/10/03 12:30:38 tsubai Exp $     */
27840b91ccSNathan Whitehorn
28840b91ccSNathan Whitehorn#include <machine/asm.h>
29840b91ccSNathan Whitehorn__FBSDID("$FreeBSD$");
30840b91ccSNathan Whitehorn
31840b91ccSNathan Whitehorn/*
32840b91ccSNathan Whitehorn * C library -- sigsetjmp, siglongjmp
33840b91ccSNathan Whitehorn *
34840b91ccSNathan Whitehorn *      siglongjmp(a,v)
35840b91ccSNathan Whitehorn * will generate a "return(v?v:1)" from the last call to
36840b91ccSNathan Whitehorn *      sigsetjmp(a, savemask)
37840b91ccSNathan Whitehorn * by restoring registers from the stack.
38840b91ccSNathan Whitehorn * The previous signal state is restored if savemask is non-zero
39840b91ccSNathan Whitehorn *
40840b91ccSNathan Whitehorn * jmpbuf layout:
41840b91ccSNathan Whitehorn *     +------------+
42840b91ccSNathan Whitehorn *     |  savemask  |
43840b91ccSNathan Whitehorn *     +------------+
44840b91ccSNathan Whitehorn *     | sig state  |
45840b91ccSNathan Whitehorn *     |            |
46840b91ccSNathan Whitehorn *     | (4 words)  |
47840b91ccSNathan Whitehorn *     |            |
48840b91ccSNathan Whitehorn *     +------------+
49840b91ccSNathan Whitehorn *     | saved regs |
50840b91ccSNathan Whitehorn *     |    ...     |
51840b91ccSNathan Whitehorn */
52840b91ccSNathan Whitehorn
53840b91ccSNathan Whitehorn
54840b91ccSNathan Whitehorn#include <sys/syscall.h>
55840b91ccSNathan Whitehorn
56840b91ccSNathan WhitehornENTRY(sigsetjmp)
57840b91ccSNathan Whitehorn	mr	%r6,%r3
58840b91ccSNathan Whitehorn	stw	%r4,0(%r3)
59840b91ccSNathan Whitehorn	or.	%r7,%r4,%r4
60840b91ccSNathan Whitehorn	beq	1f
61840b91ccSNathan Whitehorn	li	%r3,1			/* SIG_BLOCK, but doesn't matter */
62840b91ccSNathan Whitehorn					/*            since set == NULL  */
63840b91ccSNathan Whitehorn	li	%r4,0			/* set = NULL */
64840b91ccSNathan Whitehorn	mr	%r5,%r6			/* &oset */
65840b91ccSNathan Whitehorn	addi	%r5,%r5,4
66840b91ccSNathan Whitehorn	li	%r0, SYS_sigprocmask   /* sigprocmask(SIG_BLOCK, NULL, &oset)*/
67840b91ccSNathan Whitehorn	sc				/* assume no error       XXX */
68840b91ccSNathan Whitehorn1:
69840b91ccSNathan Whitehorn	mflr	%r11
70840b91ccSNathan Whitehorn	mfcr	%r12
71840b91ccSNathan Whitehorn	mr	%r10,%r1
72840b91ccSNathan Whitehorn	mr	%r9,%r2
73840b91ccSNathan Whitehorn
74840b91ccSNathan Whitehorn	std	%r9,40 + 0*8(%r6)
75840b91ccSNathan Whitehorn	std	%r10,40 + 1*8(%r6)
76840b91ccSNathan Whitehorn	std	%r11,40 + 2*8(%r6)
77840b91ccSNathan Whitehorn	std	%r12,40 + 3*8(%r6)
78840b91ccSNathan Whitehorn	std	%r13,40 + 4*8(%r6)
79840b91ccSNathan Whitehorn	std	%r14,40 + 5*8(%r6)
80840b91ccSNathan Whitehorn	std	%r15,40 + 6*8(%r6)
81840b91ccSNathan Whitehorn	std	%r16,40 + 7*8(%r6)
82840b91ccSNathan Whitehorn	std	%r17,40 + 8*8(%r6)
83840b91ccSNathan Whitehorn	std	%r18,40 + 9*8(%r6)
84840b91ccSNathan Whitehorn	std	%r19,40 + 10*8(%r6)
85840b91ccSNathan Whitehorn	std	%r20,40 + 11*8(%r6)
86840b91ccSNathan Whitehorn	std	%r21,40 + 12*8(%r6)
87840b91ccSNathan Whitehorn	std	%r22,40 + 13*8(%r6)
88840b91ccSNathan Whitehorn	std	%r23,40 + 14*8(%r6)
89840b91ccSNathan Whitehorn	std	%r24,40 + 15*8(%r6)
90840b91ccSNathan Whitehorn	std	%r25,40 + 16*8(%r6)
91840b91ccSNathan Whitehorn	std	%r26,40 + 17*8(%r6)
92840b91ccSNathan Whitehorn	std	%r27,40 + 18*8(%r6)
93840b91ccSNathan Whitehorn	std	%r28,40 + 19*8(%r6)
94840b91ccSNathan Whitehorn	std	%r29,40 + 20*8(%r6)
95840b91ccSNathan Whitehorn	std	%r30,40 + 21*8(%r6)
96840b91ccSNathan Whitehorn	std	%r31,40 + 22*8(%r6)
97840b91ccSNathan Whitehorn
98840b91ccSNathan Whitehorn	li	%r3,0
99840b91ccSNathan Whitehorn	blr
100840b91ccSNathan Whitehorn
101840b91ccSNathan WhitehornENTRY(siglongjmp)
102840b91ccSNathan Whitehorn	ld	%r9,40 + 0*8(%r3)
103840b91ccSNathan Whitehorn	ld	%r10,40 + 1*8(%r3)
104840b91ccSNathan Whitehorn	ld	%r11,40 + 2*8(%r3)
105840b91ccSNathan Whitehorn	ld	%r12,40 + 3*8(%r3)
106840b91ccSNathan Whitehorn	ld	%r13,40 + 4*8(%r3)
107840b91ccSNathan Whitehorn	ld	%r14,40 + 5*8(%r3)
108840b91ccSNathan Whitehorn	ld	%r15,40 + 6*8(%r3)
109840b91ccSNathan Whitehorn	ld	%r16,40 + 7*8(%r3)
110840b91ccSNathan Whitehorn	ld	%r17,40 + 8*8(%r3)
111840b91ccSNathan Whitehorn	ld	%r18,40 + 9*8(%r3)
112840b91ccSNathan Whitehorn	ld	%r19,40 + 10*8(%r3)
113840b91ccSNathan Whitehorn	ld	%r20,40 + 11*8(%r3)
114840b91ccSNathan Whitehorn	ld	%r21,40 + 12*8(%r3)
115840b91ccSNathan Whitehorn	ld	%r22,40 + 13*8(%r3)
116840b91ccSNathan Whitehorn	ld	%r23,40 + 14*8(%r3)
117840b91ccSNathan Whitehorn	ld	%r24,40 + 15*8(%r3)
118840b91ccSNathan Whitehorn	ld	%r25,40 + 16*8(%r3)
119840b91ccSNathan Whitehorn	ld	%r26,40 + 17*8(%r3)
120840b91ccSNathan Whitehorn	ld	%r27,40 + 18*8(%r3)
121840b91ccSNathan Whitehorn	ld	%r28,40 + 19*8(%r3)
122840b91ccSNathan Whitehorn	ld	%r29,40 + 20*8(%r3)
123840b91ccSNathan Whitehorn	ld	%r30,40 + 21*8(%r3)
124840b91ccSNathan Whitehorn	ld	%r31,40 + 22*8(%r3)
125840b91ccSNathan Whitehorn
126840b91ccSNathan Whitehorn	lwz	%r7,0(%r3)
127840b91ccSNathan Whitehorn	mr	%r6,%r4
128840b91ccSNathan Whitehorn	mtlr	%r11
129840b91ccSNathan Whitehorn	mtcr	%r12
130840b91ccSNathan Whitehorn	mr	%r2,%r9
131840b91ccSNathan Whitehorn	mr	%r1,%r10
132840b91ccSNathan Whitehorn	or.	%r7,%r7,%r7
133840b91ccSNathan Whitehorn	beq	1f
134840b91ccSNathan Whitehorn	mr	%r4,%r3
135840b91ccSNathan Whitehorn	li	%r3,3			/* SIG_SETMASK */
136840b91ccSNathan Whitehorn	addi	%r4,%r4,4		/* &set */
137840b91ccSNathan Whitehorn	li	%r5,0			/* oset = NULL */
138840b91ccSNathan Whitehorn	li	%r0,SYS_sigprocmask	/* sigprocmask(SIG_SET, &set, NULL) */
139840b91ccSNathan Whitehorn	sc				/* assume no error       XXX */
140840b91ccSNathan Whitehorn1:
141840b91ccSNathan Whitehorn	or.	%r3,%r6,%r6
142840b91ccSNathan Whitehorn	bnelr
143840b91ccSNathan Whitehorn	li	%r3,1
144840b91ccSNathan Whitehorn	blr
145*8f861da9SKonstantin Belousov
146*8f861da9SKonstantin Belousov	.section .note.GNU-stack,"",%progbits
147