interrupts_64.c 3.5 KB

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