hikey960_helpers.S 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * Copyright (c) 2017-2020, 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 <cortex_a53.h>
  9. #include <cortex_a73.h>
  10. #include "../hikey960_def.h"
  11. .globl plat_my_core_pos
  12. .globl platform_mem_init
  13. .globl plat_crash_console_init
  14. .globl plat_crash_console_putc
  15. .globl plat_crash_console_flush
  16. .globl plat_report_exception
  17. .globl plat_reset_handler
  18. .globl clr_ex
  19. .globl nop
  20. func plat_my_core_pos
  21. mrs x0, mpidr_el1
  22. and x1, x0, #MPIDR_CPU_MASK
  23. and x0, x0, #MPIDR_CLUSTER_MASK
  24. add x0, x1, x0, LSR #6
  25. ret
  26. endfunc plat_my_core_pos
  27. /* -----------------------------------------------------
  28. * void platform_mem_init(void);
  29. *
  30. * We don't need to carry out any memory initialization
  31. * on HIKEY. The Secure RAM is accessible straight away.
  32. * -----------------------------------------------------
  33. */
  34. func platform_mem_init
  35. ret
  36. endfunc platform_mem_init
  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, x1, x2
  42. * ---------------------------------------------
  43. */
  44. func plat_crash_console_init
  45. mov_imm x0, CRASH_CONSOLE_BASE
  46. mov_imm x1, PL011_UART_CLK_IN_HZ
  47. mov_imm x2, PL011_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, CRASH_CONSOLE_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 : x0, x1
  67. * ---------------------------------------------
  68. */
  69. func plat_crash_console_flush
  70. mov_imm x0, CRASH_CONSOLE_BASE
  71. b console_pl011_core_flush
  72. endfunc plat_crash_console_flush
  73. /* ---------------------------------------------
  74. * void plat_report_exception(unsigned int type)
  75. * Function to report an unhandled exception
  76. * with platform-specific means.
  77. * On HIKEY platform, it updates the LEDs
  78. * to indicate where we are
  79. * ---------------------------------------------
  80. */
  81. func plat_report_exception
  82. mov x8, x30
  83. /* Turn on LED according to x0 (0 -- f) */
  84. ldr x2, =0xf7020000
  85. and x1, x0, #1
  86. str w1, [x2, #4]
  87. and x1, x0, #2
  88. str w1, [x2, #8]
  89. and x1, x0, #4
  90. str w1, [x2, #16]
  91. and x1, x0, #8
  92. str w1, [x2, #32]
  93. mrs x2, currentel
  94. and x2, x2, #0x0c
  95. /* Check EL1 */
  96. cmp x2, #0x04
  97. beq plat_report_el1
  98. adr x4, plat_err_str
  99. bl asm_print_str
  100. adr x4, esr_el3_str
  101. bl asm_print_str
  102. mrs x4, esr_el3
  103. bl asm_print_hex
  104. adr x4, elr_el3_str
  105. bl asm_print_str
  106. mrs x4, elr_el3
  107. bl asm_print_hex
  108. b plat_report_end
  109. plat_report_el1:
  110. adr x4, plat_err_str
  111. bl asm_print_str
  112. adr x4, esr_el1_str
  113. bl asm_print_str
  114. mrs x4, esr_el1
  115. bl asm_print_hex
  116. adr x4, elr_el1_str
  117. bl asm_print_str
  118. mrs x4, elr_el1
  119. bl asm_print_hex
  120. plat_report_end:
  121. mov x30, x8
  122. ret
  123. endfunc plat_report_exception
  124. /* -----------------------------------------------------
  125. * void plat_reset_handler(void);
  126. * -----------------------------------------------------
  127. */
  128. func plat_reset_handler
  129. ret
  130. endfunc plat_reset_handler
  131. /* -----------------------------------------------------
  132. * void clrex(void);
  133. * -----------------------------------------------------
  134. */
  135. func clr_ex
  136. clrex
  137. ret
  138. endfunc clr_ex
  139. /* -----------------------------------------------------
  140. * void nop(void);
  141. * -----------------------------------------------------
  142. */
  143. func nop
  144. nop
  145. ret
  146. endfunc nop
  147. .section .rodata.rev_err_str, "aS"
  148. plat_err_str:
  149. .asciz "\nPlatform exception reporting:"
  150. esr_el3_str:
  151. .asciz "\nESR_EL3: "
  152. elr_el3_str:
  153. .asciz "\nELR_EL3: "
  154. esr_el1_str:
  155. .asciz "\nESR_EL1: "
  156. elr_el1_str:
  157. .asciz "\nELR_EL1: "