exception.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * (C) Copyright 2007 Michal Simek
  3. *
  4. * Michal SIMEK <monstr@monstr.eu>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <asm/asm.h>
  10. void _hw_exception_handler (void)
  11. {
  12. int address = 0;
  13. int state = 0;
  14. /* loading address of exception EAR */
  15. MFS (address, rear);
  16. /* loading excetpion state register ESR */
  17. MFS (state, resr);
  18. printf ("Hardware exception at 0x%x address\n", address);
  19. switch (state & 0x1f) { /* mask on exception cause */
  20. case 0x1:
  21. puts ("Unaligned data access exception\n");
  22. break;
  23. case 0x2:
  24. puts ("Illegal op-code exception\n");
  25. break;
  26. case 0x3:
  27. puts ("Instruction bus error exception\n");
  28. break;
  29. case 0x4:
  30. puts ("Data bus error exception\n");
  31. break;
  32. case 0x5:
  33. puts ("Divide by zero exception\n");
  34. break;
  35. #ifdef MICROBLAZE_V5
  36. case 0x7:
  37. puts("Priviledged or stack protection violation exception\n");
  38. break;
  39. case 0x1000:
  40. puts ("Exception in delay slot\n");
  41. break;
  42. #endif
  43. default:
  44. puts ("Undefined cause\n");
  45. break;
  46. }
  47. printf ("Unaligned %sword access\n", ((state & 0x800) ? "" : "half"));
  48. printf ("Unaligned %s access\n", ((state & 0x400) ? "store" : "load"));
  49. printf ("Register R%x\n", (state & 0x3E) >> 5);
  50. hang ();
  51. }
  52. #ifdef CONFIG_SYS_USR_EXCEP
  53. void _exception_handler (void)
  54. {
  55. puts ("User vector_exception\n");
  56. hang ();
  57. }
  58. #endif