bl1_entrypoint.S 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Copyright (c) 2016-2019, 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_exception /* Prefetch abort */
  24. b report_exception /* 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. /* -----------------------------------------------------
  49. * Perform BL1 setup
  50. * -----------------------------------------------------
  51. */
  52. bl bl1_setup
  53. /* -----------------------------------------------------
  54. * Jump to main function.
  55. * -----------------------------------------------------
  56. */
  57. bl bl1_main
  58. /* -----------------------------------------------------
  59. * Jump to next image.
  60. * -----------------------------------------------------
  61. */
  62. /*
  63. * Get the smc_context for next BL image,
  64. * program the gp/system registers and save it in `r4`.
  65. */
  66. bl smc_get_next_ctx
  67. mov r4, r0
  68. /* Only turn-off MMU if going to secure world */
  69. ldr r5, [r4, #SMC_CTX_SCR]
  70. tst r5, #SCR_NS_BIT
  71. bne skip_mmu_off
  72. /*
  73. * MMU needs to be disabled because both BL1 and BL2/BL2U execute
  74. * in PL1, and therefore share the same address space.
  75. * BL2/BL2U will initialize the address space according to its
  76. * own requirement.
  77. */
  78. bl disable_mmu_icache_secure
  79. stcopr r0, TLBIALL
  80. dsb sy
  81. isb
  82. skip_mmu_off:
  83. /* Restore smc_context from `r4` and exit secure monitor mode. */
  84. mov r0, r4
  85. monitor_exit
  86. endfunc bl1_entrypoint