bl2u_entrypoint.S 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright (c) 2015-2021, 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_entrypoint
  10. func bl2u_entrypoint
  11. /*---------------------------------------------
  12. * Store the extents of the tzram available to
  13. * BL2U and other platform specific information
  14. * for future use. x0 is currently not used.
  15. * ---------------------------------------------
  16. */
  17. mov x20, x1
  18. mov x21, x2
  19. /* ---------------------------------------------
  20. * Set the exception vector to something sane.
  21. * ---------------------------------------------
  22. */
  23. adr x0, early_exceptions
  24. msr vbar_el1, x0
  25. isb
  26. /* ---------------------------------------------
  27. * Enable the SError interrupt now that the
  28. * exception vectors have been setup.
  29. * ---------------------------------------------
  30. */
  31. msr daifclr, #DAIF_ABT_BIT
  32. /* ---------------------------------------------
  33. * Enable the instruction cache, stack pointer
  34. * and data access alignment checks and disable
  35. * speculative loads.
  36. * ---------------------------------------------
  37. */
  38. mov x1, #(SCTLR_I_BIT | SCTLR_A_BIT | SCTLR_SA_BIT)
  39. mrs x0, sctlr_el1
  40. orr x0, x0, x1
  41. bic x0, x0, #SCTLR_DSSBS_BIT
  42. msr sctlr_el1, x0
  43. isb
  44. /* ---------------------------------------------
  45. * Invalidate the RW memory used by the BL2U
  46. * image. This includes the data and NOBITS
  47. * sections. This is done to safeguard against
  48. * possible corruption of this memory by dirty
  49. * cache lines in a system cache as a result of
  50. * use by an earlier boot loader stage.
  51. * ---------------------------------------------
  52. */
  53. adr x0, __RW_START__
  54. adr x1, __RW_END__
  55. sub x1, x1, x0
  56. bl inv_dcache_range
  57. /* ---------------------------------------------
  58. * Zero out NOBITS sections. There are 2 of them:
  59. * - the .bss section;
  60. * - the coherent memory section.
  61. * ---------------------------------------------
  62. */
  63. adrp x0, __BSS_START__
  64. add x0, x0, :lo12:__BSS_START__
  65. adrp x1, __BSS_END__
  66. add x1, x1, :lo12:__BSS_END__
  67. sub x1, x1, x0
  68. bl zeromem
  69. /* --------------------------------------------
  70. * Allocate a stack whose memory will be marked
  71. * as Normal-IS-WBWA when the MMU is enabled.
  72. * There is no risk of reading stale stack
  73. * memory after enabling the MMU as only the
  74. * primary cpu is running at the moment.
  75. * --------------------------------------------
  76. */
  77. bl plat_set_my_stack
  78. /* ---------------------------------------------
  79. * Initialize the stack protector canary before
  80. * any C code is called.
  81. * ---------------------------------------------
  82. */
  83. #if STACK_PROTECTOR_ENABLED
  84. bl update_stack_protector_canary
  85. #endif
  86. /* ---------------------------------------------
  87. * Perform early platform setup & platform
  88. * specific early arch. setup e.g. mmu setup
  89. * ---------------------------------------------
  90. */
  91. mov x0, x20
  92. mov x1, x21
  93. bl bl2u_early_platform_setup
  94. bl bl2u_plat_arch_setup
  95. #if ENABLE_PAUTH
  96. /* ---------------------------------------------
  97. * Program APIAKey_EL1
  98. * and enable pointer authentication.
  99. * ---------------------------------------------
  100. */
  101. bl pauth_init_enable_el1
  102. #endif
  103. /* ---------------------------------------------
  104. * Jump to bl2u_main function.
  105. * ---------------------------------------------
  106. */
  107. bl bl2u_main
  108. /* ---------------------------------------------
  109. * Should never reach this point.
  110. * ---------------------------------------------
  111. */
  112. no_ret plat_panic_handler
  113. endfunc bl2u_entrypoint