arm_helpers.S 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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