bl1_entrypoint.S 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (c) 2016-2022, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <asm_macros.S>
  8. #include <common/bl_common.h>
  9. #include <context.h>
  10. #include <el3_common_macros.S>
  11. #include <smccc_helpers.h>
  12. #include <smccc_macros.S>
  13. .globl bl1_vector_table
  14. .globl bl1_entrypoint
  15. /* -----------------------------------------------------
  16. * Setup the vector table to support SVC & MON mode.
  17. * -----------------------------------------------------
  18. */
  19. vector_base bl1_vector_table
  20. b bl1_entrypoint
  21. b report_exception /* Undef */
  22. b bl1_aarch32_smc_handler /* SMC call */
  23. b report_prefetch_abort /* Prefetch abort */
  24. b report_data_abort /* Data abort */
  25. b report_exception /* Reserved */
  26. b report_exception /* IRQ */
  27. b report_exception /* FIQ */
  28. /* -----------------------------------------------------
  29. * bl1_entrypoint() is the entry point into the trusted
  30. * firmware code when a cpu is released from warm or
  31. * cold reset.
  32. * -----------------------------------------------------
  33. */
  34. func bl1_entrypoint
  35. /* ---------------------------------------------------------------------
  36. * If the reset address is programmable then bl1_entrypoint() is
  37. * executed only on the cold boot path. Therefore, we can skip the warm
  38. * boot mailbox mechanism.
  39. * ---------------------------------------------------------------------
  40. */
  41. el3_entrypoint_common \
  42. _init_sctlr=1 \
  43. _warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS \
  44. _secondary_cold_boot=!COLD_BOOT_SINGLE_CPU \
  45. _init_memory=1 \
  46. _init_c_runtime=1 \
  47. _exception_vectors=bl1_vector_table \
  48. _pie_fixup_size=0
  49. /* -----------------------------------------------------
  50. * Perform BL1 setup
  51. * -----------------------------------------------------
  52. */
  53. bl bl1_setup
  54. /* -----------------------------------------------------
  55. * Jump to main function.
  56. * -----------------------------------------------------
  57. */
  58. bl bl1_main
  59. /* -----------------------------------------------------
  60. * Jump to next image.
  61. * -----------------------------------------------------
  62. */
  63. /*
  64. * Get the smc_context for next BL image,
  65. * program the gp/system registers and save it in `r4`.
  66. */
  67. bl smc_get_next_ctx
  68. mov r4, r0
  69. /* Only turn-off MMU if going to secure world */
  70. ldr r5, [r4, #SMC_CTX_SCR]
  71. tst r5, #SCR_NS_BIT
  72. bne skip_mmu_off
  73. /*
  74. * MMU needs to be disabled because both BL1 and BL2/BL2U execute
  75. * in PL1, and therefore share the same address space.
  76. * BL2/BL2U will initialize the address space according to its
  77. * own requirement.
  78. */
  79. bl disable_mmu_icache_secure
  80. stcopr r0, TLBIALL
  81. dsb sy
  82. isb
  83. skip_mmu_off:
  84. /* Restore smc_context from `r4` and exit secure monitor mode. */
  85. mov r0, r4
  86. monitor_exit
  87. endfunc bl1_entrypoint