blob: e09f36f2fddd43967be827916fcddf097d9ed4b5 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenke65527f2004-02-12 00:47:09 +00002/*
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.
wdenke65527f2004-02-12 00:47:09 +00008 */
9
Tom Rini2a526c32023-12-14 13:16:51 -050010#include <config.h>
Simon Glassd1d35512023-12-15 20:14:06 -070011#include <cpu_func.h>
Simon Glass537ecc92019-11-14 12:57:48 -070012#include <init.h>
wdenke65527f2004-02-12 00:47:09 +000013#include <watchdog.h>
14#include <command.h>
15#include <asm/processor.h>
Simon Glass6b9f0102020-05-10 11:40:06 -060016#include <asm/ptrace.h>
wdenke65527f2004-02-12 00:47:09 +000017
18
19extern void _exc_handler(void);
20extern void _int_handler(void);
21
22static void show_frame(struct pt_regs *fp)
23{
24 printf ("Vector Number: %d Format: %02x Fault Status: %01x\n\n", (fp->vector & 0x3fc) >> 2,
Wolfgang Denkec7fbf52013-10-04 17:43:24 +020025 fp->format, (fp->vector & 0x3) | ((fp->vector & 0xc00) >> 8));
wdenke65527f2004-02-12 00:47:09 +000026 printf ("PC: %08lx SR: %08lx SP: %08lx\n", fp->pc, (long) fp->sr, (long) fp);
27 printf ("D0: %08lx D1: %08lx D2: %08lx D3: %08lx\n",
28 fp->d0, fp->d1, fp->d2, fp->d3);
29 printf ("D4: %08lx D5: %08lx D6: %08lx D7: %08lx\n",
30 fp->d4, fp->d5, fp->d6, fp->d7);
31 printf ("A0: %08lx A1: %08lx A2: %08lx A3: %08lx\n",
32 fp->a0, fp->a1, fp->a2, fp->a3);
33 printf ("A4: %08lx A5: %08lx A6: %08lx\n",
34 fp->a4, fp->a5, fp->a6);
35}
36
37void exc_handler(struct pt_regs *fp) {
38 printf("\n\n*** Unexpected exception ***\n");
39 show_frame (fp);
40 printf("\n*** Please Reset Board! ***\n");
41 for(;;);
42}
43
Ovidiu Panait2c823912020-11-28 10:43:18 +020044static void trap_init(ulong value) {
wdenke65527f2004-02-12 00:47:09 +000045 unsigned long *vec = (ulong *)value;
46 int i;
47
48 for(i = 2; i < 25; i++) {
49 vec[i] = (unsigned long)_exc_handler;
50 }
51 for(i = 25; i < 32; i++) {
52 vec[i] = (unsigned long)_int_handler;
53 }
54 for(i = 32; i < 64; i++) {
55 vec[i] = (unsigned long)_exc_handler;
56 }
57 for(i = 64; i < 256; i++) {
58 vec[i] = (unsigned long)_int_handler;
59 }
60
61 setvbr(value); /* set vector base register to new table */
62}
Ovidiu Panait2c823912020-11-28 10:43:18 +020063
64int arch_initr_trap(void)
65{
Tom Rinibb4dd962022-11-16 13:10:37 -050066 trap_init(CFG_SYS_SDRAM_BASE);
Ovidiu Panait2c823912020-11-28 10:43:18 +020067
68 return 0;
69}
Simon Glassd1d35512023-12-15 20:14:06 -070070
71void reset_cpu(void)
72{
73 /* TODO: Refactor all the do_reset calls to be reset_cpu() instead */
74 do_reset(NULL, 0, 0, NULL);
75}