xref: /optee_os/lib/libutils/ext/include/asm.S (revision af432c48741cd34f059aebb9d2ba9a24823e9255)
1/* SPDX-License-Identifier: BSD-2-Clause */
2/*
3 * Copyright (c) 2014, STMicroelectronics International N.V.
4 * Copyright (c) 2020, Linaro Limited
5 */
6
7#if defined(__aarch64__) && ((defined(__KERNEL__) && defined(CFG_CORE_BTI)) || \
8			     (!defined(__KERNEL__) && defined(CFG_TA_BTI)))
9#define BTI(...) __VA_ARGS__
10#else
11#define BTI(...)
12#endif
13
14#if defined(CFG_UNWIND) && defined(__arm__)
15#define UNWIND(...) __VA_ARGS__
16#else
17#define UNWIND(...)
18#endif
19
20	.macro FUNC name colon section=default align=4
21	.ifc	\section\(),default
22	.section .text.\name
23	.else
24	.section \section , "ax" , %progbits
25	.endif
26	.global \name
27	.type \name , %function
28	.balign \align
29	\name \colon
30UNWIND(	.fnstart)
31BTI(	bti	c)
32	.endm
33
34	.macro LOCAL_FUNC name colon section=default align=4
35	.ifc	\section\(),default
36	.section .text.\name
37	.else
38	.section \section , "ax" , %progbits
39	.endif
40	.type \name , %function
41	.balign \align
42	\name \colon
43UNWIND(	.fnstart)
44BTI(	bti	c)
45	.endm
46
47	.macro WEAK_FUNC name colon section=default align=4
48	.ifc	\section\(),default
49	.section .text.\name
50	.else
51	.section \section , "ax" , %progbits
52	.endif
53	.weak \name
54	.type \name , %function
55	.balign \align
56	\name \colon
57UNWIND(	.fnstart)
58BTI(	bti	c)
59	.endm
60
61	.macro END_FUNC name
62UNWIND(	.fnend)
63	.size \name , .-\name
64	.endm
65
66	.macro DATA name colon
67	.global \name
68	.type \name , %object
69	\name \colon
70	.endm
71
72	.macro LOCAL_DATA name colon
73	.type \name , %object
74	\name \colon
75	.endm
76
77	.macro END_DATA name
78	.size \name , .-\name
79	.endm
80