blob: aa34f45befe1ec5817f5c0485ccf8a996f12f38a [file] [log] [blame]
Michal Simek952d5142007-03-11 13:42:58 +01001/*
2 * (C) Copyright 2007 Michal Simek
3 *
4 * Michal SIMEK <monstr@monstr.eu>
5 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Michal Simek952d5142007-03-11 13:42:58 +01007 */
8
9#include <common.h>
Michal Simek3af398e2007-05-08 14:52:52 +020010#include <asm/asm.h>
Michal Simek952d5142007-03-11 13:42:58 +010011
12void _hw_exception_handler (void)
13{
14 int address = 0;
15 int state = 0;
Michal Simekf73749b2015-01-26 14:36:13 +010016
Michal Simek952d5142007-03-11 13:42:58 +010017 /* loading address of exception EAR */
Michal Simekf73749b2015-01-26 14:36:13 +010018 MFS(address, rear);
Michal Simek952d5142007-03-11 13:42:58 +010019 /* loading excetpion state register ESR */
Michal Simekf73749b2015-01-26 14:36:13 +010020 MFS(state, resr);
21 printf("Hardware exception at 0x%x address\n", address);
Michal Simek924819c2015-01-26 14:32:23 +010022 R17(address);
23 printf("Return address from exception 0x%x\n", address);
Michal Simek952d5142007-03-11 13:42:58 +010024 switch (state & 0x1f) { /* mask on exception cause */
25 case 0x1:
Michal Simekf73749b2015-01-26 14:36:13 +010026 puts("Unaligned data access exception\n");
Michal Simek952d5142007-03-11 13:42:58 +010027 break;
28 case 0x2:
Michal Simekf73749b2015-01-26 14:36:13 +010029 puts("Illegal op-code exception\n");
Michal Simek952d5142007-03-11 13:42:58 +010030 break;
31 case 0x3:
Michal Simekf73749b2015-01-26 14:36:13 +010032 puts("Instruction bus error exception\n");
Michal Simek952d5142007-03-11 13:42:58 +010033 break;
34 case 0x4:
Michal Simekf73749b2015-01-26 14:36:13 +010035 puts("Data bus error exception\n");
Michal Simek952d5142007-03-11 13:42:58 +010036 break;
37 case 0x5:
Michal Simekf73749b2015-01-26 14:36:13 +010038 puts("Divide by zero exception\n");
Michal Simek952d5142007-03-11 13:42:58 +010039 break;
Michal Simek3af398e2007-05-08 14:52:52 +020040#ifdef MICROBLAZE_V5
Michal Simek98565292014-01-20 21:17:07 +010041 case 0x7:
42 puts("Priviledged or stack protection violation exception\n");
43 break;
Michal Simek3af398e2007-05-08 14:52:52 +020044 case 0x1000:
Michal Simekf73749b2015-01-26 14:36:13 +010045 puts("Exception in delay slot\n");
Michal Simek3af398e2007-05-08 14:52:52 +020046 break;
47#endif
Michal Simek952d5142007-03-11 13:42:58 +010048 default:
Michal Simekf73749b2015-01-26 14:36:13 +010049 puts("Undefined cause\n");
Michal Simek952d5142007-03-11 13:42:58 +010050 break;
51 }
Michal Simekf73749b2015-01-26 14:36:13 +010052 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();
Michal Simek952d5142007-03-11 13:42:58 +010056}
57
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020058#ifdef CONFIG_SYS_USR_EXCEP
Michal Simek952d5142007-03-11 13:42:58 +010059void _exception_handler (void)
60{
Michal Simekf73749b2015-01-26 14:36:13 +010061 puts("User vector_exception\n");
62 hang();
Michal Simek952d5142007-03-11 13:42:58 +010063}
64#endif