plat_macros.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) 2018, Arm Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. 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 "../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 Offset:\t\t\tvalue\n"
  23. newline:
  24. .asciz "\n"
  25. spacer:
  26. .asciz ":\t\t0x"
  27. /* ---------------------------------------------
  28. * The below utility macro prints out relevant GIC
  29. * registers whenever an unhandled exception is
  30. * taken in BL31 on Versal platform.
  31. * Expects: GICD base in x16, GICC base in x17
  32. * Clobbers: x0 - x10, sp
  33. * ---------------------------------------------
  34. */
  35. .macro versal_print_gic_regs
  36. /* Check for GICv3 system register access */
  37. mrs x7, id_aa64pfr0_el1
  38. ubfx x7, x7, #ID_AA64PFR0_GIC_SHIFT, #ID_AA64PFR0_GIC_WIDTH
  39. cmp x7, #1
  40. b.ne print_gicv2
  41. /* Check for SRE enable */
  42. mrs x8, ICC_SRE_EL3
  43. tst x8, #ICC_SRE_SRE_BIT
  44. b.eq print_gicv2
  45. /* Load the icc reg list to x6 */
  46. adr x6, icc_regs
  47. /* Load the icc regs to gp regs used by str_in_crash_buf_print */
  48. mrs x8, ICC_HPPIR0_EL1
  49. mrs x9, ICC_HPPIR1_EL1
  50. mrs x10, ICC_CTLR_EL3
  51. /* Store to the crash buf and print to console */
  52. bl str_in_crash_buf_print
  53. b print_gic_common
  54. print_gicv2:
  55. /* Load the gicc reg list to x6 */
  56. adr x6, gicc_regs
  57. /* Load the gicc regs to gp regs used by str_in_crash_buf_print */
  58. ldr w8, [x17, #GICC_HPPIR]
  59. ldr w9, [x17, #GICC_AHPPIR]
  60. ldr w10, [x17, #GICC_CTLR]
  61. /* Store to the crash buf and print to console */
  62. bl str_in_crash_buf_print
  63. print_gic_common:
  64. /* Print the GICD_ISPENDR regs */
  65. add x7, x16, #GICD_ISPENDR
  66. adr x4, gicd_pend_reg
  67. bl asm_print_str
  68. gicd_ispendr_loop:
  69. sub x4, x7, x16
  70. cmp x4, #0x280
  71. b.eq exit_print_gic_regs
  72. bl asm_print_hex
  73. adr x4, spacer
  74. bl asm_print_str
  75. ldr x4, [x7], #8
  76. bl asm_print_hex
  77. adr x4, newline
  78. bl asm_print_str
  79. b gicd_ispendr_loop
  80. exit_print_gic_regs:
  81. .endm
  82. /* ---------------------------------------------
  83. * The below required platform porting macro
  84. * prints out relevant GIC and CCI registers
  85. * whenever an unhandled exception is taken in
  86. * BL31.
  87. * Clobbers: x0 - x10, x16, x17, sp
  88. * ---------------------------------------------
  89. */
  90. .macro plat_crash_print_regs
  91. mov_imm x17, PLAT_ARM_GICD_BASE
  92. mov_imm x16, PLAT_ARM_GICR_BASE
  93. versal_print_gic_regs
  94. .endm
  95. #endif /* PLAT_MACROS_S */