Home | History | Annotate | Line # | Download | only in include
asm.h revision 1.54.14.2
      1  1.54.14.2    martin /*	$NetBSD: asm.h,v 1.54.14.2 2020/04/21 18:42:10 martin 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.41      matt #define	_MIPS_ASM_H
     56        1.1   deraadt 
     57       1.44      matt #include <sys/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.41      matt #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.50     skrll 	.set	pop;
     80       1.13  jonathan 
     81       1.11       jtc #ifdef GPROF
     82       1.41      matt #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.15    castor #ifdef USE_AENT
     88       1.41      matt #define	AENT(x)				\
     89       1.15    castor 	.aent	x, 0
     90       1.15    castor #else
     91       1.41      matt #define	AENT(x)
     92       1.24    kleink #endif
     93       1.24    kleink 
     94       1.31    simonb /*
     95       1.31    simonb  * WEAK_ALIAS: create a weak alias.
     96       1.31    simonb  */
     97       1.24    kleink #define	WEAK_ALIAS(alias,sym)						\
     98       1.24    kleink 	.weak alias;							\
     99       1.24    kleink 	alias = sym
    100       1.37  christos /*
    101       1.37  christos  * STRONG_ALIAS: create a strong alias.
    102       1.37  christos  */
    103       1.41      matt #define	STRONG_ALIAS(alias,sym)						\
    104       1.37  christos 	.globl alias;							\
    105       1.37  christos 	alias = sym
    106       1.15    castor 
    107       1.14   thorpej /*
    108       1.33    simonb  * WARN_REFERENCES: create a warning if the specified symbol is referenced.
    109       1.14   thorpej  */
    110       1.43     joerg #define	WARN_REFERENCES(sym,msg)					\
    111       1.44      matt 	.pushsection __CONCAT(.gnu.warning.,sym);			\
    112       1.43     joerg 	.ascii msg;							\
    113       1.43     joerg 	.popsection
    114        1.6   mycroft 
    115        1.1   deraadt /*
    116       1.44      matt  * STATIC_LEAF_NOPROFILE
    117       1.44      matt  *	No profilable local leaf routine.
    118       1.15    castor  */
    119       1.44      matt #define	STATIC_LEAF_NOPROFILE(x)	\
    120       1.47     joerg 	.ent	_C_LABEL(x);		\
    121       1.15    castor _C_LABEL(x): ;				\
    122       1.44      matt 	.frame sp, 0, ra
    123        1.1   deraadt 
    124        1.1   deraadt /*
    125       1.15    castor  * LEAF_NOPROFILE
    126       1.15    castor  *	No profilable leaf routine.
    127        1.1   deraadt  */
    128       1.41      matt #define	LEAF_NOPROFILE(x)		\
    129       1.15    castor 	.globl	_C_LABEL(x);		\
    130       1.44      matt 	STATIC_LEAF_NOPROFILE(x)
    131       1.15    castor 
    132       1.15    castor /*
    133       1.34    simonb  * STATIC_LEAF
    134       1.34    simonb  *	Declare a local leaf function.
    135       1.34    simonb  */
    136       1.41      matt #define	STATIC_LEAF(x)			\
    137       1.44      matt 	STATIC_LEAF_NOPROFILE(x);	\
    138       1.34    simonb 	MCOUNT
    139       1.34    simonb 
    140       1.34    simonb /*
    141       1.44      matt  * LEAF
    142       1.44      matt  *	A leaf routine does
    143       1.44      matt  *	- call no other function,
    144       1.44      matt  *	- never use any register that callee-saved (S0-S8), and
    145       1.44      matt  *	- not use any local stack storage.
    146       1.15    castor  */
    147       1.44      matt #define	LEAF(x)				\
    148       1.44      matt 	LEAF_NOPROFILE(x);		\
    149       1.44      matt 	MCOUNT
    150       1.34    simonb 
    151       1.34    simonb /*
    152       1.34    simonb  * STATIC_XLEAF
    153       1.34    simonb  *	declare alternate entry to a static leaf routine
    154       1.34    simonb  */
    155       1.41      matt #define	STATIC_XLEAF(x)			\
    156       1.20      soda 	AENT (_C_LABEL(x));		\
    157       1.15    castor _C_LABEL(x):
    158       1.15    castor 
    159       1.15    castor /*
    160       1.44      matt  * XLEAF
    161       1.44      matt  *	declare alternate entry to leaf routine
    162       1.44      matt  */
    163       1.44      matt #define	XLEAF(x)			\
    164       1.44      matt 	.globl	_C_LABEL(x);		\
    165       1.44      matt 	STATIC_XLEAF(x)
    166       1.44      matt 
    167       1.44      matt /*
    168       1.44      matt  * STATIC_NESTED_NOPROFILE
    169       1.44      matt  *	No profilable local nested routine.
    170       1.44      matt  */
    171       1.44      matt #define	STATIC_NESTED_NOPROFILE(x, fsize, retpc)	\
    172  1.54.14.1  christos 	.ent	_C_LABEL(x);				\
    173  1.54.14.1  christos 	.type	_C_LABEL(x), @function;			\
    174  1.54.14.1  christos _C_LABEL(x): ;						\
    175       1.44      matt 	.frame	sp, fsize, retpc
    176       1.44      matt 
    177       1.44      matt /*
    178       1.44      matt  * NESTED_NOPROFILE
    179       1.44      matt  *	No profilable nested routine.
    180       1.44      matt  */
    181       1.44      matt #define	NESTED_NOPROFILE(x, fsize, retpc)	\
    182       1.44      matt 	.globl	_C_LABEL(x);			\
    183       1.44      matt 	STATIC_NESTED_NOPROFILE(x, fsize, retpc)
    184       1.44      matt 
    185       1.44      matt /*
    186       1.15    castor  * NESTED
    187       1.15    castor  *	A function calls other functions and needs
    188       1.15    castor  *	therefore stack space to save/restore registers.
    189       1.15    castor  */
    190       1.44      matt #define	NESTED(x, fsize, retpc)			\
    191       1.44      matt 	NESTED_NOPROFILE(x, fsize, retpc);	\
    192       1.15    castor 	MCOUNT
    193        1.1   deraadt 
    194        1.1   deraadt /*
    195       1.44      matt  * STATIC_NESTED
    196       1.44      matt  *	No profilable local nested routine.
    197        1.1   deraadt  */
    198       1.44      matt #define	STATIC_NESTED(x, fsize, retpc)			\
    199       1.44      matt 	STATIC_NESTED_NOPROFILE(x, fsize, retpc);	\
    200       1.44      matt 	MCOUNT
    201       1.15    castor 
    202       1.15    castor /*
    203       1.15    castor  * XNESTED
    204       1.15    castor  *	declare alternate entry point to nested routine.
    205       1.15    castor  */
    206       1.41      matt #define	XNESTED(x)			\
    207       1.15    castor 	.globl	_C_LABEL(x);		\
    208       1.20      soda 	AENT (_C_LABEL(x));		\
    209        1.6   mycroft _C_LABEL(x):
    210        1.1   deraadt 
    211        1.1   deraadt /*
    212       1.15    castor  * END
    213       1.15    castor  *	Mark end of a procedure.
    214        1.1   deraadt  */
    215       1.44      matt #define	END(x)				\
    216       1.41      matt 	.end _C_LABEL(x);		\
    217       1.41      matt 	.size _C_LABEL(x), . - _C_LABEL(x)
    218        1.2     glass 
    219        1.2     glass /*
    220       1.15    castor  * IMPORT -- import external symbol
    221        1.2     glass  */
    222       1.41      matt #define	IMPORT(sym, size)		\
    223       1.20      soda 	.extern _C_LABEL(sym),size
    224        1.1   deraadt 
    225        1.1   deraadt /*
    226       1.15    castor  * EXPORT -- export definition of symbol
    227        1.1   deraadt  */
    228       1.41      matt #define	EXPORT(x)			\
    229       1.15    castor 	.globl	_C_LABEL(x);		\
    230       1.15    castor _C_LABEL(x):
    231        1.1   deraadt 
    232       1.15    castor /*
    233       1.17  jonathan  * VECTOR
    234       1.17  jonathan  *	exception vector entrypoint
    235       1.20      soda  *	XXX: regmask should be used to generate .mask
    236       1.17  jonathan  */
    237       1.41      matt #define	VECTOR(x, regmask)		\
    238       1.47     joerg 	.ent	_C_LABEL(x);		\
    239       1.17  jonathan 	EXPORT(x);			\
    240       1.17  jonathan 
    241       1.41      matt #define	VECTOR_END(x)			\
    242       1.44      matt 	EXPORT(__CONCAT(x,_end));	\
    243       1.44      matt 	END(x);				\
    244       1.44      matt 	.org _C_LABEL(x) + 0x80
    245        1.1   deraadt 
    246        1.1   deraadt /*
    247       1.10  christos  * Macros to panic and printf from assembly language.
    248        1.1   deraadt  */
    249       1.41      matt #define	PANIC(msg)			\
    250       1.41      matt 	PTR_LA	a0, 9f;			\
    251       1.15    castor 	jal	_C_LABEL(panic);	\
    252       1.26       cgd 	nop;				\
    253        1.1   deraadt 	MSG(msg)
    254        1.1   deraadt 
    255       1.15    castor #define	PRINTF(msg)			\
    256       1.41      matt 	PTR_LA	a0, 9f;			\
    257       1.15    castor 	jal	_C_LABEL(printf);	\
    258       1.26       cgd 	nop;				\
    259        1.1   deraadt 	MSG(msg)
    260        1.1   deraadt 
    261       1.15    castor #define	MSG(msg)			\
    262       1.15    castor 	.rdata;				\
    263       1.48     joerg 9:	.asciz	msg;			\
    264        1.1   deraadt 	.text
    265        1.1   deraadt 
    266       1.41      matt #define	ASMSTR(str)			\
    267       1.48     joerg 	.asciz str;			\
    268       1.12  jonathan 	.align	3
    269       1.15    castor 
    270  1.54.14.2    martin #define RCSID(x)	.pushsection ".ident","MS",@progbits,1;		\
    271  1.54.14.2    martin 			.asciz x;					\
    272  1.54.14.2    martin 			.popsection
    273       1.41      matt 
    274       1.15    castor /*
    275       1.15    castor  * XXX retain dialects XXX
    276       1.15    castor  */
    277       1.41      matt #define	ALEAF(x)			XLEAF(x)
    278       1.41      matt #define	NLEAF(x)			LEAF_NOPROFILE(x)
    279       1.41      matt #define	NON_LEAF(x, fsize, retpc)	NESTED(x, fsize, retpc)
    280       1.41      matt #define	NNON_LEAF(x, fsize, retpc)	NESTED_NOPROFILE(x, fsize, retpc)
    281       1.41      matt 
    282       1.41      matt #if defined(__mips_o32)
    283       1.41      matt #define	SZREG	4
    284       1.41      matt #else
    285       1.41      matt #define	SZREG	8
    286       1.41      matt #endif
    287       1.41      matt 
    288       1.41      matt #if defined(__mips_o32) || defined(__mips_o64)
    289       1.41      matt #define	ALSK	7		/* stack alignment */
    290       1.41      matt #define	ALMASK	-7		/* stack alignment */
    291       1.41      matt #define	SZFPREG	4
    292       1.41      matt #define	FP_L	lwc1
    293       1.41      matt #define	FP_S	swc1
    294       1.41      matt #else
    295       1.41      matt #define	ALSK	15		/* stack alignment */
    296       1.41      matt #define	ALMASK	-15		/* stack alignment */
    297       1.41      matt #define	SZFPREG	8
    298       1.41      matt #define	FP_L	ldc1
    299       1.41      matt #define	FP_S	sdc1
    300       1.41      matt #endif
    301       1.15    castor 
    302       1.22    simonb /*
    303       1.16    castor  *  standard callframe {
    304       1.44      matt  *  	register_t cf_args[4];		arg0 - arg3 (only on o32 and o64)
    305       1.41      matt  *	register_t cf_pad[N];		o32/64 (N=0), n32 (N=1) n64 (N=1)
    306       1.41      matt  *  	register_t cf_gp;		global pointer (only on n32 and n64)
    307       1.16    castor  *  	register_t cf_sp;		frame pointer
    308       1.16    castor  *  	register_t cf_ra;		return address
    309       1.16    castor  *  };
    310       1.16    castor  */
    311       1.41      matt #if defined(__mips_o32) || defined(__mips_o64)
    312       1.41      matt #define	CALLFRAME_SIZ	(SZREG * (4 + 2))
    313       1.41      matt #define	CALLFRAME_S0	0
    314       1.41      matt #elif defined(__mips_n32) || defined(__mips_n64)
    315       1.41      matt #define	CALLFRAME_SIZ	(SZREG * 4)
    316       1.41      matt #define	CALLFRAME_S0	(CALLFRAME_SIZ - 4 * SZREG)
    317       1.41      matt #endif
    318       1.41      matt #ifndef _KERNEL
    319       1.41      matt #define	CALLFRAME_GP	(CALLFRAME_SIZ - 3 * SZREG)
    320       1.41      matt #endif
    321       1.41      matt #define	CALLFRAME_SP	(CALLFRAME_SIZ - 2 * SZREG)
    322       1.41      matt #define	CALLFRAME_RA	(CALLFRAME_SIZ - 1 * SZREG)
    323       1.16    castor 
    324       1.15    castor /*
    325       1.22    simonb  * While it would be nice to be compatible with the SGI
    326       1.15    castor  * REG_L and REG_S macros, because they do not take parameters, it
    327       1.15    castor  * is impossible to use them with the _MIPS_SIM_ABIX32 model.
    328       1.15    castor  *
    329       1.22    simonb  * These macros hide the use of mips3 instructions from the
    330       1.15    castor  * assembler to prevent the assembler from generating 64-bit style
    331       1.15    castor  * ABI calls.
    332       1.15    castor  */
    333       1.49      matt #ifdef __mips_o32
    334       1.41      matt #define	PTR_ADD		add
    335       1.41      matt #define	PTR_ADDI	addi
    336       1.41      matt #define	PTR_ADDU	addu
    337       1.41      matt #define	PTR_ADDIU	addiu
    338       1.45      matt #define	PTR_SUB		subu
    339       1.41      matt #define	PTR_SUBI	subi
    340       1.41      matt #define	PTR_SUBU	subu
    341       1.41      matt #define	PTR_SUBIU	subu
    342       1.41      matt #define	PTR_L		lw
    343       1.41      matt #define	PTR_LA		la
    344       1.41      matt #define	PTR_S		sw
    345       1.41      matt #define	PTR_SLL		sll
    346       1.41      matt #define	PTR_SLLV	sllv
    347       1.41      matt #define	PTR_SRL		srl
    348       1.41      matt #define	PTR_SRLV	srlv
    349       1.41      matt #define	PTR_SRA		sra
    350       1.41      matt #define	PTR_SRAV	srav
    351       1.41      matt #define	PTR_LL		ll
    352       1.41      matt #define	PTR_SC		sc
    353       1.41      matt #define	PTR_WORD	.word
    354       1.41      matt #define	PTR_SCALESHIFT	2
    355       1.41      matt #else /* _MIPS_SZPTR == 64 */
    356       1.41      matt #define	PTR_ADD		dadd
    357       1.41      matt #define	PTR_ADDI	daddi
    358       1.41      matt #define	PTR_ADDU	daddu
    359       1.41      matt #define	PTR_ADDIU	daddiu
    360       1.45      matt #define	PTR_SUB		dsubu
    361       1.41      matt #define	PTR_SUBI	dsubi
    362       1.41      matt #define	PTR_SUBU	dsubu
    363       1.41      matt #define	PTR_SUBIU	dsubu
    364       1.49      matt #ifdef __mips_n32
    365       1.49      matt #define	PTR_L		lw
    366       1.49      matt #define	PTR_LL		ll
    367       1.49      matt #define	PTR_SC		sc
    368       1.49      matt #define	PTR_S		sw
    369       1.49      matt #define	PTR_SCALESHIFT	2
    370       1.49      matt #define	PTR_WORD	.word
    371       1.49      matt #else
    372       1.41      matt #define	PTR_L		ld
    373       1.49      matt #define	PTR_LL		lld
    374       1.49      matt #define	PTR_SC		scd
    375       1.49      matt #define	PTR_S		sd
    376       1.49      matt #define	PTR_SCALESHIFT	3
    377       1.49      matt #define	PTR_WORD	.dword
    378       1.49      matt #endif
    379       1.41      matt #define	PTR_LA		dla
    380       1.41      matt #define	PTR_SLL		dsll
    381       1.41      matt #define	PTR_SLLV	dsllv
    382       1.41      matt #define	PTR_SRL		dsrl
    383       1.41      matt #define	PTR_SRLV	dsrlv
    384       1.41      matt #define	PTR_SRA		dsra
    385       1.41      matt #define	PTR_SRAV	dsrav
    386       1.41      matt #endif /* _MIPS_SZPTR == 64 */
    387       1.41      matt 
    388       1.41      matt #if _MIPS_SZINT == 32
    389       1.41      matt #define	INT_ADD		add
    390       1.41      matt #define	INT_ADDI	addi
    391       1.41      matt #define	INT_ADDU	addu
    392       1.41      matt #define	INT_ADDIU	addiu
    393       1.45      matt #define	INT_SUB		subu
    394       1.41      matt #define	INT_SUBI	subi
    395       1.41      matt #define	INT_SUBU	subu
    396       1.41      matt #define	INT_SUBIU	subu
    397       1.41      matt #define	INT_L		lw
    398       1.41      matt #define	INT_LA		la
    399       1.41      matt #define	INT_S		sw
    400       1.41      matt #define	INT_SLL		sll
    401       1.41      matt #define	INT_SLLV	sllv
    402       1.41      matt #define	INT_SRL		srl
    403       1.41      matt #define	INT_SRLV	srlv
    404       1.41      matt #define	INT_SRA		sra
    405       1.41      matt #define	INT_SRAV	srav
    406       1.41      matt #define	INT_LL		ll
    407       1.41      matt #define	INT_SC		sc
    408       1.41      matt #define	INT_WORD	.word
    409       1.41      matt #define	INT_SCALESHIFT	2
    410       1.41      matt #else
    411       1.41      matt #define	INT_ADD		dadd
    412       1.41      matt #define	INT_ADDI	daddi
    413       1.41      matt #define	INT_ADDU	daddu
    414       1.41      matt #define	INT_ADDIU	daddiu
    415       1.45      matt #define	INT_SUB		dsubu
    416       1.41      matt #define	INT_SUBI	dsubi
    417       1.41      matt #define	INT_SUBU	dsubu
    418       1.41      matt #define	INT_SUBIU	dsubu
    419       1.41      matt #define	INT_L		ld
    420       1.41      matt #define	INT_LA		dla
    421       1.41      matt #define	INT_S		sd
    422       1.41      matt #define	INT_SLL		dsll
    423       1.41      matt #define	INT_SLLV	dsllv
    424       1.41      matt #define	INT_SRL		dsrl
    425       1.41      matt #define	INT_SRLV	dsrlv
    426       1.41      matt #define	INT_SRA		dsra
    427       1.41      matt #define	INT_SRAV	dsrav
    428       1.41      matt #define	INT_LL		lld
    429       1.41      matt #define	INT_SC		scd
    430       1.41      matt #define	INT_WORD	.dword
    431       1.41      matt #define	INT_SCALESHIFT	3
    432       1.41      matt #endif
    433       1.15    castor 
    434       1.41      matt #if _MIPS_SZLONG == 32
    435       1.41      matt #define	LONG_ADD	add
    436       1.41      matt #define	LONG_ADDI	addi
    437       1.41      matt #define	LONG_ADDU	addu
    438       1.41      matt #define	LONG_ADDIU	addiu
    439       1.45      matt #define	LONG_SUB	subu
    440       1.41      matt #define	LONG_SUBI	subi
    441       1.41      matt #define	LONG_SUBU	subu
    442       1.41      matt #define	LONG_SUBIU	subu
    443       1.41      matt #define	LONG_L		lw
    444       1.41      matt #define	LONG_LA		la
    445       1.41      matt #define	LONG_S		sw
    446       1.41      matt #define	LONG_SLL	sll
    447       1.41      matt #define	LONG_SLLV	sllv
    448       1.41      matt #define	LONG_SRL	srl
    449       1.41      matt #define	LONG_SRLV	srlv
    450       1.41      matt #define	LONG_SRA	sra
    451       1.41      matt #define	LONG_SRAV	srav
    452       1.41      matt #define	LONG_LL		ll
    453       1.41      matt #define	LONG_SC		sc
    454       1.41      matt #define	LONG_WORD	.word
    455       1.41      matt #define	LONG_SCALESHIFT	2
    456       1.41      matt #else
    457       1.41      matt #define	LONG_ADD	dadd
    458       1.41      matt #define	LONG_ADDI	daddi
    459       1.41      matt #define	LONG_ADDU	daddu
    460       1.41      matt #define	LONG_ADDIU	daddiu
    461       1.45      matt #define	LONG_SUB	dsubu
    462       1.41      matt #define	LONG_SUBI	dsubi
    463       1.41      matt #define	LONG_SUBU	dsubu
    464       1.41      matt #define	LONG_SUBIU	dsubu
    465       1.41      matt #define	LONG_L		ld
    466       1.41      matt #define	LONG_LA		dla
    467       1.41      matt #define	LONG_S		sd
    468       1.41      matt #define	LONG_SLL	dsll
    469       1.41      matt #define	LONG_SLLV	dsllv
    470       1.41      matt #define	LONG_SRL	dsrl
    471       1.41      matt #define	LONG_SRLV	dsrlv
    472       1.41      matt #define	LONG_SRA	dsra
    473       1.41      matt #define	LONG_SRAV	dsrav
    474       1.41      matt #define	LONG_LL		lld
    475       1.41      matt #define	LONG_SC		scd
    476       1.41      matt #define	LONG_WORD	.dword
    477       1.41      matt #define	LONG_SCALESHIFT	3
    478       1.41      matt #endif
    479       1.41      matt 
    480       1.41      matt #if SZREG == 4
    481       1.41      matt #define	REG_L		lw
    482       1.41      matt #define	REG_S		sw
    483       1.41      matt #define	REG_LI		li
    484       1.41      matt #define	REG_ADDU	addu
    485       1.41      matt #define	REG_SLL		sll
    486       1.41      matt #define	REG_SLLV	sllv
    487       1.41      matt #define	REG_SRL		srl
    488       1.41      matt #define	REG_SRLV	srlv
    489       1.41      matt #define	REG_SRA		sra
    490       1.41      matt #define	REG_SRAV	srav
    491       1.41      matt #define	REG_LL		ll
    492       1.41      matt #define	REG_SC		sc
    493       1.41      matt #define	REG_SCALESHIFT	2
    494       1.41      matt #else
    495       1.41      matt #define	REG_L		ld
    496       1.41      matt #define	REG_S		sd
    497       1.41      matt #define	REG_LI		dli
    498       1.41      matt #define	REG_ADDU	daddu
    499       1.41      matt #define	REG_SLL		dsll
    500       1.41      matt #define	REG_SLLV	dsllv
    501       1.41      matt #define	REG_SRL		dsrl
    502       1.41      matt #define	REG_SRLV	dsrlv
    503       1.41      matt #define	REG_SRA		dsra
    504       1.41      matt #define	REG_SRAV	dsrav
    505       1.41      matt #define	REG_LL		lld
    506       1.41      matt #define	REG_SC		scd
    507       1.41      matt #define	REG_SCALESHIFT	3
    508       1.41      matt #endif
    509       1.41      matt 
    510       1.51     skrll #if (MIPS1 + MIPS2) > 0
    511       1.51     skrll #define	NOP_L		nop
    512       1.51     skrll #else
    513       1.51     skrll #define	NOP_L		/* nothing */
    514       1.51     skrll #endif
    515       1.51     skrll 
    516       1.52      maya /* CPU dependent hook for cp0 load delays */
    517       1.52      maya #if defined(MIPS1) || defined(MIPS2) || defined(MIPS3)
    518       1.53      maya #define MFC0_HAZARD	sll $0,$0,1	/* super scalar nop */
    519       1.52      maya #else
    520       1.52      maya #define MFC0_HAZARD	/* nothing */
    521       1.52      maya #endif
    522       1.52      maya 
    523       1.41      matt #if _MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2 || \
    524       1.41      matt     _MIPS_ISA == _MIPS_ISA_MIPS32
    525       1.41      matt #define	MFC0		mfc0
    526       1.41      matt #define	MTC0		mtc0
    527       1.41      matt #endif
    528       1.41      matt #if _MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4 || \
    529       1.41      matt     _MIPS_ISA == _MIPS_ISA_MIPS64
    530       1.41      matt #define	MFC0		dmfc0
    531       1.41      matt #define	MTC0		dmtc0
    532       1.41      matt #endif
    533       1.41      matt 
    534       1.41      matt #if defined(__mips_o32) || defined(__mips_o64)
    535       1.41      matt 
    536       1.54     joerg #ifdef __mips_abicalls
    537       1.41      matt #define	CPRESTORE(r)	.cprestore r
    538       1.41      matt #define	CPLOAD(r)	.cpload r
    539       1.41      matt #else
    540       1.41      matt #define	CPRESTORE(r)	/* not needed */
    541       1.41      matt #define	CPLOAD(r)	/* not needed */
    542       1.41      matt #endif
    543       1.41      matt 
    544       1.41      matt #define	SETUP_GP	\
    545       1.41      matt 			.set push;				\
    546       1.41      matt 			.set noreorder;				\
    547       1.41      matt 			.cpload	t9;				\
    548       1.41      matt 			.set pop
    549       1.41      matt #define	SETUP_GPX(r)	\
    550       1.41      matt 			.set push;				\
    551       1.41      matt 			.set noreorder;				\
    552       1.41      matt 			move	r,ra;	/* save old ra */	\
    553       1.41      matt 			bal	7f;				\
    554       1.41      matt 			nop;					\
    555       1.41      matt 		7:	.cpload	ra;				\
    556       1.41      matt 			move	ra,r;				\
    557       1.41      matt 			.set pop
    558       1.41      matt #define	SETUP_GPX_L(r,lbl)	\
    559       1.41      matt 			.set push;				\
    560       1.41      matt 			.set noreorder;				\
    561       1.41      matt 			move	r,ra;	/* save old ra */	\
    562       1.41      matt 			bal	lbl;				\
    563       1.41      matt 			nop;					\
    564       1.41      matt 		lbl:	.cpload	ra;				\
    565       1.41      matt 			move	ra,r;				\
    566       1.41      matt 			.set pop
    567       1.41      matt #define	SAVE_GP(x)	.cprestore x
    568       1.41      matt 
    569       1.41      matt #define	SETUP_GP64(a,b)		/* n32/n64 specific */
    570       1.41      matt #define	SETUP_GP64_R(a,b)	/* n32/n64 specific */
    571       1.41      matt #define	SETUP_GPX64(a,b)	/* n32/n64 specific */
    572       1.41      matt #define	SETUP_GPX64_L(a,b,c)	/* n32/n64 specific */
    573       1.41      matt #define	RESTORE_GP64		/* n32/n64 specific */
    574       1.41      matt #define	USE_ALT_CP(a)		/* n32/n64 specific */
    575       1.41      matt #endif /* __mips_o32 || __mips_o64 */
    576       1.41      matt 
    577       1.41      matt #if defined(__mips_o32) || defined(__mips_o64)
    578       1.22    simonb #define	REG_PROLOGUE	.set push
    579       1.16    castor #define	REG_EPILOGUE	.set pop
    580       1.41      matt #endif
    581       1.41      matt #if defined(__mips_n32) || defined(__mips_n64)
    582       1.15    castor #define	REG_PROLOGUE	.set push ; .set mips3
    583       1.15    castor #define	REG_EPILOGUE	.set pop
    584       1.41      matt #endif
    585       1.41      matt 
    586       1.41      matt #if defined(__mips_n32) || defined(__mips_n64)
    587       1.41      matt #define	SETUP_GP		/* o32 specific */
    588       1.41      matt #define	SETUP_GPX(r)		/* o32 specific */
    589       1.41      matt #define	SETUP_GPX_L(r,lbl)	/* o32 specific */
    590       1.41      matt #define	SAVE_GP(x)		/* o32 specific */
    591       1.41      matt #define	SETUP_GP64(a,b)		.cpsetup $25, a, b
    592       1.41      matt #define	SETUP_GPX64(a,b)	\
    593       1.41      matt 				.set push;			\
    594       1.41      matt 				move	b,ra;			\
    595       1.41      matt 				.set noreorder;			\
    596       1.41      matt 				bal	7f;			\
    597       1.41      matt 				nop;				\
    598       1.41      matt 			7:	.set pop;			\
    599       1.41      matt 				.cpsetup ra, a, 7b;		\
    600       1.41      matt 				move	ra,b
    601       1.41      matt #define	SETUP_GPX64_L(a,b,c)	\
    602       1.41      matt 				.set push;			\
    603       1.41      matt 				move	b,ra;			\
    604       1.41      matt 				.set noreorder;			\
    605       1.41      matt 				bal	c;			\
    606       1.41      matt 				nop;				\
    607       1.41      matt 			c:	.set pop;			\
    608       1.41      matt 				.cpsetup ra, a, c;		\
    609       1.41      matt 				move	ra,b
    610       1.41      matt #define	RESTORE_GP64		.cpreturn
    611       1.41      matt #define	USE_ALT_CP(a)		.cplocal a
    612       1.41      matt #endif	/* __mips_n32 || __mips_n64 */
    613       1.25     jeffs 
    614       1.25     jeffs /*
    615       1.25     jeffs  * The DYNAMIC_STATUS_MASK option adds an additional masking operation
    616       1.25     jeffs  * when updating the hardware interrupt mask in the status register.
    617       1.25     jeffs  *
    618       1.25     jeffs  * This is useful for platforms that need to at run-time mask
    619       1.25     jeffs  * interrupts based on motherboard configuration or to handle
    620       1.25     jeffs  * slowly clearing interrupts.
    621       1.25     jeffs  *
    622       1.25     jeffs  * XXX this is only currently implemented for mips3.
    623       1.25     jeffs  */
    624       1.25     jeffs #ifdef MIPS_DYNAMIC_STATUS_MASK
    625       1.41      matt #define	DYNAMIC_STATUS_MASK(sr,scratch)	\
    626       1.25     jeffs 	lw	scratch, mips_dynamic_status_mask; \
    627       1.25     jeffs 	and	sr, sr, scratch
    628       1.29     jeffs 
    629       1.41      matt #define	DYNAMIC_STATUS_MASK_TOUSER(sr,scratch1)		\
    630       1.29     jeffs 	ori	sr, (MIPS_INT_MASK | MIPS_SR_INT_IE);	\
    631       1.29     jeffs 	DYNAMIC_STATUS_MASK(sr,scratch1)
    632       1.25     jeffs #else
    633       1.41      matt #define	DYNAMIC_STATUS_MASK(sr,scratch)
    634       1.41      matt #define	DYNAMIC_STATUS_MASK_TOUSER(sr,scratch1)
    635       1.25     jeffs #endif
    636        1.1   deraadt 
    637       1.38        ad /* See lock_stubs.S. */
    638       1.44      matt #define	LOG2_MIPS_LOCK_RAS_SIZE	8
    639       1.44      matt #define	MIPS_LOCK_RAS_SIZE	256	/* 16 bytes left over */
    640       1.38        ad 
    641       1.41      matt #define	CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off)
    642       1.39      yamt 
    643        1.8  jonathan #endif /* _MIPS_ASM_H */
    644