interrupts_64.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2013
  4. * David Feng <fenghua@phytium.com.cn>
  5. */
  6. #include <common.h>
  7. #include <irq_func.h>
  8. #include <linux/compiler.h>
  9. #include <efi_loader.h>
  10. DECLARE_GLOBAL_DATA_PTR;
  11. int interrupt_init(void)
  12. {
  13. return 0;
  14. }
  15. void enable_interrupts(void)
  16. {
  17. return;
  18. }
  19. int disable_interrupts(void)
  20. {
  21. return 0;
  22. }
  23. static void show_efi_loaded_images(struct pt_regs *regs)
  24. {
  25. efi_print_image_infos((void *)regs->elr);
  26. }
  27. static void dump_instr(struct pt_regs *regs)
  28. {
  29. u32 *addr = (u32 *)(regs->elr & ~3UL);
  30. int i;
  31. printf("Code: ");
  32. for (i = -4; i < 1; i++)
  33. printf(i == 0 ? "(%08x) " : "%08x ", addr[i]);
  34. printf("\n");
  35. }
  36. void show_regs(struct pt_regs *regs)
  37. {
  38. int i;
  39. if (gd->flags & GD_FLG_RELOC)
  40. printf("elr: %016lx lr : %016lx (reloc)\n",
  41. regs->elr - gd->reloc_off,
  42. regs->regs[30] - gd->reloc_off);
  43. printf("elr: %016lx lr : %016lx\n", regs->elr, regs->regs[30]);
  44. for (i = 0; i < 29; i += 2)
  45. printf("x%-2d: %016lx x%-2d: %016lx\n",
  46. i, regs->regs[i], i+1, regs->regs[i+1]);
  47. printf("\n");
  48. dump_instr(regs);
  49. }
  50. /*
  51. * do_bad_sync handles the impossible case in the Synchronous Abort vector.
  52. */
  53. void do_bad_sync(struct pt_regs *pt_regs, unsigned int esr)
  54. {
  55. efi_restore_gd();
  56. printf("Bad mode in \"Synchronous Abort\" handler, esr 0x%08x\n", esr);
  57. show_regs(pt_regs);
  58. show_efi_loaded_images(pt_regs);
  59. panic("Resetting CPU ...\n");
  60. }
  61. /*
  62. * do_bad_irq handles the impossible case in the Irq vector.
  63. */
  64. void do_bad_irq(struct pt_regs *pt_regs, unsigned int esr)
  65. {
  66. efi_restore_gd();
  67. printf("Bad mode in \"Irq\" handler, esr 0x%08x\n", esr);
  68. show_regs(pt_regs);
  69. show_efi_loaded_images(pt_regs);
  70. panic("Resetting CPU ...\n");
  71. }
  72. /*
  73. * do_bad_fiq handles the impossible case in the Fiq vector.
  74. */
  75. void do_bad_fiq(struct pt_regs *pt_regs, unsigned int esr)
  76. {
  77. efi_restore_gd();
  78. printf("Bad mode in \"Fiq\" handler, esr 0x%08x\n", esr);
  79. show_regs(pt_regs);
  80. show_efi_loaded_images(pt_regs);
  81. panic("Resetting CPU ...\n");
  82. }
  83. /*
  84. * do_bad_error handles the impossible case in the Error vector.
  85. */
  86. void do_bad_error(struct pt_regs *pt_regs, unsigned int esr)
  87. {
  88. efi_restore_gd();
  89. printf("Bad mode in \"Error\" handler, esr 0x%08x\n", esr);
  90. show_regs(pt_regs);
  91. show_efi_loaded_images(pt_regs);
  92. panic("Resetting CPU ...\n");
  93. }
  94. /*
  95. * do_sync handles the Synchronous Abort exception.
  96. */
  97. void do_sync(struct pt_regs *pt_regs, unsigned int esr)
  98. {
  99. efi_restore_gd();
  100. printf("\"Synchronous Abort\" handler, esr 0x%08x\n", esr);
  101. show_regs(pt_regs);
  102. show_efi_loaded_images(pt_regs);
  103. panic("Resetting CPU ...\n");
  104. }
  105. /*
  106. * do_irq handles the Irq exception.
  107. */
  108. void do_irq(struct pt_regs *pt_regs, unsigned int esr)
  109. {
  110. efi_restore_gd();
  111. printf("\"Irq\" handler, esr 0x%08x\n", esr);
  112. show_regs(pt_regs);
  113. show_efi_loaded_images(pt_regs);
  114. panic("Resetting CPU ...\n");
  115. }
  116. /*
  117. * do_fiq handles the Fiq exception.
  118. */
  119. void do_fiq(struct pt_regs *pt_regs, unsigned int esr)
  120. {
  121. efi_restore_gd();
  122. printf("\"Fiq\" handler, esr 0x%08x\n", esr);
  123. show_regs(pt_regs);
  124. show_efi_loaded_images(pt_regs);
  125. panic("Resetting CPU ...\n");
  126. }
  127. /*
  128. * do_error handles the Error exception.
  129. * Errors are more likely to be processor specific,
  130. * it is defined with weak attribute and can be redefined
  131. * in processor specific code.
  132. */
  133. void __weak do_error(struct pt_regs *pt_regs, unsigned int esr)
  134. {
  135. efi_restore_gd();
  136. printf("\"Error\" handler, esr 0x%08x\n", esr);
  137. show_regs(pt_regs);
  138. show_efi_loaded_images(pt_regs);
  139. panic("Resetting CPU ...\n");
  140. }