arm_helpers.S 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <asm_macros.S>
  7. #include <platform_def.h>
  8. .weak plat_arm_calc_core_pos
  9. .weak plat_my_core_pos
  10. .globl plat_crash_console_init
  11. .globl plat_crash_console_putc
  12. .globl plat_crash_console_flush
  13. .globl platform_mem_init
  14. /* -----------------------------------------------------
  15. * unsigned int plat_my_core_pos(void)
  16. * This function uses the plat_arm_calc_core_pos()
  17. * definition to get the index of the calling CPU.
  18. * -----------------------------------------------------
  19. */
  20. func plat_my_core_pos
  21. mrs x0, mpidr_el1
  22. b plat_arm_calc_core_pos
  23. endfunc plat_my_core_pos
  24. /* -----------------------------------------------------
  25. * unsigned int plat_arm_calc_core_pos(u_register_t mpidr)
  26. * Helper function to calculate the core position.
  27. * With this function: CorePos = (ClusterId * 4) +
  28. * CoreId
  29. * -----------------------------------------------------
  30. */
  31. func plat_arm_calc_core_pos
  32. and x1, x0, #MPIDR_CPU_MASK
  33. and x0, x0, #MPIDR_CLUSTER_MASK
  34. add x0, x1, x0, LSR #6
  35. ret
  36. endfunc plat_arm_calc_core_pos
  37. /* ---------------------------------------------
  38. * int plat_crash_console_init(void)
  39. * Function to initialize the crash console
  40. * without a C Runtime to print crash report.
  41. * Clobber list : x0 - x4
  42. * ---------------------------------------------
  43. */
  44. func plat_crash_console_init
  45. mov_imm x0, PLAT_ARM_CRASH_UART_BASE
  46. mov_imm x1, PLAT_ARM_CRASH_UART_CLK_IN_HZ
  47. mov_imm x2, ARM_CONSOLE_BAUDRATE
  48. b console_pl011_core_init
  49. endfunc plat_crash_console_init
  50. /* ---------------------------------------------
  51. * int plat_crash_console_putc(int c)
  52. * Function to print a character on the crash
  53. * console without a C Runtime.
  54. * Clobber list : x1, x2
  55. * ---------------------------------------------
  56. */
  57. func plat_crash_console_putc
  58. mov_imm x1, PLAT_ARM_CRASH_UART_BASE
  59. b console_pl011_core_putc
  60. endfunc plat_crash_console_putc
  61. /* ---------------------------------------------
  62. * void plat_crash_console_flush()
  63. * Function to force a write of all buffered
  64. * data that hasn't been output.
  65. * Out : void.
  66. * Clobber list : r0
  67. * ---------------------------------------------
  68. */
  69. func plat_crash_console_flush
  70. mov_imm x0, PLAT_ARM_CRASH_UART_BASE
  71. b console_pl011_core_flush
  72. endfunc plat_crash_console_flush
  73. /* ---------------------------------------------------------------------
  74. * We don't need to carry out any memory initialization on ARM
  75. * platforms. The Secure RAM is accessible straight away.
  76. * ---------------------------------------------------------------------
  77. */
  78. func platform_mem_init
  79. ret
  80. endfunc platform_mem_init
  81. /*
  82. * Need to use coherent stack when ARM Cryptocell is used to autheticate images
  83. * since Cryptocell uses DMA to transfer data and it is not coherent with the
  84. * AP CPU.
  85. */
  86. #if ARM_CRYPTOCELL_INTEG
  87. #if defined(IMAGE_BL1) || defined(IMAGE_BL2)
  88. .globl plat_get_my_stack
  89. .globl plat_set_my_stack
  90. .local platform_coherent_stacks
  91. /* -------------------------------------------------------
  92. * uintptr_t plat_get_my_stack ()
  93. *
  94. * For cold-boot BL images, only the primary CPU needs a
  95. * stack. This function returns the stack pointer for a
  96. * stack allocated in coherent memory.
  97. * -------------------------------------------------------
  98. */
  99. func plat_get_my_stack
  100. get_up_stack platform_coherent_stacks, PLATFORM_STACK_SIZE
  101. ret
  102. endfunc plat_get_my_stack
  103. /* -------------------------------------------------------
  104. * void plat_set_my_stack ()
  105. *
  106. * For cold-boot BL images, only the primary CPU needs a
  107. * stack. This function sets the stack pointer to a stack
  108. * allocated in coherent memory.
  109. * -------------------------------------------------------
  110. */
  111. func plat_set_my_stack
  112. get_up_stack platform_coherent_stacks, PLATFORM_STACK_SIZE
  113. mov sp, x0
  114. ret
  115. endfunc plat_set_my_stack
  116. /* ----------------------------------------------------
  117. * Single cpu stack in coherent memory.
  118. * ----------------------------------------------------
  119. */
  120. declare_stack platform_coherent_stacks, .tzfw_coherent_mem, \
  121. PLATFORM_STACK_SIZE, 1, CACHE_WRITEBACK_GRANULE
  122. #endif /* defined(IMAGE_BL1) || defined(IMAGE_BL2) */
  123. #endif /* ARM_CRYPTOCELL_INTEG */