secure.h 1.4 KB

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