uniphier_image_desc.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <platform_def.h>
  8. #include <arch.h>
  9. #include <common/desc_image_load.h>
  10. #include "uniphier.h"
  11. #define UNIPHIER_BL33_OFFSET 0x04000000UL
  12. #define UNIPHIER_BL33_MAX_SIZE 0x00800000UL
  13. #define UNIPHIER_SCP_OFFSET 0x04800000UL
  14. #define UNIPHIER_SCP_MAX_SIZE 0x00020000UL
  15. static struct bl_mem_params_node uniphier_image_descs[] = {
  16. {
  17. .image_id = SCP_BL2_IMAGE_ID,
  18. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
  19. VERSION_2, image_info_t, 0),
  20. .image_info.image_base = UNIPHIER_SCP_OFFSET,
  21. .image_info.image_max_size = UNIPHIER_SCP_MAX_SIZE,
  22. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
  23. VERSION_2, entry_point_info_t,
  24. NON_SECURE | NON_EXECUTABLE),
  25. .next_handoff_image_id = INVALID_IMAGE_ID,
  26. },
  27. {
  28. .image_id = BL31_IMAGE_ID,
  29. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
  30. VERSION_2, image_info_t, 0),
  31. .image_info.image_base = UNIPHIER_BL31_OFFSET,
  32. .image_info.image_max_size = UNIPHIER_BL31_MAX_SIZE,
  33. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
  34. VERSION_2, entry_point_info_t,
  35. SECURE | EXECUTABLE | EP_FIRST_EXE),
  36. .ep_info.pc = UNIPHIER_BL31_OFFSET,
  37. .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
  38. DISABLE_ALL_EXCEPTIONS),
  39. #ifdef UNIPHIER_LOAD_BL32
  40. .next_handoff_image_id = BL32_IMAGE_ID,
  41. #else
  42. .next_handoff_image_id = BL33_IMAGE_ID,
  43. #endif
  44. },
  45. #ifdef UNIPHIER_LOAD_BL32
  46. {
  47. .image_id = BL32_IMAGE_ID,
  48. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
  49. VERSION_2, image_info_t, 0),
  50. .image_info.image_base = UNIPHIER_BL32_OFFSET,
  51. .image_info.image_max_size = UNIPHIER_BL32_MAX_SIZE,
  52. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
  53. VERSION_2, entry_point_info_t,
  54. SECURE | EXECUTABLE),
  55. .ep_info.pc = UNIPHIER_BL32_OFFSET,
  56. .ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
  57. DISABLE_ALL_EXCEPTIONS),
  58. .next_handoff_image_id = BL33_IMAGE_ID,
  59. },
  60. #endif
  61. {
  62. .image_id = BL33_IMAGE_ID,
  63. SET_STATIC_PARAM_HEAD(image_info, PARAM_EP,
  64. VERSION_2, image_info_t, 0),
  65. .image_info.image_base = UNIPHIER_BL33_OFFSET,
  66. .image_info.image_max_size = UNIPHIER_BL33_MAX_SIZE,
  67. SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP,
  68. VERSION_2, entry_point_info_t,
  69. NON_SECURE | EXECUTABLE),
  70. .ep_info.pc = UNIPHIER_BL33_OFFSET,
  71. .ep_info.spsr = SPSR_64(MODE_EL2, MODE_SP_ELX,
  72. DISABLE_ALL_EXCEPTIONS),
  73. .next_handoff_image_id = INVALID_IMAGE_ID,
  74. },
  75. };
  76. REGISTER_BL_IMAGE_DESCS(uniphier_image_descs)
  77. /*
  78. * image_info.image_base and ep_info.pc are the offset from the memory base.
  79. * When ENABLE_PIE is set, we never know the real memory base at link-time.
  80. * Fix-up the addresses by adding the run-time detected base.
  81. */
  82. void uniphier_init_image_descs(uintptr_t mem_base)
  83. {
  84. int i;
  85. for (i = 0; i < ARRAY_SIZE(uniphier_image_descs); i++) {
  86. uniphier_image_descs[i].image_info.image_base += mem_base;
  87. uniphier_image_descs[i].ep_info.pc += mem_base;
  88. }
  89. }
  90. struct image_info *uniphier_get_image_info(unsigned int image_id)
  91. {
  92. struct bl_mem_params_node *desc;
  93. desc = get_bl_mem_params_node(image_id);
  94. assert(desc);
  95. return &desc->image_info;
  96. }