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