1 1.3 thorpej /* $NetBSD: __sigtramp3.S,v 1.3 2021/11/24 15:05:16 thorpej Exp $ */ 2 1.1 matt 3 1.1 matt /* 4 1.1 matt * Copyright (c) 2003 Matt Thomas <matt (at) 3am-software.com> 5 1.1 matt * All rights reserved. 6 1.1 matt * 7 1.1 matt * Redistribution and use in source and binary forms, with or without 8 1.1 matt * modification, are permitted provided that the following conditions 9 1.1 matt * are met: 10 1.1 matt * 1. Redistributions of source code must retain the above copyright 11 1.1 matt * notice, this list of conditions and the following disclaimer. 12 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 matt * notice, this list of conditions and the following disclaimer in the 14 1.1 matt * documentation and/or other materials provided with the distribution. 15 1.1 matt * 3. The name of the author may not be used to endorse or promote products 16 1.1 matt * derived from this software without specific prior written permission 17 1.1 matt * 18 1.1 matt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 1.1 matt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 1.1 matt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 1.1 matt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 1.1 matt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 1.1 matt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 1.1 matt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 1.1 matt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 1.1 matt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 1.1 matt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 1.1 matt */ 29 1.1 matt 30 1.3 thorpej #include "SYS.h" 31 1.3 thorpej #include "assym.h" 32 1.3 thorpej 33 1.3 thorpej #ifdef SYSLIBC_SCCS 34 1.3 thorpej RCSID("$NetBSD: __sigtramp3.S,v 1.3 2021/11/24 15:05:16 thorpej Exp $") 35 1.3 thorpej #endif 36 1.3 thorpej 37 1.1 matt /* 38 1.1 matt * Signal trampoline; registers when called: 39 1.1 matt * pc, psl - obvious 40 1.3 thorpej * sp, ap - points to a CALLG argument list 41 1.1 matt * fp - address of signal handler 42 1.3 thorpej * 43 1.3 thorpej * Stack is set up like so: 44 1.3 thorpej * ucontext structure 45 1.3 thorpej * siginfo structure 46 1.3 thorpej * vvvv CALLG argument list vvvv 47 1.3 thorpej * 12(ap) -- pointer to ucontext 48 1.3 thorpej * 8(ap) -- pointer to siginfo 49 1.3 thorpej * 4(ap) -- signal number 50 1.3 thorpej * sp -> 0(ap) -- argument count 51 1.3 thorpej * ^^^^ CALLG argument list ^^^^ 52 1.3 thorpej * 53 1.3 thorpej * N.B. all of the DWARF register numbers match our _REG_* constants. 54 1.3 thorpej * Also notice that while the %ap is adjusted inside the trampoline, 55 1.3 thorpej * the %sp is not adjusted, and so the CFA base does not change. 56 1.1 matt */ 57 1.1 matt 58 1.3 thorpej #define CFI_OFFSET(r) .cfi_offset r, r * 4 59 1.1 matt 60 1.3 thorpej .text 61 1.3 thorpej #if 0 62 1.3 thorpej .cfi_startproc simple 63 1.3 thorpej .cfi_signal_frame 64 1.3 thorpej .cfi_def_cfa _REG_SP, 16 + SIZEOF_SIGINFO + UC_GREGS 65 1.3 thorpej CFI_OFFSET(_REG_R0) 66 1.3 thorpej CFI_OFFSET(_REG_R1) 67 1.3 thorpej CFI_OFFSET(_REG_R2) 68 1.3 thorpej CFI_OFFSET(_REG_R3) 69 1.3 thorpej CFI_OFFSET(_REG_R4) 70 1.3 thorpej CFI_OFFSET(_REG_R5) 71 1.3 thorpej CFI_OFFSET(_REG_R6) 72 1.3 thorpej CFI_OFFSET(_REG_R7) 73 1.3 thorpej CFI_OFFSET(_REG_R8) 74 1.3 thorpej CFI_OFFSET(_REG_R9) 75 1.3 thorpej CFI_OFFSET(_REG_R10) 76 1.3 thorpej CFI_OFFSET(_REG_R11) 77 1.3 thorpej CFI_OFFSET(_REG_AP) 78 1.3 thorpej CFI_OFFSET(_REG_FP) 79 1.3 thorpej CFI_OFFSET(_REG_SP) 80 1.3 thorpej CFI_OFFSET(_REG_PC) 81 1.3 thorpej CFI_OFFSET(_REG_PSL) 82 1.2 matt #endif 83 1.2 matt 84 1.3 thorpej /* 85 1.3 thorpej * The unwind entry includes one instruction slot prior to the trampoline 86 1.3 thorpej * because the unwinder will look up to (return PC - 1) while unwinding. 87 1.3 thorpej * Normally this would be the jump / branch, but since there isn't one in 88 1.3 thorpej * this case, we place an explicit nop there instead. 89 1.3 thorpej */ 90 1.3 thorpej 91 1.3 thorpej #if 0 92 1.3 thorpej nop 93 1.3 thorpej #endif 94 1.1 matt _ALIGN_TEXT 95 1.1 matt 96 1.1 matt .globl _C_LABEL(__sigtramp_siginfo_3) 97 1.1 matt _C_LABEL(__sigtramp_siginfo_3): 98 1.2 matt nop; nop 99 1.1 matt callg (%ap),(%fp) # use global arg list 100 1.1 matt addl2 $8,%ap # arg is pointer to ucontext 101 1.1 matt SYSTRAP(setcontext) # exit from here 102 1.1 matt halt # illegal insn 103 1.3 thorpej #if 0 104 1.3 thorpej .cfi_endproc 105 1.3 thorpej #endif 106