exception.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #include "../common/mipsregs.h"
  11. /**
  12. * @addtogroup Jz47xx
  13. */
  14. /*@{*/
  15. /**
  16. * exception handle table
  17. */
  18. exception_func_t sys_exception_handlers[33];
  19. /**
  20. * setup the exception handle
  21. */
  22. exception_func_t rt_set_except_vector(int n, exception_func_t func)
  23. {
  24. exception_func_t old_handler = sys_exception_handlers[n];
  25. if ((n == 0) || (n > 32) || (!func))
  26. {
  27. return 0;
  28. }
  29. sys_exception_handlers[n] = func;
  30. return old_handler;
  31. }
  32. void tlb_refill_handler(void)
  33. {
  34. rt_kprintf("tlb-miss happens, epc: 0x%08x\n", read_c0_epc());
  35. rt_hw_cpu_shutdown();
  36. }
  37. void cache_error_handler(void)
  38. {
  39. rt_kprintf("cache exception happens, epc: 0x%08x\n", read_c0_epc());
  40. rt_hw_cpu_shutdown();
  41. }
  42. static void unhandled_exception_handle(pt_regs_t *regs)
  43. {
  44. rt_kprintf("exception happens, epc: 0x%08x\n", regs->cp0_epc);
  45. }
  46. void install_default_execpt_handle(void)
  47. {
  48. rt_int32_t i;
  49. for (i=0; i<33; i++)
  50. sys_exception_handlers[i] = (exception_func_t)unhandled_exception_handle;
  51. }
  52. /*@}*/