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