plat_macros.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (c) 2018, Arm Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2021-2022, Xilinx, Inc. All rights reserved.
  4. * Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef PLAT_MACROS_S
  9. #define PLAT_MACROS_S
  10. #include <drivers/arm/gic_common.h>
  11. #include <drivers/arm/gicv2.h>
  12. #include <drivers/arm/gicv3.h>
  13. #include "../include/platform_def.h"
  14. .section .rodata.gic_reg_name, "aS"
  15. /* Applicable only to GICv2 and GICv3 with SRE disabled (legacy mode) */
  16. gicc_regs:
  17. .asciz "gicc_hppir", "gicc_ahppir", "gicc_ctlr", ""
  18. /* Applicable only to GICv3 with SRE enabled */
  19. icc_regs:
  20. .asciz "icc_hppir0_el1", "icc_hppir1_el1", "icc_ctlr_el3", ""
  21. /* Registers common to both GICv2 and GICv3 */
  22. gicd_pend_reg:
  23. .asciz "gicd_ispendr regs (Offsets 0x200 - 0x278)\n Offset:\t\t\tvalue\n"
  24. newline:
  25. .asciz "\n"
  26. spacer:
  27. .asciz ":\t\t0x"
  28. /* ---------------------------------------------
  29. * The below utility macro prints out relevant GIC
  30. * registers whenever an unhandled exception is
  31. * taken in BL31 on platform.
  32. * Expects: GICD base in x16, GICC base in x17
  33. * Clobbers: x0 - x10, sp
  34. * ---------------------------------------------
  35. */
  36. .macro _print_gic_regs
  37. /* Check for GICv3 system register access */
  38. mrs x7, id_aa64pfr0_el1
  39. ubfx x7, x7, #ID_AA64PFR0_GIC_SHIFT, #ID_AA64PFR0_GIC_WIDTH
  40. cmp x7, #1
  41. b.ne print_gicv2
  42. /* Check for SRE enable */
  43. mrs x8, ICC_SRE_EL3
  44. tst x8, #ICC_SRE_SRE_BIT
  45. b.eq print_gicv2
  46. /* Load the icc reg list to x6 */
  47. adr x6, icc_regs
  48. /* Load the icc regs to gp regs used by str_in_crash_buf_print */
  49. mrs x8, ICC_HPPIR0_EL1
  50. mrs x9, ICC_HPPIR1_EL1
  51. mrs x10, ICC_CTLR_EL3
  52. /* Store to the crash buf and print to console */
  53. bl str_in_crash_buf_print
  54. b print_gic_common
  55. print_gicv2:
  56. /* Load the gicc reg list to x6 */
  57. adr x6, gicc_regs
  58. /* Load the gicc regs to gp regs used by str_in_crash_buf_print */
  59. ldr w8, [x17, #GICC_HPPIR]
  60. ldr w9, [x17, #GICC_AHPPIR]
  61. ldr w10, [x17, #GICC_CTLR]
  62. /* Store to the crash buf and print to console */
  63. bl str_in_crash_buf_print
  64. print_gic_common:
  65. /* Print the GICD_ISPENDR regs */
  66. add x7, x16, #GICD_ISPENDR
  67. adr x4, gicd_pend_reg
  68. bl asm_print_str
  69. gicd_ispendr_loop:
  70. sub x4, x7, x16
  71. cmp x4, #0x280
  72. b.eq exit_print_gic_regs
  73. bl asm_print_hex
  74. adr x4, spacer
  75. bl asm_print_str
  76. ldr x4, [x7], #8
  77. bl asm_print_hex
  78. adr x4, newline
  79. bl asm_print_str
  80. b gicd_ispendr_loop
  81. exit_print_gic_regs:
  82. .endm
  83. /* ---------------------------------------------
  84. * The below required platform porting macro
  85. * prints out relevant GIC and CCI registers
  86. * whenever an unhandled exception is taken in
  87. * BL31.
  88. * Clobbers: x0 - x10, x16, x17, sp
  89. * ---------------------------------------------
  90. */
  91. .macro plat_crash_print_regs
  92. /*
  93. * Empty for now to handle more platforms variant.
  94. * Uncomment it when versions are stable
  95. */
  96. /*
  97. mov_imm x17, PLAT_GICD_BASE_VALUE
  98. mov_imm x16, PLAT_GICR_BASE_VALUE
  99. _print_gic_regs
  100. */
  101. .endm
  102. #endif /* PLAT_MACROS_S */