Advertisement
Guest User

Untitled

a guest
Jul 30th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. --- homec11067workC32buildspic32-microchip-release-1.12-20101221-rc2-20101221pic32-libslibcstubsdefault-general-exception-handler.c
  2. 9D00DD28 1000FFFF beq zero,zero,0x9d00dd28
  3. 9D00DD2C 00000000 nop
  4.  
  5. // declared static in case exception condition would prevent
  6. // auto variable being created
  7. static enum {
  8. EXCEP_IRQ = 0, // interrupt
  9. EXCEP_AdEL = 4, // address error exception (load or ifetch)
  10. EXCEP_AdES, // address error exception (store)
  11. EXCEP_IBE, // bus error (ifetch)
  12. EXCEP_DBE, // bus error (load/store)
  13. EXCEP_Sys, // syscall
  14. EXCEP_Bp, // breakpoint
  15. EXCEP_RI, // reserved instruction
  16. EXCEP_CpU, // coprocessor unusable
  17. EXCEP_Overflow, // arithmetic overflow
  18. EXCEP_Trap, // trap (possible divide by zero)
  19. EXCEP_IS1 = 16, // implementation specfic 1
  20. EXCEP_CEU, // CorExtend Unuseable
  21. EXCEP_C2E // coprocessor 2
  22. } _excep_code;
  23.  
  24.  
  25.  
  26. static unsigned int _epc_code;
  27. static unsigned int _excep_addr;
  28.  
  29. // this function overrides the normal _weak_ generic handler
  30. void _general_exception_handler(void)
  31. {
  32. asm volatile("mfc0 %0,$13" : "=r" (_excep_code));
  33. asm volatile("mfc0 %0,$14" : "=r" (_excep_addr));
  34.  
  35. _excep_code = (_excep_code & 0x0000007C) >> 2;
  36.  
  37. while (1) {
  38. // Examine _excep_code to identify the type of exception
  39. // Examine _excep_addr to find the address that caused the exception
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement