Home | History | Annotate | Line # | Download | only in sys
__sigtramp2.S revision 1.7
      1  1.7  skrll /*	$NetBSD: __sigtramp2.S,v 1.7 2022/06/26 14:37:13 skrll Exp $	*/
      2  1.1    chs 
      3  1.1    chs /*
      4  1.1    chs  * Copyright (c) 1998-2001 Michael Shalayeff
      5  1.1    chs  * All rights reserved.
      6  1.1    chs  *
      7  1.1    chs  * Redistribution and use in source and binary forms, with or without
      8  1.1    chs  * modification, are permitted provided that the following conditions
      9  1.1    chs  * are met:
     10  1.1    chs  * 1. Redistributions of source code must retain the above copyright
     11  1.1    chs  *    notice, this list of conditions and the following disclaimer.
     12  1.1    chs  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1    chs  *    notice, this list of conditions and the following disclaimer in the
     14  1.1    chs  *    documentation and/or other materials provided with the distribution.
     15  1.1    chs  *
     16  1.1    chs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1    chs  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.1    chs  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.1    chs  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
     20  1.1    chs  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     21  1.1    chs  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     22  1.1    chs  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.1    chs  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     24  1.1    chs  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     25  1.1    chs  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     26  1.1    chs  * THE POSSIBILITY OF SUCH DAMAGE.
     27  1.1    chs  *
     28  1.1    chs  * Portitions of this file are derived from other sources, see
     29  1.1    chs  * the copyrights and acknowledgements below.
     30  1.1    chs  */
     31  1.1    chs /*
     32  1.1    chs  * Copyright (c) 1990,1991,1992,1994 The University of Utah and
     33  1.1    chs  * the Computer Systems Laboratory (CSL).  All rights reserved.
     34  1.1    chs  *
     35  1.1    chs  * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS"
     36  1.1    chs  * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
     37  1.1    chs  * WHATSOEVER RESULTING FROM ITS USE.
     38  1.1    chs  *
     39  1.1    chs  * CSL requests users of this software to return to csl-dist (at) cs.utah.edu any
     40  1.1    chs  * improvements that they make and grant CSL redistribution rights.
     41  1.1    chs  *
     42  1.1    chs  *	Utah $Hdr: locore.s 1.62 94/12/15$
     43  1.1    chs  */
     44  1.1    chs /*
     45  1.1    chs  *  (c) Copyright 1988 HEWLETT-PACKARD COMPANY
     46  1.1    chs  *
     47  1.1    chs  *  To anyone who acknowledges that this file is provided "AS IS"
     48  1.1    chs  *  without any express or implied warranty:
     49  1.1    chs  *      permission to use, copy, modify, and distribute this file
     50  1.1    chs  *  for any purpose is hereby granted without fee, provided that
     51  1.1    chs  *  the above copyright notice and this notice appears in all
     52  1.1    chs  *  copies, and that the name of Hewlett-Packard Company not be
     53  1.1    chs  *  used in advertising or publicity pertaining to distribution
     54  1.1    chs  *  of the software without specific, written prior permission.
     55  1.1    chs  *  Hewlett-Packard Company makes no representations about the
     56  1.1    chs  *  suitability of this software for any purpose.
     57  1.1    chs  */
     58  1.1    chs 
     59  1.1    chs #include "SYS.h"
     60  1.7  skrll #include "assym.h"
     61  1.1    chs 
     62  1.3  skrll /*
     63  1.3  skrll  * The hppa signal trampoline is required to call the handler
     64  1.3  skrll  * possibily via a PLABEL.
     65  1.3  skrll  *
     66  1.3  skrll  * On entry, stack looks like:
     67  1.3  skrll  *
     68  1.3  skrll  *	sp->					[x]
     69  1.3  skrll  * r3,arg2->	ucontext structure
     70  1.3  skrll  *    arg1->	siginfo structure		[0]
     71  1.3  skrll  *
     72  1.3  skrll  * where
     73  1.3  skrll  *	x = HPPA_FRAME_ROUND(sizeof(sigframe_siginfo))
     74  1.3  skrll  *
     75  1.3  skrll  * and
     76  1.3  skrll  * 	struct sigframe_siginfo {
     77  1.3  skrll  *		siginfo_t sf_si;
     78  1.3  skrll  *		ucontext_t sf_uc;
     79  1.3  skrll  *	};
     80  1.7  skrll  *
     81  1.7  skrll  * The DWARF register numbers for the general purpose registers are the
     82  1.7  skrll  * same as the architected register numbers.  For HPPA, there is a DWARF
     83  1.7  skrll  * pseudo-register for signal handler return addresses.
     84  1.3  skrll  */
     85  1.3  skrll 
     86  1.7  skrll #if defined(__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__)
     87  1.7  skrll #define	DWARF_SIGRETURN_REG		__LIBGCC_DWARF_ALT_FRAME_RETURN_COLUMN__
     88  1.7  skrll #else
     89  1.7  skrll #define	DWARF_SIGRETURN_REG		89	/* 61 on hppa64 */
     90  1.7  skrll #endif
     91  1.7  skrll 
     92  1.7  skrll #define	CFI_OFFSET_DWARF_REG(d, r)	.cfi_offset d, r * 4
     93  1.7  skrll #define	CFI_OFFSET(r)			CFI_OFFSET_DWARF_REG(r, r)
     94  1.7  skrll 
     95  1.7  skrll 	.text
     96  1.7  skrll 	.cfi_startproc
     97  1.7  skrll 	.cfi_signal_frame
     98  1.7  skrll 	.cfi_def_cfa _REG_R30,  -SIZEOF_SIGTRAMP + SIZEOF_SIGINFO + _UC_GREGS
     99  1.7  skrll 	CFI_OFFSET(_REG_R1)
    100  1.7  skrll 	CFI_OFFSET(_REG_R2)
    101  1.7  skrll 	CFI_OFFSET(_REG_R3)
    102  1.7  skrll 	CFI_OFFSET(_REG_R4)
    103  1.7  skrll 	CFI_OFFSET(_REG_R5)
    104  1.7  skrll 	CFI_OFFSET(_REG_R6)
    105  1.7  skrll 	CFI_OFFSET(_REG_R7)
    106  1.7  skrll 	CFI_OFFSET(_REG_R8)
    107  1.7  skrll 	CFI_OFFSET(_REG_R9)
    108  1.7  skrll 	CFI_OFFSET(_REG_R10)
    109  1.7  skrll 	CFI_OFFSET(_REG_R11)
    110  1.7  skrll 	CFI_OFFSET(_REG_R12)
    111  1.7  skrll 	CFI_OFFSET(_REG_R13)
    112  1.7  skrll 	CFI_OFFSET(_REG_R14)
    113  1.7  skrll 	CFI_OFFSET(_REG_R15)
    114  1.7  skrll 	CFI_OFFSET(_REG_R16)
    115  1.7  skrll 	CFI_OFFSET(_REG_R17)
    116  1.7  skrll 	CFI_OFFSET(_REG_R18)
    117  1.7  skrll 	CFI_OFFSET(_REG_R19)
    118  1.7  skrll 	CFI_OFFSET(_REG_R20)
    119  1.7  skrll 	CFI_OFFSET(_REG_R21)
    120  1.7  skrll 	CFI_OFFSET(_REG_R22)
    121  1.7  skrll 	CFI_OFFSET(_REG_R23)
    122  1.7  skrll 	CFI_OFFSET(_REG_R24)
    123  1.7  skrll 	CFI_OFFSET(_REG_R25)
    124  1.7  skrll 	CFI_OFFSET(_REG_R26)
    125  1.7  skrll 	CFI_OFFSET(_REG_R27)
    126  1.7  skrll 	CFI_OFFSET(_REG_R28)
    127  1.7  skrll 	CFI_OFFSET(_REG_R29)
    128  1.7  skrll 	CFI_OFFSET(_REG_R30)
    129  1.7  skrll 	CFI_OFFSET(_REG_R31)
    130  1.7  skrll 	.cfi_return_column DWARF_SIGRETURN_REG
    131  1.7  skrll 	CFI_OFFSET_DWARF_REG(DWARF_SIGRETURN_REG, _REG_PCOQH)
    132  1.7  skrll 
    133  1.7  skrll /*
    134  1.7  skrll  * The unwind entry includes one instruction slot prior to the trampoline
    135  1.7  skrll  * because the unwinder will look up to (return PC - 1 insn) while unwinding.
    136  1.7  skrll  * Normally this would be the jump / branch, but since there isn't one in
    137  1.7  skrll  * this case, we place an explicit nop there instead.
    138  1.7  skrll  */
    139  1.7  skrll 
    140  1.7  skrll 	nop
    141  1.7  skrll 
    142  1.1    chs ENTRY_NOPROFILE(__sigtramp_siginfo_2, 0)
    143  1.1    chs 	.call
    144  1.1    chs 
    145  1.1    chs 	/*
    146  1.1    chs 	 * Our sendsig() places the address of the signal handler in %arg3.
    147  1.1    chs 	 * It may actually be a PLABEL.
    148  1.1    chs 	 */
    149  1.1    chs 	bb,>=,n	%arg3, 30, L$sigcode_bounce	; branch if not a PLABEL
    150  1.1    chs 	depi	0, 31, 2, %arg3			; zero L bit in PLABEL pointer
    151  1.1    chs 	ldw	4(%arg3), %r19			; load shared library linkage
    152  1.1    chs 	ldw	0(%arg3), %arg3			; load real catcher address
    153  1.1    chs 
    154  1.1    chs L$sigcode_bounce:
    155  1.1    chs 
    156  1.1    chs 	/*
    157  1.1    chs 	 * This blr puts the address of the following nop in rp.
    158  1.1    chs 	 * It also schedules the nop for execution, which is why
    159  1.1    chs 	 * that instruction has to be a nop, or, rather, not any
    160  1.1    chs 	 * instruction only meant to execute once the signal handler
    161  1.1    chs 	 * returns.
    162  1.1    chs 	 */
    163  1.1    chs 	blr	%r0, %rp
    164  1.1    chs 
    165  1.1    chs 	/*
    166  1.1    chs 	 * This bv schedules the instruction pointed to by arg3
    167  1.1    chs 	 * for execution.  So, arg3 is the address of the signal
    168  1.1    chs 	 * handler.
    169  1.1    chs 	 */
    170  1.1    chs 	bv,n	%r0(%arg3)
    171  1.1    chs 	nop
    172  1.1    chs 
    173  1.1    chs 	/*
    174  1.1    chs 	 * The signal handler has returned.  Since r3 is on the list
    175  1.1    chs 	 * of callee-saved registers, it's whatever the sendsig
    176  1.1    chs 	 * code wanted it set to.  Since we copy it into arg0,
    177  1.1    chs 	 * it looks like sendsig leaves r3 holding the desired
    178  1.1    chs 	 * single argument to sys_setcontext, i.e., the ucontext_t *.
    179  1.1    chs 	 */
    180  1.1    chs 
    181  1.1    chs 	/* Make a SYS_setcontext system call. */
    182  1.1    chs 	copy	%r3, %arg0
    183  1.1    chs 	ldil	L%SYSCALLGATE, %r1
    184  1.1    chs 	.call
    185  1.5  skrll 	ble	4(%sr2, %r1)
    186  1.6  skrll 	 ldi	SYS_setcontext, %t1
    187  1.1    chs 
    188  1.1    chs 	/* Make a SYS_exit system call. */
    189  1.1    chs 	copy	%ret0, %arg0
    190  1.1    chs 	ldil	L%SYSCALLGATE, %r1
    191  1.1    chs 	.call
    192  1.5  skrll 	ble	4(%sr2, %r1)
    193  1.6  skrll 	 ldi	SYS_exit, %t1
    194  1.7  skrll 	.cfi_endproc
    195  1.2    chs EXIT(__sigtramp_siginfo_2)
    196