Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 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. |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
Simon Glass | 537ecc9 | 2019-11-14 12:57:48 -0700 | [diff] [blame] | 11 | #include <init.h> |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 12 | #include <watchdog.h> |
| 13 | #include <command.h> |
| 14 | #include <asm/processor.h> |
Simon Glass | 6b9f010 | 2020-05-10 11:40:06 -0600 | [diff] [blame] | 15 | #include <asm/ptrace.h> |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 16 | |
| 17 | |
| 18 | extern void _exc_handler(void); |
| 19 | extern void _int_handler(void); |
| 20 | |
| 21 | static void show_frame(struct pt_regs *fp) |
| 22 | { |
| 23 | printf ("Vector Number: %d Format: %02x Fault Status: %01x\n\n", (fp->vector & 0x3fc) >> 2, |
Wolfgang Denk | ec7fbf5 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 24 | fp->format, (fp->vector & 0x3) | ((fp->vector & 0xc00) >> 8)); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 25 | printf ("PC: %08lx SR: %08lx SP: %08lx\n", fp->pc, (long) fp->sr, (long) fp); |
| 26 | printf ("D0: %08lx D1: %08lx D2: %08lx D3: %08lx\n", |
| 27 | fp->d0, fp->d1, fp->d2, fp->d3); |
| 28 | printf ("D4: %08lx D5: %08lx D6: %08lx D7: %08lx\n", |
| 29 | fp->d4, fp->d5, fp->d6, fp->d7); |
| 30 | printf ("A0: %08lx A1: %08lx A2: %08lx A3: %08lx\n", |
| 31 | fp->a0, fp->a1, fp->a2, fp->a3); |
| 32 | printf ("A4: %08lx A5: %08lx A6: %08lx\n", |
| 33 | fp->a4, fp->a5, fp->a6); |
| 34 | } |
| 35 | |
| 36 | void exc_handler(struct pt_regs *fp) { |
| 37 | printf("\n\n*** Unexpected exception ***\n"); |
| 38 | show_frame (fp); |
| 39 | printf("\n*** Please Reset Board! ***\n"); |
| 40 | for(;;); |
| 41 | } |
| 42 | |
Ovidiu Panait | 2c82391 | 2020-11-28 10:43:18 +0200 | [diff] [blame] | 43 | static void trap_init(ulong value) { |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 44 | unsigned long *vec = (ulong *)value; |
| 45 | int i; |
| 46 | |
| 47 | for(i = 2; i < 25; i++) { |
| 48 | vec[i] = (unsigned long)_exc_handler; |
| 49 | } |
| 50 | for(i = 25; i < 32; i++) { |
| 51 | vec[i] = (unsigned long)_int_handler; |
| 52 | } |
| 53 | for(i = 32; i < 64; i++) { |
| 54 | vec[i] = (unsigned long)_exc_handler; |
| 55 | } |
| 56 | for(i = 64; i < 256; i++) { |
| 57 | vec[i] = (unsigned long)_int_handler; |
| 58 | } |
| 59 | |
| 60 | setvbr(value); /* set vector base register to new table */ |
| 61 | } |
Ovidiu Panait | 2c82391 | 2020-11-28 10:43:18 +0200 | [diff] [blame] | 62 | |
| 63 | int arch_initr_trap(void) |
| 64 | { |
Tom Rini | bb4dd96 | 2022-11-16 13:10:37 -0500 | [diff] [blame] | 65 | trap_init(CFG_SYS_SDRAM_BASE); |
Ovidiu Panait | 2c82391 | 2020-11-28 10:43:18 +0200 | [diff] [blame] | 66 | |
| 67 | return 0; |
| 68 | } |