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