interrupts_64.c 3.5 KB

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