xref: /openbmc/u-boot/arch/microblaze/cpu/exception.c (revision 23ff8633)
1 /*
2  * (C) Copyright 2007 Michal Simek
3  *
4  * Michal  SIMEK <monstr@monstr.eu>
5  *
6  * SPDX-License-Identifier:	GPL-2.0+
7  */
8 
9 #include <common.h>
10 #include <asm/asm.h>
11 
12 void _hw_exception_handler (void)
13 {
14 	int address = 0;
15 	int state = 0;
16 
17 	/* loading address of exception EAR */
18 	MFS(address, rear);
19 	/* loading excetpion state register ESR */
20 	MFS(state, resr);
21 	printf("Hardware exception at 0x%x address\n", address);
22 	R17(address);
23 	printf("Return address from exception 0x%x\n", address);
24 	switch (state & 0x1f) {	/* mask on exception cause */
25 	case 0x1:
26 		puts("Unaligned data access exception\n");
27 		break;
28 	case 0x2:
29 		puts("Illegal op-code exception\n");
30 		break;
31 	case 0x3:
32 		puts("Instruction bus error exception\n");
33 		break;
34 	case 0x4:
35 		puts("Data bus error exception\n");
36 		break;
37 	case 0x5:
38 		puts("Divide by zero exception\n");
39 		break;
40 #ifdef MICROBLAZE_V5
41 	case 0x7:
42 		puts("Priviledged or stack protection violation exception\n");
43 		break;
44 	case 0x1000:
45 		puts("Exception in delay slot\n");
46 		break;
47 #endif
48 	default:
49 		puts("Undefined cause\n");
50 		break;
51 	}
52 	printf("Unaligned %sword access\n", ((state & 0x800) ? "" : "half"));
53 	printf("Unaligned %s access\n", ((state & 0x400) ? "store" : "load"));
54 	printf("Register R%x\n", (state & 0x3E) >> 5);
55 	hang();
56 }
57 
58 #ifdef CONFIG_SYS_USR_EXCEP
59 void _exception_handler (void)
60 {
61 	puts("User vector_exception\n");
62 	hang();
63 }
64 #endif
65