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