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