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 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
Michal Simek | 3af398e | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 26 | #include <asm/asm.h> |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 27 | |
| 28 | void _hw_exception_handler (void) |
| 29 | { |
| 30 | int address = 0; |
| 31 | int state = 0; |
| 32 | /* loading address of exception EAR */ |
Michal Simek | ebf7b23 | 2007-05-08 15:57:43 +0200 | [diff] [blame] | 33 | MFS (address, rear); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 34 | /* loading excetpion state register ESR */ |
Michal Simek | ebf7b23 | 2007-05-08 15:57:43 +0200 | [diff] [blame] | 35 | MFS (state, resr); |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 36 | printf ("Hardware exception at 0x%x address\n", address); |
| 37 | switch (state & 0x1f) { /* mask on exception cause */ |
| 38 | case 0x1: |
| 39 | puts ("Unaligned data access exception\n"); |
| 40 | break; |
| 41 | case 0x2: |
| 42 | puts ("Illegal op-code exception\n"); |
| 43 | break; |
| 44 | case 0x3: |
| 45 | puts ("Instruction bus error exception\n"); |
| 46 | break; |
| 47 | case 0x4: |
| 48 | puts ("Data bus error exception\n"); |
| 49 | break; |
| 50 | case 0x5: |
| 51 | puts ("Divide by zero exception\n"); |
| 52 | break; |
Michal Simek | 3af398e | 2007-05-08 14:52:52 +0200 | [diff] [blame] | 53 | #ifdef MICROBLAZE_V5 |
| 54 | case 0x1000: |
| 55 | puts ("Exception in delay slot\n"); |
| 56 | break; |
| 57 | #endif |
Michal Simek | 952d514 | 2007-03-11 13:42:58 +0100 | [diff] [blame] | 58 | default: |
| 59 | puts ("Undefined cause\n"); |
| 60 | break; |
| 61 | } |
| 62 | printf ("Unaligned %sword access\n", ((state & 0x800) ? "" : "half")); |
| 63 | printf ("Unaligned %s access\n", ((state & 0x400) ? "store" : "load")); |
| 64 | printf ("Register R%x\n", (state & 0x3E) >> 5); |
| 65 | hang (); |
| 66 | } |
| 67 | |
| 68 | #ifdef CFG_USR_EXCEP |
| 69 | void _exception_handler (void) |
| 70 | { |
| 71 | puts ("User vector_exception\n"); |
| 72 | hang (); |
| 73 | } |
| 74 | #endif |