1 /* $NetBSD: _setjmp.S,v 1.1 2014/09/03 19:34:25 matt Exp $ */
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
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>
35 #if defined(LIBC_SCCS)
36 __RCSID("$NetBSD: _setjmp.S,v 1.1 2014/09/03 19:34:25 matt Exp $")
40 * C library -- _setjmp, _longjmp
43 * will generate a "return(v?v:1)" from the last call to
45 * by restoring registers from the stack.
46 * The previous signal state is NOT restored.
50 l.sw JB_MAGIC(r3), r0 /* indicate no sigmask */
51 l.sw JB_PC(r3), lr /* save return address */
52 l.sw JB_LR(r3), lr /* save return address */
53 l.sw JB_SP(r3), r1 /* save stack pointer */
54 l.sw JB_FP(r3), r2 /* save frame pointer */
55 l.sw JB_R10(r3), r10 /* save callee saved register */
56 l.sw JB_R14(r3), r14 /* save callee saved register */
57 l.sw JB_R16(r3), r16 /* save callee saved register */
58 l.sw JB_R18(r3), r18 /* save callee saved register */
59 l.sw JB_R20(r3), r20 /* save callee saved register */
60 l.sw JB_R22(r3), r22 /* save callee saved register */
61 l.sw JB_R24(r3), r24 /* save callee saved register */
62 l.sw JB_R26(r3), r26 /* save callee saved register */
63 l.sw JB_R28(r3), r28 /* save callee saved register */
64 l.sw JB_R30(r3), r30 /* save callee saved register */
65 l.xor r11, r11, r11 /* indicate success */
71 l.lwz lr, JB_LR(r3) /* get return address */
72 l.lwz r1, JB_SP(r3) /* get stack pointer */
73 l.lwz r2, JB_FP(r3) /* get frame pointer */
74 l.lwz r10, JB_R10(r3) /* get callee saved register */
75 l.lwz r14, JB_R14(r3) /* get callee saved register */
76 l.lwz r16, JB_R16(r3) /* get callee saved register */
77 l.lwz r18, JB_R18(r3) /* get callee saved register */
78 l.lwz r20, JB_R20(r3) /* get callee saved register */
79 l.lwz r22, JB_R22(r3) /* get callee saved register */
80 l.lwz r24, JB_R24(r3) /* get callee saved register */
81 l.lwz r26, JB_R26(r3) /* get callee saved register */
82 l.lwz r28, JB_R28(r3) /* get callee saved register */
83 l.lwz r30, JB_R30(r3) /* get callee saved register */
84 l.ori r11, r0, 1 /* default return value */
85 l.sfeqi r4, 0 /* test return value */
86 l.cmov r11, r11, r4 /* use it if not 0 */