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