Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.18.6.1
      1 /*	$NetBSD: asm.h,v 1.18.6.1 1999/12/27 18:32:30 wrstuden 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 _M68K_ASM_H_
     81 #define _M68K_ASM_H_
     82 
     83 #if defined(__ELF__) && defined(PIC)
     84 #define PIC_PLT(name)	name@PLTPC
     85 #else
     86 #define PIC_PLT(name)	name
     87 #endif
     88 
     89 #ifdef __ELF__
     90 # if __STDC__
     91 #  define _C_LABEL(name)	name
     92 # else
     93 #  define _C_LABEL(name)	name
     94 #endif /* __STDC__ */
     95 #else /* __ELF__ */
     96 # if __STDC__
     97 #  define _C_LABEL(name)	_ ## name
     98 # else
     99 #  define _C_LABEL(name)	_/**/name
    100 # endif /* __STDC__ */
    101 #endif /* __ELF__ */
    102 
    103 #define	_ASM_LABEL(name)	name
    104 
    105 #define	_ENTRY(name) \
    106 	.text; .even; .globl name; .type name,@function; name:
    107 
    108 #ifdef GPROF
    109 #define _PROF_PROLOG	link %a6,#0; jbsr mcount; unlk %a6
    110 #else
    111 #define _PROF_PROLOG
    112 #endif
    113 
    114 #define ENTRY(name)		_ENTRY(_C_LABEL(name)) _PROF_PROLOG
    115 #define	ASENTRY(name)		_ENTRY(_ASM_LABEL(name)) _PROF_PROLOG
    116 
    117 #define	ENTRY_NOPROFILE(name)	_ENTRY(_C_LABEL(name))
    118 #define	ASENTRY_NOPROFILE(name)	_ENTRY(_ASM_LABEL(name))
    119 
    120 /*
    121  * The m68k ALTENTRY macro is very different than the traditional
    122  * implementation used by other NetBSD ports.  Usually ALTENTRY
    123  * simply provides an alternate function entry point.  The m68k
    124  * definition takes a second argument and jumps inside the second
    125  * function when profiling is enabled.
    126  *
    127  * The m68k behavior is similar to the ENTRY2 macro found in
    128  * solaris' asm_linkage.h.
    129  *
    130  * Providing ENTRY2 and changing all the code that uses ALTENTRY
    131  * to use it would be a desirable change.
    132  */
    133 #ifdef PROF
    134 #define ALTENTRY(name, rname)	ENTRY(name); jra rname+12
    135 #else
    136 #define ALTENTRY(name, rname)	_ENTRY(_C_LABEL(name))
    137 #endif
    138 
    139 #define RCSID(x)	.text			;	\
    140 			.asciz x		;	\
    141 			.even
    142 
    143 /*
    144  * Global variables of whatever sort.
    145  */
    146 #define	GLOBAL(x)					\
    147 		.globl	_C_LABEL(x)		;	\
    148 	_C_LABEL(x):
    149 
    150 #define	ASGLOBAL(x)					\
    151 		.globl	_ASM_LABEL(x)		;	\
    152 	_ASM_LABEL(x):
    153 
    154 /*
    155  * ...and local variables.
    156  */
    157 #define	LOCAL(x)					\
    158 	_C_LABEL(x):
    159 
    160 #define	ASLOCAL(x)					\
    161 	_ASM_LABEL(x):
    162 
    163 /*
    164  * Items in the BSS segment.
    165  */
    166 #define	BSS(name, size)					\
    167 	.comm	_C_LABEL(name),size
    168 
    169 #define	ASBSS(name, size)				\
    170 	.comm	_ASM_LABEL(name),size
    171 
    172 #ifdef _KERNEL
    173 /*
    174  * Shorthand for calling panic().
    175  * Note the side-effect: it uses up the 9: label, so be careful!
    176  */
    177 #define	PANIC(x)					\
    178 		pea	9f			;	\
    179 		jbsr	_C_LABEL(panic)		;	\
    180 	9:	.asciz	x			;	\
    181 		.even
    182 
    183 /*
    184  * Shorthand for defining vectors for the vector table.
    185  */
    186 #define	VECTOR(x)					\
    187 	.long	_C_LABEL(x)
    188 
    189 #define	ASVECTOR(x)					\
    190 	.long	_ASM_LABEL(x)
    191 
    192 #define	VECTOR_UNUSED					\
    193 	.long	0
    194 
    195 #endif /* _KERNEL */
    196 
    197 #ifdef __STDC__
    198 #define	__STRING(x)			#x
    199 #define	WARN_REFERENCES(sym,msg)					\
    200 	.stabs msg ## ,30,0,0,0 ;					\
    201 	.stabs __STRING(_ ## sym) ## ,1,0,0,0
    202 #else
    203 #define	__STRING(x)			"x"
    204 #define	WARN_REFERENCES(sym,msg)					\
    205 	.stabs msg,30,0,0,0 ;						\
    206 	.stabs __STRING(_/**/sym),1,0,0,0
    207 #endif /* __STDC__ */
    208 
    209 #endif /* _M68K_ASM_H_ */
    210