(nnpfs_block_open): better cleanup on failure
[arla.git] / lwp / process.m68k.S
blob0a5eb699e7e6a70f799b1debe6b422fbae85f21c
1 /* $Id$ */
3 /*
4 ****************************************************************************
5 *        Copyright IBM Corporation 1988, 1989 - All Rights Reserved        *
6 *                                                                          *
7 * Permission to use, copy, modify, and distribute this software and its    *
8 * documentation for any purpose and without fee is hereby granted,         *
9 * provided that the above copyright notice appear in all copies and        *
10 * that both that copyright notice and this permission notice appear in     *
11 * supporting documentation, and that the name of IBM not be used in        *
12 * advertising or publicity pertaining to distribution of the software      *
13 * without specific, written prior permission.                              *
14 *                                                                          *
15 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
17 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY      *
18 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER  *
19 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING   *
20 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.    *
21 ****************************************************************************
24 #include <config.h>
26 #undef RCSID
28 #include <lwp_elf.h>
30 #if !defined(__ELF__) && !defined(sun3)
31 #define reg(x) x
32 #else /* __ELF__ || sun3 */
33 #ifdef __STDC__
34 #define reg(x) %##x
35 #else
36 #define reg(x) %/**/x
37 #endif /* __STDC__ */
38 #endif /* __ELF__ || sun3 */
42 #       Information Technology Center
43 #       Carnegie-Mellon University
47         .data
51 #       Process assembly language assist for Suns.
55         .text
56         .even
60 # struct savearea {
61 #       char    *topstack;
62 # }
66         .globl  _C_LABEL(PRE_Block)
67         .globl  _C_LABEL(savecontext)
68         .globl  _C_LABEL(returnto)
69         
70 topstack =      0
72 /* Stuff to allow saving/restoring registers */
73 nregs   =       13
74 regs    =       0x3ffe                  | d1-d7 & a0-a5
77 # savecontext(f, area1, newsp)
78 #     int (*f)(); struct savearea *area1; char *newsp;
81 /* Stack offsets of arguments */
82 f       =       8
83 area1   =       12
84 newsp   =       16
86 ENTRY(savecontext)
87         movl    #1,_C_LABEL(PRE_Block)  | Dont allow any interrupt finagling
88         link    reg(a6),#-(nregs*4)     | Save frame pointer & ...
89                                         | ... allocate space for nregs registers
90 /* Save registers */
91         moveml  #regs,reg(sp)@
93         movl    reg(a6)@(area1),reg(a0)         | a0 = base of savearea
94         movl    reg(sp),reg(a0)@(topstack)      | area->topstack = sp
95         movl    reg(a6)@(newsp),reg(d0)         | Get new sp
96         jeq     forw1                   | If newsp == 0, no stack switch
97         movl    reg(d0),reg(sp)                 | Switch to new stack
98 forw1:
99         movl    reg(a6)@(f),reg(a0)             | a0 = f
100         jbsr    reg(a0)@                        | f()
102 /* It is impossible to be here, so abort() */
104         jbsr    _C_LABEL(abort)
107 # returnto(area2)
108 #     struct savearea *area2;
111 /* Stack offset of argument */
112 area2   =       8
114 ENTRY(returnto)
115         link    reg(a6),#0
116         movl    reg(a6)@(area2),reg(a0)         | Base of savearea
117         movl    reg(a0)@(topstack),reg(sp)      | Restore sp
118 /* Restore registers */
119         moveml  reg(sp)@,#regs
121         addl    #(nregs*4),reg(sp)
122         movl    reg(sp),reg(a6)                 | Argghh...be careful here
123         unlk    reg(a6)
124         clrl    _C_LABEL(PRE_Block)
125         rts                                     | Return to previous process