Home | History | Annotate | Line # | Download | only in hppa
      1 /*	$NetBSD: sigcode.S,v 1.10 2021/10/28 11:11:11 christos Exp $	*/
      2 
      3 /*	$OpenBSD: locore.S,v 1.46 2001/09/20 18:33:03 mickey Exp $	*/
      4 
      5 /*
      6  * Copyright (c) 1998-2004 Michael Shalayeff
      7  * All rights reserved.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
     22  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     24  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     27  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     28  * THE POSSIBILITY OF SUCH DAMAGE.
     29  *
     30  * Portitions of this file are derived from other sources, see
     31  * the copyrights and acknowledgements below.
     32  */
     33 /*
     34  * Copyright (c) 1990,1991,1992,1994 The University of Utah and
     35  * the Computer Systems Laboratory (CSL).  All rights reserved.
     36  *
     37  * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS"
     38  * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
     39  * WHATSOEVER RESULTING FROM ITS USE.
     40  *
     41  * CSL requests users of this software to return to csl-dist (at) cs.utah.edu any
     42  * improvements that they make and grant CSL redistribution rights.
     43  *
     44  *	Utah $Hdr: locore.s 1.62 94/12/15$
     45  */
     46 /*
     47  *  (c) Copyright 1988 HEWLETT-PACKARD COMPANY
     48  *
     49  *  To anyone who acknowledges that this file is provided "AS IS"
     50  *  without any express or implied warranty:
     51  *      permission to use, copy, modify, and distribute this file
     52  *  for any purpose is hereby granted without fee, provided that
     53  *  the above copyright notice and this notice appears in all
     54  *  copies, and that the name of Hewlett-Packard Company not be
     55  *  used in advertising or publicity pertaining to distribution
     56  *  of the software without specific, written prior permission.
     57  *  Hewlett-Packard Company makes no representations about the
     58  *  suitability of this software for any purpose.
     59  */
     60 
     61 /*
     62  * NOTICE: This is not a standalone file.  To use it, #include it in
     63  * your port's locore.S, like so:
     64  *
     65  *	#include <hppa/hppa/sigcode.S>
     66  */
     67 
     68 /*
     69  * Signal "trampoline" code. Invoked from RTE setup by sendsig().
     70  */
     71 ENTRY_NOPROFILE(sigcode,0)
     72 	.call
     73 	/*
     74 	 * Our sendsig() places the address of the signal handler
     75 	 * in %arg3.  It may actually be a PLABEL.
     76 	 */
     77 	bb,>=,n	%arg3, 30, L$sigcode_bounce	; branch if not a PLABEL
     78 	depi	0, 31, 2, %arg3			; zero L bit in PLABEL pointer
     79 	ldw	4(%arg3), %r19			; load shared library linkage
     80 	ldw	0(%arg3), %arg3			; load real catcher address
     81 L$sigcode_bounce:
     82 	/*
     83 	 * This blr puts the address of the following nop in rp.
     84 	 * It also schedules the nop for execution, which is why
     85 	 * that instruction has to be a nop, or, rather, not any
     86 	 * instruction only meant to execute once the signal handler
     87 	 * returns.
     88 	 */
     89 	blr	%r0, %rp
     90 	/*
     91 	 * This bv schedules the instruction pointed to by arg3
     92 	 * for execution.  So, arg3 is the address of the signal
     93 	 * handler.
     94 	 */
     95 	bv,n	%r0(%arg3)
     96 	nop
     97 	/*
     98 	 * The signal handler has returned.  Since %r3 is on the list
     99 	 * of callee-saved registers, it's whatever the sendsig
    100 	 * code wanted it set to.  Since we copy it into arg0,
    101 	 * it looks like sendsig leaves %r3 holding the desired
    102 	 * single argument to sys___sigreturn14, i.e., the
    103 	 * struct sigcontext *.
    104 	 */
    105 	/* Make a SYS___sigreturn14 system call. */
    106 	copy	%r3, %arg0
    107 	ldil	L%SYSCALLGATE, %r1
    108 	.call
    109 	ble	4(%sr7, %r1)
    110 	ldi	SYS_compat_16___sigreturn14, %t1
    111 	/* Make a SYS_exit system call. */
    112 	copy	%ret0, %arg0
    113 	ldil	L%SYSCALLGATE, %r1
    114 	.call
    115 	ble	4(%sr7, %r1)
    116 	ldi	SYS_exit, %t1
    117 ALTENTRY(esigcode)
    118 EXIT(sigcode)
    119