bl2u_entrypoint.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 bl2u_vector_table
  10. .globl bl2u_entrypoint
  11. vector_base bl2u_vector_table
  12. b bl2u_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 bl2u_entrypoint
  21. /*---------------------------------------------
  22. * Save from r1 the extents of the trusted ram
  23. * available to BL2U for future use.
  24. * r0 is not currently used.
  25. * ---------------------------------------------
  26. */
  27. mov r11, r1
  28. mov r10, r2
  29. /* ---------------------------------------------
  30. * Set the exception vector to something sane.
  31. * ---------------------------------------------
  32. */
  33. ldr r0, =bl2u_vector_table
  34. stcopr r0, VBAR
  35. isb
  36. /* --------------------------------------------------------
  37. * Enable the instruction cache - disable speculative loads
  38. * --------------------------------------------------------
  39. */
  40. ldcopr r0, SCTLR
  41. orr r0, r0, #SCTLR_I_BIT
  42. bic r0, r0, #SCTLR_DSSBS_BIT
  43. stcopr r0, SCTLR
  44. isb
  45. /* ---------------------------------------------
  46. * Since BL2U executes after BL1, it is assumed
  47. * here that BL1 has already has done the
  48. * necessary register initializations.
  49. * ---------------------------------------------
  50. */
  51. /* ---------------------------------------------
  52. * Invalidate the RW memory used by the BL2U
  53. * image. This includes the data and NOBITS
  54. * sections. This is done to safeguard against
  55. * possible corruption of this memory by dirty
  56. * cache lines in a system cache as a result of
  57. * use by an earlier boot loader stage.
  58. * ---------------------------------------------
  59. */
  60. ldr r0, =__RW_START__
  61. ldr r1, =__RW_END__
  62. sub r1, r1, r0
  63. bl inv_dcache_range
  64. /* ---------------------------------------------
  65. * Zero out NOBITS sections. There are 2 of them:
  66. * - the .bss section;
  67. * - the coherent memory section.
  68. * ---------------------------------------------
  69. */
  70. ldr r0, =__BSS_START__
  71. ldr r1, =__BSS_END__
  72. sub r1, r1, r0
  73. bl zeromem
  74. /* --------------------------------------------
  75. * Allocate a stack whose memory will be marked
  76. * as Normal-IS-WBWA when the MMU is enabled.
  77. * There is no risk of reading stale stack
  78. * memory after enabling the MMU as only the
  79. * primary cpu is running at the moment.
  80. * --------------------------------------------
  81. */
  82. bl plat_set_my_stack
  83. /* ---------------------------------------------
  84. * Initialize the stack protector canary before
  85. * any C code is called.
  86. * ---------------------------------------------
  87. */
  88. #if STACK_PROTECTOR_ENABLED
  89. bl update_stack_protector_canary
  90. #endif
  91. /* ---------------------------------------------
  92. * Perform early platform setup & platform
  93. * specific early arch. setup e.g. mmu setup
  94. * ---------------------------------------------
  95. */
  96. mov r0, r11
  97. mov r1, r10
  98. bl bl2u_early_platform_setup
  99. bl bl2u_plat_arch_setup
  100. /* ---------------------------------------------
  101. * Jump to main function.
  102. * ---------------------------------------------
  103. */
  104. bl bl2u_main
  105. /* ---------------------------------------------
  106. * Should never reach this point.
  107. * ---------------------------------------------
  108. */
  109. no_ret plat_panic_handler
  110. endfunc bl2u_entrypoint