interrupts.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * (C) Copyright 2003
  3. * Texas Instruments <www.ti.com>
  4. *
  5. * (C) Copyright 2002
  6. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  7. * Marius Groeger <mgroeger@sysgo.de>
  8. *
  9. * (C) Copyright 2002
  10. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  11. * Alex Zuepke <azu@sysgo.de>
  12. *
  13. * (C) Copyright 2002-2004
  14. * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
  15. *
  16. * (C) Copyright 2004
  17. * Philippe Robin, ARM Ltd. <philippe.robin@arm.com>
  18. *
  19. * SPDX-License-Identifier: GPL-2.0+
  20. */
  21. #include <common.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. void show_regs (struct pt_regs *regs)
  48. {
  49. unsigned long __maybe_unused flags;
  50. const char __maybe_unused *processor_modes[] = {
  51. "USER_26", "FIQ_26", "IRQ_26", "SVC_26",
  52. "UK4_26", "UK5_26", "UK6_26", "UK7_26",
  53. "UK8_26", "UK9_26", "UK10_26", "UK11_26",
  54. "UK12_26", "UK13_26", "UK14_26", "UK15_26",
  55. "USER_32", "FIQ_32", "IRQ_32", "SVC_32",
  56. "UK4_32", "UK5_32", "UK6_32", "ABT_32",
  57. "UK8_32", "UK9_32", "HYP_32", "UND_32",
  58. "UK12_32", "UK13_32", "UK14_32", "SYS_32",
  59. };
  60. flags = condition_codes (regs);
  61. printf("pc : [<%08lx>] lr : [<%08lx>]\n",
  62. instruction_pointer(regs), regs->ARM_lr);
  63. if (gd->flags & GD_FLG_RELOC) {
  64. printf("reloc pc : [<%08lx>] lr : [<%08lx>]\n",
  65. instruction_pointer(regs) - gd->reloc_off,
  66. regs->ARM_lr - gd->reloc_off);
  67. }
  68. printf("sp : %08lx ip : %08lx fp : %08lx\n",
  69. regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
  70. printf ("r10: %08lx r9 : %08lx r8 : %08lx\n",
  71. regs->ARM_r10, regs->ARM_r9, regs->ARM_r8);
  72. printf ("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
  73. regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4);
  74. printf ("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
  75. regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0);
  76. printf ("Flags: %c%c%c%c",
  77. flags & CC_N_BIT ? 'N' : 'n',
  78. flags & CC_Z_BIT ? 'Z' : 'z',
  79. flags & CC_C_BIT ? 'C' : 'c', flags & CC_V_BIT ? 'V' : 'v');
  80. printf (" IRQs %s FIQs %s Mode %s%s\n",
  81. interrupts_enabled (regs) ? "on" : "off",
  82. fast_interrupts_enabled (regs) ? "on" : "off",
  83. processor_modes[processor_mode (regs)],
  84. thumb_mode (regs) ? " (T)" : "");
  85. }
  86. /* fixup PC to point to the instruction leading to the exception */
  87. static inline void fixup_pc(struct pt_regs *regs, int offset)
  88. {
  89. uint32_t pc = instruction_pointer(regs) + offset;
  90. regs->ARM_pc = pc | (regs->ARM_pc & PCMASK);
  91. }
  92. void do_undefined_instruction (struct pt_regs *pt_regs)
  93. {
  94. efi_restore_gd();
  95. printf ("undefined instruction\n");
  96. fixup_pc(pt_regs, -4);
  97. show_regs (pt_regs);
  98. bad_mode ();
  99. }
  100. void do_software_interrupt (struct pt_regs *pt_regs)
  101. {
  102. efi_restore_gd();
  103. printf ("software interrupt\n");
  104. fixup_pc(pt_regs, -4);
  105. show_regs (pt_regs);
  106. bad_mode ();
  107. }
  108. void do_prefetch_abort (struct pt_regs *pt_regs)
  109. {
  110. efi_restore_gd();
  111. printf ("prefetch abort\n");
  112. fixup_pc(pt_regs, -8);
  113. show_regs (pt_regs);
  114. bad_mode ();
  115. }
  116. void do_data_abort (struct pt_regs *pt_regs)
  117. {
  118. efi_restore_gd();
  119. printf ("data abort\n");
  120. fixup_pc(pt_regs, -8);
  121. show_regs (pt_regs);
  122. bad_mode ();
  123. }
  124. void do_not_used (struct pt_regs *pt_regs)
  125. {
  126. efi_restore_gd();
  127. printf ("not used\n");
  128. fixup_pc(pt_regs, -8);
  129. show_regs (pt_regs);
  130. bad_mode ();
  131. }
  132. void do_fiq (struct pt_regs *pt_regs)
  133. {
  134. efi_restore_gd();
  135. printf ("fast interrupt request\n");
  136. fixup_pc(pt_regs, -8);
  137. show_regs (pt_regs);
  138. bad_mode ();
  139. }
  140. void do_irq (struct pt_regs *pt_regs)
  141. {
  142. efi_restore_gd();
  143. printf ("interrupt request\n");
  144. fixup_pc(pt_regs, -8);
  145. show_regs (pt_regs);
  146. bad_mode ();
  147. }