1 1.5 thorpej /* $NetBSD: __sigtramp2.S,v 1.5 2021/11/21 23:58:09 thorpej Exp $ */ 2 1.1 cl 3 1.1 cl /*- 4 1.1 cl * Copyright (c) 2003 The NetBSD Foundation, Inc. 5 1.1 cl * All rights reserved. 6 1.1 cl * 7 1.1 cl * Redistribution and use in source and binary forms, with or without 8 1.1 cl * modification, are permitted provided that the following conditions 9 1.1 cl * are met: 10 1.1 cl * 1. Redistributions of source code must retain the above copyright 11 1.1 cl * notice, this list of conditions and the following disclaimer. 12 1.1 cl * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 cl * notice, this list of conditions and the following disclaimer in the 14 1.1 cl * documentation and/or other materials provided with the distribution. 15 1.1 cl * 16 1.1 cl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 1.1 cl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 1.1 cl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 1.1 cl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 1.1 cl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 1.1 cl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 1.1 cl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 1.1 cl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 1.1 cl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 1.1 cl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 1.1 cl * POSSIBILITY OF SUCH DAMAGE. 27 1.1 cl */ 28 1.1 cl 29 1.1 cl #include "SYS.h" 30 1.5 thorpej #include "assym.h" 31 1.1 cl 32 1.1 cl /* 33 1.1 cl * The m68k signal trampoline is invoked only to return from 34 1.1 cl * the signal; the kernel calls the signal handler directly. 35 1.1 cl * 36 1.1 cl * On entry, stack looks like: 37 1.1 cl * 38 1.1 cl * ucontext structure [12+sizeof(siginfo_t)] 39 1.1 cl * siginfo structure [12] 40 1.1 cl * pointer to ucontext structure [8] 41 1.1 cl * pointer to siginfo structure [4] 42 1.1 cl * sp-> signal number [0] 43 1.5 thorpej * 44 1.5 thorpej * The DWARF register numbers are 0-7 (dX), 8-15 (aX), 16-23 (fpX), 45 1.5 thorpej * which maps nicely to _REG_D[0-7] and _REG_A[0-7]. For m68k, there 46 1.5 thorpej * is a DWARF pseudo-register for the return address, and additionally 47 1.5 thorpej * another DWARF pseudo-register for signal handler return addresses. 48 1.5 thorpej * We will specify both return address pseudo-registers (without 49 1.5 thorpej * explicitly specifying .cfi_return_column) to keep the compiler 50 1.5 thorpej * run-time happy with whichever one it decides to use. 51 1.5 thorpej */ 52 1.5 thorpej 53 1.5 thorpej #define DWARF_RETURN_REG 24 54 1.5 thorpej #if defined(__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__) 55 1.5 thorpej #define DWARF_SIGRETURN_REG __LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__ 56 1.5 thorpej #else 57 1.5 thorpej #define DWARF_SIGRETURN_REG 25 58 1.5 thorpej #endif 59 1.5 thorpej 60 1.5 thorpej #define CFI_OFFSET_DWARF_REG(d, r) .cfi_offset d, r * 4 61 1.5 thorpej #define CFI_OFFSET(r) CFI_OFFSET_DWARF_REG(r, r) 62 1.5 thorpej 63 1.5 thorpej .text 64 1.5 thorpej .cfi_startproc simple 65 1.5 thorpej .cfi_signal_frame 66 1.5 thorpej .cfi_def_cfa _REG_A7, 12 + SIZEOF_SIGINFO + UC_GREGS 67 1.5 thorpej CFI_OFFSET(_REG_D0) 68 1.5 thorpej CFI_OFFSET(_REG_D1) 69 1.5 thorpej CFI_OFFSET(_REG_D2) 70 1.5 thorpej CFI_OFFSET(_REG_D3) 71 1.5 thorpej CFI_OFFSET(_REG_D4) 72 1.5 thorpej CFI_OFFSET(_REG_D5) 73 1.5 thorpej CFI_OFFSET(_REG_D6) 74 1.5 thorpej CFI_OFFSET(_REG_D7) 75 1.5 thorpej CFI_OFFSET(_REG_A0) 76 1.5 thorpej CFI_OFFSET(_REG_A1) 77 1.5 thorpej CFI_OFFSET(_REG_A2) 78 1.5 thorpej CFI_OFFSET(_REG_A3) 79 1.5 thorpej CFI_OFFSET(_REG_A4) 80 1.5 thorpej CFI_OFFSET(_REG_A5) 81 1.5 thorpej CFI_OFFSET(_REG_A6) 82 1.5 thorpej CFI_OFFSET(_REG_A7) 83 1.5 thorpej CFI_OFFSET_DWARF_REG(DWARF_RETURN_REG, _REG_PC) 84 1.5 thorpej CFI_OFFSET_DWARF_REG(DWARF_SIGRETURN_REG, _REG_PC) 85 1.5 thorpej 86 1.5 thorpej /* 87 1.5 thorpej * The unwind entry includes one instruction slot prior to the trampoline 88 1.5 thorpej * because the unwinder will look up to (return PC - 1 insn) while unwinding. 89 1.5 thorpej * Normally this would be the jump / branch, but since there isn't one in 90 1.5 thorpej * this case, we place an explicit nop there instead. 91 1.1 cl */ 92 1.5 thorpej nop 93 1.5 thorpej 94 1.1 cl ENTRY_NOPROFILE(__sigtramp_siginfo_2) 95 1.3 matt movl 8(%sp),%a0 /* get pointer to ucontext */ 96 1.3 matt movl %a0,4(%sp) /* put it in the argument slot */ 97 1.1 cl /* fake return address already there */ 98 1.4 matt SYSTRAP(setcontext) 99 1.3 matt movl %d0,4(%sp) /* error code */ 100 1.1 cl SYSTRAP(exit) /* exit */ 101 1.5 thorpej .cfi_endproc 102 1.4 matt END(__sigtramp_siginfo_2) 103