interrupts.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2003
  4. * Texas Instruments <www.ti.com>
  5. *
  6. * (C) Copyright 2002
  7. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  8. * Marius Groeger <mgroeger@sysgo.de>
  9. *
  10. * (C) Copyright 2002
  11. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  12. * Alex Zuepke <azu@sysgo.de>
  13. *
  14. * (C) Copyright 2002-2004
  15. * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
  16. *
  17. * (C) Copyright 2004
  18. * Philippe Robin, ARM Ltd. <philippe.robin@arm.com>
  19. */
  20. #include <common.h>
  21. #include <efi_loader.h>
  22. #include <asm/proc-armv/ptrace.h>
  23. #include <asm/u-boot-arm.h>
  24. DECLARE_GLOBAL_DATA_PTR;
  25. int interrupt_init (void)
  26. {
  27. /*
  28. * setup up stacks if necessary
  29. */
  30. IRQ_STACK_START_IN = gd->irq_sp + 8;
  31. return 0;
  32. }
  33. void enable_interrupts (void)
  34. {
  35. return;
  36. }
  37. int disable_interrupts (void)
  38. {
  39. return 0;
  40. }
  41. void bad_mode (void)
  42. {
  43. panic ("Resetting CPU ...\n");
  44. reset_cpu (0);
  45. }
  46. static void show_efi_loaded_images(struct pt_regs *regs)
  47. {
  48. efi_print_image_infos((void *)instruction_pointer(regs));
  49. }
  50. static void dump_instr(struct pt_regs *regs)
  51. {
  52. unsigned long addr = instruction_pointer(regs);
  53. const int thumb = thumb_mode(regs);
  54. const int width = thumb ? 4 : 8;
  55. int i;
  56. if (thumb)
  57. addr &= ~1L;
  58. else
  59. addr &= ~3L;
  60. printf("Code: ");
  61. for (i = -4; i < 1 + !!thumb; i++) {
  62. unsigned int val;
  63. if (thumb)
  64. val = ((u16 *)addr)[i];
  65. else
  66. val = ((u32 *)addr)[i];
  67. printf(i == 0 ? "(%0*x) " : "%0*x ", width, val);
  68. }
  69. printf("\n");
  70. }
  71. void show_regs (struct pt_regs *regs)
  72. {
  73. unsigned long __maybe_unused flags;
  74. const char __maybe_unused *processor_modes[] = {
  75. "USER_26", "FIQ_26", "IRQ_26", "SVC_26",
  76. "UK4_26", "UK5_26", "UK6_26", "UK7_26",
  77. "UK8_26", "UK9_26", "UK10_26", "UK11_26",
  78. "UK12_26", "UK13_26", "UK14_26", "UK15_26",
  79. "USER_32", "FIQ_32", "IRQ_32", "SVC_32",
  80. "UK4_32", "UK5_32", "UK6_32", "ABT_32",
  81. "UK8_32", "UK9_32", "HYP_32", "UND_32",
  82. "UK12_32", "UK13_32", "UK14_32", "SYS_32",
  83. };
  84. flags = condition_codes (regs);
  85. printf("pc : [<%08lx>] lr : [<%08lx>]\n",
  86. instruction_pointer(regs), regs->ARM_lr);
  87. if (gd->flags & GD_FLG_RELOC) {
  88. printf("reloc pc : [<%08lx>] lr : [<%08lx>]\n",
  89. instruction_pointer(regs) - gd->reloc_off,
  90. regs->ARM_lr - gd->reloc_off);
  91. }
  92. printf("sp : %08lx ip : %08lx fp : %08lx\n",
  93. regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
  94. printf ("r10: %08lx r9 : %08lx r8 : %08lx\n",
  95. regs->ARM_r10, regs->ARM_r9, regs->ARM_r8);
  96. printf ("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
  97. regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4);
  98. printf ("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
  99. regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0);
  100. printf ("Flags: %c%c%c%c",
  101. flags & CC_N_BIT ? 'N' : 'n',
  102. flags & CC_Z_BIT ? 'Z' : 'z',
  103. flags & CC_C_BIT ? 'C' : 'c', flags & CC_V_BIT ? 'V' : 'v');
  104. printf (" IRQs %s FIQs %s Mode %s%s\n",
  105. interrupts_enabled (regs) ? "on" : "off",
  106. fast_interrupts_enabled (regs) ? "on" : "off",
  107. processor_modes[processor_mode (regs)],
  108. thumb_mode (regs) ? " (T)" : "");
  109. dump_instr(regs);
  110. }
  111. /* fixup PC to point to the instruction leading to the exception */
  112. static inline void fixup_pc(struct pt_regs *regs, int offset)
  113. {
  114. uint32_t pc = instruction_pointer(regs) + offset;
  115. regs->ARM_pc = pc | (regs->ARM_pc & PCMASK);
  116. }
  117. void do_undefined_instruction (struct pt_regs *pt_regs)
  118. {
  119. efi_restore_gd();
  120. printf ("undefined instruction\n");
  121. fixup_pc(pt_regs, -4);
  122. show_regs (pt_regs);
  123. show_efi_loaded_images(pt_regs);
  124. bad_mode ();
  125. }
  126. void do_software_interrupt (struct pt_regs *pt_regs)
  127. {
  128. efi_restore_gd();
  129. printf ("software interrupt\n");
  130. fixup_pc(pt_regs, -4);
  131. show_regs (pt_regs);
  132. show_efi_loaded_images(pt_regs);
  133. bad_mode ();
  134. }
  135. void do_prefetch_abort (struct pt_regs *pt_regs)
  136. {
  137. efi_restore_gd();
  138. printf ("prefetch abort\n");
  139. fixup_pc(pt_regs, -8);
  140. show_regs (pt_regs);
  141. show_efi_loaded_images(pt_regs);
  142. bad_mode ();
  143. }
  144. void do_data_abort (struct pt_regs *pt_regs)
  145. {
  146. efi_restore_gd();
  147. printf ("data abort\n");
  148. fixup_pc(pt_regs, -8);
  149. show_regs (pt_regs);
  150. show_efi_loaded_images(pt_regs);
  151. bad_mode ();
  152. }
  153. void do_not_used (struct pt_regs *pt_regs)
  154. {
  155. efi_restore_gd();
  156. printf ("not used\n");
  157. fixup_pc(pt_regs, -8);
  158. show_regs (pt_regs);
  159. show_efi_loaded_images(pt_regs);
  160. bad_mode ();
  161. }
  162. void do_fiq (struct pt_regs *pt_regs)
  163. {
  164. efi_restore_gd();
  165. printf ("fast interrupt request\n");
  166. fixup_pc(pt_regs, -8);
  167. show_regs (pt_regs);
  168. show_efi_loaded_images(pt_regs);
  169. bad_mode ();
  170. }
  171. void do_irq (struct pt_regs *pt_regs)
  172. {
  173. efi_restore_gd();
  174. printf ("interrupt request\n");
  175. fixup_pc(pt_regs, -8);
  176. show_regs (pt_regs);
  177. show_efi_loaded_images(pt_regs);
  178. bad_mode ();
  179. }