xref: /optee_os/lib/libutils/ext/include/asm.S (revision 03bada660698e0f3c65a6a19136bfa32eb9bee36)
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 _bti=default
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)
31	.ifc	\_bti\(),default
32BTI(	bti	c)
33	.endif
34	.endm
35
36	.macro LOCAL_FUNC name colon section=default align=4 _bti=default
37	.ifc	\section\(),default
38	.section .text.\name
39	.else
40	.section \section , "ax" , %progbits
41	.endif
42	.type \name , %function
43	.balign \align
44	\name \colon
45UNWIND(	.fnstart)
46	.ifc	\_bti\(),default
47BTI(	bti	c)
48	.endif
49	.endm
50
51	.macro WEAK_FUNC name colon section=default align=4 _bti=default
52	.ifc	\section\(),default
53	.section .text.\name
54	.else
55	.section \section , "ax" , %progbits
56	.endif
57	.weak \name
58	.type \name , %function
59	.balign \align
60	\name \colon
61UNWIND(	.fnstart)
62	.ifc	\_bti\(),default
63BTI(	bti	c)
64	.endif
65	.endm
66
67	.macro END_FUNC name
68UNWIND(	.fnend)
69	.size \name , .-\name
70	.endm
71
72	.macro DATA name colon
73	.global \name
74	.type \name , %object
75	\name \colon
76	.endm
77
78	.macro LOCAL_DATA name colon
79	.type \name , %object
80	\name \colon
81	.endm
82
83	.macro END_DATA name
84	.size \name , .-\name
85	.endm
86