fvp_bl2_setup.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <common/debug.h>
  8. #include <common/desc_image_load.h>
  9. #include <drivers/arm/sp804_delay_timer.h>
  10. #include <fvp_pas_def.h>
  11. #include <lib/fconf/fconf.h>
  12. #include <lib/fconf/fconf_dyn_cfg_getter.h>
  13. #include <lib/transfer_list.h>
  14. #include <plat/arm/common/plat_arm.h>
  15. #include <plat/common/platform.h>
  16. #include <platform_def.h>
  17. #include "fvp_private.h"
  18. #if ENABLE_RME
  19. /*
  20. * The GPT library might modify the gpt regions structure to optimize
  21. * the layout, so the array cannot be constant.
  22. */
  23. static pas_region_t pas_regions[] = {
  24. ARM_PAS_KERNEL,
  25. ARM_PAS_SECURE,
  26. ARM_PAS_REALM,
  27. ARM_PAS_EL3_DRAM,
  28. ARM_PAS_GPTS,
  29. ARM_PAS_KERNEL_1
  30. };
  31. static const arm_gpt_info_t arm_gpt_info = {
  32. .pas_region_base = pas_regions,
  33. .pas_region_count = (unsigned int)ARRAY_SIZE(pas_regions),
  34. .l0_base = (uintptr_t)ARM_L0_GPT_BASE,
  35. .l1_base = (uintptr_t)ARM_L1_GPT_BASE,
  36. .l0_size = (size_t)ARM_L0_GPT_SIZE,
  37. .l1_size = (size_t)ARM_L1_GPT_SIZE,
  38. .pps = GPCCR_PPS_64GB,
  39. .pgs = GPCCR_PGS_4K
  40. };
  41. #endif
  42. void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1, u_register_t arg2, u_register_t arg3)
  43. {
  44. struct transfer_list_entry *te __unused;
  45. #if TRANSFER_LIST
  46. arg0 = arg3;
  47. #endif
  48. arm_bl2_early_platform_setup((uintptr_t)arg0, (meminfo_t *)arg1);
  49. /* Initialize the platform config for future decision making */
  50. fvp_config_setup();
  51. }
  52. void bl2_platform_setup(void)
  53. {
  54. arm_bl2_platform_setup();
  55. /* Initialize System level generic or SP804 timer */
  56. fvp_timer_init();
  57. }
  58. #if ENABLE_RME
  59. const arm_gpt_info_t *plat_arm_get_gpt_info(void)
  60. {
  61. return &arm_gpt_info;
  62. }
  63. #endif /* ENABLE_RME */
  64. /*******************************************************************************
  65. * This function returns the list of executable images
  66. ******************************************************************************/
  67. struct bl_params *plat_get_next_bl_params(void)
  68. {
  69. struct bl_params *arm_bl_params;
  70. bl_mem_params_node_t *param_node __unused;
  71. const struct dyn_cfg_dtb_info_t *fw_config_info __unused;
  72. const struct dyn_cfg_dtb_info_t *hw_config_info __unused;
  73. entry_point_info_t *ep __unused;
  74. uint32_t next_exe_img_id __unused;
  75. uintptr_t fw_config_base __unused;
  76. arm_bl_params = arm_get_next_bl_params();
  77. #if __aarch64__
  78. /* Get BL31 image node */
  79. param_node = get_bl_mem_params_node(BL31_IMAGE_ID);
  80. #else /* aarch32 */
  81. /* Get SP_MIN image node */
  82. param_node = get_bl_mem_params_node(BL32_IMAGE_ID);
  83. #endif /* __aarch64__ */
  84. assert(param_node != NULL);
  85. #if TRANSFER_LIST
  86. arm_bl_params->head = &param_node->params_node_mem;
  87. arm_bl_params->head->ep_info = &param_node->ep_info;
  88. arm_bl_params->head->image_id = param_node->image_id;
  89. arm_bl2_setup_next_ep_info(param_node);
  90. #elif !RESET_TO_BL2 && !EL3_PAYLOAD_BASE
  91. fw_config_base = 0UL;
  92. /* Update the next image's ep info with the FW config address */
  93. fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, FW_CONFIG_ID);
  94. assert(fw_config_info != NULL);
  95. fw_config_base = fw_config_info->config_addr;
  96. assert(fw_config_base != 0UL);
  97. param_node->ep_info.args.arg1 = (uint32_t)fw_config_base;
  98. /* Update BL33's ep info with the NS HW config address */
  99. param_node = get_bl_mem_params_node(BL33_IMAGE_ID);
  100. assert(param_node != NULL);
  101. hw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, HW_CONFIG_ID);
  102. assert(hw_config_info != NULL);
  103. param_node->ep_info.args.arg1 = hw_config_info->secondary_config_addr;
  104. #endif /* TRANSFER_LIST */
  105. return arm_bl_params;
  106. }
  107. int bl2_plat_handle_post_image_load(unsigned int image_id)
  108. {
  109. #if !RESET_TO_BL2 && !EL3_PAYLOAD_BASE && !TRANSFER_LIST
  110. if (image_id == HW_CONFIG_ID) {
  111. const struct dyn_cfg_dtb_info_t *hw_config_info __unused;
  112. struct transfer_list_entry *te __unused;
  113. bl_mem_params_node_t *param_node __unused;
  114. param_node = get_bl_mem_params_node(image_id);
  115. assert(param_node != NULL);
  116. hw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, HW_CONFIG_ID);
  117. assert(hw_config_info != NULL);
  118. memcpy((void *)hw_config_info->secondary_config_addr,
  119. (void *)hw_config_info->config_addr,
  120. (size_t)param_node->image_info.image_size);
  121. /*
  122. * Ensure HW-config device tree is committed to memory, as the HW-Config
  123. * might be used without cache and MMU enabled at BL33.
  124. */
  125. flush_dcache_range(hw_config_info->secondary_config_addr,
  126. param_node->image_info.image_size);
  127. }
  128. #endif /* !RESET_TO_BL2 && !EL3_PAYLOAD_BASE && !TRANSFER_LIST*/
  129. return arm_bl2_plat_handle_post_image_load(image_id);
  130. }