juno_bl2_setup.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2016-2017,2021, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <common/bl_common.h>
  8. #include <common/desc_image_load.h>
  9. #include <lib/fconf/fconf.h>
  10. #include <lib/fconf/fconf_dyn_cfg_getter.h>
  11. #include <plat/arm/common/plat_arm.h>
  12. #if JUNO_AARCH32_EL3_RUNTIME
  13. /*******************************************************************************
  14. * This function changes the spsr for BL32 image to bypass
  15. * the check in BL1 AArch64 exception handler. This is needed in the aarch32
  16. * boot flow as the core comes up in aarch64 and to enter the BL32 image a warm
  17. * reset in aarch32 state is required.
  18. ******************************************************************************/
  19. int arm_bl2_plat_handle_post_image_load(unsigned int image_id)
  20. {
  21. int err = arm_bl2_handle_post_image_load(image_id);
  22. if (!err && (image_id == BL32_IMAGE_ID)) {
  23. bl_mem_params_node_t *bl_mem_params = get_bl_mem_params_node(image_id);
  24. assert(bl_mem_params);
  25. bl_mem_params->ep_info.spsr = SPSR_64(MODE_EL3, MODE_SP_ELX,
  26. DISABLE_ALL_EXCEPTIONS);
  27. }
  28. return err;
  29. }
  30. #else
  31. /*******************************************************************************
  32. * This function returns the list of executable images
  33. ******************************************************************************/
  34. struct bl_params *plat_get_next_bl_params(void)
  35. {
  36. struct bl_params *arm_bl_params = arm_get_next_bl_params();
  37. #if __aarch64__
  38. const struct dyn_cfg_dtb_info_t *fw_config_info;
  39. bl_mem_params_node_t *param_node;
  40. uintptr_t fw_config_base = 0U;
  41. entry_point_info_t *ep_info;
  42. /* Get BL31 image node */
  43. param_node = get_bl_mem_params_node(BL31_IMAGE_ID);
  44. assert(param_node != NULL);
  45. /* Get fw_config load address */
  46. fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, FW_CONFIG_ID);
  47. assert(fw_config_info != NULL);
  48. fw_config_base = fw_config_info->config_addr;
  49. assert(fw_config_base != 0U);
  50. /*
  51. * Get the entry point info of BL31 image and override
  52. * arg1 of entry point info with fw_config base address
  53. */
  54. ep_info = &param_node->ep_info;
  55. ep_info->args.arg1 = (uint32_t)fw_config_base;
  56. #endif /* __aarch64__ */
  57. return arm_bl_params;
  58. }
  59. #endif /* JUNO_AARCH32_EL3_RUNTIME */