1 /* $NetBSD: asm.h,v 1.24 2006/01/20 22:02:40 christos Exp $ */
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Copyright (c) 1994 Allen Briggs
34 * All rights reserved.
36 * Gleaned from locore.s and sun3 asm.h which had the following copyrights:
38 * Copyright (c) 1988 University of Utah.
39 * Copyright (c) 1982, 1990 The Regents of the University of California.
41 * Copyright (c) 1993 Adam Glass
42 * Copyright (c) 1990 The Regents of the University of California.
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the University of
55 * California, Berkeley and its contributors.
56 * 4. Neither the name of the University nor the names of its contributors
57 * may be used to endorse or promote products derived from this software
58 * without specific prior written permission.
60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
76 #if defined(__ELF__) && defined(PIC)
77 #define PIC_PLT(name) name@PLTPC
79 #define PIC_PLT(name) name
84 # define _C_LABEL(name) name
86 # define _C_LABEL(name) name
90 # define _C_LABEL(name) _ ## name
92 # define _C_LABEL(name) _/**/name
93 # endif /* __STDC__ */
96 #define _ASM_LABEL(name) name
98 #define _ENTRY(name) \
99 .text; .even; .globl name; .type name,@function; name:
102 #define MCOUNT_ENTRY __mcount
104 #define MCOUNT_ENTRY mcount
108 #define _PROF_PROLOG link %a6,#0; jbsr MCOUNT_ENTRY; unlk %a6
113 #define ENTRY(name) _ENTRY(_C_LABEL(name)) _PROF_PROLOG
114 #define ASENTRY(name) _ENTRY(_ASM_LABEL(name)) _PROF_PROLOG
116 #define ENTRY_NOPROFILE(name) _ENTRY(_C_LABEL(name))
117 #define ASENTRY_NOPROFILE(name) _ENTRY(_ASM_LABEL(name))
120 * The m68k ALTENTRY macro is very different than the traditional
121 * implementation used by other NetBSD ports. Usually ALTENTRY
122 * simply provides an alternate function entry point. The m68k
123 * definition takes a second argument and jumps inside the second
124 * function when profiling is enabled.
126 * The m68k behavior is similar to the ENTRY2 macro found in
127 * solaris' asm_linkage.h.
129 * Providing ENTRY2 and changing all the code that uses ALTENTRY
130 * to use it would be a desirable change.
133 #define ALTENTRY(name, rname) ENTRY(name); jra rname+12
135 #define ALTENTRY(name, rname) _ENTRY(_C_LABEL(name))
138 #define RCSID(x) .text ; \
143 * Global variables of whatever sort.
146 .globl _C_LABEL(x) ; \
149 #define ASGLOBAL(x) \
150 .globl _ASM_LABEL(x) ; \
154 * ...and local variables.
163 * Items in the BSS segment.
165 #define BSS(name, size) \
166 .comm _C_LABEL(name),size
168 #define ASBSS(name, size) \
169 .comm _ASM_LABEL(name),size
173 * Shorthand for calling panic().
174 * Note the side-effect: it uses up the 9: label, so be careful!
178 jbsr _C_LABEL(panic) ; \
185 * Shorthand for defining vectors for the vector table.
190 #define ASVECTOR(x) \
193 #define VECTOR_UNUSED \
197 #define WEAK_ALIAS(alias,sym) \
202 * STRONG_ALIAS: create a strong alias.
204 #define STRONG_ALIAS(alias,sym) \
209 #define __STRING(x) #x
210 #define WARN_REFERENCES(sym,msg) \
211 .stabs msg ## ,30,0,0,0 ; \
212 .stabs __STRING(_ ## sym) ## ,1,0,0,0
214 #define __STRING(x) "x"
215 #define WARN_REFERENCES(sym,msg) \
216 .stabs msg,30,0,0,0 ; \
217 .stabs __STRING(_/**/sym),1,0,0,0
218 #endif /* __STDC__ */
221 * Macros to hide shortcomings in the 68010.
226 #else /* __mc68010__ */
230 #endif /* __mc68010__ */
232 #endif /* _M68K_ASM_H_ */