bl2_entrypoint.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. .globl bl2_vector_table
  10. .globl bl2_entrypoint
  11. vector_base bl2_vector_table
  12. b bl2_entrypoint
  13. b report_exception /* Undef */
  14. b report_exception /* SVC call */
  15. b report_prefetch_abort /* Prefetch abort */
  16. b report_data_abort /* Data abort */
  17. b report_exception /* Reserved */
  18. b report_exception /* IRQ */
  19. b report_exception /* FIQ */
  20. func bl2_entrypoint
  21. /*---------------------------------------------
  22. * Save arguments x0 - x3 from BL1 for future
  23. * use.
  24. * ---------------------------------------------
  25. */
  26. mov r9, r0
  27. mov r10, r1
  28. mov r11, r2
  29. mov r12, r3
  30. /* ---------------------------------------------
  31. * Set the exception vector to something sane.
  32. * ---------------------------------------------
  33. */
  34. ldr r0, =bl2_vector_table
  35. stcopr r0, VBAR
  36. isb
  37. /* --------------------------------------------------------
  38. * Enable the instruction cache - disable speculative loads
  39. * --------------------------------------------------------
  40. */
  41. ldcopr r0, SCTLR
  42. orr r0, r0, #SCTLR_I_BIT
  43. bic r0, r0, #SCTLR_DSSBS_BIT
  44. stcopr r0, SCTLR
  45. isb
  46. /* ---------------------------------------------
  47. * Since BL2 executes after BL1, it is assumed
  48. * here that BL1 has already has done the
  49. * necessary register initializations.
  50. * ---------------------------------------------
  51. */
  52. /* ---------------------------------------------
  53. * Invalidate the RW memory used by the BL2
  54. * image. This includes the data and NOBITS
  55. * sections. This is done to safeguard against
  56. * possible corruption of this memory by dirty
  57. * cache lines in a system cache as a result of
  58. * use by an earlier boot loader stage.
  59. * ---------------------------------------------
  60. */
  61. ldr r0, =__RW_START__
  62. ldr r1, =__RW_END__
  63. sub r1, r1, r0
  64. bl inv_dcache_range
  65. /* ---------------------------------------------
  66. * Zero out NOBITS sections. There are 2 of them:
  67. * - the .bss section;
  68. * - the coherent memory section.
  69. * ---------------------------------------------
  70. */
  71. ldr r0, =__BSS_START__
  72. ldr r1, =__BSS_END__
  73. sub r1, r1, r0
  74. bl zeromem
  75. #if USE_COHERENT_MEM
  76. ldr r0, =__COHERENT_RAM_START__
  77. ldr r1, =__COHERENT_RAM_END_UNALIGNED__
  78. sub r1, r1, r0
  79. bl zeromem
  80. #endif
  81. /* --------------------------------------------
  82. * Allocate a stack whose memory will be marked
  83. * as Normal-IS-WBWA when the MMU is enabled.
  84. * There is no risk of reading stale stack
  85. * memory after enabling the MMU as only the
  86. * primary cpu is running at the moment.
  87. * --------------------------------------------
  88. */
  89. bl plat_set_my_stack
  90. /* ---------------------------------------------
  91. * Initialize the stack protector canary before
  92. * any C code is called.
  93. * ---------------------------------------------
  94. */
  95. #if STACK_PROTECTOR_ENABLED
  96. bl update_stack_protector_canary
  97. #endif
  98. /* ---------------------------------------------
  99. * Perform BL2 setup
  100. * ---------------------------------------------
  101. */
  102. mov r0, r9
  103. mov r1, r10
  104. mov r2, r11
  105. mov r3, r12
  106. bl bl2_setup
  107. /* ---------------------------------------------
  108. * Jump to main function.
  109. * ---------------------------------------------
  110. */
  111. bl bl2_main
  112. /* ---------------------------------------------
  113. * Should never reach this point.
  114. * ---------------------------------------------
  115. */
  116. no_ret plat_panic_handler
  117. endfunc bl2_entrypoint