bl2_interrupt_error.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch_helpers.h>
  7. #include <common/bl_common.h>
  8. #include <common/debug.h>
  9. #include <common/runtime_svc.h>
  10. #include <drivers/arm/gicv2.h>
  11. #include <lib/mmio.h>
  12. #include "rcar_def.h"
  13. #define SWDT_ERROR_ID (1024U)
  14. #define SWDT_ERROR_TYPE (16U)
  15. #define SWDT_CHAR_MAX (13U)
  16. extern void rcar_swdt_release(void);
  17. void bl2_interrupt_error_id(uint32_t int_id)
  18. {
  19. ERROR("\n");
  20. if (int_id >= SWDT_ERROR_ID) {
  21. ERROR("Unhandled exception occurred.\n");
  22. ERROR(" Exception type = FIQ_SP_EL0\n");
  23. panic();
  24. }
  25. /* Clear the interrupt request */
  26. gicv2_end_of_interrupt((uint32_t) int_id);
  27. rcar_swdt_release();
  28. ERROR("Unhandled exception occurred.\n");
  29. ERROR(" Exception type = FIQ_SP_EL0\n");
  30. ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
  31. ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
  32. ERROR(" ESR_EL3 = 0x%x\n", (uint32_t) read_esr_el3());
  33. ERROR(" FAR_EL3 = 0x%x\n", (uint32_t) read_far_el3());
  34. ERROR("\n");
  35. panic();
  36. }
  37. void bl2_interrupt_error_type(uint32_t ex_type)
  38. {
  39. const uint8_t interrupt_ex[SWDT_ERROR_TYPE][SWDT_CHAR_MAX] = {
  40. "SYNC SP EL0",
  41. "IRQ SP EL0",
  42. "FIQ SP EL0",
  43. "SERR SP EL0",
  44. "SYNC SP ELx",
  45. "IRQ SP ELx",
  46. "FIQ SP ELx",
  47. "SERR SP ELx",
  48. "SYNC AARCH64",
  49. "IRQ AARCH64",
  50. "FIQ AARCH64",
  51. "SERR AARCH64",
  52. "SYNC AARCH32",
  53. "IRQ AARCH32",
  54. "FIQ AARCH32",
  55. "SERR AARCH32"
  56. };
  57. char msg[128];
  58. /* Clear the interrupt request */
  59. if (ex_type >= SWDT_ERROR_TYPE) {
  60. ERROR("\n");
  61. ERROR("Unhandled exception occurred.\n");
  62. ERROR(" Exception type = Unknown (%d)\n", ex_type);
  63. goto loop;
  64. }
  65. rcar_swdt_release();
  66. ERROR("\n");
  67. ERROR("Unhandled exception occurred.\n");
  68. snprintf(msg, sizeof(msg), " Exception type = %s\n",
  69. &interrupt_ex[ex_type][0]);
  70. ERROR("%s", msg);
  71. switch (ex_type) {
  72. case SYNC_EXCEPTION_SP_EL0:
  73. ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
  74. ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
  75. ERROR(" ESR_EL3 = 0x%x\n", (uint32_t) read_esr_el3());
  76. ERROR(" FAR_EL3 = 0x%x\n", (uint32_t) read_far_el3());
  77. break;
  78. case IRQ_SP_EL0:
  79. ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
  80. ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
  81. ERROR(" IAR_EL3 = 0x%x\n", gicv2_acknowledge_interrupt());
  82. break;
  83. case FIQ_SP_EL0:
  84. ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
  85. ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
  86. ERROR(" IAR_EL3 = 0x%x\n", gicv2_acknowledge_interrupt());
  87. break;
  88. case SERROR_SP_EL0:
  89. ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
  90. ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
  91. ERROR(" ESR_EL3 = 0x%x\n", (uint32_t) read_esr_el3());
  92. ERROR(" FAR_EL3 = 0x%x\n", (uint32_t) read_far_el3());
  93. break;
  94. default:
  95. break;
  96. }
  97. loop:
  98. ERROR("\n");
  99. panic();
  100. }