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