blob: bdcbe0868599fdbd1851ce056f4b25a59ea8511b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Michal Simek952d5142007-03-11 13:42:58 +01002/*
3 * (C) Copyright 2007 Michal Simek
4 *
5 * Michal SIMEK <monstr@monstr.eu>
Michal Simek952d5142007-03-11 13:42:58 +01006 */
7
8#include <common.h>
Michal Simek3af398e2007-05-08 14:52:52 +02009#include <asm/asm.h>
Michal Simek952d5142007-03-11 13:42:58 +010010
11void _hw_exception_handler (void)
12{
13 int address = 0;
14 int state = 0;
Michal Simekf73749b2015-01-26 14:36:13 +010015
Michal Simek952d5142007-03-11 13:42:58 +010016 /* loading address of exception EAR */
Michal Simekf73749b2015-01-26 14:36:13 +010017 MFS(address, rear);
Michal Simek952d5142007-03-11 13:42:58 +010018 /* loading excetpion state register ESR */
Michal Simekf73749b2015-01-26 14:36:13 +010019 MFS(state, resr);
20 printf("Hardware exception at 0x%x address\n", address);
Michal Simek924819c2015-01-26 14:32:23 +010021 R17(address);
22 printf("Return address from exception 0x%x\n", address);
Michal Simek952d5142007-03-11 13:42:58 +010023 switch (state & 0x1f) { /* mask on exception cause */
24 case 0x1:
Michal Simekf73749b2015-01-26 14:36:13 +010025 puts("Unaligned data access exception\n");
Michal Simek952d5142007-03-11 13:42:58 +010026 break;
27 case 0x2:
Michal Simekf73749b2015-01-26 14:36:13 +010028 puts("Illegal op-code exception\n");
Michal Simek952d5142007-03-11 13:42:58 +010029 break;
30 case 0x3:
Michal Simekf73749b2015-01-26 14:36:13 +010031 puts("Instruction bus error exception\n");
Michal Simek952d5142007-03-11 13:42:58 +010032 break;
33 case 0x4:
Michal Simekf73749b2015-01-26 14:36:13 +010034 puts("Data bus error exception\n");
Michal Simek952d5142007-03-11 13:42:58 +010035 break;
36 case 0x5:
Michal Simekf73749b2015-01-26 14:36:13 +010037 puts("Divide by zero exception\n");
Michal Simek952d5142007-03-11 13:42:58 +010038 break;
Michal Simek3af398e2007-05-08 14:52:52 +020039#ifdef MICROBLAZE_V5
Michal Simek98565292014-01-20 21:17:07 +010040 case 0x7:
41 puts("Priviledged or stack protection violation exception\n");
42 break;
Michal Simek3af398e2007-05-08 14:52:52 +020043 case 0x1000:
Michal Simekf73749b2015-01-26 14:36:13 +010044 puts("Exception in delay slot\n");
Michal Simek3af398e2007-05-08 14:52:52 +020045 break;
46#endif
Michal Simek952d5142007-03-11 13:42:58 +010047 default:
Michal Simekf73749b2015-01-26 14:36:13 +010048 puts("Undefined cause\n");
Michal Simek952d5142007-03-11 13:42:58 +010049 break;
50 }
Michal Simekf73749b2015-01-26 14:36:13 +010051 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();
Michal Simek952d5142007-03-11 13:42:58 +010055}
56
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020057#ifdef CONFIG_SYS_USR_EXCEP
Michal Simek952d5142007-03-11 13:42:58 +010058void _exception_handler (void)
59{
Michal Simekf73749b2015-01-26 14:36:13 +010060 puts("User vector_exception\n");
61 hang();
Michal Simek952d5142007-03-11 13:42:58 +010062}
63#endif