exception.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * File : exception.c
  3. * Change Logs:
  4. * Date Author Notes
  5. * 2010-05-17 swkyer first version
  6. */
  7. #include <rtthread.h>
  8. #include <rthw.h>
  9. #include "../common/exception.h"
  10. /**
  11. * @addtogroup Jz47xx
  12. */
  13. /*@{*/
  14. /**
  15. * exception handle table
  16. */
  17. exception_func_t sys_exception_handlers[33];
  18. /**
  19. * setup the exception handle
  20. */
  21. exception_func_t rt_set_except_vector(int n, exception_func_t func)
  22. {
  23. exception_func_t old_handler = sys_exception_handlers[n];
  24. if ((n == 0) || (n > 32) || (!func))
  25. {
  26. return 0;
  27. }
  28. sys_exception_handlers[n] = func;
  29. return old_handler;
  30. }
  31. void tlbmiss_handle(rt_uint32_t epc)
  32. {
  33. rt_kprintf("tlb-miss happens, epc: 0x%08x\n", epc);
  34. }
  35. static void unhandled_exception_handle(pt_regs_t *regs)
  36. {
  37. rt_kprintf("exception happens, epc: 0x%08x\n", regs->cp0_epc);
  38. }
  39. void install_default_execpt_handle(void)
  40. {
  41. rt_int32_t i;
  42. for (i=0; i<33; i++)
  43. sys_exception_handlers[i] = (exception_func_t)unhandled_exception_handle;
  44. }
  45. /*@}*/