interrupts.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2002
  4. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  5. * Alex Zuepke <azu@sysgo.de>
  6. *
  7. * Copyright (C) 2011 Andes Technology Corporation
  8. * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
  9. * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
  10. */
  11. #include <common.h>
  12. #include <asm/ptrace.h>
  13. #include <asm/system.h>
  14. #undef INTERRUPT_MODE
  15. static int int_flag;
  16. int irq_flags; /* needed by asm-nds32/system.h */
  17. int GIE_STATUS(void)
  18. {
  19. int ret;
  20. __asm__ __volatile__ (
  21. "mfsr $p0, $psw\n\t"
  22. "andi %0, %0, 0x1\n\t"
  23. : "=r" (ret)
  24. :
  25. : "memory"
  26. );
  27. return ret;
  28. }
  29. #ifdef CONFIG_USE_INTERRUPT
  30. int interrupt_init(void)
  31. {
  32. return 0;
  33. }
  34. /* enable interrupts */
  35. void enable_interrupts(void)
  36. {
  37. local_irq_restore(int_flag);
  38. }
  39. /*
  40. * disable interrupts
  41. * Return true if GIE is enabled before we disable it.
  42. */
  43. int disable_interrupts(void)
  44. {
  45. int gie_ori_status;
  46. gie_ori_status = GIE_STATUS();
  47. local_irq_save(int_flag);
  48. return gie_ori_status;
  49. }
  50. #endif
  51. void bad_mode(void)
  52. {
  53. panic("Resetting CPU ...\n");
  54. reset_cpu(0);
  55. }
  56. void show_regs(struct pt_regs *regs)
  57. {
  58. const char *processor_modes[] = {"USER", "SuperUser" , "HyperVisor"};
  59. printf("\n");
  60. printf("pc : [<%08lx>] sp: [<%08lx>]\n"
  61. "lp : %08lx gp : %08lx fp : %08lx\n",
  62. regs->ipc, regs->sp, regs->lp, regs->gp, regs->fp);
  63. printf("D1H: %08lx D1L: %08lx D0H: %08lx D0L: %08lx\n",
  64. regs->d1hi, regs->d1lo, regs->d0hi, regs->d0lo);
  65. printf("r27: %08lx r26: %08lx r25: %08lx r24: %08lx\n",
  66. regs->p1, regs->p0, regs->r[25], regs->r[24]);
  67. printf("r23: %08lx r22: %08lx r21: %08lx r20: %08lx\n",
  68. regs->r[23], regs->r[22], regs->r[21], regs->r[20]);
  69. printf("r19: %08lx r18: %08lx r17: %08lx r16: %08lx\n",
  70. regs->r[19], regs->r[18], regs->r[17], regs->r[16]);
  71. printf("r15: %08lx r14: %08lx r13: %08lx r12: %08lx\n",
  72. regs->r[15], regs->r[14], regs->r[13], regs->r[12]);
  73. printf("r11: %08lx r10: %08lx r9 : %08lx r8 : %08lx\n",
  74. regs->r[11], regs->r[10], regs->r[9], regs->r[8]);
  75. printf("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
  76. regs->r[7], regs->r[6], regs->r[5], regs->r[4]);
  77. printf("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
  78. regs->r[3], regs->r[2], regs->r[1], regs->r[0]);
  79. printf(" Interrupts %s Mode %s\n",
  80. interrupts_enabled(regs) ? "on" : "off",
  81. processor_modes[processor_mode(regs)]);
  82. }
  83. void do_interruption(struct pt_regs *pt_regs, int EVIC_num)
  84. {
  85. const char *interruption_type[] = {
  86. "Reset",
  87. "TLB Fill",
  88. "TLB Not Present",
  89. "TLB Misc",
  90. "VLPT Miss",
  91. "Cache Parity Error",
  92. "Debug",
  93. "General Exception",
  94. "External Interrupt"
  95. };
  96. printf("%s\n", interruption_type[EVIC_num]);
  97. show_regs(pt_regs);
  98. bad_mode();
  99. }