Home | History | Annotate | Line # | Download | only in gen
      1  1.1  matt /*	$NetBSD: _setjmp.S,v 1.1 2014/09/03 19:34:25 matt Exp $	*/
      2  1.1  matt 
      3  1.1  matt /*-
      4  1.1  matt  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      5  1.1  matt  * All rights reserved.
      6  1.1  matt  *
      7  1.1  matt  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  matt  * by Matt Thomas of 3am Software Foundry.
      9  1.1  matt  *
     10  1.1  matt  * Redistribution and use in source and binary forms, with or without
     11  1.1  matt  * modification, are permitted provided that the following conditions
     12  1.1  matt  * are met:
     13  1.1  matt  * 1. Redistributions of source code must retain the above copyright
     14  1.1  matt  *    notice, this list of conditions and the following disclaimer.
     15  1.1  matt  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  matt  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  matt  *    documentation and/or other materials provided with the distribution.
     18  1.1  matt  *
     19  1.1  matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1  matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1  matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1  matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1  matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1  matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1  matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1  matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1  matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1  matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1  matt  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1  matt  */
     31  1.1  matt 
     32  1.1  matt #include <machine/asm.h>
     33  1.1  matt #include "assym.h"
     34  1.1  matt 
     35  1.1  matt #if defined(LIBC_SCCS)
     36  1.1  matt __RCSID("$NetBSD: _setjmp.S,v 1.1 2014/09/03 19:34:25 matt Exp $")
     37  1.1  matt #endif
     38  1.1  matt 
     39  1.1  matt /*
     40  1.1  matt  * C library -- _setjmp, _longjmp
     41  1.1  matt  *
     42  1.1  matt  *	_longjmp(a,v)
     43  1.1  matt  * will generate a "return(v?v:1)" from the last call to
     44  1.1  matt  *	_setjmp(a)
     45  1.1  matt  * by restoring registers from the stack.
     46  1.1  matt  * The previous signal state is NOT restored.
     47  1.1  matt  */
     48  1.1  matt 
     49  1.1  matt ENTRY(_setjmp)
     50  1.1  matt 	l.sw	JB_MAGIC(r3), r0	/* indicate no sigmask */
     51  1.1  matt 	l.sw	JB_PC(r3), lr		/* save return address */
     52  1.1  matt 	l.sw	JB_LR(r3), lr		/* save return address */
     53  1.1  matt 	l.sw	JB_SP(r3), r1		/* save stack pointer */
     54  1.1  matt 	l.sw	JB_FP(r3), r2		/* save frame pointer */
     55  1.1  matt 	l.sw	JB_R10(r3), r10		/* save callee saved register */
     56  1.1  matt 	l.sw	JB_R14(r3), r14		/* save callee saved register */
     57  1.1  matt 	l.sw	JB_R16(r3), r16		/* save callee saved register */
     58  1.1  matt 	l.sw	JB_R18(r3), r18		/* save callee saved register */
     59  1.1  matt 	l.sw	JB_R20(r3), r20		/* save callee saved register */
     60  1.1  matt 	l.sw	JB_R22(r3), r22		/* save callee saved register */
     61  1.1  matt 	l.sw	JB_R24(r3), r24		/* save callee saved register */
     62  1.1  matt 	l.sw	JB_R26(r3), r26		/* save callee saved register */
     63  1.1  matt 	l.sw	JB_R28(r3), r28		/* save callee saved register */
     64  1.1  matt 	l.sw	JB_R30(r3), r30		/* save callee saved register */
     65  1.1  matt 	l.xor	r11, r11, r11		/* indicate success */
     66  1.1  matt 	l.jr	lr			/* return */
     67  1.1  matt 	l.nop
     68  1.1  matt END(_setjmp)
     69  1.1  matt 
     70  1.1  matt ENTRY(_longjmp)
     71  1.1  matt 	l.lwz	lr, JB_LR(r3)		/* get return address */
     72  1.1  matt 	l.lwz	r1, JB_SP(r3)		/* get stack pointer */
     73  1.1  matt 	l.lwz	r2, JB_FP(r3)		/* get frame pointer */
     74  1.1  matt 	l.lwz	r10, JB_R10(r3)		/* get callee saved register */
     75  1.1  matt 	l.lwz	r14, JB_R14(r3)		/* get callee saved register */
     76  1.1  matt 	l.lwz	r16, JB_R16(r3)		/* get callee saved register */
     77  1.1  matt 	l.lwz	r18, JB_R18(r3)		/* get callee saved register */
     78  1.1  matt 	l.lwz	r20, JB_R20(r3)		/* get callee saved register */
     79  1.1  matt 	l.lwz	r22, JB_R22(r3)		/* get callee saved register */
     80  1.1  matt 	l.lwz	r24, JB_R24(r3)		/* get callee saved register */
     81  1.1  matt 	l.lwz	r26, JB_R26(r3)		/* get callee saved register */
     82  1.1  matt 	l.lwz	r28, JB_R28(r3)		/* get callee saved register */
     83  1.1  matt 	l.lwz	r30, JB_R30(r3)		/* get callee saved register */
     84  1.1  matt 	l.ori	r11, r0, 1		/* default return value */
     85  1.1  matt 	l.sfeqi	r4, 0			/* test return value */
     86  1.1  matt 	l.cmov	r11, r11, r4		/* use it if not 0 */
     87  1.1  matt 	l.jr	lr			/* return */
     88  1.1  matt 	l.nop
     89  1.1  matt END(_longjmp)
     90