Shin-ichiro KAWASAKI | 1009327 | 2009-09-28 16:11:39 +0900 | [diff] [blame] | 1 | /* $OpenBSD: _setjmp.S,v 1.2 2007/03/02 06:11:54 miod Exp $ */ |
| 2 | /* $NetBSD: _setjmp.S,v 1.7 2006/01/05 02:04:41 uwe Exp $ */ |
| 3 | |
| 4 | /*- |
| 5 | * Copyright (c) 1990 The Regents of the University of California. |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * This code is derived from software contributed to Berkeley by |
| 9 | * William Jolitz. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in the |
| 18 | * documentation and/or other materials provided with the distribution. |
| 19 | * 3. Neither the name of the University nor the names of its contributors |
| 20 | * may be used to endorse or promote products derived from this software |
| 21 | * without specific prior written permission. |
| 22 | * |
| 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 33 | * SUCH DAMAGE. |
| 34 | * |
| 35 | * from: @(#)_setjmp.s 5.1 (Berkeley) 4/23/90 |
| 36 | */ |
| 37 | |
| 38 | #include <machine/asm.h> |
| 39 | #include <machine/setjmp.h> |
| 40 | |
| 41 | /* |
| 42 | * C library -- _setjmp, _longjmp |
| 43 | * |
| 44 | * _longjmp(a,v) |
| 45 | * will generate a "return(v)" from the last call to |
| 46 | * _setjmp(a) |
| 47 | * by restoring registers from the stack. |
| 48 | * The previous signal state is NOT restored. |
| 49 | */ |
| 50 | |
| 51 | ENTRY(_setjmp) |
| 52 | xor r0, r0 |
| 53 | #if defined(__SH4__) && !defined(__SH4_NOFPU__) |
| 54 | add #(_JBLEN * 4), r4 |
| 55 | sts fpscr, r1 |
| 56 | mov.l r1, @-r4 |
| 57 | lds r0, fpscr |
| 58 | sts.l fpul, @-r4 |
| 59 | fmov.s fr15, @-r4 |
| 60 | fmov.s fr14, @-r4 |
| 61 | fmov.s fr13, @-r4 |
| 62 | fmov.s fr12, @-r4 |
| 63 | frchg |
| 64 | fmov.s fr15, @-r4 |
| 65 | fmov.s fr14, @-r4 |
| 66 | fmov.s fr13, @-r4 |
| 67 | fmov.s fr12, @-r4 |
| 68 | lds r1, fpscr |
| 69 | #else |
| 70 | add #((_JBLEN - 10) * 4), r4 |
| 71 | #endif |
| 72 | sts.l mach, @-r4 |
| 73 | sts.l macl, @-r4 |
| 74 | mov.l r15, @-r4 |
| 75 | mov.l r14, @-r4 |
| 76 | mov.l r13, @-r4 |
| 77 | mov.l r12, @-r4 |
| 78 | mov.l r11, @-r4 |
| 79 | mov.l r10, @-r4 |
| 80 | mov.l r9, @-r4 |
| 81 | mov.l r8, @-r4 |
| 82 | sts.l pr, @-r4 |
| 83 | mov.l r0, @-r4 /* dummy signal mask */ |
| 84 | rts |
| 85 | mov.l r0, @-r4 /* no saved signal mask */ |
| 86 | SET_ENTRY_SIZE(_setjmp) |
| 87 | |
| 88 | ENTRY(_longjmp) |
| 89 | add #8, r4 |
| 90 | lds.l @r4+, pr |
| 91 | mov.l @r4+, r8 |
| 92 | mov.l @r4+, r9 |
| 93 | mov.l @r4+, r10 |
| 94 | mov.l @r4+, r11 |
| 95 | mov.l @r4+, r12 |
| 96 | mov.l @r4+, r13 |
| 97 | mov.l @r4+, r14 |
| 98 | mov.l @r4+, r15 |
| 99 | lds.l @r4+, macl |
| 100 | lds.l @r4+, mach |
| 101 | #if defined(__SH4__) && !defined(__SH4_NOFPU__) |
| 102 | xor r0, r0 |
| 103 | lds r0, fpscr |
| 104 | frchg |
| 105 | fmov.s @r4+, fr12 |
| 106 | fmov.s @r4+, fr13 |
| 107 | fmov.s @r4+, fr14 |
| 108 | fmov.s @r4+, fr15 |
| 109 | frchg |
| 110 | fmov.s @r4+, fr12 |
| 111 | fmov.s @r4+, fr13 |
| 112 | fmov.s @r4+, fr14 |
| 113 | fmov.s @r4+, fr15 |
| 114 | lds.l @r4+, fpul |
| 115 | lds.l @r4+, fpscr |
| 116 | #endif |
| 117 | |
| 118 | mov r5, r0 |
| 119 | tst r0, r0 |
| 120 | bf .L0 |
| 121 | add #1, r0 |
| 122 | .L0: |
| 123 | rts |
| 124 | nop |
| 125 | SET_ENTRY_SIZE(_longjmp) |