2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2007-03-11 12:42:58 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2007 Michal Simek
|
|
|
|
*
|
|
|
|
* Michal SIMEK <monstr@monstr.eu>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-12-28 17:45:07 +00:00
|
|
|
#include <hang.h>
|
2007-05-08 12:52:52 +00:00
|
|
|
#include <asm/asm.h>
|
2007-03-11 12:42:58 +00:00
|
|
|
|
|
|
|
void _hw_exception_handler (void)
|
|
|
|
{
|
|
|
|
int address = 0;
|
|
|
|
int state = 0;
|
2015-01-26 13:36:13 +00:00
|
|
|
|
2007-03-11 12:42:58 +00:00
|
|
|
/* loading address of exception EAR */
|
2015-01-26 13:36:13 +00:00
|
|
|
MFS(address, rear);
|
2007-03-11 12:42:58 +00:00
|
|
|
/* loading excetpion state register ESR */
|
2015-01-26 13:36:13 +00:00
|
|
|
MFS(state, resr);
|
|
|
|
printf("Hardware exception at 0x%x address\n", address);
|
2015-01-26 13:32:23 +00:00
|
|
|
R17(address);
|
2022-02-13 08:09:21 +00:00
|
|
|
|
|
|
|
if (CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_DELAY_SLOT_EXCEP) &&
|
2022-02-13 08:09:22 +00:00
|
|
|
(state & 0x1000)) {
|
|
|
|
/*
|
|
|
|
* For exceptions in delay slots, the return address is stored
|
|
|
|
* in the Branch Target Register (BTR), rather than R17.
|
|
|
|
*/
|
|
|
|
MFS(address, rbtr);
|
|
|
|
|
2022-02-13 08:09:21 +00:00
|
|
|
puts("Exception in delay slot\n");
|
2022-02-13 08:09:22 +00:00
|
|
|
}
|
2022-02-13 08:09:21 +00:00
|
|
|
|
2007-03-11 12:42:58 +00:00
|
|
|
switch (state & 0x1f) { /* mask on exception cause */
|
|
|
|
case 0x1:
|
2015-01-26 13:36:13 +00:00
|
|
|
puts("Unaligned data access exception\n");
|
2022-02-13 08:09:23 +00:00
|
|
|
|
|
|
|
printf("Unaligned %sword access\n", ((state & 0x800) ? "" : "half"));
|
|
|
|
printf("Unaligned %s access\n", ((state & 0x400) ? "store" : "load"));
|
|
|
|
printf("Register R%x\n", (state & 0x3E) >> 5);
|
2007-03-11 12:42:58 +00:00
|
|
|
break;
|
|
|
|
case 0x2:
|
2015-01-26 13:36:13 +00:00
|
|
|
puts("Illegal op-code exception\n");
|
2007-03-11 12:42:58 +00:00
|
|
|
break;
|
|
|
|
case 0x3:
|
2015-01-26 13:36:13 +00:00
|
|
|
puts("Instruction bus error exception\n");
|
2007-03-11 12:42:58 +00:00
|
|
|
break;
|
|
|
|
case 0x4:
|
2015-01-26 13:36:13 +00:00
|
|
|
puts("Data bus error exception\n");
|
2007-03-11 12:42:58 +00:00
|
|
|
break;
|
|
|
|
case 0x5:
|
2015-01-26 13:36:13 +00:00
|
|
|
puts("Divide by zero exception\n");
|
2007-03-11 12:42:58 +00:00
|
|
|
break;
|
2014-01-20 20:17:07 +00:00
|
|
|
case 0x7:
|
|
|
|
puts("Priviledged or stack protection violation exception\n");
|
|
|
|
break;
|
2007-03-11 12:42:58 +00:00
|
|
|
default:
|
2015-01-26 13:36:13 +00:00
|
|
|
puts("Undefined cause\n");
|
2007-03-11 12:42:58 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-02-13 08:09:22 +00:00
|
|
|
|
|
|
|
printf("Return address from exception 0x%x\n", address);
|
2015-01-26 13:36:13 +00:00
|
|
|
hang();
|
2007-03-11 12:42:58 +00:00
|
|
|
}
|
|
|
|
|
2021-11-30 16:33:54 +00:00
|
|
|
#if CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USR_EXCEP)
|
2007-03-11 12:42:58 +00:00
|
|
|
void _exception_handler (void)
|
|
|
|
{
|
2015-01-26 13:36:13 +00:00
|
|
|
puts("User vector_exception\n");
|
|
|
|
hang();
|
2007-03-11 12:42:58 +00:00
|
|
|
}
|
|
|
|
#endif
|