blob: 45729331f3d326baeca82e3511c090bee519b871 [file] [log] [blame]
Michal Simek76316a32007-03-11 13:42:58 +01001/*
2 * (C) Copyright 2007 Michal Simek
3 *
4 * Michal SIMEK <monstr@monstr.eu>
5 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Michal Simek76316a32007-03-11 13:42:58 +01007 */
8
9#include <common.h>
Michal Simek1a50f1642007-05-08 14:52:52 +020010#include <asm/asm.h>
Michal Simek76316a32007-03-11 13:42:58 +010011
12void _hw_exception_handler (void)
13{
14 int address = 0;
15 int state = 0;
16 /* loading address of exception EAR */
Michal Simeke69f66c2007-05-08 15:57:43 +020017 MFS (address, rear);
Michal Simek76316a32007-03-11 13:42:58 +010018 /* loading excetpion state register ESR */
Michal Simeke69f66c2007-05-08 15:57:43 +020019 MFS (state, resr);
Michal Simek76316a32007-03-11 13:42:58 +010020 printf ("Hardware exception at 0x%x address\n", address);
Michal Simek1c424d22015-01-26 14:32:23 +010021 R17(address);
22 printf("Return address from exception 0x%x\n", address);
Michal Simek76316a32007-03-11 13:42:58 +010023 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;
Michal Simek1a50f1642007-05-08 14:52:52 +020039#ifdef MICROBLAZE_V5
Michal Simekef2c1d82014-01-20 21:17:07 +010040 case 0x7:
41 puts("Priviledged or stack protection violation exception\n");
42 break;
Michal Simek1a50f1642007-05-08 14:52:52 +020043 case 0x1000:
44 puts ("Exception in delay slot\n");
45 break;
46#endif
Michal Simek76316a32007-03-11 13:42:58 +010047 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
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020057#ifdef CONFIG_SYS_USR_EXCEP
Michal Simek76316a32007-03-11 13:42:58 +010058void _exception_handler (void)
59{
60 puts ("User vector_exception\n");
61 hang ();
62}
63#endif