interrupts.c 4.6 KB

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