*** empty log message ***
[arla.git] / lwp / process.m88k.S
blob32b5a5d7640cd23440d9ebc5a63d774e23625fc1
1 /*      $OpenBSD: process.m88k.S,v 1.5 2006/11/17 20:54:47 deraadt Exp $        */
3 /*
4  * Copyright (c) 2004, Miodrag Vallat.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
28 #include <machine/asm.h>
30 #include <config.h>
32 .globl  _C_LABEL(PRE_Block)
35  * savecontext(int (*f)(), struct savearea *a1, char *newsp)
36  */
37 ENTRY(savecontext)
38         /* save all registers but r0, r2, r3 and r31 on stack - we could
39            skip r4 but saving it allows us to use it as a temporary below. */
40         subu    r31, r31, 4 * 30
41         st.d    r4,  r31, 4 * 0
42         st.d    r6,  r31, 4 * 2
43         st.d    r8,  r31, 4 * 4
44         st.d    r10, r31, 4 * 6
45         st.d    r12, r31, 4 * 8
46         st.d    r14, r31, 4 * 10
47         st.d    r16, r31, 4 * 12
48         st.d    r18, r31, 4 * 14
49         st.d    r20, r31, 4 * 16
50         st.d    r22, r31, 4 * 18
51         st.d    r24, r31, 4 * 20
52         st.d    r26, r31, 4 * 22
53         st.d    r28, r31, 4 * 24
54         st      r30, r31, 4 * 26
55         st      r1,  r31, 4 * 27
56         fldcr   r4,  fcr62
57         fldcr   r5,  fcr63
58         st.d    r4,  r31, 4 * 28
60         /* set preemption lock */
61         or.u    r4,  r0,  hi16(_C_LABEL(PRE_Block))
62         set     r1,  r0,  1<0>
63         st      r1,  r4,  lo16(_C_LABEL(PRE_Block))
64         ld.d    r4,  r31, 4 * 0
66         /* save stack pointer, and fetch the new one if non NULL */
67         bcnd.n  eq0, r4,  1f
68          st     r31, r3,  0
69         or      r31, r4,  r0
72         /* invoke function */
73         jsr     r2
75         /* should not return, invoke abort() if this happens */
76         bsr     _C_LABEL(abort)
77         /* NOTREACHED */
78         
80  * returnto(struct savearea *a2)
82 ENTRY(returnto)
83         /* pick stack */
84         ld      r31, r2,  0
86         /* restore registers */
87         ld.d    r4,  r31, 4 * 28
88         fstcr   r4,  fcr62
89         fstcr   r5,  fcr63
90         ld.d    r4,  r31, 4 * 0
91         ld.d    r6,  r31, 4 * 2
92         ld.d    r8,  r31, 4 * 4
93         ld.d    r10, r31, 4 * 6
94         ld.d    r12, r31, 4 * 8
95         ld.d    r14, r31, 4 * 10
96         ld.d    r16, r31, 4 * 12
97         ld.d    r18, r31, 4 * 14
98         ld.d    r20, r31, 4 * 16
99         ld.d    r22, r31, 4 * 18
100         ld.d    r24, r31, 4 * 20
101         ld.d    r26, r31, 4 * 22
102         ld.d    r28, r31, 4 * 24
103         ld      r30, r31, 4 * 26
104         ld      r1,  r31, 4 * 27
105         addu    r31, r31, 4 * 30
107         /* clear preemption lock and return */
108         or.u    r2,  r0,  hi16(_C_LABEL(PRE_Block))
109         jmp.n   r1
110          st     r0,  r2,  lo16(_C_LABEL(PRE_Block))