1/*	$NetBSD: __sigtramp2.S,v 1.5 2021/11/27 10:00:01 skrll Exp $	*/
2
3/*-
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#include "SYS.h"
33#include "assym.h"
34
35/*
36 * The ARM signal trampoline is invoked only to return from
37 * the signal; the kernel calls the signal handler directly.
38 *
39 * On entry, the stack looks like:
40 *
41 *		ucontext structure
42 *	sp->	siginfo structure
43 * and r5 points to the ucontext
44 */
45
46#define	CFI_OFFSET(r)			.cfi_offset r, r * 4
47
48	_TEXT_SECTION
49	.cfi_startproc
50	.cfi_signal_frame
51	.cfi_def_cfa _REG_SP, SIZEOF_SIGINFO + _UC_GREGS
52	CFI_OFFSET(_REG_R0)
53	CFI_OFFSET(_REG_R1)
54	CFI_OFFSET(_REG_R2)
55	CFI_OFFSET(_REG_R3)
56	CFI_OFFSET(_REG_R4)
57	CFI_OFFSET(_REG_R5)
58	CFI_OFFSET(_REG_R6)
59	CFI_OFFSET(_REG_R7)
60	CFI_OFFSET(_REG_R8)
61	CFI_OFFSET(_REG_R9)
62	CFI_OFFSET(_REG_R10)
63	CFI_OFFSET(_REG_R11)
64	CFI_OFFSET(_REG_R12)
65	CFI_OFFSET(_REG_R13)	/* a.k.a. _REG_SP */
66	CFI_OFFSET(_REG_R14)	/* a.k.a. _REG_LR */
67	.cfi_return_column _REG_R15
68	CFI_OFFSET(_REG_R15)	/* a.k.a. _REG_PC */
69
70/*
71 * The unwind entry includes the one instruction prior to the trampoline
72 * because the unwinder will look up (return PC - 1) while unwinding.
73 * Normally this would be the jump / branch, but since there isn't one in
74 * this case, we place an explicit nop there instead.
75 */
76	nop
77
78ENTRY_NP(__sigtramp_siginfo_2)
79	mov r0, r5				/* set the arg         */
80	SYSTRAP(setcontext)			/* and call setcontext */
81
82	/* If that failed, exit with the error code. */
83	SYSTRAP(exit)
84	.cfi_endproc
85END(__sigtramp_siginfo_2)
86