Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2007 Michal Simek |
| 4 | * |
| 5 | * Michal SIMEK <monstr@monstr.eu> |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Michal Simek | 3af398e | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 9 | #include <asm/asm.h> |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 10 | |
| 11 | void _hw_exception_handler (void) |
| 12 | { |
| 13 | int address = 0; |
| 14 | int state = 0; |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 15 | |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 16 | /* loading address of exception EAR */ |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 17 | MFS(address, rear); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 18 | /* loading excetpion state register ESR */ |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 19 | MFS(state, resr); |
| 20 | printf("Hardware exception at 0x%x address\n", address); |
Michal Simek | 924819c | 2015-01-26 14:32:23 +0100 | [diff] [blame] | 21 | R17(address); |
| 22 | printf("Return address from exception 0x%x\n", address); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 23 | switch (state & 0x1f) { /* mask on exception cause */ |
| 24 | case 0x1: |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 25 | puts("Unaligned data access exception\n"); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 26 | break; |
| 27 | case 0x2: |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 28 | puts("Illegal op-code exception\n"); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 29 | break; |
| 30 | case 0x3: |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 31 | puts("Instruction bus error exception\n"); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 32 | break; |
| 33 | case 0x4: |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 34 | puts("Data bus error exception\n"); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 35 | break; |
| 36 | case 0x5: |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 37 | puts("Divide by zero exception\n"); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 38 | break; |
Michal Simek | 3af398e | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 39 | #ifdef MICROBLAZE_V5 |
Michal Simek | 9856529 | 2014-01-20 21:17:07 +0100 | [diff] [blame] | 40 | case 0x7: |
| 41 | puts("Priviledged or stack protection violation exception\n"); |
| 42 | break; |
Michal Simek | 3af398e | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 43 | case 0x1000: |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 44 | puts("Exception in delay slot\n"); |
Michal Simek | 3af398e | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 45 | break; |
| 46 | #endif |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 47 | default: |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 48 | puts("Undefined cause\n"); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 49 | break; |
| 50 | } |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 51 | 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 Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 55 | } |
| 56 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 57 | #ifdef CONFIG_SYS_USR_EXCEP |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 58 | void _exception_handler (void) |
| 59 | { |
Michal Simek | f73749b | 2015-01-26 14:36:13 +0100 | [diff] [blame] | 60 | puts("User vector_exception\n"); |
| 61 | hang(); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 62 | } |
| 63 | #endif |