exception.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * (C) Copyright 2007 Michal Simek
  3. *
  4. * Michal SIMEK <monstr@monstr.eu>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <asm/asm.h>
  26. void _hw_exception_handler (void)
  27. {
  28. int address = 0;
  29. int state = 0;
  30. /* loading address of exception EAR */
  31. MFS (address, rear);
  32. /* loading excetpion state register ESR */
  33. MFS (state, resr);
  34. printf ("Hardware exception at 0x%x address\n", address);
  35. switch (state & 0x1f) { /* mask on exception cause */
  36. case 0x1:
  37. puts ("Unaligned data access exception\n");
  38. break;
  39. case 0x2:
  40. puts ("Illegal op-code exception\n");
  41. break;
  42. case 0x3:
  43. puts ("Instruction bus error exception\n");
  44. break;
  45. case 0x4:
  46. puts ("Data bus error exception\n");
  47. break;
  48. case 0x5:
  49. puts ("Divide by zero exception\n");
  50. break;
  51. #ifdef MICROBLAZE_V5
  52. case 0x1000:
  53. puts ("Exception in delay slot\n");
  54. break;
  55. #endif
  56. default:
  57. puts ("Undefined cause\n");
  58. break;
  59. }
  60. printf ("Unaligned %sword access\n", ((state & 0x800) ? "" : "half"));
  61. printf ("Unaligned %s access\n", ((state & 0x400) ? "store" : "load"));
  62. printf ("Register R%x\n", (state & 0x3E) >> 5);
  63. hang ();
  64. }
  65. #ifdef CONFIG_SYS_USR_EXCEP
  66. void _exception_handler (void)
  67. {
  68. puts ("User vector_exception\n");
  69. hang ();
  70. }
  71. #endif