Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007 Michal Simek |
| 3 | * |
| 4 | * Michal SIMEK <monstr@monstr.eu> |
| 5 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame^] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Michal Simek | 3af398e | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 10 | #include <asm/asm.h> |
Michal Simek | 952d514 | 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; |
| 16 | /* loading address of exception EAR */ |
Michal Simek | ebf7b23 | 2007-05-08 15:57:43 +0200 | [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 | ebf7b23 | 2007-05-08 15:57:43 +0200 | [diff] [blame] | 19 | MFS (state, resr); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 20 | printf ("Hardware exception at 0x%x address\n", address); |
| 21 | switch (state & 0x1f) { /* mask on exception cause */ |
| 22 | case 0x1: |
| 23 | puts ("Unaligned data access exception\n"); |
| 24 | break; |
| 25 | case 0x2: |
| 26 | puts ("Illegal op-code exception\n"); |
| 27 | break; |
| 28 | case 0x3: |
| 29 | puts ("Instruction bus error exception\n"); |
| 30 | break; |
| 31 | case 0x4: |
| 32 | puts ("Data bus error exception\n"); |
| 33 | break; |
| 34 | case 0x5: |
| 35 | puts ("Divide by zero exception\n"); |
| 36 | break; |
Michal Simek | 3af398e | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 37 | #ifdef MICROBLAZE_V5 |
| 38 | case 0x1000: |
| 39 | puts ("Exception in delay slot\n"); |
| 40 | break; |
| 41 | #endif |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 42 | default: |
| 43 | puts ("Undefined cause\n"); |
| 44 | break; |
| 45 | } |
| 46 | printf ("Unaligned %sword access\n", ((state & 0x800) ? "" : "half")); |
| 47 | printf ("Unaligned %s access\n", ((state & 0x400) ? "store" : "load")); |
| 48 | printf ("Register R%x\n", (state & 0x3E) >> 5); |
| 49 | hang (); |
| 50 | } |
| 51 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 52 | #ifdef CONFIG_SYS_USR_EXCEP |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 53 | void _exception_handler (void) |
| 54 | { |
| 55 | puts ("User vector_exception\n"); |
| 56 | hang (); |
| 57 | } |
| 58 | #endif |