blob: 64d5fe4a80c5ef2a3d81299f74b7b21d74c0d16b [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);
Ovidiu Panait7422b412022-02-13 10:09:21 +020024
25 if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_DELAY_SLOT_EXCEP) &&
26 (state & 0x1000))
27 puts("Exception in delay slot\n");
28
Michal Simek76316a32007-03-11 13:42:58 +010029 switch (state & 0x1f) { /* mask on exception cause */
30 case 0x1:
Michal Simek5e2fc802015-01-26 14:36:13 +010031 puts("Unaligned data access exception\n");
Michal Simek76316a32007-03-11 13:42:58 +010032 break;
33 case 0x2:
Michal Simek5e2fc802015-01-26 14:36:13 +010034 puts("Illegal op-code exception\n");
Michal Simek76316a32007-03-11 13:42:58 +010035 break;
36 case 0x3:
Michal Simek5e2fc802015-01-26 14:36:13 +010037 puts("Instruction bus error exception\n");
Michal Simek76316a32007-03-11 13:42:58 +010038 break;
39 case 0x4:
Michal Simek5e2fc802015-01-26 14:36:13 +010040 puts("Data bus error exception\n");
Michal Simek76316a32007-03-11 13:42:58 +010041 break;
42 case 0x5:
Michal Simek5e2fc802015-01-26 14:36:13 +010043 puts("Divide by zero exception\n");
Michal Simek76316a32007-03-11 13:42:58 +010044 break;
Michal Simekef2c1d82014-01-20 21:17:07 +010045 case 0x7:
46 puts("Priviledged or stack protection violation exception\n");
47 break;
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
Ovidiu Panait83b175b2021-11-30 18:33:54 +020058#if CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_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