ep_info_exp.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef ARM_TRUSTED_FIRMWARE_EXPORT_COMMON_EP_INFO_EXP_H
  7. #define ARM_TRUSTED_FIRMWARE_EXPORT_COMMON_EP_INFO_EXP_H
  8. /* EXPORT HEADER -- See include/export/README for details! -- EXPORT HEADER */
  9. #include "../lib/utils_def_exp.h"
  10. #include "param_header_exp.h"
  11. /*******************************************************************************
  12. * Constants that allow assembler code to access members of and the
  13. * 'entry_point_info' structure at their correct offsets.
  14. ******************************************************************************/
  15. #define ENTRY_POINT_INFO_PC_OFFSET U(0x08)
  16. #ifdef __aarch64__
  17. #define ENTRY_POINT_INFO_ARGS_OFFSET U(0x18)
  18. #else
  19. #define ENTRY_POINT_INFO_LR_SVC_OFFSET U(0x10)
  20. #define ENTRY_POINT_INFO_ARGS_OFFSET U(0x14)
  21. #endif
  22. /*
  23. * Security state of the image. Bit 0 and
  24. * bit 5 are used to determine the security
  25. * state of the image as follows:
  26. *
  27. * ---------------------------------
  28. * Bit 5 | Bit 0 | Security state
  29. * ---------------------------------
  30. * 0 0 EP_SECURE
  31. * 0 1 EP_NON_SECURE
  32. * 1 1 EP_REALM
  33. */
  34. #define EP_SECURITY_MASK UL(0x21)
  35. #define EP_SECURITY_SHIFT UL(0)
  36. #define EP_SECURE UL(0x0)
  37. #define EP_NON_SECURE UL(0x1)
  38. #define EP_REALM UL(0x21)
  39. /* Endianness of the image. */
  40. #define EP_EE_MASK U(0x2)
  41. #define EP_EE_SHIFT U(1)
  42. #define EP_EE_LITTLE U(0x0)
  43. #define EP_EE_BIG U(0x2)
  44. #define EP_GET_EE(x) ((x) & EP_EE_MASK)
  45. #define EP_SET_EE(x, ee) ((x) = ((x) & ~EP_EE_MASK) | (ee))
  46. /* Enable or disable access to the secure timer from secure images. */
  47. #define EP_ST_MASK U(0x4)
  48. #define EP_ST_SHIFT U(2)
  49. #define EP_ST_DISABLE U(0x0)
  50. #define EP_ST_ENABLE U(0x4)
  51. #define EP_GET_ST(x) ((x) & EP_ST_MASK)
  52. #define EP_SET_ST(x, ee) ((x) = ((x) & ~EP_ST_MASK) | (ee))
  53. /* Determine if an image is executable or not. */
  54. #define EP_EXE_MASK U(0x8)
  55. #define EP_EXE_SHIFT U(3)
  56. #define EP_NON_EXECUTABLE U(0x0)
  57. #define EP_EXECUTABLE U(0x8)
  58. #define EP_GET_EXE(x) ((x) & EP_EXE_MASK)
  59. #define EP_SET_EXE(x, ee) ((x) = ((x) & ~EP_EXE_MASK) | (ee))
  60. /* Flag to indicate the first image that is executed. */
  61. #define EP_FIRST_EXE_MASK U(0x10)
  62. #define EP_FIRST_EXE_SHIFT U(4)
  63. #define EP_FIRST_EXE U(0x10)
  64. #define EP_GET_FIRST_EXE(x) ((x) & EP_FIRST_EXE_MASK)
  65. #define EP_SET_FIRST_EXE(x, ee) ((x) = ((x) & ~EP_FIRST_EXE_MASK) | (ee))
  66. #ifndef __ASSEMBLER__
  67. typedef struct aapcs64_params {
  68. uint64_t arg0;
  69. uint64_t arg1;
  70. uint64_t arg2;
  71. uint64_t arg3;
  72. uint64_t arg4;
  73. uint64_t arg5;
  74. uint64_t arg6;
  75. uint64_t arg7;
  76. } aapcs64_params_t;
  77. typedef struct aapcs32_params {
  78. uint32_t arg0;
  79. uint32_t arg1;
  80. uint32_t arg2;
  81. uint32_t arg3;
  82. } aapcs32_params_t;
  83. /*****************************************************************************
  84. * This structure represents the superset of information needed while
  85. * switching exception levels. The only two mechanisms to do so are
  86. * ERET & SMC. Security state is indicated using bit zero of header
  87. * attribute
  88. * NOTE: BL1 expects entrypoint followed by spsr at an offset from the start
  89. * of this structure defined by the macro `ENTRY_POINT_INFO_PC_OFFSET` while
  90. * processing SMC to jump to BL31.
  91. *****************************************************************************/
  92. typedef struct entry_point_info {
  93. param_header_t h;
  94. uintptr_t pc;
  95. uint32_t spsr;
  96. #ifdef __aarch64__
  97. aapcs64_params_t args;
  98. #else
  99. uintptr_t lr_svc;
  100. aapcs32_params_t args;
  101. #endif
  102. } entry_point_info_t;
  103. #endif /*__ASSEMBLER__*/
  104. #endif /* ARM_TRUSTED_FIRMWARE_EXPORT_COMMON_EP_INFO_EXP_H */