xref: /freebsd/sys/arm/include/asm.h (revision 6fc729af6302dafea6d55379b7175fb40c81ac4d)
16fc729afSOlivier Houchard /*	$NetBSD: asm.h,v 1.5 2003/08/07 16:26:53 agc Exp $	*/
26fc729afSOlivier Houchard 
36fc729afSOlivier Houchard /*
46fc729afSOlivier Houchard  * Copyright (c) 1990 The Regents of the University of California.
56fc729afSOlivier Houchard  * All rights reserved.
66fc729afSOlivier Houchard  *
76fc729afSOlivier Houchard  * This code is derived from software contributed to Berkeley by
86fc729afSOlivier Houchard  * William Jolitz.
96fc729afSOlivier Houchard  *
106fc729afSOlivier Houchard  * Redistribution and use in source and binary forms, with or without
116fc729afSOlivier Houchard  * modification, are permitted provided that the following conditions
126fc729afSOlivier Houchard  * are met:
136fc729afSOlivier Houchard  * 1. Redistributions of source code must retain the above copyright
146fc729afSOlivier Houchard  *    notice, this list of conditions and the following disclaimer.
156fc729afSOlivier Houchard  * 2. Redistributions in binary form must reproduce the above copyright
166fc729afSOlivier Houchard  *    notice, this list of conditions and the following disclaimer in the
176fc729afSOlivier Houchard  *    documentation and/or other materials provided with the distribution.
186fc729afSOlivier Houchard  * 3. Neither the name of the University nor the names of its contributors
196fc729afSOlivier Houchard  *    may be used to endorse or promote products derived from this software
206fc729afSOlivier Houchard  *    without specific prior written permission.
216fc729afSOlivier Houchard  *
226fc729afSOlivier Houchard  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
236fc729afSOlivier Houchard  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
246fc729afSOlivier Houchard  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
256fc729afSOlivier Houchard  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
266fc729afSOlivier Houchard  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
276fc729afSOlivier Houchard  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
286fc729afSOlivier Houchard  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
296fc729afSOlivier Houchard  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
306fc729afSOlivier Houchard  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
316fc729afSOlivier Houchard  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
326fc729afSOlivier Houchard  * SUCH DAMAGE.
336fc729afSOlivier Houchard  *
346fc729afSOlivier Houchard  *	from: @(#)asm.h	5.5 (Berkeley) 5/7/91
356fc729afSOlivier Houchard  *
366fc729afSOlivier Houchard  * $FreeBSD$
376fc729afSOlivier Houchard  */
386fc729afSOlivier Houchard 
396fc729afSOlivier Houchard #ifndef _MACHINE_ASM_H_
406fc729afSOlivier Houchard #define _MACHINE_ASM_H_
416fc729afSOlivier Houchard #include <sys/cdefs.h>
426fc729afSOlivier Houchard 
436fc729afSOlivier Houchard #ifdef __ELF__
446fc729afSOlivier Houchard # define _C_LABEL(x)	x
456fc729afSOlivier Houchard #else
466fc729afSOlivier Houchard # ifdef __STDC__
476fc729afSOlivier Houchard #  define _C_LABEL(x)	_ ## x
486fc729afSOlivier Houchard # else
496fc729afSOlivier Houchard #  define _C_LABEL(x)	_/**/x
506fc729afSOlivier Houchard # endif
516fc729afSOlivier Houchard #endif
526fc729afSOlivier Houchard #define	_ASM_LABEL(x)	x
536fc729afSOlivier Houchard 
546fc729afSOlivier Houchard #ifndef _JB_MAGIC__SETJMP
556fc729afSOlivier Houchard #define _JB_MAGIC__SETJMP       0x4278f500
566fc729afSOlivier Houchard #define _JB_MAGIC_SETJMP        0x4278f501
576fc729afSOlivier Houchard #endif
586fc729afSOlivier Houchard #if 0
596fc729afSOlivier Houchard #ifdef __STDC__
606fc729afSOlivier Houchard # define __CONCAT(x,y)	x ## y
616fc729afSOlivier Houchard # define __STRING(x)	#x
626fc729afSOlivier Houchard #else
636fc729afSOlivier Houchard # define __CONCAT(x,y)	x/**/y
646fc729afSOlivier Houchard # define __STRING(x)	"x"
656fc729afSOlivier Houchard #endif
666fc729afSOlivier Houchard #endif
676fc729afSOlivier Houchard 
686fc729afSOlivier Houchard #define I32_bit (1 << 7)	/* IRQ disable */
696fc729afSOlivier Houchard #define F32_bit (1 << 6)        /* FIQ disable */
706fc729afSOlivier Houchard 
716fc729afSOlivier Houchard #define CPU_CONTROL_32BP_ENABLE 0x00000010 /* P: 32-bit exception handlers */
726fc729afSOlivier Houchard #define CPU_CONTROL_32BD_ENABLE 0x00000020 /* D: 32-bit addressing */
736fc729afSOlivier Houchard 
746fc729afSOlivier Houchard #ifndef _ALIGN_TEXT
756fc729afSOlivier Houchard # define _ALIGN_TEXT .align 0
766fc729afSOlivier Houchard #endif
776fc729afSOlivier Houchard 
786fc729afSOlivier Houchard /*
796fc729afSOlivier Houchard  * gas/arm uses @ as a single comment character and thus cannot be used here
806fc729afSOlivier Houchard  * Instead it recognised the # instead of an @ symbols in .type directives
816fc729afSOlivier Houchard  * We define a couple of macros so that assembly code will not be dependant
826fc729afSOlivier Houchard  * on one or the other.
836fc729afSOlivier Houchard  */
846fc729afSOlivier Houchard #define _ASM_TYPE_FUNCTION	#function
856fc729afSOlivier Houchard #define _ASM_TYPE_OBJECT	#object
866fc729afSOlivier Houchard #define GLOBAL(X) .globl x
876fc729afSOlivier Houchard #define _ENTRY(x) \
886fc729afSOlivier Houchard 	.text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x:
896fc729afSOlivier Houchard 
906fc729afSOlivier Houchard #ifdef GPROF
916fc729afSOlivier Houchard # ifdef __ELF__
926fc729afSOlivier Houchard #  define _PROF_PROLOGUE	\
936fc729afSOlivier Houchard 	mov ip, lr; bl __mcount
946fc729afSOlivier Houchard # else
956fc729afSOlivier Houchard #  define _PROF_PROLOGUE	\
966fc729afSOlivier Houchard 	mov ip,lr; bl mcount
976fc729afSOlivier Houchard # endif
986fc729afSOlivier Houchard #else
996fc729afSOlivier Houchard # define _PROF_PROLOGUE
1006fc729afSOlivier Houchard #endif
1016fc729afSOlivier Houchard 
1026fc729afSOlivier Houchard #define	ENTRY(y)	_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
1036fc729afSOlivier Houchard #define	ENTRY_NP(y)	_ENTRY(_C_LABEL(y))
1046fc729afSOlivier Houchard #define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
1056fc729afSOlivier Houchard #define	ASENTRY_NP(y)	_ENTRY(_ASM_LABEL(y))
1066fc729afSOlivier Houchard 
1076fc729afSOlivier Houchard #define	ASMSTR		.asciz
1086fc729afSOlivier Houchard 
1096fc729afSOlivier Houchard #if defined(__ELF__) && defined(PIC)
1106fc729afSOlivier Houchard #ifdef __STDC__
1116fc729afSOlivier Houchard #define	PIC_SYM(x,y)	x ## ( ## y ## )
1126fc729afSOlivier Houchard #else
1136fc729afSOlivier Houchard #define	PIC_SYM(x,y)	x/**/(/**/y/**/)
1146fc729afSOlivier Houchard #endif
1156fc729afSOlivier Houchard #else
1166fc729afSOlivier Houchard #define	PIC_SYM(x,y)	x
1176fc729afSOlivier Houchard #endif
1186fc729afSOlivier Houchard 
1196fc729afSOlivier Houchard #undef __FBSDID
1206fc729afSOlivier Houchard #if !defined(lint) && !defined(STRIP_FBSDID)
1216fc729afSOlivier Houchard #define __FBSDID(s)     .ident s
1226fc729afSOlivier Houchard #else
1236fc729afSOlivier Houchard #define __FBSDID(s)     /* nothing */
1246fc729afSOlivier Houchard #endif
1256fc729afSOlivier Houchard 
1266fc729afSOlivier Houchard 
1276fc729afSOlivier Houchard #ifdef __ELF__
1286fc729afSOlivier Houchard #define	WEAK_ALIAS(alias,sym)						\
1296fc729afSOlivier Houchard 	.weak alias;							\
1306fc729afSOlivier Houchard 	alias = sym
1316fc729afSOlivier Houchard #endif
1326fc729afSOlivier Houchard 
1336fc729afSOlivier Houchard #ifdef __STDC__
1346fc729afSOlivier Houchard #define	WARN_REFERENCES(sym,msg)					\
1356fc729afSOlivier Houchard 	.stabs msg ## ,30,0,0,0 ;					\
1366fc729afSOlivier Houchard 	.stabs __STRING(_C_LABEL(sym)) ## ,1,0,0,0
1376fc729afSOlivier Houchard #elif defined(__ELF__)
1386fc729afSOlivier Houchard #define	WARN_REFERENCES(sym,msg)					\
1396fc729afSOlivier Houchard 	.stabs msg,30,0,0,0 ;						\
1406fc729afSOlivier Houchard 	.stabs __STRING(sym),1,0,0,0
1416fc729afSOlivier Houchard #else
1426fc729afSOlivier Houchard #define	WARN_REFERENCES(sym,msg)					\
1436fc729afSOlivier Houchard 	.stabs msg,30,0,0,0 ;						\
1446fc729afSOlivier Houchard 	.stabs __STRING(_/**/sym),1,0,0,0
1456fc729afSOlivier Houchard #endif /* __STDC__ */
1466fc729afSOlivier Houchard 
1476fc729afSOlivier Houchard #endif /* !_MACHINE_ASM_H_ */
148