Marc Zyngier | f510aea | 2014-07-12 14:24:03 +0100 | [diff] [blame] | 1 | #ifndef __ASM_SECURE_H |
| 2 | #define __ASM_SECURE_H |
| 3 | |
| 4 | #include <config.h> |
| 5 | |
Chen-Yu Tsai | afc1f65 | 2016-06-19 12:38:41 +0800 | [diff] [blame] | 6 | #define __secure __attribute__ ((section ("._secure.text"))) |
Chen-Yu Tsai | a5aa7ff | 2016-07-05 21:45:06 +0800 | [diff] [blame] | 7 | #define __secure_data __attribute__ ((section ("._secure.data"))) |
Chen-Yu Tsai | afc1f65 | 2016-06-19 12:38:41 +0800 | [diff] [blame] | 8 | |
Chee Hong Ang | f6b0115 | 2019-02-12 00:27:02 -0800 | [diff] [blame] | 9 | #ifndef __ASSEMBLY__ |
| 10 | |
| 11 | typedef struct secure_svc_tbl { |
| 12 | u32 id; |
| 13 | #ifdef CONFIG_ARMV8_PSCI |
| 14 | u8 pad[4]; |
| 15 | #endif |
| 16 | void *func; |
| 17 | } secure_svc_tbl_t; |
| 18 | |
| 19 | /* |
| 20 | * Macro to declare a SiP function service in '_secure_svc_tbl_entries' section |
| 21 | */ |
| 22 | #define DECLARE_SECURE_SVC(_name, _id, _fn) \ |
| 23 | static const secure_svc_tbl_t __secure_svc_ ## _name \ |
| 24 | __attribute__((used, section("._secure_svc_tbl_entries"))) \ |
| 25 | = { \ |
| 26 | .id = _id, \ |
| 27 | .func = _fn } |
| 28 | |
| 29 | #else |
| 30 | |
| 31 | #ifdef CONFIG_ARMV8_PSCI |
| 32 | #define SECURE_SVC_TBL_OFFSET 16 |
| 33 | #else |
| 34 | #define SECURE_SVC_TBL_OFFSET 8 |
| 35 | |
| 36 | #endif |
| 37 | |
| 38 | #endif /* __ASSEMBLY__ */ |
| 39 | |
macro.wave.z@gmail.com | 9a56175 | 2016-12-08 11:58:25 +0800 | [diff] [blame] | 40 | #if defined(CONFIG_ARMV7_SECURE_BASE) || defined(CONFIG_ARMV8_SECURE_BASE) |
Marc Zyngier | f510aea | 2014-07-12 14:24:03 +0100 | [diff] [blame] | 41 | /* |
| 42 | * Warning, horror ahead. |
| 43 | * |
| 44 | * The target code lives in our "secure ram", but u-boot doesn't know |
| 45 | * that, and has blindly added reloc_off to every relocation |
| 46 | * entry. Gahh. Do the opposite conversion. This hack also prevents |
| 47 | * GCC from generating code veeners, which u-boot doesn't relocate at |
| 48 | * all... |
| 49 | */ |
| 50 | #define secure_ram_addr(_fn) ({ \ |
| 51 | DECLARE_GLOBAL_DATA_PTR; \ |
| 52 | void *__fn = _fn; \ |
| 53 | typeof(_fn) *__tmp = (__fn - gd->reloc_off); \ |
| 54 | __tmp; \ |
| 55 | }) |
| 56 | #else |
| 57 | #define secure_ram_addr(_fn) (_fn) |
| 58 | #endif |
| 59 | |
| 60 | #endif |