blob: b135acbad9ddbe60a3ef858dfec3212607be3639 [file] [log] [blame]
Michal Simek76316a32007-03-11 13:42:58 +01001/*
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>
26
27void _hw_exception_handler (void)
28{
29 int address = 0;
30 int state = 0;
31 /* loading address of exception EAR */
32 __asm__ __volatile ("mfs %0,rear"::"r" (address):"memory");
33 /* loading excetpion state register ESR */
34 __asm__ __volatile ("mfs %0,resr"::"r" (state):"memory");
35 printf ("Hardware exception at 0x%x address\n", address);
36 switch (state & 0x1f) { /* mask on exception cause */
37 case 0x1:
38 puts ("Unaligned data access exception\n");
39 break;
40 case 0x2:
41 puts ("Illegal op-code exception\n");
42 break;
43 case 0x3:
44 puts ("Instruction bus error exception\n");
45 break;
46 case 0x4:
47 puts ("Data bus error exception\n");
48 break;
49 case 0x5:
50 puts ("Divide by zero exception\n");
51 break;
52 default:
53 puts ("Undefined cause\n");
54 break;
55 }
56 printf ("Unaligned %sword access\n", ((state & 0x800) ? "" : "half"));
57 printf ("Unaligned %s access\n", ((state & 0x400) ? "store" : "load"));
58 printf ("Register R%x\n", (state & 0x3E) >> 5);
59 hang ();
60}
61
62#ifdef CFG_USR_EXCEP
63void _exception_handler (void)
64{
65 puts ("User vector_exception\n");
66 hang ();
67}
68#endif