hikey_helpers.S 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 <hikey_def.h>
  9. .globl plat_my_core_pos
  10. .globl platform_mem_init
  11. .globl plat_crash_console_init
  12. .globl plat_crash_console_putc
  13. .globl plat_crash_console_flush
  14. .globl plat_report_exception
  15. .globl plat_reset_handler
  16. func plat_my_core_pos
  17. mrs x0, mpidr_el1
  18. and x1, x0, #MPIDR_CPU_MASK
  19. and x0, x0, #MPIDR_CLUSTER_MASK
  20. add x0, x1, x0, LSR #6
  21. ret
  22. endfunc plat_my_core_pos
  23. /* -----------------------------------------------------
  24. * void platform_mem_init(void);
  25. *
  26. * We don't need to carry out any memory initialization
  27. * on HIKEY. The Secure RAM is accessible straight away.
  28. * -----------------------------------------------------
  29. */
  30. func platform_mem_init
  31. ret
  32. endfunc platform_mem_init
  33. /* ---------------------------------------------
  34. * int plat_crash_console_init(void)
  35. * Function to initialize the crash console
  36. * without a C Runtime to print crash report.
  37. * Clobber list : x0, x1, x2
  38. * ---------------------------------------------
  39. */
  40. func plat_crash_console_init
  41. mov_imm x0, CRASH_CONSOLE_BASE
  42. mov_imm x1, PL011_UART_CLK_IN_HZ
  43. mov_imm x2, PL011_BAUDRATE
  44. b console_pl011_core_init
  45. endfunc plat_crash_console_init
  46. /* ---------------------------------------------
  47. * int plat_crash_console_putc(int c)
  48. * Function to print a character on the crash
  49. * console without a C Runtime.
  50. * Clobber list : x1, x2
  51. * ---------------------------------------------
  52. */
  53. func plat_crash_console_putc
  54. mov_imm x1, CRASH_CONSOLE_BASE
  55. b console_pl011_core_putc
  56. endfunc plat_crash_console_putc
  57. /* ---------------------------------------------
  58. * void plat_crash_console_flush()
  59. * Function to force a write of all buffered
  60. * data that hasn't been output.
  61. * Out : void.
  62. * Clobber list : x0, x1
  63. * ---------------------------------------------
  64. */
  65. func plat_crash_console_flush
  66. mov_imm x0, CRASH_CONSOLE_BASE
  67. b console_pl011_core_flush
  68. endfunc plat_crash_console_flush
  69. /* ---------------------------------------------
  70. * void plat_report_exception(unsigned int type)
  71. * Function to report an unhandled exception
  72. * with platform-specific means.
  73. * On HIKEY platform, it updates the LEDs
  74. * to indicate where we are
  75. * ---------------------------------------------
  76. */
  77. func plat_report_exception
  78. mov x8, x30
  79. /* Turn on LED according to x0 (0 -- f) */
  80. ldr x2, =0xf7020000
  81. and x1, x0, #1
  82. str w1, [x2, #4]
  83. and x1, x0, #2
  84. str w1, [x2, #8]
  85. and x1, x0, #4
  86. str w1, [x2, #16]
  87. and x1, x0, #8
  88. str w1, [x2, #32]
  89. mrs x2, currentel
  90. and x2, x2, #0xc0
  91. /* Check EL1 */
  92. cmp x2, #0x04
  93. beq plat_report_el1
  94. adr x4, plat_err_str
  95. bl asm_print_str
  96. adr x4, esr_el3_str
  97. bl asm_print_str
  98. mrs x4, esr_el3
  99. bl asm_print_hex
  100. adr x4, elr_el3_str
  101. bl asm_print_str
  102. mrs x4, elr_el3
  103. bl asm_print_hex
  104. b plat_report_end
  105. plat_report_el1:
  106. adr x4, plat_err_str
  107. bl asm_print_str
  108. adr x4, esr_el1_str
  109. bl asm_print_str
  110. mrs x4, esr_el1
  111. bl asm_print_hex
  112. adr x4, elr_el1_str
  113. bl asm_print_str
  114. mrs x4, elr_el1
  115. bl asm_print_hex
  116. plat_report_end:
  117. mov x30, x8
  118. ret
  119. endfunc plat_report_exception
  120. /* -----------------------------------------------------
  121. * void plat_reset_handler(void);
  122. * -----------------------------------------------------
  123. */
  124. func plat_reset_handler
  125. ret
  126. endfunc plat_reset_handler
  127. .section .rodata.rev_err_str, "aS"
  128. plat_err_str:
  129. .asciz "\nPlatform exception reporting:"
  130. esr_el3_str:
  131. .asciz "\nESR_EL3: "
  132. elr_el3_str:
  133. .asciz "\nELR_EL3: "
  134. esr_el1_str:
  135. .asciz "\nESR_EL1: "
  136. elr_el1_str:
  137. .asciz "\nELR_EL1: "