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