xref: /optee_os/lib/libutils/ext/include/asm.S (revision c3deb3d6f3b13d0e17fc9efe5880aec039e47594)
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__)
8#include <arm64_bti.S>
9#elif defined(__riscv)
10#include <riscv.S>
11#endif
12
13#if defined(__aarch64__) && \
14    (((defined(__KERNEL__) || defined(__LDELF__)) && defined(CFG_CORE_BTI)) || \
15     (!(defined(__KERNEL__) || defined(__LDELF__)) && defined(CFG_TA_BTI)))
16#define BTI(...) __VA_ARGS__
17#else
18#define BTI(...)
19#endif
20
21#if defined(CFG_UNWIND) && defined(__arm__)
22#define UNWIND(...) __VA_ARGS__
23#else
24#define UNWIND(...)
25#endif
26
27	.macro FUNC name colon section=default align=4 _bti=default
28	.ifc	\section\(),default
29	.section .text.\name
30	.else
31	.section \section , "ax" , %progbits
32	.endif
33	.global \name
34	.type \name , %function
35	.balign \align
36	\name \colon
37UNWIND(	.fnstart)
38	.ifc	\_bti\(),default
39BTI(	bti	c)
40	.endif
41	.endm
42
43	.macro LOCAL_FUNC name colon section=default align=4 _bti=default
44	.ifc	\section\(),default
45	.section .text.\name
46	.else
47	.section \section , "ax" , %progbits
48	.endif
49	.type \name , %function
50	.balign \align
51	\name \colon
52UNWIND(	.fnstart)
53	.ifc	\_bti\(),default
54BTI(	bti	c)
55	.endif
56	.endm
57
58	.macro WEAK_FUNC name colon section=default align=4 _bti=default
59	.ifc	\section\(),default
60	.section .text.\name
61	.else
62	.section \section , "ax" , %progbits
63	.endif
64	.weak \name
65	.type \name , %function
66	.balign \align
67	\name \colon
68UNWIND(	.fnstart)
69	.ifc	\_bti\(),default
70BTI(	bti	c)
71	.endif
72	.endm
73
74	.macro END_FUNC name
75UNWIND(	.fnend)
76	.size \name , .-\name
77	.endm
78
79	.macro DATA name colon
80	.global \name
81	.type \name , %object
82	\name \colon
83	.endm
84
85	.macro LOCAL_DATA name colon
86	.type \name , %object
87	\name \colon
88	.endm
89
90	.macro END_DATA name
91	.size \name , .-\name
92	.endm
93