xref: /openbsd-src/sys/arch/arm/include/asm.h (revision 8162193374858e8d7dceca506657f13b21b8be44)
1*81621933Sguenther /*	$OpenBSD: asm.h,v 1.13 2022/12/08 01:25:44 guenther Exp $	*/
2e1e4f5b1Sdrahn /*	$NetBSD: asm.h,v 1.4 2001/07/16 05:43:32 matt Exp $	*/
3e1e4f5b1Sdrahn 
4e1e4f5b1Sdrahn /*
5e1e4f5b1Sdrahn  * Copyright (c) 1990 The Regents of the University of California.
6e1e4f5b1Sdrahn  * All rights reserved.
7e1e4f5b1Sdrahn  *
8e1e4f5b1Sdrahn  * This code is derived from software contributed to Berkeley by
9e1e4f5b1Sdrahn  * William Jolitz.
10e1e4f5b1Sdrahn  *
11e1e4f5b1Sdrahn  * Redistribution and use in source and binary forms, with or without
12e1e4f5b1Sdrahn  * modification, are permitted provided that the following conditions
13e1e4f5b1Sdrahn  * are met:
14e1e4f5b1Sdrahn  * 1. Redistributions of source code must retain the above copyright
15e1e4f5b1Sdrahn  *    notice, this list of conditions and the following disclaimer.
16e1e4f5b1Sdrahn  * 2. Redistributions in binary form must reproduce the above copyright
17e1e4f5b1Sdrahn  *    notice, this list of conditions and the following disclaimer in the
18e1e4f5b1Sdrahn  *    documentation and/or other materials provided with the distribution.
19e1e4f5b1Sdrahn  * 3. Neither the name of the University nor the names of its contributors
20e1e4f5b1Sdrahn  *    may be used to endorse or promote products derived from this software
21e1e4f5b1Sdrahn  *    without specific prior written permission.
22e1e4f5b1Sdrahn  *
23e1e4f5b1Sdrahn  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24e1e4f5b1Sdrahn  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25e1e4f5b1Sdrahn  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26e1e4f5b1Sdrahn  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27e1e4f5b1Sdrahn  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28e1e4f5b1Sdrahn  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29e1e4f5b1Sdrahn  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30e1e4f5b1Sdrahn  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31e1e4f5b1Sdrahn  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32e1e4f5b1Sdrahn  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33e1e4f5b1Sdrahn  * SUCH DAMAGE.
34e1e4f5b1Sdrahn  *
35e1e4f5b1Sdrahn  *	from: @(#)asm.h	5.5 (Berkeley) 5/7/91
36e1e4f5b1Sdrahn  */
37e1e4f5b1Sdrahn 
382fa72412Spirofti #ifndef _ARM_ASM_H_
392fa72412Spirofti #define _ARM_ASM_H_
40e1e4f5b1Sdrahn 
41e1e4f5b1Sdrahn #define _C_LABEL(x)	x
42e1e4f5b1Sdrahn #define	_ASM_LABEL(x)	x
43e1e4f5b1Sdrahn 
44e1e4f5b1Sdrahn #ifdef __STDC__
45e1e4f5b1Sdrahn # define __CONCAT(x,y)	x ## y
46e1e4f5b1Sdrahn # define __STRING(x)	#x
47e1e4f5b1Sdrahn #else
48e1e4f5b1Sdrahn # define __CONCAT(x,y)	x/**/y
49e1e4f5b1Sdrahn # define __STRING(x)	"x"
50e1e4f5b1Sdrahn #endif
51e1e4f5b1Sdrahn 
52e1e4f5b1Sdrahn #ifndef _ALIGN_TEXT
53e1753c98Skettenis # define _ALIGN_TEXT .align 2
54e1e4f5b1Sdrahn #endif
55e1e4f5b1Sdrahn 
56e1e4f5b1Sdrahn /*
57e1e4f5b1Sdrahn  * gas/arm uses @ as a single comment character and thus cannot be used here
58e1e4f5b1Sdrahn  * Instead it recognised the # instead of an @ symbols in .type directives
59e1e4f5b1Sdrahn  * We define a couple of macros so that assembly code will not be dependant
60e1e4f5b1Sdrahn  * on one or the other.
61e1e4f5b1Sdrahn  */
62e1e4f5b1Sdrahn #define _ASM_TYPE_FUNCTION	#function
63e1e4f5b1Sdrahn #define _ASM_TYPE_OBJECT	#object
6442d2c245Sguenther 
6542d2c245Sguenther /* NB == No Binding: use .globl or .weak as necessary */
6642d2c245Sguenther #define _ENTRY_NB(x) \
6742d2c245Sguenther 	.text; _ALIGN_TEXT; .type x,_ASM_TYPE_FUNCTION; x:
6842d2c245Sguenther #define _ENTRY(x)		.globl x; _ENTRY_NB(x)
69e1e4f5b1Sdrahn 
70f5d1667bSmpi #if defined(PROF) || defined(GPROF)
71e1e4f5b1Sdrahn # define _PROF_PROLOGUE	\
72e1e4f5b1Sdrahn 	mov ip, lr; bl __mcount
73e1e4f5b1Sdrahn #else
74e1e4f5b1Sdrahn # define _PROF_PROLOGUE
75e1e4f5b1Sdrahn #endif
76e1e4f5b1Sdrahn 
77*81621933Sguenther #define	ENTRY(y)	_ENTRY(y); _PROF_PROLOGUE
78*81621933Sguenther #define	ENTRY_NP(y)	_ENTRY(y)
7942d2c245Sguenther #define	ENTRY_NB(y)	_ENTRY_NB(y); _PROF_PROLOGUE
80*81621933Sguenther #define	ASENTRY(y)	_ENTRY(y); _PROF_PROLOGUE
81*81621933Sguenther #define	ASENTRY_NP(y)	_ENTRY(y)
82f2d3668aSguenther #define	END(y)		.size y, . - y
83e1e4f5b1Sdrahn 
84a5cc6a2bSderaadt #if defined(__PIC__)
85fb956c4cSguenther #define	PIC_SYM(x,y)	x(y)
86e1e4f5b1Sdrahn #else
87e1e4f5b1Sdrahn #define	PIC_SYM(x,y)	x
88e1e4f5b1Sdrahn #endif
89e1e4f5b1Sdrahn 
905a25e2caSmartynas #define	STRONG_ALIAS(alias,sym)						\
915a25e2caSmartynas 	.global alias;							\
925a25e2caSmartynas 	alias = sym
93e1e4f5b1Sdrahn #define	WEAK_ALIAS(alias,sym)						\
94e1e4f5b1Sdrahn 	.weak alias;							\
95e1e4f5b1Sdrahn 	alias = sym
96e1e4f5b1Sdrahn 
97e1e4f5b1Sdrahn #endif /* !_ARM_ASM_H_ */
98