1 /* $NetBSD: __setjmp14.S,v 1.5 2008/04/28 20:22:55 martin Exp $ */
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <machine/asm.h>
33 /* XXX fredette - this is awful */
35 #include <machine/frame.h>
37 #include <machine/psl.h>
39 #if defined(LIBC_SCCS) && !defined(lint)
40 RCSID("$NetBSD: __setjmp14.S,v 1.5 2008/04/28 20:22:55 martin Exp $")
41 #endif /* LIBC_SCCS and not lint */
44 * C library -- setjmp, longjmp
47 * will generate a "return(v)" from
50 * by restoring registers from the stack,
51 * and a struct sigcontext, see <signal.h>
55 /* Finish our stack frame. */
56 stw %rp, HPPA_FRAME_CRP(%sp)
57 stw %arg0, HPPA_FRAME_ARG(0)(%sp)
59 /* A sigcontext is at the beginning of our jmp_buf. */
60 stw %r0, 4(%arg0) ; unused word (old style signal mask)
61 stw %sp, 8(%arg0) ; sc.sc_sp = %sp
62 stw %r0, 16(%arg0) ; sc.sc_ap = NULL
64 stw %r1, 20(%arg0) ; sc.sc_pcsqh = %sr0
65 stw %rp, 24(%arg0) ; sc.sc_pcoqh = %rp
66 stw %r1, 28(%arg0) ; sc.sc_pcsqh = %sr0
68 stw %r1, 32(%arg0) ; sc.sc_pcoqt = %rp + 4
69 #define PSW_MBS (PSW_C|PSW_Q|PSW_P|PSW_D|PSW_I)
71 ldo R%PSW_MBS(%r1), %r1
72 stw %r1, 36(%arg0) ; set sc.sc_ps
74 /* We store all callee-saved registers after the sigcontext. */
94 * Start the stack frame for the calls we will make.
95 * The minimum frame is 48 bytes, but the stack must
96 * always be 64-byte aligned; we use the top 4 bytes
97 * to save our caller's %r3, and the following 12 bytes
98 * as the stack_t for our sigaltstack call.
99 * XXX - this assumes that sizeof(stack_t) <= 12
103 stwm %r1, HPPA_FRAME_SIZE(%sp)
105 /* Get signal stack info. */
106 ldo 4(%r3), %arg1 ; set up oss
107 bl __sigaltstack14, %rp
108 copy %r0, %arg0 ; set up ss
110 /* Recover our jmp_buf and extract SS_ONSTACK */
111 ldw HPPA_FRAME_ARG(0)(%r3), %arg0
112 ldw 12(%r3), %r1 ; get ss_flags
113 ldi 1, %r20 ; SS_ONSTACK
115 stw %r1, 0(%arg0) ; sc.sc_onstack
117 /* Get the signal mask. */
118 ldo 40(%arg0), %arg2 ; oset = &sc.sc_mask
119 copy %r0, %arg1 ; set = NULL
120 bl __sigprocmask14, %rp
121 copy %r0, %arg0 ; action = 0 <ignored>
124 ldo HPPA_FRAME_SIZE(%r3),%sp
125 ldwm -HPPA_FRAME_SIZE(%sp),%r3
126 ldw HPPA_FRAME_CRP(%sp), %rp