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