Get rid of the #define mess for other platforms. We're just Unix.
[dragonfly.git] / sys / boot / arc / lib / arch / alpha / setjmp.S
1 /*
2  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
3  * All rights reserved.
4  *
5  * Author: Chris G. Demetriou
6  *
7  * Permission to use, copy, modify and distribute this software and
8  * its documentation is hereby granted, provided that both the copyright
9  * notice and this permission notice appear in all copies of the
10  * software, derivative works or modified versions, and any portions
11  * thereof, and that both notices appear in supporting documentation.
12  *
13  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
14  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
15  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16  *
17  * Carnegie Mellon requests users of this software to return to
18  *
19  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
20  *  School of Computer Science
21  *  Carnegie Mellon University
22  *  Pittsburgh PA 15213-3890
23  *
24  * any improvements or extensions that they make and grant Carnegie the
25  * rights to redistribute these changes.
26  *
27  * $FreeBSD: src/sys/boot/arc/lib/arch/alpha/setjmp.S,v 1.2 1999/08/28 00:39:40 peter Exp $
28  * $DragonFly: src/sys/boot/arc/lib/arch/alpha/Attic/setjmp.S,v 1.3 2003/11/10 06:08:31 dillon Exp $
29  */
30
31 #include <machine/asm.h>
32
33         .text
34 /*
35  * Kernel setjmp and longjmp.  Rather minimalist.
36  *
37  *      longjmp(label_t *a)
38  * will generate a "return (1)" from the last call to
39  *      setjmp(label_t *a)
40  * by restoring registers from the stack,
41  */
42
43         .set    noreorder
44
45 LEAF(setjmp, 1)
46         LDGP(pv)
47
48         stq     ra, (0 * 8)(a0)                 /* return address */
49         stq     s0, (1 * 8)(a0)                 /* callee-saved registers */
50         stq     s1, (2 * 8)(a0)
51         stq     s2, (3 * 8)(a0)
52         stq     s3, (4 * 8)(a0)
53         stq     s4, (5 * 8)(a0)
54         stq     s5, (6 * 8)(a0)
55         stq     s6, (7 * 8)(a0)
56         stq     sp, (8 * 8)(a0)
57
58         ldiq    t0, 0xbeeffedadeadbabe          /* set magic number */
59         stq     t0, (9 * 8)(a0)
60
61         mov     zero, v0                        /* return zero */
62         RET
63 END(setjmp)
64
65 LEAF(longjmp, 1)
66         LDGP(pv)
67
68         ldiq    t0, 0xbeeffedadeadbabe          /* check magic number */
69         ldq     t1, (9 * 8)(a0)
70         cmpeq   t0, t1, t0
71         beq     t0, longjmp_botch               /* if bad, punt */
72
73         ldq     ra, (0 * 8)(a0)                 /* return address */
74         ldq     s0, (1 * 8)(a0)                 /* callee-saved registers */
75         ldq     s1, (2 * 8)(a0)
76         ldq     s2, (3 * 8)(a0)
77         ldq     s3, (4 * 8)(a0)
78         ldq     s4, (5 * 8)(a0)
79         ldq     s5, (6 * 8)(a0)
80         ldq     s6, (7 * 8)(a0)
81         ldq     sp, (8 * 8)(a0)
82
83         ldiq    v0, 1
84         RET
85
86 longjmp_botch:
87         lda     a0, longjmp_botchmsg
88         mov     ra, a1
89         CALL(panic)
90         call_pal PAL_bugchk
91
92         .data
93 longjmp_botchmsg:
94         .asciz  "longjmp botch from %p"
95         .text
96
97 END(longjmp)