arm_bl2_el3_setup.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (c) 2017-2023, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <drivers/generic_delay_timer.h>
  8. #include <plat/arm/common/plat_arm.h>
  9. #include <plat/common/platform.h>
  10. #include <platform_def.h>
  11. #pragma weak bl2_el3_early_platform_setup
  12. #pragma weak bl2_el3_plat_arch_setup
  13. #pragma weak bl2_el3_plat_prepare_exit
  14. #define MAP_BL2_EL3_TOTAL MAP_REGION_FLAT( \
  15. bl2_el3_tzram_layout.total_base, \
  16. bl2_el3_tzram_layout.total_size, \
  17. MT_MEMORY | MT_RW | MT_SECURE)
  18. static meminfo_t bl2_el3_tzram_layout;
  19. /*
  20. * Perform arm specific early platform setup. At this moment we only initialize
  21. * the console and the memory layout.
  22. */
  23. void arm_bl2_el3_early_platform_setup(void)
  24. {
  25. /* Initialize the console to provide early debug support */
  26. arm_console_boot_init();
  27. /*
  28. * Allow BL2 to see the whole Trusted RAM. This is determined
  29. * statically since we cannot rely on BL1 passing this information
  30. * in the RESET_TO_BL2 case.
  31. */
  32. bl2_el3_tzram_layout.total_base = ARM_BL_RAM_BASE;
  33. bl2_el3_tzram_layout.total_size = ARM_BL_RAM_SIZE;
  34. /* Initialise the IO layer and register platform IO devices */
  35. plat_arm_io_setup();
  36. }
  37. void bl2_el3_early_platform_setup(u_register_t arg0 __unused,
  38. u_register_t arg1 __unused,
  39. u_register_t arg2 __unused,
  40. u_register_t arg3 __unused)
  41. {
  42. arm_bl2_el3_early_platform_setup();
  43. /*
  44. * Initialize Interconnect for this cluster during cold boot.
  45. * No need for locks as no other CPU is active.
  46. */
  47. plat_arm_interconnect_init();
  48. /*
  49. * Enable Interconnect coherency for the primary CPU's cluster.
  50. */
  51. plat_arm_interconnect_enter_coherency();
  52. generic_delay_timer_init();
  53. }
  54. /*******************************************************************************
  55. * Perform the very early platform specific architectural setup here. At the
  56. * moment this is only initializes the mmu in a quick and dirty way.
  57. ******************************************************************************/
  58. void arm_bl2_el3_plat_arch_setup(void)
  59. {
  60. #if USE_COHERENT_MEM
  61. /* Ensure ARM platforms dont use coherent memory
  62. * in RESET_TO_BL2
  63. */
  64. assert(BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE == 0U);
  65. #endif
  66. const mmap_region_t bl_regions[] = {
  67. MAP_BL2_EL3_TOTAL,
  68. ARM_MAP_BL_RO,
  69. {0}
  70. };
  71. setup_page_tables(bl_regions, plat_arm_get_mmap());
  72. #ifdef __aarch64__
  73. enable_mmu_el3(0);
  74. #else
  75. enable_mmu_svc_mon(0);
  76. #endif
  77. }
  78. void bl2_el3_plat_arch_setup(void)
  79. {
  80. arm_bl2_el3_plat_arch_setup();
  81. }
  82. void bl2_el3_plat_prepare_exit(void)
  83. {
  84. }