bl1_entrypoint.S 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (c) 2013-2021, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <common/bl_common.h>
  8. #include <el3_common_macros.S>
  9. .globl bl1_entrypoint
  10. .globl bl1_run_bl2_in_root
  11. /* -----------------------------------------------------
  12. * bl1_entrypoint() is the entry point into the trusted
  13. * firmware code when a cpu is released from warm or
  14. * cold reset.
  15. * -----------------------------------------------------
  16. */
  17. func bl1_entrypoint
  18. /* ---------------------------------------------------------------------
  19. * If the reset address is programmable then bl1_entrypoint() is
  20. * executed only on the cold boot path. Therefore, we can skip the warm
  21. * boot mailbox mechanism.
  22. * ---------------------------------------------------------------------
  23. */
  24. el3_entrypoint_common \
  25. _init_sctlr=1 \
  26. _warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS \
  27. _secondary_cold_boot=!COLD_BOOT_SINGLE_CPU \
  28. _init_memory=1 \
  29. _init_c_runtime=1 \
  30. _exception_vectors=bl1_exceptions \
  31. _pie_fixup_size=0
  32. /* --------------------------------------------------------------------
  33. * Perform BL1 setup
  34. * --------------------------------------------------------------------
  35. */
  36. bl bl1_setup
  37. #if ENABLE_PAUTH
  38. /* --------------------------------------------------------------------
  39. * Program APIAKey_EL1 and enable pointer authentication.
  40. * --------------------------------------------------------------------
  41. */
  42. bl pauth_init_enable_el3
  43. #endif /* ENABLE_PAUTH */
  44. /* --------------------------------------------------------------------
  45. * Initialize platform and jump to our c-entry point
  46. * for this type of reset.
  47. * --------------------------------------------------------------------
  48. */
  49. bl bl1_main
  50. #if ENABLE_PAUTH
  51. /* --------------------------------------------------------------------
  52. * Disable pointer authentication before jumping to next boot image.
  53. * --------------------------------------------------------------------
  54. */
  55. bl pauth_disable_el3
  56. #endif /* ENABLE_PAUTH */
  57. /* --------------------------------------------------
  58. * Do the transition to next boot image.
  59. * --------------------------------------------------
  60. */
  61. #if ENABLE_RME
  62. b bl1_run_bl2_in_root
  63. #else
  64. b el3_exit
  65. #endif
  66. endfunc bl1_entrypoint
  67. /* -----------------------------------------------------
  68. * void bl1_run_bl2_in_root();
  69. * This function runs BL2 in root/EL3 when RME is enabled.
  70. * -----------------------------------------------------
  71. */
  72. func bl1_run_bl2_in_root
  73. /* read bl2_ep_info */
  74. adrp x20, bl2_ep_info
  75. add x20, x20, :lo12:bl2_ep_info
  76. ldr x20, [x20]
  77. /* ---------------------------------------------
  78. * MMU needs to be disabled because BL2 executes
  79. * in EL3. It will initialize the address space
  80. * according to its own requirements.
  81. * ---------------------------------------------
  82. */
  83. bl disable_mmu_icache_el3
  84. tlbi alle3
  85. ldp x0, x1, [x20, #ENTRY_POINT_INFO_PC_OFFSET]
  86. msr elr_el3, x0
  87. msr spsr_el3, x1
  88. ldp x6, x7, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x30)]
  89. ldp x4, x5, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x20)]
  90. ldp x2, x3, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x10)]
  91. ldp x0, x1, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x0)]
  92. exception_return
  93. endfunc bl1_run_bl2_in_root