exception.c 1.4 KB

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