1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_STATIC_CALL_H
3 #define _ASM_POWERPC_STATIC_CALL_H
4 
5 #define __PPC_SCT(name, inst)					\
6 	asm(".pushsection .text, \"ax\"				\n"	\
7 	    ".align 5						\n"	\
8 	    ".globl " STATIC_CALL_TRAMP_STR(name) "		\n"	\
9 	    STATIC_CALL_TRAMP_STR(name) ":			\n"	\
10 	    inst "						\n"	\
11 	    "	lis	12,2f@ha				\n"	\
12 	    "	lwz	12,2f@l(12)				\n"	\
13 	    "	mtctr	12					\n"	\
14 	    "	bctr						\n"	\
15 	    "1:	li	3, 0					\n"	\
16 	    "	blr						\n"	\
17 	    "2:	.long 0						\n"	\
18 	    ".type " STATIC_CALL_TRAMP_STR(name) ", @function	\n"	\
19 	    ".size " STATIC_CALL_TRAMP_STR(name) ", . - " STATIC_CALL_TRAMP_STR(name) " \n" \
20 	    ".popsection					\n")
21 
22 #define PPC_SCT_RET0		20		/* Offset of label 1 */
23 #define PPC_SCT_DATA		28		/* Offset of label 2 */
24 
25 #define ARCH_DEFINE_STATIC_CALL_TRAMP(name, func)	__PPC_SCT(name, "b " #func)
26 #define ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name)	__PPC_SCT(name, "blr")
27 #define ARCH_DEFINE_STATIC_CALL_RET0_TRAMP(name)	__PPC_SCT(name, "b .+20")
28 
29 #endif /* _ASM_POWERPC_STATIC_CALL_H */
30