arm_helpers.S 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2016-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. /* -----------------------------------------------------
  14. * unsigned int plat_my_core_pos(void)
  15. * This function uses the plat_arm_calc_core_pos()
  16. * definition to get the index of the calling CPU.
  17. * -----------------------------------------------------
  18. */
  19. func plat_my_core_pos
  20. ldcopr r0, MPIDR
  21. b plat_arm_calc_core_pos
  22. endfunc plat_my_core_pos
  23. /* -----------------------------------------------------
  24. * unsigned int plat_arm_calc_core_pos(uint64_t mpidr)
  25. * Helper function to calculate the core position.
  26. * With this function: CorePos = (ClusterId * 4) +
  27. * CoreId
  28. * -----------------------------------------------------
  29. */
  30. func plat_arm_calc_core_pos
  31. and r1, r0, #MPIDR_CPU_MASK
  32. and r0, r0, #MPIDR_CLUSTER_MASK
  33. add r0, r1, r0, LSR #6
  34. bx lr
  35. endfunc plat_arm_calc_core_pos
  36. /* ---------------------------------------------
  37. * int plat_crash_console_init(void)
  38. * Function to initialize the crash console
  39. * without a C Runtime to print crash report.
  40. * Clobber list : r0 - r3
  41. * ---------------------------------------------
  42. */
  43. func plat_crash_console_init
  44. ldr r0, =PLAT_ARM_CRASH_UART_BASE
  45. ldr r1, =PLAT_ARM_CRASH_UART_CLK_IN_HZ
  46. ldr r2, =ARM_CONSOLE_BAUDRATE
  47. b console_pl011_core_init
  48. endfunc plat_crash_console_init
  49. /* ---------------------------------------------
  50. * int plat_crash_console_putc(int c)
  51. * Function to print a character on the crash
  52. * console without a C Runtime.
  53. * Clobber list : r1 - r2
  54. * ---------------------------------------------
  55. */
  56. func plat_crash_console_putc
  57. ldr r1, =PLAT_ARM_CRASH_UART_BASE
  58. b console_pl011_core_putc
  59. endfunc plat_crash_console_putc
  60. /* ---------------------------------------------
  61. * void plat_crash_console_flush()
  62. * Function to force a write of all buffered
  63. * data that hasn't been output.
  64. * Out : void.
  65. * Clobber list : r0
  66. * ---------------------------------------------
  67. */
  68. func plat_crash_console_flush
  69. ldr r0, =PLAT_ARM_CRASH_UART_BASE
  70. b console_pl011_core_flush
  71. endfunc plat_crash_console_flush