xref: /openbmc/u-boot/arch/arm/include/asm/secure.h (revision f510aeae689925a660bff14683eef4147785d271)
1*f510aeaeSMarc Zyngier #ifndef __ASM_SECURE_H
2*f510aeaeSMarc Zyngier #define __ASM_SECURE_H
3*f510aeaeSMarc Zyngier 
4*f510aeaeSMarc Zyngier #include <config.h>
5*f510aeaeSMarc Zyngier 
6*f510aeaeSMarc Zyngier #ifdef CONFIG_ARMV7_SECURE_BASE
7*f510aeaeSMarc Zyngier /*
8*f510aeaeSMarc Zyngier  * Warning, horror ahead.
9*f510aeaeSMarc Zyngier  *
10*f510aeaeSMarc Zyngier  * The target code lives in our "secure ram", but u-boot doesn't know
11*f510aeaeSMarc Zyngier  * that, and has blindly added reloc_off to every relocation
12*f510aeaeSMarc Zyngier  * entry. Gahh. Do the opposite conversion. This hack also prevents
13*f510aeaeSMarc Zyngier  * GCC from generating code veeners, which u-boot doesn't relocate at
14*f510aeaeSMarc Zyngier  * all...
15*f510aeaeSMarc Zyngier  */
16*f510aeaeSMarc Zyngier #define secure_ram_addr(_fn) ({						\
17*f510aeaeSMarc Zyngier 			DECLARE_GLOBAL_DATA_PTR;			\
18*f510aeaeSMarc Zyngier 			void *__fn = _fn;				\
19*f510aeaeSMarc Zyngier 			typeof(_fn) *__tmp = (__fn - gd->reloc_off);	\
20*f510aeaeSMarc Zyngier 			__tmp;						\
21*f510aeaeSMarc Zyngier 		})
22*f510aeaeSMarc Zyngier #else
23*f510aeaeSMarc Zyngier #define secure_ram_addr(_fn)	(_fn)
24*f510aeaeSMarc Zyngier #endif
25*f510aeaeSMarc Zyngier 
26*f510aeaeSMarc Zyngier #endif
27