qemu_bl2_mem_params_desc.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * Copyright (c) 2017-2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. #include <common/desc_image_load.h>
  8. #include <plat/common/platform.h>
  9. #define SP_PKG_ENTRY(id) \
  10. { \
  11. .image_id = (id), \
  12. SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY, VERSION_2, \
  13. entry_point_info_t, \
  14. SECURE | NON_EXECUTABLE), \
  15. SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY, \
  16. VERSION_2, image_info_t, \
  17. IMAGE_ATTRIB_SKIP_LOADING), \
  18. .next_handoff_image_id = INVALID_IMAGE_ID, \
  19. }
  20. /*******************************************************************************
  21. * Following descriptor provides BL image/ep information that gets used
  22. * by BL2 to load the images and also subset of this information is
  23. * passed to next BL image. The image loading sequence is managed by
  24. * populating the images in required loading order. The image execution
  25. * sequence is managed by populating the `next_handoff_image_id` with
  26. * the next executable image id.
  27. ******************************************************************************/
  28. static bl_mem_params_node_t bl2_mem_params_descs[] = {
  29. #ifdef EL3_PAYLOAD_BASE
  30. /* Fill EL3 payload related information (BL31 is EL3 payload) */
  31. { .image_id = BL31_IMAGE_ID,
  32. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  33. entry_point_info_t,
  34. SECURE | EXECUTABLE | EP_FIRST_EXE),
  35. .ep_info.pc = EL3_PAYLOAD_BASE,
  36. .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
  37. DISABLE_ALL_EXCEPTIONS),
  38. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
  39. IMAGE_ATTRIB_PLAT_SETUP | IMAGE_ATTRIB_SKIP_LOADING),
  40. .next_handoff_image_id = INVALID_IMAGE_ID,
  41. },
  42. #else /* EL3_PAYLOAD_BASE */
  43. #ifdef __aarch64__
  44. /* Fill BL31 related information */
  45. { .image_id = BL31_IMAGE_ID,
  46. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  47. entry_point_info_t,
  48. SECURE | EXECUTABLE | EP_FIRST_EXE),
  49. .ep_info.pc = BL31_BASE,
  50. .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
  51. DISABLE_ALL_EXCEPTIONS),
  52. # if DEBUG
  53. .ep_info.args.arg1 = QEMU_BL31_PLAT_PARAM_VAL,
  54. # endif
  55. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
  56. IMAGE_ATTRIB_PLAT_SETUP),
  57. .image_info.image_base = BL31_BASE,
  58. .image_info.image_max_size = BL31_LIMIT - BL31_BASE,
  59. # ifdef QEMU_LOAD_BL32
  60. .next_handoff_image_id = BL32_IMAGE_ID,
  61. # elif ENABLE_RME
  62. .next_handoff_image_id = RMM_IMAGE_ID,
  63. # else
  64. .next_handoff_image_id = BL33_IMAGE_ID,
  65. # endif
  66. },
  67. #endif /* __aarch64__ */
  68. #if ENABLE_RME
  69. /* Fill RMM related information */
  70. { .image_id = RMM_IMAGE_ID,
  71. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
  72. VERSION_2, entry_point_info_t, EP_REALM | EXECUTABLE),
  73. .ep_info.pc = RMM_BASE,
  74. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
  75. VERSION_2, image_info_t, 0),
  76. .image_info.image_base = RMM_BASE,
  77. .image_info.image_max_size = RMM_LIMIT - RMM_BASE,
  78. .next_handoff_image_id = BL33_IMAGE_ID,
  79. },
  80. #endif /* ENABLE_RME */
  81. # ifdef QEMU_LOAD_BL32
  82. #ifdef __aarch64__
  83. #define BL32_EP_ATTRIBS (SECURE | EXECUTABLE)
  84. #define BL32_IMG_ATTRIBS 0
  85. #else
  86. #define BL32_EP_ATTRIBS (SECURE | EXECUTABLE | EP_FIRST_EXE)
  87. #define BL32_IMG_ATTRIBS IMAGE_ATTRIB_PLAT_SETUP
  88. #endif
  89. /* Fill BL32 related information */
  90. { .image_id = BL32_IMAGE_ID,
  91. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  92. entry_point_info_t, BL32_EP_ATTRIBS),
  93. .ep_info.pc = BL32_BASE,
  94. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
  95. image_info_t, BL32_IMG_ATTRIBS),
  96. .image_info.image_base = BL32_BASE,
  97. .image_info.image_max_size = BL32_LIMIT - BL32_BASE,
  98. #if ENABLE_RME
  99. .next_handoff_image_id = RMM_IMAGE_ID,
  100. #else
  101. .next_handoff_image_id = BL33_IMAGE_ID,
  102. #endif
  103. },
  104. /*
  105. * Fill BL32 external 1 related information.
  106. * A typical use for extra1 image is with OP-TEE where it is the
  107. * pager image.
  108. */
  109. { .image_id = BL32_EXTRA1_IMAGE_ID,
  110. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  111. entry_point_info_t, SECURE | NON_EXECUTABLE),
  112. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
  113. image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
  114. .image_info.image_base = BL32_BASE,
  115. .image_info.image_max_size = BL32_LIMIT - BL32_BASE,
  116. .next_handoff_image_id = INVALID_IMAGE_ID,
  117. },
  118. /*
  119. * Fill BL32 external 2 related information.
  120. * A typical use for extra2 image is with OP-TEE where it is the
  121. * paged image.
  122. */
  123. { .image_id = BL32_EXTRA2_IMAGE_ID,
  124. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  125. entry_point_info_t, SECURE | NON_EXECUTABLE),
  126. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
  127. image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
  128. #if defined(SPD_opteed) || defined(AARCH32_SP_OPTEE) || defined(SPMC_OPTEE)
  129. .image_info.image_base = QEMU_OPTEE_PAGEABLE_LOAD_BASE,
  130. .image_info.image_max_size = QEMU_OPTEE_PAGEABLE_LOAD_SIZE,
  131. #endif
  132. .next_handoff_image_id = INVALID_IMAGE_ID,
  133. },
  134. #if defined(SPD_spmd)
  135. /* Fill TOS_FW_CONFIG related information */
  136. {
  137. .image_id = TOS_FW_CONFIG_ID,
  138. SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY,
  139. VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
  140. SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
  141. VERSION_2, image_info_t, 0),
  142. .image_info.image_base = TOS_FW_CONFIG_BASE,
  143. .image_info.image_max_size = TOS_FW_CONFIG_LIMIT -
  144. TOS_FW_CONFIG_BASE,
  145. .next_handoff_image_id = INVALID_IMAGE_ID,
  146. },
  147. #if SPMD_SPM_AT_SEL2
  148. /* Fill TB_FW_CONFIG related information */
  149. {
  150. .image_id = TB_FW_CONFIG_ID,
  151. SET_STATIC_PARAM_HEAD(ep_info, PARAM_IMAGE_BINARY,
  152. VERSION_2, entry_point_info_t, SECURE | NON_EXECUTABLE),
  153. SET_STATIC_PARAM_HEAD(image_info, PARAM_IMAGE_BINARY,
  154. VERSION_2, image_info_t, 0),
  155. .image_info.image_base = TB_FW_CONFIG_BASE,
  156. .image_info.image_max_size = TB_FW_CONFIG_LIMIT - TB_FW_CONFIG_BASE,
  157. .next_handoff_image_id = INVALID_IMAGE_ID,
  158. },
  159. /*
  160. * Empty entries for SP packages to be filled in according to
  161. * TB_FW_CONFIG.
  162. */
  163. SP_PKG_ENTRY(SP_PKG1_ID),
  164. SP_PKG_ENTRY(SP_PKG2_ID),
  165. SP_PKG_ENTRY(SP_PKG3_ID),
  166. SP_PKG_ENTRY(SP_PKG4_ID),
  167. SP_PKG_ENTRY(SP_PKG5_ID),
  168. SP_PKG_ENTRY(SP_PKG6_ID),
  169. SP_PKG_ENTRY(SP_PKG7_ID),
  170. SP_PKG_ENTRY(SP_PKG8_ID),
  171. #endif
  172. #endif
  173. # endif /* QEMU_LOAD_BL32 */
  174. /* Fill BL33 related information */
  175. { .image_id = BL33_IMAGE_ID,
  176. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  177. entry_point_info_t, NON_SECURE | EXECUTABLE),
  178. # ifdef PRELOADED_BL33_BASE
  179. .ep_info.pc = PRELOADED_BL33_BASE,
  180. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
  181. IMAGE_ATTRIB_SKIP_LOADING),
  182. # else /* PRELOADED_BL33_BASE */
  183. .ep_info.pc = NS_IMAGE_OFFSET,
  184. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
  185. 0),
  186. .image_info.image_base = NS_IMAGE_OFFSET,
  187. .image_info.image_max_size = NS_IMAGE_MAX_SIZE,
  188. # endif /* !PRELOADED_BL33_BASE */
  189. .next_handoff_image_id = INVALID_IMAGE_ID,
  190. }
  191. #endif /* !EL3_PAYLOAD_BASE */
  192. };
  193. REGISTER_BL_IMAGE_DESCS(bl2_mem_params_descs)