blob: cbd410ceb7648e5df3149a313a4aa4c610014bd1 [file] [log] [blame]
wdenkbf9e3b32004-02-12 00:47:09 +00001/*
2 * (C) Copyright 2003
3 * Josef Baumgartner <josef.baumgartner@telex.de>
4 *
5 * (C) Copyright 2000
6 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
wdenkbf9e3b32004-02-12 00:47:09 +00009 */
10
11#include <common.h>
12#include <watchdog.h>
13#include <command.h>
14#include <asm/processor.h>
15
16
17extern void _exc_handler(void);
18extern void _int_handler(void);
19
20static void show_frame(struct pt_regs *fp)
21{
22 printf ("Vector Number: %d Format: %02x Fault Status: %01x\n\n", (fp->vector & 0x3fc) >> 2,
Wolfgang Denk93e14592013-10-04 17:43:24 +020023 fp->format, (fp->vector & 0x3) | ((fp->vector & 0xc00) >> 8));
wdenkbf9e3b32004-02-12 00:47:09 +000024 printf ("PC: %08lx SR: %08lx SP: %08lx\n", fp->pc, (long) fp->sr, (long) fp);
25 printf ("D0: %08lx D1: %08lx D2: %08lx D3: %08lx\n",
26 fp->d0, fp->d1, fp->d2, fp->d3);
27 printf ("D4: %08lx D5: %08lx D6: %08lx D7: %08lx\n",
28 fp->d4, fp->d5, fp->d6, fp->d7);
29 printf ("A0: %08lx A1: %08lx A2: %08lx A3: %08lx\n",
30 fp->a0, fp->a1, fp->a2, fp->a3);
31 printf ("A4: %08lx A5: %08lx A6: %08lx\n",
32 fp->a4, fp->a5, fp->a6);
33}
34
35void exc_handler(struct pt_regs *fp) {
36 printf("\n\n*** Unexpected exception ***\n");
37 show_frame (fp);
38 printf("\n*** Please Reset Board! ***\n");
39 for(;;);
40}
41
42void trap_init(ulong value) {
43 unsigned long *vec = (ulong *)value;
44 int i;
45
46 for(i = 2; i < 25; i++) {
47 vec[i] = (unsigned long)_exc_handler;
48 }
49 for(i = 25; i < 32; i++) {
50 vec[i] = (unsigned long)_int_handler;
51 }
52 for(i = 32; i < 64; i++) {
53 vec[i] = (unsigned long)_exc_handler;
54 }
55 for(i = 64; i < 256; i++) {
56 vec[i] = (unsigned long)_int_handler;
57 }
58
59 setvbr(value); /* set vector base register to new table */
60}