traps.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  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. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <common.h>
  27. #include <watchdog.h>
  28. #include <command.h>
  29. #include <asm/processor.h>
  30. extern void _exc_handler(void);
  31. extern void _int_handler(void);
  32. static void show_frame(struct pt_regs *fp)
  33. {
  34. printf ("Vector Number: %d Format: %02x Fault Status: %01x\n\n", (fp->vector & 0x3fc) >> 2,
  35. fp->format, (fp->vector & 0x3) | ((fp->vector & 0xc00) >> 8));
  36. printf ("PC: %08lx SR: %08lx SP: %08lx\n", fp->pc, (long) fp->sr, (long) fp);
  37. printf ("D0: %08lx D1: %08lx D2: %08lx D3: %08lx\n",
  38. fp->d0, fp->d1, fp->d2, fp->d3);
  39. printf ("D4: %08lx D5: %08lx D6: %08lx D7: %08lx\n",
  40. fp->d4, fp->d5, fp->d6, fp->d7);
  41. printf ("A0: %08lx A1: %08lx A2: %08lx A3: %08lx\n",
  42. fp->a0, fp->a1, fp->a2, fp->a3);
  43. printf ("A4: %08lx A5: %08lx A6: %08lx\n",
  44. fp->a4, fp->a5, fp->a6);
  45. }
  46. void exc_handler(struct pt_regs *fp) {
  47. printf("\n\n*** Unexpected exception ***\n");
  48. show_frame (fp);
  49. printf("\n*** Please Reset Board! ***\n");
  50. for(;;);
  51. }
  52. void trap_init(ulong value) {
  53. unsigned long *vec = (ulong *)value;
  54. int i;
  55. for(i = 2; i < 25; i++) {
  56. vec[i] = (unsigned long)_exc_handler;
  57. }
  58. for(i = 25; i < 32; i++) {
  59. vec[i] = (unsigned long)_int_handler;
  60. }
  61. for(i = 32; i < 64; i++) {
  62. vec[i] = (unsigned long)_exc_handler;
  63. }
  64. for(i = 64; i < 256; i++) {
  65. vec[i] = (unsigned long)_int_handler;
  66. }
  67. setvbr(value); /* set vector base register to new table */
  68. }