blob: 966c19a1ae53b9f8ee1ff32e182422c78ee6abf1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Macpaul Lin0d1f4742011-10-11 22:33:19 +00002/*
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>
Macpaul Lin0d1f4742011-10-11 22:33:19 +000010 */
11
12#include <common.h>
13#include <asm/ptrace.h>
14#include <asm/system.h>
15#undef INTERRUPT_MODE
16
17static int int_flag;
18
19int irq_flags; /* needed by asm-nds32/system.h */
20
21int GIE_STATUS(void)
22{
23 int ret;
24
25 __asm__ __volatile__ (
26 "mfsr $p0, $psw\n\t"
27 "andi %0, %0, 0x1\n\t"
28 : "=r" (ret)
29 :
30 : "memory"
31 );
32 return ret;
33}
34
35#ifdef CONFIG_USE_INTERRUPT
36
Kun-Hua Huang89299e22015-08-24 14:52:35 +080037int interrupt_init(void)
38{
39 return 0;
40}
Macpaul Lin0d1f4742011-10-11 22:33:19 +000041/* enable interrupts */
42void enable_interrupts(void)
43{
44 local_irq_restore(int_flag);
45}
46
47/*
48 * disable interrupts
York Sun4a598092013-04-01 11:29:11 -070049 * Return true if GIE is enabled before we disable it.
Macpaul Lin0d1f4742011-10-11 22:33:19 +000050 */
51int disable_interrupts(void)
52{
53
54 int gie_ori_status;
55
56 gie_ori_status = GIE_STATUS();
57
58 local_irq_save(int_flag);
59
60 return gie_ori_status;
61}
62#endif
63
64void bad_mode(void)
65{
66 panic("Resetting CPU ...\n");
67 reset_cpu(0);
68}
69
70void show_regs(struct pt_regs *regs)
71{
72 const char *processor_modes[] = {"USER", "SuperUser" , "HyperVisor"};
73
74 printf("\n");
75 printf("pc : [<%08lx>] sp: [<%08lx>]\n"
76 "lp : %08lx gp : %08lx fp : %08lx\n",
77 regs->ipc, regs->sp, regs->lp, regs->gp, regs->fp);
78 printf("D1H: %08lx D1L: %08lx D0H: %08lx D0L: %08lx\n",
79 regs->d1hi, regs->d1lo, regs->d0hi, regs->d0lo);
80 printf("r27: %08lx r26: %08lx r25: %08lx r24: %08lx\n",
Macpaul Lind29086a2012-03-11 16:30:18 +080081 regs->p1, regs->p0, regs->r[25], regs->r[24]);
Macpaul Lin0d1f4742011-10-11 22:33:19 +000082 printf("r23: %08lx r22: %08lx r21: %08lx r20: %08lx\n",
83 regs->r[23], regs->r[22], regs->r[21], regs->r[20]);
84 printf("r19: %08lx r18: %08lx r17: %08lx r16: %08lx\n",
85 regs->r[19], regs->r[18], regs->r[17], regs->r[16]);
86 printf("r15: %08lx r14: %08lx r13: %08lx r12: %08lx\n",
87 regs->r[15], regs->r[14], regs->r[13], regs->r[12]);
88 printf("r11: %08lx r10: %08lx r9 : %08lx r8 : %08lx\n",
89 regs->r[11], regs->r[10], regs->r[9], regs->r[8]);
90 printf("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
91 regs->r[7], regs->r[6], regs->r[5], regs->r[4]);
92 printf("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
93 regs->r[3], regs->r[2], regs->r[1], regs->r[0]);
94 printf(" Interrupts %s Mode %s\n",
95 interrupts_enabled(regs) ? "on" : "off",
96 processor_modes[processor_mode(regs)]);
97}
98
99void do_interruption(struct pt_regs *pt_regs, int EVIC_num)
100{
101 const char *interruption_type[] = {
102 "Reset",
103 "TLB Fill",
104 "TLB Not Present",
105 "TLB Misc",
106 "VLPT Miss",
107 "Cache Parity Error",
108 "Debug",
109 "General Exception",
110 "External Interrupt"
111 };
112
113 printf("%s\n", interruption_type[EVIC_num]);
114 show_regs(pt_regs);
115 bad_mode();
116}