secure.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __ASM_SECURE_H
  2. #define __ASM_SECURE_H
  3. #include <config.h>
  4. #define __secure __attribute__ ((section ("._secure.text")))
  5. #define __secure_data __attribute__ ((section ("._secure.data")))
  6. #ifndef __ASSEMBLY__
  7. typedef struct secure_svc_tbl {
  8. u32 id;
  9. #ifdef CONFIG_ARMV8_PSCI
  10. u8 pad[4];
  11. #endif
  12. void *func;
  13. } secure_svc_tbl_t;
  14. /*
  15. * Macro to declare a SiP function service in '_secure_svc_tbl_entries' section
  16. */
  17. #define DECLARE_SECURE_SVC(_name, _id, _fn) \
  18. static const secure_svc_tbl_t __secure_svc_ ## _name \
  19. __attribute__((used, section("._secure_svc_tbl_entries"))) \
  20. = { \
  21. .id = _id, \
  22. .func = _fn }
  23. #else
  24. #ifdef CONFIG_ARMV8_PSCI
  25. #define SECURE_SVC_TBL_OFFSET 16
  26. #else
  27. #define SECURE_SVC_TBL_OFFSET 8
  28. #endif
  29. #endif /* __ASSEMBLY__ */
  30. #if defined(CONFIG_ARMV7_SECURE_BASE) || defined(CONFIG_ARMV8_SECURE_BASE)
  31. /*
  32. * Warning, horror ahead.
  33. *
  34. * The target code lives in our "secure ram", but u-boot doesn't know
  35. * that, and has blindly added reloc_off to every relocation
  36. * entry. Gahh. Do the opposite conversion. This hack also prevents
  37. * GCC from generating code veeners, which u-boot doesn't relocate at
  38. * all...
  39. */
  40. #define secure_ram_addr(_fn) ({ \
  41. DECLARE_GLOBAL_DATA_PTR; \
  42. void *__fn = _fn; \
  43. typeof(_fn) *__tmp = (__fn - gd->reloc_off); \
  44. __tmp; \
  45. })
  46. #else
  47. #define secure_ram_addr(_fn) (_fn)
  48. #endif
  49. #endif