qemu_bl2_mem_params_desc.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright (c) 2017-2021, 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. /*******************************************************************************
  10. * Following descriptor provides BL image/ep information that gets used
  11. * by BL2 to load the images and also subset of this information is
  12. * passed to next BL image. The image loading sequence is managed by
  13. * populating the images in required loading order. The image execution
  14. * sequence is managed by populating the `next_handoff_image_id` with
  15. * the next executable image id.
  16. ******************************************************************************/
  17. static bl_mem_params_node_t bl2_mem_params_descs[] = {
  18. #ifdef EL3_PAYLOAD_BASE
  19. /* Fill EL3 payload related information (BL31 is EL3 payload) */
  20. { .image_id = BL31_IMAGE_ID,
  21. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  22. entry_point_info_t,
  23. SECURE | EXECUTABLE | EP_FIRST_EXE),
  24. .ep_info.pc = EL3_PAYLOAD_BASE,
  25. .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
  26. DISABLE_ALL_EXCEPTIONS),
  27. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
  28. IMAGE_ATTRIB_PLAT_SETUP | IMAGE_ATTRIB_SKIP_LOADING),
  29. .next_handoff_image_id = INVALID_IMAGE_ID,
  30. },
  31. #else /* EL3_PAYLOAD_BASE */
  32. #ifdef __aarch64__
  33. /* Fill BL31 related information */
  34. { .image_id = BL31_IMAGE_ID,
  35. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  36. entry_point_info_t,
  37. SECURE | EXECUTABLE | EP_FIRST_EXE),
  38. .ep_info.pc = BL31_BASE,
  39. .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
  40. DISABLE_ALL_EXCEPTIONS),
  41. # if DEBUG
  42. .ep_info.args.arg1 = QEMU_BL31_PLAT_PARAM_VAL,
  43. # endif
  44. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
  45. IMAGE_ATTRIB_PLAT_SETUP),
  46. .image_info.image_base = BL31_BASE,
  47. .image_info.image_max_size = BL31_LIMIT - BL31_BASE,
  48. # ifdef QEMU_LOAD_BL32
  49. .next_handoff_image_id = BL32_IMAGE_ID,
  50. # else
  51. .next_handoff_image_id = BL33_IMAGE_ID,
  52. # endif
  53. },
  54. #endif /* __aarch64__ */
  55. # ifdef QEMU_LOAD_BL32
  56. #ifdef __aarch64__
  57. #define BL32_EP_ATTRIBS (SECURE | EXECUTABLE)
  58. #define BL32_IMG_ATTRIBS 0
  59. #else
  60. #define BL32_EP_ATTRIBS (SECURE | EXECUTABLE | EP_FIRST_EXE)
  61. #define BL32_IMG_ATTRIBS IMAGE_ATTRIB_PLAT_SETUP
  62. #endif
  63. /* Fill BL32 related information */
  64. { .image_id = BL32_IMAGE_ID,
  65. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  66. entry_point_info_t, BL32_EP_ATTRIBS),
  67. .ep_info.pc = BL32_BASE,
  68. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
  69. image_info_t, BL32_IMG_ATTRIBS),
  70. .image_info.image_base = BL32_BASE,
  71. .image_info.image_max_size = BL32_LIMIT - BL32_BASE,
  72. .next_handoff_image_id = BL33_IMAGE_ID,
  73. },
  74. /*
  75. * Fill BL32 external 1 related information.
  76. * A typical use for extra1 image is with OP-TEE where it is the
  77. * pager image.
  78. */
  79. { .image_id = BL32_EXTRA1_IMAGE_ID,
  80. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  81. entry_point_info_t, SECURE | NON_EXECUTABLE),
  82. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
  83. image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
  84. .image_info.image_base = BL32_BASE,
  85. .image_info.image_max_size = BL32_LIMIT - BL32_BASE,
  86. .next_handoff_image_id = INVALID_IMAGE_ID,
  87. },
  88. /*
  89. * Fill BL32 external 2 related information.
  90. * A typical use for extra2 image is with OP-TEE where it is the
  91. * paged image.
  92. */
  93. { .image_id = BL32_EXTRA2_IMAGE_ID,
  94. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  95. entry_point_info_t, SECURE | NON_EXECUTABLE),
  96. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
  97. image_info_t, IMAGE_ATTRIB_SKIP_LOADING),
  98. #if defined(SPD_opteed) || defined(AARCH32_SP_OPTEE) || defined(SPMC_OPTEE)
  99. .image_info.image_base = QEMU_OPTEE_PAGEABLE_LOAD_BASE,
  100. .image_info.image_max_size = QEMU_OPTEE_PAGEABLE_LOAD_SIZE,
  101. #endif
  102. .next_handoff_image_id = INVALID_IMAGE_ID,
  103. },
  104. # endif /* QEMU_LOAD_BL32 */
  105. /* Fill BL33 related information */
  106. { .image_id = BL33_IMAGE_ID,
  107. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, VERSION_2,
  108. entry_point_info_t, NON_SECURE | EXECUTABLE),
  109. # ifdef PRELOADED_BL33_BASE
  110. .ep_info.pc = PRELOADED_BL33_BASE,
  111. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
  112. IMAGE_ATTRIB_SKIP_LOADING),
  113. # else /* PRELOADED_BL33_BASE */
  114. .ep_info.pc = NS_IMAGE_OFFSET,
  115. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2, image_info_t,
  116. 0),
  117. .image_info.image_base = NS_IMAGE_OFFSET,
  118. .image_info.image_max_size = NS_IMAGE_MAX_SIZE,
  119. # endif /* !PRELOADED_BL33_BASE */
  120. .next_handoff_image_id = INVALID_IMAGE_ID,
  121. }
  122. #endif /* !EL3_PAYLOAD_BASE */
  123. };
  124. REGISTER_BL_IMAGE_DESCS(bl2_mem_params_descs)