Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.14
      1 /*	$NetBSD: asm.h,v 1.14 1998/12/02 00:58:43 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1992, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * Ralph Campbell.
      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 University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  *	@(#)machAsmDefs.h	8.1 (Berkeley) 6/10/93
     39  */
     40 
     41 /*
     42  * machAsmDefs.h --
     43  *
     44  *	Macros used when writing assembler programs.
     45  *
     46  *	Copyright (C) 1989 Digital Equipment Corporation.
     47  *	Permission to use, copy, modify, and distribute this software and
     48  *	its documentation for any purpose and without fee is hereby granted,
     49  *	provided that the above copyright notice appears in all copies.
     50  *	Digital Equipment Corporation makes no representations about the
     51  *	suitability of this software for any purpose.  It is provided "as is"
     52  *	without express or implied warranty.
     53  *
     54  * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h,
     55  *	v 1.2 89/08/15 18:28:24 rab Exp  SPRITE (DECWRL)
     56  */
     57 
     58 #ifndef _MIPS_ASM_H
     59 #define _MIPS_ASM_H
     60 
     61 #include <machine/regdef.h>
     62 
     63 /*
     64  * Define -pg profile entry code.
     65  * XXX assume .set noreorder for kernel, .set reorder for user code.
     66  */
     67 #define _KERN_MCOUNT \
     68 	.set noat; \
     69 	move $1,$31; \
     70 	jal _mcount; \
     71 	subu sp,sp,8; \
     72 	.set at;
     73 
     74 
     75 #ifdef GPROF
     76 # if defined(_KERNEL) || defined(_LOCORE)
     77 #  define MCOUNT _KERN_MCOUNT
     78 # else
     79 #  define MCOUNT .set noreorder; _KERN_MCOUNT ;  .set reorder;
     80 # endif
     81 #else
     82 #define	MCOUNT
     83 #endif
     84 
     85 #ifdef __NO_LEADING_UNDERSCORES__
     86 # define _C_LABEL(x)	x
     87 #else
     88 # ifdef __STDC__
     89 #  define _C_LABEL(x)	_ ## x
     90 # else
     91 #  define _C_LABEL(x)	_/**/x
     92 # endif
     93 #endif
     94 
     95 /*
     96  * WARN_REFERENCES: create a warning if the specified symbol is referenced
     97  * (ELF only, and thus, no leading underscores).
     98  */
     99 #ifdef __ELF__
    100 #ifdef __STDC__
    101 #define	WARN_REFERENCES(_sym,_msg)				\
    102 	.section .gnu.warning. ## _sym ; .ascii _msg ; .text
    103 #else
    104 #define	WARN_REFERENCES(_sym,_msg)				\
    105 	.section .gnu.warning./**/_sym ; .ascii _msg ; .text
    106 #endif /* __STDC__ */
    107 #endif /* __ELF__ */
    108 
    109 /*
    110  * LEAF(x)
    111  *
    112  *	Declare a leaf routine.
    113  */
    114 #define LEAF(x) \
    115 	.globl _C_LABEL(x); \
    116 	.ent _C_LABEL(x), 0; \
    117 _C_LABEL(x): ; \
    118 	.frame sp, 0, ra; \
    119 	MCOUNT
    120 
    121 /*
    122  * NLEAF(x)
    123  *
    124  *	Declare a non-profiled leaf routine.
    125  */
    126 #define NLEAF(x) \
    127 	.globl _C_LABEL(x); \
    128 	.ent _C_LABEL(x), 0; \
    129 _C_LABEL(x): ; \
    130 	.frame sp, 0, ra
    131 
    132 /*
    133  * ALEAF -- declare alternate entry to a leaf routine.
    134  */
    135 #ifdef USE_AENT
    136 #define AENT(x) \
    137 	.aent	x, 0
    138 #else
    139 #define AENT(x)
    140 #endif
    141 #define	ALEAF(x)					\
    142 	.globl	_C_LABEL(x);				\
    143 	AENT (_C_LABEL(x))				\
    144 _C_LABEL(x):
    145 
    146 /*
    147  * NON_LEAF(x)
    148  *
    149  *	Declare a non-leaf routine (a routine that makes other C calls).
    150  */
    151 #define NON_LEAF(x, fsize, retpc) \
    152 	.globl _C_LABEL(x); \
    153 	.ent _C_LABEL(x), 0; \
    154 _C_LABEL(x): ; \
    155 	.frame sp, fsize, retpc; \
    156 	MCOUNT
    157 
    158 /*
    159  * NNON_LEAF(x)
    160  *
    161  *	Declare a non-profiled non-leaf routine
    162  *	(a routine that makes other C calls).
    163  */
    164 #define NNON_LEAF(x, fsize, retpc) \
    165 	.globl _C_LABEL(x); \
    166 	.ent _C_LABEL(x), 0; \
    167 _C_LABEL(x): ; \
    168 	.frame sp, fsize, retpc
    169 
    170 /*
    171  * END(x)
    172  *
    173  *	Mark end of a procedure.
    174  */
    175 #define END(x) \
    176 	.end _C_LABEL(x)
    177 
    178 #define STAND_FRAME_SIZE	24
    179 #define STAND_RA_OFFSET		20
    180 
    181 /*
    182  * Macros to panic and printf from assembly language.
    183  */
    184 #define PANIC(msg) \
    185 	la	a0, 9f; \
    186 	jal	_C_LABEL(panic); \
    187 	MSG(msg)
    188 
    189 #define	PRINTF(msg) \
    190 	la	a0, 9f; \
    191 	jal	_C_LABEL(printf); \
    192 	MSG(msg)
    193 
    194 #define	MSG(msg) \
    195 	.rdata; \
    196 9:	.asciiz	msg; \
    197 	.text
    198 
    199 #define ASMSTR(str) \
    200 	.asciiz str; \
    201 	.align	3
    202 
    203 #endif /* _MIPS_ASM_H */
    204