arm_bl2u_setup.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <string.h>
  8. #include <platform_def.h>
  9. #include <arch_helpers.h>
  10. #include <common/bl_common.h>
  11. #include <drivers/generic_delay_timer.h>
  12. #include <plat/arm/common/plat_arm.h>
  13. #include <plat/common/platform.h>
  14. /* Weak definitions may be overridden in specific ARM standard platform */
  15. #pragma weak bl2u_platform_setup
  16. #pragma weak bl2u_early_platform_setup
  17. #pragma weak bl2u_plat_arch_setup
  18. #define MAP_BL2U_TOTAL MAP_REGION_FLAT( \
  19. BL2U_BASE, \
  20. BL2U_LIMIT - BL2U_BASE, \
  21. MT_MEMORY | MT_RW | MT_SECURE)
  22. /*
  23. * Perform ARM standard platform setup for BL2U
  24. */
  25. void arm_bl2u_platform_setup(void)
  26. {
  27. /* Initialize the secure environment */
  28. plat_arm_security_setup();
  29. }
  30. void bl2u_platform_setup(void)
  31. {
  32. arm_bl2u_platform_setup();
  33. }
  34. void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
  35. {
  36. /* Initialize the console to provide early debug support */
  37. arm_console_boot_init();
  38. generic_delay_timer_init();
  39. }
  40. /*******************************************************************************
  41. * BL1 can pass platform dependent information to BL2U in x1.
  42. * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
  43. * In case of ARM FVP platforms x1 is not used.
  44. * In both cases, x0 contains the extents of the memory available to BL2U
  45. ******************************************************************************/
  46. void bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
  47. {
  48. arm_bl2u_early_platform_setup(mem_layout, plat_info);
  49. }
  50. /*******************************************************************************
  51. * Perform the very early platform specific architectural setup here. At the
  52. * moment this is only initializes the mmu in a quick and dirty way.
  53. * The memory that is used by BL2U is only mapped.
  54. ******************************************************************************/
  55. void arm_bl2u_plat_arch_setup(void)
  56. {
  57. #if USE_COHERENT_MEM
  58. /* Ensure ARM platforms dont use coherent memory in BL2U */
  59. assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
  60. #endif
  61. const mmap_region_t bl_regions[] = {
  62. MAP_BL2U_TOTAL,
  63. ARM_MAP_BL_RO,
  64. #if USE_ROMLIB
  65. ARM_MAP_ROMLIB_CODE,
  66. ARM_MAP_ROMLIB_DATA,
  67. #endif
  68. {0}
  69. };
  70. setup_page_tables(bl_regions, plat_arm_get_mmap());
  71. #ifdef __aarch64__
  72. enable_mmu_el1(0);
  73. #else
  74. enable_mmu_svc_mon(0);
  75. #endif
  76. arm_setup_romlib();
  77. }
  78. void bl2u_plat_arch_setup(void)
  79. {
  80. arm_bl2u_plat_arch_setup();
  81. }