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