xref: /netbsd-src/sys/arch/m68k/include/asm.h (revision 2a399c6883d870daece976daec6ffa7bb7f934ce)
1 /*	$NetBSD: asm.h,v 1.15 1997/10/04 17:34:08 thorpej Exp $	*/
2 
3 /*-
4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jason R. Thorpe.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the NetBSD
21  *	Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 /*
40  * Copyright (c) 1994 Allen Briggs
41  * All rights reserved.
42  *
43  * Gleaned from locore.s and sun3 asm.h which had the following copyrights:
44  * locore.s:
45  * Copyright (c) 1988 University of Utah.
46  * Copyright (c) 1982, 1990 The Regents of the University of California.
47  * sun3/include/asm.h:
48  * Copyright (c) 1993 Adam Glass
49  * Copyright (c) 1990 The Regents of the University of California.
50  *
51  * Redistribution and use in source and binary forms, with or without
52  * modification, are permitted provided that the following conditions
53  * are met:
54  * 1. Redistributions of source code must retain the above copyright
55  *    notice, this list of conditions and the following disclaimer.
56  * 2. Redistributions in binary form must reproduce the above copyright
57  *    notice, this list of conditions and the following disclaimer in the
58  *    documentation and/or other materials provided with the distribution.
59  * 3. All advertising materials mentioning features or use of this software
60  *    must display the following acknowledgement:
61  *	This product includes software developed by the University of
62  *	California, Berkeley and its contributors.
63  * 4. Neither the name of the University nor the names of its contributors
64  *    may be used to endorse or promote products derived from this software
65  *    without specific prior written permission.
66  *
67  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
68  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
69  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
70  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
71  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
72  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
73  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
74  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
75  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
76  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
77  * SUCH DAMAGE.
78  */
79 
80 #ifndef _ASM_H_
81 #define _ASM_H_
82 
83 #ifdef __STDC__
84 #define	_C_LABEL(name)		_ ## name
85 #else
86 #define	_C_LABEL(name)		_/**/name
87 #endif /* __STDC__ */
88 
89 #define	_ASM_LABEL(name)	name
90 
91 #define	_ENTRY(name) \
92 	.text; .even; .globl name; .type name,@function; name:
93 
94 #ifdef GPROF
95 #define _PROF_PROLOG	link a6,#0; jbsr mcount; unlk a6
96 #else
97 #define _PROF_PROLOG
98 #endif
99 
100 #define ENTRY(name)		_ENTRY(_C_LABEL(name)) _PROF_PROLOG
101 #define	ASENTRY(name)		_ENTRY(_ASM_LABEL(name)) _PROF_PROLOG
102 
103 #define	ENTRY_NOPROFILE(name)	_ENTRY(_C_LABEL(name))
104 #define	ASENTRY_NOPROFILE(name)	_ENTRY(_ASM_LABEL(name))
105 
106 /*
107  * The m68k ALTENTRY macro is very different than the traditional
108  * implementation used by other NetBSD ports.  Usually ALTENTRY
109  * simply provides an alternate function entry point.  The m68k
110  * definition takes a second argument and jumps inside the second
111  * function when profiling is enabled.
112  *
113  * The m68k behavior is similar to the ENTRY2 macro found in
114  * solaris' asm_linkage.h.
115  *
116  * Providing ENTRY2 and changing all the code that uses ALTENTRY
117  * to use it would be a desirable change.
118  */
119 #ifdef PROF
120 #define ALTENTRY(name, rname)	ENTRY(name); jra rname+12
121 #else
122 #define ALTENTRY(name, rname)	_ENTRY(_C_LABEL(name))
123 #endif
124 
125 #define RCSID(x)	.text			;	\
126 			.asciz x		;	\
127 			.even
128 
129 /*
130  * Global variables of whatever sort.
131  */
132 #define	GLOBAL(x)					\
133 		.globl	_C_LABEL(x)		;	\
134 	_C_LABEL(x):
135 
136 #define	ASGLOBAL(x)					\
137 		.globl	_ASM_LABEL(x)		;	\
138 	_ASM_LABEL(x):
139 
140 /*
141  * ...and local variables.
142  */
143 #define	LOCAL(x)					\
144 	_C_LABEL(x):
145 
146 #define	ASLOCAL(x)					\
147 	_ASM_LABEL(x):
148 
149 /*
150  * Items in the BSS segment.
151  */
152 #define	BSS(name, size)					\
153 	.comm	_C_LABEL(name),size
154 
155 #define	ASBSS(name, size)				\
156 	.comm	_ASM_LABEL(name),size
157 
158 #ifdef _KERNEL
159 /*
160  * Shorthand for calling panic().
161  * Note the side-effect: it uses up the 9: label, so be careful!
162  */
163 #define	PANIC(x)					\
164 		pea	9f			;	\
165 		jbsr	_C_LABEL(panic)		;	\
166 	9:	.asciz	x			;	\
167 		.even
168 
169 /*
170  * Shorthand for defining vectors for the vector table.
171  */
172 #define	VECTOR(x)					\
173 	.long	_C_LABEL(x)
174 
175 #define	ASVECTOR(x)					\
176 	.long	_ASM_LABEL(x)
177 
178 #define	VECTOR_UNUSED					\
179 	.long	0
180 
181 #endif /* _KERNEL */
182 
183 #endif /* _ASM_H_ */
184