xref: /minix/lib/libc/arch/hppa/sys/__sigtramp2.S (revision 0a6a1f1d)
1/*	$NetBSD: __sigtramp2.S,v 1.5 2014/03/06 19:02:58 skrll Exp $	*/
2
3/*
4 * Copyright (c) 1998-2001 Michael Shalayeff
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 * THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Portitions of this file are derived from other sources, see
29 * the copyrights and acknowledgements below.
30 */
31/*
32 * Copyright (c) 1990,1991,1992,1994 The University of Utah and
33 * the Computer Systems Laboratory (CSL).  All rights reserved.
34 *
35 * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS"
36 * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
37 * WHATSOEVER RESULTING FROM ITS USE.
38 *
39 * CSL requests users of this software to return to csl-dist@cs.utah.edu any
40 * improvements that they make and grant CSL redistribution rights.
41 *
42 *	Utah $Hdr: locore.s 1.62 94/12/15$
43 */
44/*
45 *  (c) Copyright 1988 HEWLETT-PACKARD COMPANY
46 *
47 *  To anyone who acknowledges that this file is provided "AS IS"
48 *  without any express or implied warranty:
49 *      permission to use, copy, modify, and distribute this file
50 *  for any purpose is hereby granted without fee, provided that
51 *  the above copyright notice and this notice appears in all
52 *  copies, and that the name of Hewlett-Packard Company not be
53 *  used in advertising or publicity pertaining to distribution
54 *  of the software without specific, written prior permission.
55 *  Hewlett-Packard Company makes no representations about the
56 *  suitability of this software for any purpose.
57 */
58
59#include "SYS.h"
60
61/*
62 * The hppa signal trampoline is required to call the handler
63 * possibily via a PLABEL.
64 *
65 * On entry, stack looks like:
66 *
67 *	sp->					[x]
68 * r3,arg2->	ucontext structure
69 *    arg1->	siginfo structure		[0]
70 *
71 * where
72 *	x = HPPA_FRAME_ROUND(sizeof(sigframe_siginfo))
73 *
74 * and
75 * 	struct sigframe_siginfo {
76 *		siginfo_t sf_si;
77 *		ucontext_t sf_uc;
78 *	};
79 */
80
81ENTRY_NOPROFILE(__sigtramp_siginfo_2, 0)
82	.call
83
84	/*
85	 * Our sendsig() places the address of the signal handler in %arg3.
86	 * It may actually be a PLABEL.
87	 */
88	bb,>=,n	%arg3, 30, L$sigcode_bounce	; branch if not a PLABEL
89	depi	0, 31, 2, %arg3			; zero L bit in PLABEL pointer
90	ldw	4(%arg3), %r19			; load shared library linkage
91	ldw	0(%arg3), %arg3			; load real catcher address
92
93L$sigcode_bounce:
94
95	/*
96	 * This blr puts the address of the following nop in rp.
97	 * It also schedules the nop for execution, which is why
98	 * that instruction has to be a nop, or, rather, not any
99	 * instruction only meant to execute once the signal handler
100	 * returns.
101	 */
102	blr	%r0, %rp
103
104	/*
105	 * This bv schedules the instruction pointed to by arg3
106	 * for execution.  So, arg3 is the address of the signal
107	 * handler.
108	 */
109	bv,n	%r0(%arg3)
110	nop
111
112	/*
113	 * The signal handler has returned.  Since r3 is on the list
114	 * of callee-saved registers, it's whatever the sendsig
115	 * code wanted it set to.  Since we copy it into arg0,
116	 * it looks like sendsig leaves r3 holding the desired
117	 * single argument to sys_setcontext, i.e., the ucontext_t *.
118	 */
119
120	/* Make a SYS_setcontext system call. */
121	copy	%r3, %arg0
122	ldil	L%SYSCALLGATE, %r1
123	.call
124	ble	4(%sr2, %r1)
125	ldi	SYS_setcontext, %t1
126
127	/* Make a SYS_exit system call. */
128	copy	%ret0, %arg0
129	ldil	L%SYSCALLGATE, %r1
130	.call
131	ble	4(%sr2, %r1)
132	ldi	SYS_exit, %t1
133EXIT(__sigtramp_siginfo_2)
134