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