summaryrefslogtreecommitdiffstats
path: root/usr.sbin/afs/src/lwp/process.m68k.S
blob: bc7fd9691bf1464e0df8b8f4debbdba450636e3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* $arla: process.m68k.S,v 1.7 2000/08/25 14:49:04 lha Exp $ */

/*
****************************************************************************
*        Copyright IBM Corporation 1988, 1989 - All Rights Reserved        *
*                                                                          *
* Permission to use, copy, modify, and distribute this software and its    *
* documentation for any purpose and without fee is hereby granted,         *
* provided that the above copyright notice appear in all copies and        *
* that both that copyright notice and this permission notice appear in     *
* supporting documentation, and that the name of IBM not be used in        *
* advertising or publicity pertaining to distribution of the software      *
* without specific, written prior permission.                              *
*                                                                          *
* IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY      *
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER  *
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING   *
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.    *
****************************************************************************
*/

#include <config.h>

#undef RCSID

#include <lwp_elf.h>

#if !defined(__ELF__) && !defined(sun3)
#define reg(x) x
#else /* __ELF__ || sun3 */
#ifdef __STDC__
#define reg(x) %##x
#else
#define reg(x) %/**/x
#endif /* __STDC__ */
#endif /* __ELF__ || sun3 */

/*
#
#	Information Technology Center
#	Carnegie-Mellon University
#
#
*/
	.data

/*
#
#	Process assembly language assist for Suns.
#
*/

	.text
	.even

/*
#
# struct savearea {
#	char	*topstack;
# }
#
*/

	.globl	_C_LABEL(PRE_Block)
	.globl	_C_LABEL(savecontext)
	.globl	_C_LABEL(returnto)
	
topstack =	0

/* Stuff to allow saving/restoring registers */
nregs	=	13
regs	=	0x3ffe			| d1-d7 & a0-a5

/*
# savecontext(f, area1, newsp)
#     int (*f)(); struct savearea *area1; char *newsp;
*/

/* Stack offsets of arguments */
f	=	8
area1	=	12
newsp	=	16

ENTRY(savecontext)
	movl	#1,_C_LABEL(PRE_Block)	| Dont allow any interrupt finagling
	link	reg(a6),#-(nregs*4)	| Save frame pointer & ...
					| ... allocate space for nregs registers
/* Save registers */
	moveml	#regs,reg(sp)@

	movl	reg(a6)@(area1),reg(a0)		| a0 = base of savearea
	movl	reg(sp),reg(a0)@(topstack)	| area->topstack = sp
	movl	reg(a6)@(newsp),reg(d0)		| Get new sp
	jeq	forw1			| If newsp == 0, no stack switch
	movl	reg(d0),reg(sp)			| Switch to new stack
forw1:
	movl	reg(a6)@(f),reg(a0)		| a0 = f
	jbsr	reg(a0)@			| f()

/* It is impossible to be here, so abort() */

	jbsr	_C_LABEL(abort)

/*
# returnto(area2)
#     struct savearea *area2;
*/

/* Stack offset of argument */
area2	=	8

ENTRY(returnto)
	link	reg(a6),#0
	movl	reg(a6)@(area2),reg(a0)		| Base of savearea
	movl	reg(a0)@(topstack),reg(sp)	| Restore sp
/* Restore registers */
	moveml	reg(sp)@,#regs

	addl	#(nregs*4),reg(sp)
	movl	reg(sp),reg(a6)			| Argghh...be careful here
	unlk	reg(a6)
	clrl	_C_LABEL(PRE_Block)
	rts					| Return to previous process