bl2_el3_entrypoint.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <platform_def.h>
  7. #include <arch.h>
  8. #include <asm_macros.S>
  9. #include <common/bl_common.h>
  10. #include <el3_common_macros.S>
  11. .globl bl2_entrypoint
  12. .globl bl2_el3_run_image
  13. .globl bl2_run_next_image
  14. #if BL2_IN_XIP_MEM
  15. #define FIXUP_SIZE 0
  16. #else
  17. #define FIXUP_SIZE ((BL2_LIMIT) - (BL2_BASE))
  18. #endif
  19. func bl2_entrypoint
  20. /* Save arguments x0-x3 from previous Boot loader */
  21. mov x20, x0
  22. mov x21, x1
  23. mov x22, x2
  24. mov x23, x3
  25. el3_entrypoint_common \
  26. _init_sctlr=1 \
  27. _warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS \
  28. _secondary_cold_boot=!COLD_BOOT_SINGLE_CPU \
  29. _init_memory=1 \
  30. _init_c_runtime=1 \
  31. _exception_vectors=bl2_el3_exceptions \
  32. _pie_fixup_size=FIXUP_SIZE
  33. /* ---------------------------------------------
  34. * Restore parameters of boot rom
  35. * ---------------------------------------------
  36. */
  37. mov x0, x20
  38. mov x1, x21
  39. mov x2, x22
  40. mov x3, x23
  41. /* ---------------------------------------------
  42. * Perform BL2 setup
  43. * ---------------------------------------------
  44. */
  45. bl bl2_el3_setup
  46. #if ENABLE_PAUTH
  47. /* ---------------------------------------------
  48. * Program APIAKey_EL1 and enable pointer authentication.
  49. * ---------------------------------------------
  50. */
  51. bl pauth_init_enable_el3
  52. #endif /* ENABLE_PAUTH */
  53. /* ---------------------------------------------
  54. * Jump to main function.
  55. * ---------------------------------------------
  56. */
  57. bl bl2_main
  58. /* ---------------------------------------------
  59. * Should never reach this point.
  60. * ---------------------------------------------
  61. */
  62. no_ret plat_panic_handler
  63. endfunc bl2_entrypoint
  64. func bl2_run_next_image
  65. mov x20,x0
  66. /* ---------------------------------------------
  67. * MMU needs to be disabled because both BL2 and BL31 execute
  68. * in EL3, and therefore share the same address space.
  69. * BL31 will initialize the address space according to its
  70. * own requirement.
  71. * ---------------------------------------------
  72. */
  73. bl disable_mmu_icache_el3
  74. tlbi alle3
  75. bl bl2_el3_plat_prepare_exit
  76. #if ENABLE_PAUTH
  77. /* ---------------------------------------------
  78. * Disable pointer authentication before jumping
  79. * to next boot image.
  80. * ---------------------------------------------
  81. */
  82. bl pauth_disable_el3
  83. #endif /* ENABLE_PAUTH */
  84. ldp x0, x1, [x20, #ENTRY_POINT_INFO_PC_OFFSET]
  85. msr elr_el3, x0
  86. msr spsr_el3, x1
  87. ldp x6, x7, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x30)]
  88. ldp x4, x5, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x20)]
  89. ldp x2, x3, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x10)]
  90. ldp x0, x1, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x0)]
  91. exception_return
  92. endfunc bl2_run_next_image