Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.40.20.2
      1  1.40.20.2      yamt /*	$NetBSD: asm.h,v 1.40.20.2 2010/08/11 22:52:23 yamt Exp $	*/
      2        1.4       cgd 
      3        1.1   deraadt /*
      4        1.2     glass  * Copyright (c) 1992, 1993
      5        1.2     glass  *	The Regents of the University of California.  All rights reserved.
      6        1.1   deraadt  *
      7        1.1   deraadt  * This code is derived from software contributed to Berkeley by
      8        1.1   deraadt  * Ralph Campbell.
      9        1.1   deraadt  *
     10        1.1   deraadt  * Redistribution and use in source and binary forms, with or without
     11        1.1   deraadt  * modification, are permitted provided that the following conditions
     12        1.1   deraadt  * are met:
     13        1.1   deraadt  * 1. Redistributions of source code must retain the above copyright
     14        1.1   deraadt  *    notice, this list of conditions and the following disclaimer.
     15        1.1   deraadt  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.1   deraadt  *    notice, this list of conditions and the following disclaimer in the
     17        1.1   deraadt  *    documentation and/or other materials provided with the distribution.
     18       1.35       agc  * 3. Neither the name of the University nor the names of its contributors
     19        1.1   deraadt  *    may be used to endorse or promote products derived from this software
     20        1.1   deraadt  *    without specific prior written permission.
     21        1.1   deraadt  *
     22        1.1   deraadt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23        1.1   deraadt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24        1.1   deraadt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25        1.1   deraadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26        1.1   deraadt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27        1.1   deraadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28        1.1   deraadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29        1.1   deraadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30        1.1   deraadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31        1.1   deraadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32        1.1   deraadt  * SUCH DAMAGE.
     33        1.1   deraadt  *
     34        1.4       cgd  *	@(#)machAsmDefs.h	8.1 (Berkeley) 6/10/93
     35        1.1   deraadt  */
     36        1.1   deraadt 
     37        1.1   deraadt /*
     38        1.1   deraadt  * machAsmDefs.h --
     39        1.1   deraadt  *
     40        1.1   deraadt  *	Macros used when writing assembler programs.
     41        1.1   deraadt  *
     42        1.1   deraadt  *	Copyright (C) 1989 Digital Equipment Corporation.
     43        1.1   deraadt  *	Permission to use, copy, modify, and distribute this software and
     44        1.1   deraadt  *	its documentation for any purpose and without fee is hereby granted,
     45        1.1   deraadt  *	provided that the above copyright notice appears in all copies.
     46        1.1   deraadt  *	Digital Equipment Corporation makes no representations about the
     47        1.1   deraadt  *	suitability of this software for any purpose.  It is provided "as is"
     48        1.1   deraadt  *	without express or implied warranty.
     49        1.1   deraadt  *
     50        1.1   deraadt  * from: Header: /sprite/src/kernel/mach/ds3100.md/RCS/machAsmDefs.h,
     51        1.2     glass  *	v 1.2 89/08/15 18:28:24 rab Exp  SPRITE (DECWRL)
     52        1.1   deraadt  */
     53        1.1   deraadt 
     54        1.8  jonathan #ifndef _MIPS_ASM_H
     55  1.40.20.1      yamt #define	_MIPS_ASM_H
     56        1.1   deraadt 
     57       1.30    simonb #include <machine/cdefs.h>	/* for API selection */
     58       1.21      soda #include <mips/regdef.h>
     59        1.1   deraadt 
     60        1.1   deraadt /*
     61        1.1   deraadt  * Define -pg profile entry code.
     62       1.23    castor  * Must always be noreorder, must never use a macro instruction
     63       1.23    castor  * Final addiu to t9 must always equal the size of this _KERN_MCOUNT
     64        1.1   deraadt  */
     65  1.40.20.1      yamt #define	_KERN_MCOUNT						\
     66       1.23    castor 	.set	push;						\
     67       1.23    castor 	.set	noreorder;					\
     68       1.23    castor 	.set	noat;						\
     69       1.27     jeffs 	subu	sp,sp,16;					\
     70       1.27     jeffs 	sw	t9,12(sp);					\
     71       1.23    castor 	move	AT,ra;						\
     72       1.23    castor 	lui	t9,%hi(_mcount); 				\
     73       1.23    castor 	addiu	t9,t9,%lo(_mcount);				\
     74       1.23    castor 	jalr	t9;						\
     75       1.27     jeffs 	nop;							\
     76       1.23    castor 	lw	t9,4(sp);					\
     77       1.23    castor 	addiu	sp,sp,8;					\
     78       1.28     jeffs 	addiu	t9,t9,40;					\
     79       1.23    castor 	.set	pop;
     80       1.13  jonathan 
     81       1.11       jtc #ifdef GPROF
     82  1.40.20.1      yamt #define	MCOUNT _KERN_MCOUNT
     83        1.1   deraadt #else
     84        1.1   deraadt #define	MCOUNT
     85        1.2     glass #endif
     86        1.1   deraadt 
     87        1.7    mellon #ifdef __NO_LEADING_UNDERSCORES__
     88        1.6   mycroft # define _C_LABEL(x)	x
     89        1.6   mycroft #else
     90        1.6   mycroft # ifdef __STDC__
     91        1.6   mycroft #  define _C_LABEL(x)	_ ## x
     92        1.6   mycroft # else
     93        1.6   mycroft #  define _C_LABEL(x)	_/**/x
     94        1.6   mycroft # endif
     95        1.6   mycroft #endif
     96       1.14   thorpej 
     97       1.15    castor #ifdef USE_AENT
     98  1.40.20.1      yamt #define	AENT(x)				\
     99       1.15    castor 	.aent	x, 0
    100       1.15    castor #else
    101  1.40.20.1      yamt #define	AENT(x)
    102       1.24    kleink #endif
    103       1.24    kleink 
    104       1.31    simonb /*
    105       1.31    simonb  * WEAK_ALIAS: create a weak alias.
    106       1.31    simonb  */
    107       1.24    kleink #define	WEAK_ALIAS(alias,sym)						\
    108       1.24    kleink 	.weak alias;							\
    109       1.24    kleink 	alias = sym
    110       1.37  christos /*
    111       1.37  christos  * STRONG_ALIAS: create a strong alias.
    112       1.37  christos  */
    113  1.40.20.1      yamt #define	STRONG_ALIAS(alias,sym)						\
    114       1.37  christos 	.globl alias;							\
    115       1.37  christos 	alias = sym
    116       1.15    castor 
    117       1.14   thorpej /*
    118       1.33    simonb  * WARN_REFERENCES: create a warning if the specified symbol is referenced.
    119       1.14   thorpej  */
    120       1.14   thorpej #ifdef __STDC__
    121       1.14   thorpej #define	WARN_REFERENCES(_sym,_msg)				\
    122       1.14   thorpej 	.section .gnu.warning. ## _sym ; .ascii _msg ; .text
    123       1.14   thorpej #else
    124       1.14   thorpej #define	WARN_REFERENCES(_sym,_msg)				\
    125       1.14   thorpej 	.section .gnu.warning./**/_sym ; .ascii _msg ; .text
    126       1.14   thorpej #endif /* __STDC__ */
    127        1.6   mycroft 
    128        1.1   deraadt /*
    129       1.15    castor  * LEAF
    130       1.15    castor  *	A leaf routine does
    131       1.15    castor  *	- call no other function,
    132       1.15    castor  *	- never use any register that callee-saved (S0-S8), and
    133       1.15    castor  *	- not use any local stack storage.
    134       1.15    castor  */
    135  1.40.20.1      yamt #define	LEAF(x)				\
    136       1.15    castor 	.globl	_C_LABEL(x);		\
    137       1.15    castor 	.ent	_C_LABEL(x), 0;		\
    138       1.15    castor _C_LABEL(x): ;				\
    139       1.15    castor 	.frame sp, 0, ra;		\
    140        1.1   deraadt 	MCOUNT
    141        1.1   deraadt 
    142        1.1   deraadt /*
    143       1.15    castor  * LEAF_NOPROFILE
    144       1.15    castor  *	No profilable leaf routine.
    145        1.1   deraadt  */
    146  1.40.20.1      yamt #define	LEAF_NOPROFILE(x)		\
    147       1.15    castor 	.globl	_C_LABEL(x);		\
    148       1.15    castor 	.ent	_C_LABEL(x), 0;		\
    149       1.15    castor _C_LABEL(x): ;				\
    150       1.15    castor 	.frame	sp, 0, ra
    151       1.15    castor 
    152       1.15    castor /*
    153       1.34    simonb  * STATIC_LEAF
    154       1.34    simonb  *	Declare a local leaf function.
    155       1.34    simonb  */
    156  1.40.20.1      yamt #define	STATIC_LEAF(x)			\
    157       1.34    simonb 	.ent	_C_LABEL(x), 0;		\
    158       1.34    simonb _C_LABEL(x): ;				\
    159       1.34    simonb 	.frame sp, 0, ra;		\
    160       1.34    simonb 	MCOUNT
    161       1.34    simonb 
    162       1.34    simonb /*
    163       1.15    castor  * XLEAF
    164       1.15    castor  *	declare alternate entry to leaf routine
    165       1.15    castor  */
    166  1.40.20.1      yamt #define	XLEAF(x)			\
    167       1.15    castor 	.globl	_C_LABEL(x);		\
    168       1.34    simonb 	AENT (_C_LABEL(x));		\
    169       1.34    simonb _C_LABEL(x):
    170       1.34    simonb 
    171       1.34    simonb /*
    172       1.34    simonb  * STATIC_XLEAF
    173       1.34    simonb  *	declare alternate entry to a static leaf routine
    174       1.34    simonb  */
    175  1.40.20.1      yamt #define	STATIC_XLEAF(x)			\
    176       1.20      soda 	AENT (_C_LABEL(x));		\
    177       1.15    castor _C_LABEL(x):
    178       1.15    castor 
    179       1.15    castor /*
    180       1.15    castor  * NESTED
    181       1.15    castor  *	A function calls other functions and needs
    182       1.15    castor  *	therefore stack space to save/restore registers.
    183       1.15    castor  */
    184  1.40.20.1      yamt #define	NESTED(x, fsize, retpc)		\
    185       1.15    castor 	.globl	_C_LABEL(x);		\
    186       1.15    castor 	.ent	_C_LABEL(x), 0; 	\
    187       1.15    castor _C_LABEL(x): ;				\
    188       1.15    castor 	.frame	sp, fsize, retpc;	\
    189       1.15    castor 	MCOUNT
    190        1.1   deraadt 
    191        1.1   deraadt /*
    192       1.15    castor  * NESTED_NOPROFILE(x)
    193       1.15    castor  *	No profilable nested routine.
    194        1.1   deraadt  */
    195  1.40.20.1      yamt #define	NESTED_NOPROFILE(x, fsize, retpc)	\
    196       1.15    castor 	.globl	_C_LABEL(x);		\
    197       1.15    castor 	.ent	_C_LABEL(x), 0;		\
    198       1.15    castor _C_LABEL(x): ;				\
    199       1.15    castor 	.frame	sp, fsize, retpc
    200       1.15    castor 
    201       1.15    castor /*
    202       1.15    castor  * XNESTED
    203       1.15    castor  *	declare alternate entry point to nested routine.
    204       1.15    castor  */
    205  1.40.20.1      yamt #define	XNESTED(x)			\
    206       1.15    castor 	.globl	_C_LABEL(x);		\
    207       1.20      soda 	AENT (_C_LABEL(x));		\
    208        1.6   mycroft _C_LABEL(x):
    209        1.1   deraadt 
    210        1.1   deraadt /*
    211       1.15    castor  * END
    212       1.15    castor  *	Mark end of a procedure.
    213        1.1   deraadt  */
    214  1.40.20.1      yamt #define	END(x) \
    215  1.40.20.1      yamt 	.end _C_LABEL(x);		\
    216  1.40.20.1      yamt 	.size _C_LABEL(x), . - _C_LABEL(x)
    217        1.2     glass 
    218        1.2     glass /*
    219       1.15    castor  * IMPORT -- import external symbol
    220        1.2     glass  */
    221  1.40.20.1      yamt #define	IMPORT(sym, size)		\
    222       1.20      soda 	.extern _C_LABEL(sym),size
    223        1.1   deraadt 
    224        1.1   deraadt /*
    225       1.15    castor  * EXPORT -- export definition of symbol
    226        1.1   deraadt  */
    227  1.40.20.1      yamt #define	EXPORT(x)			\
    228       1.15    castor 	.globl	_C_LABEL(x);		\
    229       1.15    castor _C_LABEL(x):
    230        1.1   deraadt 
    231       1.15    castor /*
    232       1.17  jonathan  * VECTOR
    233       1.17  jonathan  *	exception vector entrypoint
    234       1.20      soda  *	XXX: regmask should be used to generate .mask
    235       1.17  jonathan  */
    236  1.40.20.1      yamt #define	VECTOR(x, regmask)		\
    237       1.17  jonathan 	.ent	_C_LABEL(x),0;		\
    238       1.17  jonathan 	EXPORT(x);			\
    239       1.17  jonathan 
    240       1.19      soda #ifdef __STDC__
    241  1.40.20.1      yamt #define	VECTOR_END(x)			\
    242       1.20      soda 	EXPORT(x ## End);		\
    243       1.20      soda 	END(x)
    244       1.19      soda #else
    245  1.40.20.1      yamt #define	VECTOR_END(x)			\
    246       1.20      soda 	EXPORT(x/**/End);		\
    247       1.20      soda 	END(x)
    248       1.19      soda #endif
    249        1.1   deraadt 
    250        1.1   deraadt /*
    251       1.10  christos  * Macros to panic and printf from assembly language.
    252        1.1   deraadt  */
    253  1.40.20.1      yamt #define	PANIC(msg)			\
    254  1.40.20.1      yamt 	PTR_LA	a0, 9f;			\
    255       1.15    castor 	jal	_C_LABEL(panic);	\
    256       1.26       cgd 	nop;				\
    257        1.1   deraadt 	MSG(msg)
    258        1.1   deraadt 
    259       1.15    castor #define	PRINTF(msg)			\
    260  1.40.20.1      yamt 	PTR_LA	a0, 9f;			\
    261       1.15    castor 	jal	_C_LABEL(printf);	\
    262       1.26       cgd 	nop;				\
    263        1.1   deraadt 	MSG(msg)
    264        1.1   deraadt 
    265       1.15    castor #define	MSG(msg)			\
    266       1.15    castor 	.rdata;				\
    267       1.15    castor 9:	.asciiz	msg;			\
    268        1.1   deraadt 	.text
    269        1.1   deraadt 
    270  1.40.20.1      yamt #define	ASMSTR(str)			\
    271       1.15    castor 	.asciiz str;			\
    272       1.12  jonathan 	.align	3
    273       1.15    castor 
    274  1.40.20.1      yamt #define	RCSID(name)	.pushsection ".ident"; .asciz name; .popsection
    275  1.40.20.1      yamt 
    276       1.15    castor /*
    277       1.15    castor  * XXX retain dialects XXX
    278       1.15    castor  */
    279  1.40.20.1      yamt #define	ALEAF(x)			XLEAF(x)
    280  1.40.20.1      yamt #define	NLEAF(x)			LEAF_NOPROFILE(x)
    281  1.40.20.1      yamt #define	NON_LEAF(x, fsize, retpc)	NESTED(x, fsize, retpc)
    282  1.40.20.1      yamt #define	NNON_LEAF(x, fsize, retpc)	NESTED_NOPROFILE(x, fsize, retpc)
    283  1.40.20.1      yamt 
    284  1.40.20.1      yamt #if defined(__mips_o32)
    285  1.40.20.1      yamt #define	SZREG	4
    286  1.40.20.1      yamt #else
    287  1.40.20.1      yamt #define	SZREG	8
    288  1.40.20.1      yamt #endif
    289  1.40.20.1      yamt 
    290  1.40.20.1      yamt #if defined(__mips_o32) || defined(__mips_o64)
    291  1.40.20.1      yamt #define	ALSK	7		/* stack alignment */
    292  1.40.20.1      yamt #define	ALMASK	-7		/* stack alignment */
    293  1.40.20.1      yamt #define	SZFPREG	4
    294  1.40.20.1      yamt #define	FP_L	lwc1
    295  1.40.20.1      yamt #define	FP_S	swc1
    296  1.40.20.1      yamt #else
    297  1.40.20.1      yamt #define	ALSK	15		/* stack alignment */
    298  1.40.20.1      yamt #define	ALMASK	-15		/* stack alignment */
    299  1.40.20.1      yamt #define	SZFPREG	8
    300  1.40.20.1      yamt #define	FP_L	ldc1
    301  1.40.20.1      yamt #define	FP_S	sdc1
    302  1.40.20.1      yamt #endif
    303       1.15    castor 
    304       1.22    simonb /*
    305       1.16    castor  *  standard callframe {
    306  1.40.20.1      yamt  *	register_t cf_pad[N];		o32/64 (N=0), n32 (N=1) n64 (N=1)
    307  1.40.20.1      yamt  *  	register_t cf_args[4];		arg0 - arg3 (only on o32 and o64)
    308  1.40.20.1      yamt  *  	register_t cf_gp;		global pointer (only on n32 and n64)
    309       1.16    castor  *  	register_t cf_sp;		frame pointer
    310       1.16    castor  *  	register_t cf_ra;		return address
    311       1.16    castor  *  };
    312       1.16    castor  */
    313  1.40.20.1      yamt #if defined(__mips_o32) || defined(__mips_o64)
    314  1.40.20.1      yamt #define	CALLFRAME_SIZ	(SZREG * (4 + 2))
    315  1.40.20.1      yamt #define	CALLFRAME_S0	0
    316  1.40.20.1      yamt #elif defined(__mips_n32) || defined(__mips_n64)
    317  1.40.20.1      yamt #define	CALLFRAME_SIZ	(SZREG * 4)
    318  1.40.20.1      yamt #define	CALLFRAME_S0	(CALLFRAME_SIZ - 4 * SZREG)
    319  1.40.20.1      yamt #endif
    320  1.40.20.1      yamt #ifndef _KERNEL
    321  1.40.20.1      yamt #define	CALLFRAME_GP	(CALLFRAME_SIZ - 3 * SZREG)
    322  1.40.20.1      yamt #endif
    323  1.40.20.1      yamt #define	CALLFRAME_SP	(CALLFRAME_SIZ - 2 * SZREG)
    324  1.40.20.1      yamt #define	CALLFRAME_RA	(CALLFRAME_SIZ - 1 * SZREG)
    325       1.16    castor 
    326       1.15    castor /*
    327       1.22    simonb  * While it would be nice to be compatible with the SGI
    328       1.15    castor  * REG_L and REG_S macros, because they do not take parameters, it
    329       1.15    castor  * is impossible to use them with the _MIPS_SIM_ABIX32 model.
    330       1.15    castor  *
    331       1.22    simonb  * These macros hide the use of mips3 instructions from the
    332       1.15    castor  * assembler to prevent the assembler from generating 64-bit style
    333       1.15    castor  * ABI calls.
    334       1.15    castor  */
    335  1.40.20.1      yamt #if _MIPS_SZPTR == 32
    336  1.40.20.1      yamt #define	PTR_ADD		add
    337  1.40.20.1      yamt #define	PTR_ADDI	addi
    338  1.40.20.1      yamt #define	PTR_ADDU	addu
    339  1.40.20.1      yamt #define	PTR_ADDIU	addiu
    340  1.40.20.1      yamt #define	PTR_SUB		add
    341  1.40.20.1      yamt #define	PTR_SUBI	subi
    342  1.40.20.1      yamt #define	PTR_SUBU	subu
    343  1.40.20.1      yamt #define	PTR_SUBIU	subu
    344  1.40.20.1      yamt #define	PTR_L		lw
    345  1.40.20.1      yamt #define	PTR_LA		la
    346  1.40.20.1      yamt #define	PTR_S		sw
    347  1.40.20.1      yamt #define	PTR_SLL		sll
    348  1.40.20.1      yamt #define	PTR_SLLV	sllv
    349  1.40.20.1      yamt #define	PTR_SRL		srl
    350  1.40.20.1      yamt #define	PTR_SRLV	srlv
    351  1.40.20.1      yamt #define	PTR_SRA		sra
    352  1.40.20.1      yamt #define	PTR_SRAV	srav
    353  1.40.20.1      yamt #define	PTR_LL		ll
    354  1.40.20.1      yamt #define	PTR_SC		sc
    355  1.40.20.1      yamt #define	PTR_WORD	.word
    356  1.40.20.1      yamt #define	PTR_SCALESHIFT	2
    357  1.40.20.1      yamt #else /* _MIPS_SZPTR == 64 */
    358  1.40.20.1      yamt #define	PTR_ADD		dadd
    359  1.40.20.1      yamt #define	PTR_ADDI	daddi
    360  1.40.20.1      yamt #define	PTR_ADDU	daddu
    361  1.40.20.1      yamt #define	PTR_ADDIU	daddiu
    362  1.40.20.1      yamt #define	PTR_SUB		dadd
    363  1.40.20.1      yamt #define	PTR_SUBI	dsubi
    364  1.40.20.1      yamt #define	PTR_SUBU	dsubu
    365  1.40.20.1      yamt #define	PTR_SUBIU	dsubu
    366  1.40.20.1      yamt #define	PTR_L		ld
    367  1.40.20.1      yamt #define	PTR_LA		dla
    368  1.40.20.1      yamt #define	PTR_S		sd
    369  1.40.20.1      yamt #define	PTR_SLL		dsll
    370  1.40.20.1      yamt #define	PTR_SLLV	dsllv
    371  1.40.20.1      yamt #define	PTR_SRL		dsrl
    372  1.40.20.1      yamt #define	PTR_SRLV	dsrlv
    373  1.40.20.1      yamt #define	PTR_SRA		dsra
    374  1.40.20.1      yamt #define	PTR_SRAV	dsrav
    375  1.40.20.1      yamt #define	PTR_LL		lld
    376  1.40.20.1      yamt #define	PTR_SC		scd
    377  1.40.20.1      yamt #define	PTR_WORD	.dword
    378  1.40.20.1      yamt #define	PTR_SCALESHIFT	3
    379  1.40.20.1      yamt #endif /* _MIPS_SZPTR == 64 */
    380  1.40.20.1      yamt 
    381  1.40.20.1      yamt #if _MIPS_SZINT == 32
    382  1.40.20.1      yamt #define	INT_ADD		add
    383  1.40.20.1      yamt #define	INT_ADDI	addi
    384  1.40.20.1      yamt #define	INT_ADDU	addu
    385  1.40.20.1      yamt #define	INT_ADDIU	addiu
    386  1.40.20.1      yamt #define	INT_SUB		add
    387  1.40.20.1      yamt #define	INT_SUBI	subi
    388  1.40.20.1      yamt #define	INT_SUBU	subu
    389  1.40.20.1      yamt #define	INT_SUBIU	subu
    390  1.40.20.1      yamt #define	INT_L		lw
    391  1.40.20.1      yamt #define	INT_LA		la
    392  1.40.20.1      yamt #define	INT_S		sw
    393  1.40.20.1      yamt #define	INT_SLL		sll
    394  1.40.20.1      yamt #define	INT_SLLV	sllv
    395  1.40.20.1      yamt #define	INT_SRL		srl
    396  1.40.20.1      yamt #define	INT_SRLV	srlv
    397  1.40.20.1      yamt #define	INT_SRA		sra
    398  1.40.20.1      yamt #define	INT_SRAV	srav
    399  1.40.20.1      yamt #define	INT_LL		ll
    400  1.40.20.1      yamt #define	INT_SC		sc
    401  1.40.20.1      yamt #define	INT_WORD	.word
    402  1.40.20.1      yamt #define	INT_SCALESHIFT	2
    403  1.40.20.1      yamt #else
    404  1.40.20.1      yamt #define	INT_ADD		dadd
    405  1.40.20.1      yamt #define	INT_ADDI	daddi
    406  1.40.20.1      yamt #define	INT_ADDU	daddu
    407  1.40.20.1      yamt #define	INT_ADDIU	daddiu
    408  1.40.20.1      yamt #define	INT_SUB		dadd
    409  1.40.20.1      yamt #define	INT_SUBI	dsubi
    410  1.40.20.1      yamt #define	INT_SUBU	dsubu
    411  1.40.20.1      yamt #define	INT_SUBIU	dsubu
    412  1.40.20.1      yamt #define	INT_L		ld
    413  1.40.20.1      yamt #define	INT_LA		dla
    414  1.40.20.1      yamt #define	INT_S		sd
    415  1.40.20.1      yamt #define	INT_SLL		dsll
    416  1.40.20.1      yamt #define	INT_SLLV	dsllv
    417  1.40.20.1      yamt #define	INT_SRL		dsrl
    418  1.40.20.1      yamt #define	INT_SRLV	dsrlv
    419  1.40.20.1      yamt #define	INT_SRA		dsra
    420  1.40.20.1      yamt #define	INT_SRAV	dsrav
    421  1.40.20.1      yamt #define	INT_LL		lld
    422  1.40.20.1      yamt #define	INT_SC		scd
    423  1.40.20.1      yamt #define	INT_WORD	.dword
    424  1.40.20.1      yamt #define	INT_SCALESHIFT	3
    425  1.40.20.1      yamt #endif
    426       1.15    castor 
    427  1.40.20.1      yamt #if _MIPS_SZLONG == 32
    428  1.40.20.1      yamt #define	LONG_ADD	add
    429  1.40.20.1      yamt #define	LONG_ADDI	addi
    430  1.40.20.1      yamt #define	LONG_ADDU	addu
    431  1.40.20.1      yamt #define	LONG_ADDIU	addiu
    432  1.40.20.1      yamt #define	LONG_SUB	add
    433  1.40.20.1      yamt #define	LONG_SUBI	subi
    434  1.40.20.1      yamt #define	LONG_SUBU	subu
    435  1.40.20.1      yamt #define	LONG_SUBIU	subu
    436  1.40.20.1      yamt #define	LONG_L		lw
    437  1.40.20.1      yamt #define	LONG_LA		la
    438  1.40.20.1      yamt #define	LONG_S		sw
    439  1.40.20.1      yamt #define	LONG_SLL	sll
    440  1.40.20.1      yamt #define	LONG_SLLV	sllv
    441  1.40.20.1      yamt #define	LONG_SRL	srl
    442  1.40.20.1      yamt #define	LONG_SRLV	srlv
    443  1.40.20.1      yamt #define	LONG_SRA	sra
    444  1.40.20.1      yamt #define	LONG_SRAV	srav
    445  1.40.20.1      yamt #define	LONG_LL		ll
    446  1.40.20.1      yamt #define	LONG_SC		sc
    447  1.40.20.1      yamt #define	LONG_WORD	.word
    448  1.40.20.1      yamt #define	LONG_SCALESHIFT	2
    449  1.40.20.1      yamt #else
    450  1.40.20.1      yamt #define	LONG_ADD	dadd
    451  1.40.20.1      yamt #define	LONG_ADDI	daddi
    452  1.40.20.1      yamt #define	LONG_ADDU	daddu
    453  1.40.20.1      yamt #define	LONG_ADDIU	daddiu
    454  1.40.20.1      yamt #define	LONG_SUB	dadd
    455  1.40.20.1      yamt #define	LONG_SUBI	dsubi
    456  1.40.20.1      yamt #define	LONG_SUBU	dsubu
    457  1.40.20.1      yamt #define	LONG_SUBIU	dsubu
    458  1.40.20.1      yamt #define	LONG_L		ld
    459  1.40.20.1      yamt #define	LONG_LA		dla
    460  1.40.20.1      yamt #define	LONG_S		sd
    461  1.40.20.1      yamt #define	LONG_SLL	dsll
    462  1.40.20.1      yamt #define	LONG_SLLV	dsllv
    463  1.40.20.1      yamt #define	LONG_SRL	dsrl
    464  1.40.20.1      yamt #define	LONG_SRLV	dsrlv
    465  1.40.20.1      yamt #define	LONG_SRA	dsra
    466  1.40.20.1      yamt #define	LONG_SRAV	dsrav
    467  1.40.20.1      yamt #define	LONG_LL		lld
    468  1.40.20.1      yamt #define	LONG_SC		scd
    469  1.40.20.1      yamt #define	LONG_WORD	.dword
    470  1.40.20.1      yamt #define	LONG_SCALESHIFT	3
    471  1.40.20.1      yamt #endif
    472  1.40.20.1      yamt 
    473  1.40.20.1      yamt #if SZREG == 4
    474  1.40.20.1      yamt #define	REG_L		lw
    475  1.40.20.1      yamt #define	REG_S		sw
    476  1.40.20.1      yamt #define	REG_LI		li
    477  1.40.20.1      yamt #define	REG_ADDU	addu
    478  1.40.20.1      yamt #define	REG_SLL		sll
    479  1.40.20.1      yamt #define	REG_SLLV	sllv
    480  1.40.20.1      yamt #define	REG_SRL		srl
    481  1.40.20.1      yamt #define	REG_SRLV	srlv
    482  1.40.20.1      yamt #define	REG_SRA		sra
    483  1.40.20.1      yamt #define	REG_SRAV	srav
    484  1.40.20.1      yamt #define	REG_LL		ll
    485  1.40.20.1      yamt #define	REG_SC		sc
    486  1.40.20.1      yamt #define	REG_SCALESHIFT	2
    487  1.40.20.1      yamt #else
    488  1.40.20.1      yamt #define	REG_L		ld
    489  1.40.20.1      yamt #define	REG_S		sd
    490  1.40.20.1      yamt #define	REG_LI		dli
    491  1.40.20.1      yamt #define	REG_ADDU	daddu
    492  1.40.20.1      yamt #define	REG_SLL		dsll
    493  1.40.20.1      yamt #define	REG_SLLV	dsllv
    494  1.40.20.1      yamt #define	REG_SRL		dsrl
    495  1.40.20.1      yamt #define	REG_SRLV	dsrlv
    496  1.40.20.1      yamt #define	REG_SRA		dsra
    497  1.40.20.1      yamt #define	REG_SRAV	dsrav
    498  1.40.20.1      yamt #define	REG_LL		lld
    499  1.40.20.1      yamt #define	REG_SC		scd
    500  1.40.20.1      yamt #define	REG_SCALESHIFT	3
    501  1.40.20.1      yamt #endif
    502  1.40.20.1      yamt 
    503  1.40.20.1      yamt #if _MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2 || \
    504  1.40.20.1      yamt     _MIPS_ISA == _MIPS_ISA_MIPS32
    505  1.40.20.1      yamt #define	MFC0		mfc0
    506  1.40.20.1      yamt #define	MTC0		mtc0
    507  1.40.20.1      yamt #endif
    508  1.40.20.1      yamt #if _MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4 || \
    509  1.40.20.1      yamt     _MIPS_ISA == _MIPS_ISA_MIPS64
    510  1.40.20.1      yamt #define	MFC0		dmfc0
    511  1.40.20.1      yamt #define	MTC0		dmtc0
    512  1.40.20.1      yamt #endif
    513  1.40.20.1      yamt 
    514  1.40.20.1      yamt #if defined(__mips_o32) || defined(__mips_o64)
    515  1.40.20.1      yamt 
    516  1.40.20.1      yamt #ifdef __ABICALLS__
    517  1.40.20.1      yamt #define	CPRESTORE(r)	.cprestore r
    518  1.40.20.1      yamt #define	CPLOAD(r)	.cpload r
    519  1.40.20.1      yamt #else
    520  1.40.20.1      yamt #define	CPRESTORE(r)	/* not needed */
    521  1.40.20.1      yamt #define	CPLOAD(r)	/* not needed */
    522  1.40.20.1      yamt #endif
    523  1.40.20.1      yamt 
    524  1.40.20.1      yamt #define	SETUP_GP	\
    525  1.40.20.1      yamt 			.set push;				\
    526  1.40.20.1      yamt 			.set noreorder;				\
    527  1.40.20.1      yamt 			.cpload	t9;				\
    528  1.40.20.1      yamt 			.set pop
    529  1.40.20.1      yamt #define	SETUP_GPX(r)	\
    530  1.40.20.1      yamt 			.set push;				\
    531  1.40.20.1      yamt 			.set noreorder;				\
    532  1.40.20.1      yamt 			move	r,ra;	/* save old ra */	\
    533  1.40.20.1      yamt 			bal	7f;				\
    534  1.40.20.1      yamt 			nop;					\
    535  1.40.20.1      yamt 		7:	.cpload	ra;				\
    536  1.40.20.1      yamt 			move	ra,r;				\
    537  1.40.20.1      yamt 			.set pop
    538  1.40.20.1      yamt #define	SETUP_GPX_L(r,lbl)	\
    539  1.40.20.1      yamt 			.set push;				\
    540  1.40.20.1      yamt 			.set noreorder;				\
    541  1.40.20.1      yamt 			move	r,ra;	/* save old ra */	\
    542  1.40.20.1      yamt 			bal	lbl;				\
    543  1.40.20.1      yamt 			nop;					\
    544  1.40.20.1      yamt 		lbl:	.cpload	ra;				\
    545  1.40.20.1      yamt 			move	ra,r;				\
    546  1.40.20.1      yamt 			.set pop
    547  1.40.20.1      yamt #define	SAVE_GP(x)	.cprestore x
    548  1.40.20.1      yamt 
    549  1.40.20.1      yamt #define	SETUP_GP64(a,b)		/* n32/n64 specific */
    550  1.40.20.1      yamt #define	SETUP_GP64_R(a,b)	/* n32/n64 specific */
    551  1.40.20.1      yamt #define	SETUP_GPX64(a,b)	/* n32/n64 specific */
    552  1.40.20.1      yamt #define	SETUP_GPX64_L(a,b,c)	/* n32/n64 specific */
    553  1.40.20.1      yamt #define	RESTORE_GP64		/* n32/n64 specific */
    554  1.40.20.1      yamt #define	USE_ALT_CP(a)		/* n32/n64 specific */
    555  1.40.20.1      yamt #endif /* __mips_o32 || __mips_o64 */
    556  1.40.20.1      yamt 
    557  1.40.20.1      yamt #if defined(__mips_o32) || defined(__mips_o64)
    558       1.22    simonb #define	REG_PROLOGUE	.set push
    559       1.16    castor #define	REG_EPILOGUE	.set pop
    560  1.40.20.1      yamt #endif
    561  1.40.20.1      yamt #if defined(__mips_n32) || defined(__mips_n64)
    562       1.15    castor #define	REG_PROLOGUE	.set push ; .set mips3
    563       1.15    castor #define	REG_EPILOGUE	.set pop
    564  1.40.20.1      yamt #endif
    565  1.40.20.1      yamt 
    566  1.40.20.1      yamt #if defined(__mips_n32) || defined(__mips_n64)
    567  1.40.20.1      yamt #define	SETUP_GP		/* o32 specific */
    568  1.40.20.1      yamt #define	SETUP_GPX(r)		/* o32 specific */
    569  1.40.20.1      yamt #define	SETUP_GPX_L(r,lbl)	/* o32 specific */
    570  1.40.20.1      yamt #define	SAVE_GP(x)		/* o32 specific */
    571  1.40.20.1      yamt #define	SETUP_GP64(a,b)		.cpsetup $25, a, b
    572  1.40.20.1      yamt #define	SETUP_GPX64(a,b)	\
    573  1.40.20.1      yamt 				.set push;			\
    574  1.40.20.1      yamt 				move	b,ra;			\
    575  1.40.20.1      yamt 				.set noreorder;			\
    576  1.40.20.1      yamt 				bal	7f;			\
    577  1.40.20.1      yamt 				nop;				\
    578  1.40.20.1      yamt 			7:	.set pop;			\
    579  1.40.20.1      yamt 				.cpsetup ra, a, 7b;		\
    580  1.40.20.1      yamt 				move	ra,b
    581  1.40.20.1      yamt #define	SETUP_GPX64_L(a,b,c)	\
    582  1.40.20.1      yamt 				.set push;			\
    583  1.40.20.1      yamt 				move	b,ra;			\
    584  1.40.20.1      yamt 				.set noreorder;			\
    585  1.40.20.1      yamt 				bal	c;			\
    586  1.40.20.1      yamt 				nop;				\
    587  1.40.20.1      yamt 			c:	.set pop;			\
    588  1.40.20.1      yamt 				.cpsetup ra, a, c;		\
    589  1.40.20.1      yamt 				move	ra,b
    590  1.40.20.1      yamt #define	RESTORE_GP64		.cpreturn
    591  1.40.20.1      yamt #define	USE_ALT_CP(a)		.cplocal a
    592  1.40.20.1      yamt #endif	/* __mips_n32 || __mips_n64 */
    593       1.25     jeffs 
    594       1.25     jeffs /*
    595       1.25     jeffs  * The DYNAMIC_STATUS_MASK option adds an additional masking operation
    596       1.25     jeffs  * when updating the hardware interrupt mask in the status register.
    597       1.25     jeffs  *
    598       1.25     jeffs  * This is useful for platforms that need to at run-time mask
    599       1.25     jeffs  * interrupts based on motherboard configuration or to handle
    600       1.25     jeffs  * slowly clearing interrupts.
    601       1.25     jeffs  *
    602       1.25     jeffs  * XXX this is only currently implemented for mips3.
    603       1.25     jeffs  */
    604       1.25     jeffs #ifdef MIPS_DYNAMIC_STATUS_MASK
    605  1.40.20.1      yamt #define	DYNAMIC_STATUS_MASK(sr,scratch)	\
    606       1.25     jeffs 	lw	scratch, mips_dynamic_status_mask; \
    607       1.25     jeffs 	and	sr, sr, scratch
    608       1.29     jeffs 
    609  1.40.20.1      yamt #define	DYNAMIC_STATUS_MASK_TOUSER(sr,scratch1)		\
    610       1.29     jeffs 	ori	sr, (MIPS_INT_MASK | MIPS_SR_INT_IE);	\
    611       1.29     jeffs 	DYNAMIC_STATUS_MASK(sr,scratch1)
    612       1.25     jeffs #else
    613  1.40.20.1      yamt #define	DYNAMIC_STATUS_MASK(sr,scratch)
    614  1.40.20.1      yamt #define	DYNAMIC_STATUS_MASK_TOUSER(sr,scratch1)
    615       1.25     jeffs #endif
    616        1.1   deraadt 
    617       1.38        ad /* See lock_stubs.S. */
    618  1.40.20.2      yamt #define	MIPS_LOCK_RAS_SIZE	256
    619       1.38        ad 
    620  1.40.20.1      yamt #define	CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off)
    621       1.39      yamt 
    622        1.8  jonathan #endif /* _MIPS_ASM_H */
    623