plat_macros.S 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2018,2020, The Linux Foundation. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef __PLAT_MACROS_S__
  8. #define __PLAT_MACROS_S__
  9. #include <drivers/arm/gic_common.h>
  10. #include <drivers/arm/gicv2.h>
  11. #include <drivers/arm/gicv3.h>
  12. #include <platform_def.h>
  13. .section .rodata.gic_reg_name, "aS"
  14. /* Applicable only to GICv2 and GICv3 with SRE disabled (legacy mode) */
  15. gicc_regs:
  16. .asciz "gicc_hppir", "gicc_ahppir", "gicc_ctlr", ""
  17. /* Applicable only to GICv3 with SRE enabled */
  18. icc_regs:
  19. .asciz "icc_hppir0_el1", "icc_hppir1_el1", "icc_ctlr_el3", ""
  20. /* Registers common to both GICv2 and GICv3 */
  21. gicd_pend_reg:
  22. .asciz "gicd_ispendr regs (Offsets 0x200 - 0x278)\n" \
  23. " Offset:\t\t\tvalue\n"
  24. newline:
  25. .asciz "\n"
  26. spacer:
  27. .asciz ":\t\t0x"
  28. /** Macro : plat_crash_print_regs
  29. * This macro allows the crash reporting routine to print GIC registers
  30. * in case of an unhandled exception in BL31. This aids in debugging and
  31. * this macro can be defined to be empty in case GIC register reporting is
  32. * not desired.
  33. * The below required platform porting macro
  34. * prints out relevant GIC registers whenever an
  35. * unhandled exception is taken in BL31.
  36. * Clobbers: x0 - x10, x26, x27, sp
  37. * ---------------------------------------------
  38. */
  39. .macro plat_crash_print_regs
  40. print_gic_regs:
  41. ldr x26, =QTI_GICD_BASE
  42. ldr x27, =QTI_GICC_BASE
  43. /* Check for GICv3 system register access */
  44. mrs x7, id_aa64pfr0_el1
  45. ubfx x7, x7, #ID_AA64PFR0_GIC_SHIFT, #ID_AA64PFR0_GIC_WIDTH
  46. cmp x7, #1
  47. b.ne print_gicv2
  48. /* Check for SRE enable */
  49. mrs x8, ICC_SRE_EL3
  50. tst x8, #ICC_SRE_SRE_BIT
  51. b.eq print_gicv2
  52. /* Load the icc reg list to x6 */
  53. adr x6, icc_regs
  54. /* Load the icc regs to gp regs used by str_in_crash_buf_print */
  55. mrs x8, ICC_HPPIR0_EL1
  56. mrs x9, ICC_HPPIR1_EL1
  57. mrs x10, ICC_CTLR_EL3
  58. /* Store to the crash buf and print to console */
  59. bl str_in_crash_buf_print
  60. b print_gic_common
  61. print_gicv2:
  62. /* Load the gicc reg list to x6 */
  63. adr x6, gicc_regs
  64. /* Load the gicc regs to gp regs used by str_in_crash_buf_print */
  65. ldr w8, [x27, #GICC_HPPIR]
  66. ldr w9, [x27, #GICC_AHPPIR]
  67. ldr w10, [x27, #GICC_CTLR]
  68. /* Store to the crash buf and print to console */
  69. bl str_in_crash_buf_print
  70. print_gic_common:
  71. /* Print the GICD_ISPENDR regs */
  72. add x7, x26, #GICD_ISPENDR
  73. adr x4, gicd_pend_reg
  74. bl asm_print_str
  75. gicd_ispendr_loop:
  76. sub x4, x7, x26
  77. cmp x4, #0x280
  78. b.eq exit_print_gic_regs
  79. bl asm_print_hex
  80. adr x4, spacer
  81. bl asm_print_str
  82. ldr x4, [x7], #8
  83. bl asm_print_hex
  84. adr x4, newline
  85. bl asm_print_str
  86. b gicd_ispendr_loop
  87. exit_print_gic_regs:
  88. .endm
  89. #endif /* __PLAT_MACROS_S__ */