void __attribute__((weak, nomips16)) _general_exception_handler (void) { char buff[SYS_CONSOLE_BUFFER_LEN]; uint32_t epc, cause; int cause_ix; const char* cause_str; snprintf(buff, SYS_CONSOLE_BUFFER_LEN, "\n\rSystem Exception Handler entered.\n\r"); (debug_handle->pObj->print)(debug_handle->obHandle, buff); epc = _CP0_GET_EPC(); cause = _CP0_GET_CAUSE(); cause_ix = (cause & _CP0_CAUSE_EXCCODE_MASK) >> _CP0_CAUSE_EXCCODE_POSITION; if(cause_ix < sizeof(_sys_excep_tbl)/sizeof(*_sys_excep_tbl)) { cause_str = _sys_excep_tbl[cause_ix]; } else { cause_str = "Unidentified"; } snprintf(buff, SYS_CONSOLE_BUFFER_LEN, "\n\rA %s type exception occurred at address: 0x%08x\n\r", cause_str, epc); (debug_handle->pObj->print)(debug_handle->obHandle, buff); snprintf(buff, SYS_CONSOLE_BUFFER_LEN, "\n\rSystem will halt!\n\r"); (debug_handle->pObj->print)(debug_handle->obHandle, buff); // break into the debugger __asm__ volatile (" sdbbp 0"); }
void _general_exception_handler(unsigned cause, unsigned status) { #if defined(DEBUG_MODE) unsigned long address = _CP0_GET_EPC(); #endif while(1){} }
void _general_exception_handler(unsigned cause, unsigned status) { unsigned long address = _CP0_GET_EPC(); while(1){} }
/******************************************************************************/ /* Exception Handling */ /******************************************************************************/ /* This function overrides the normal _weak_ _generic_exception_handler which is defined in the C32 User's Guide. The _weak_ _generic_exception_handler just does an infinite loop. */ void _general_exception_handler(void) { // unsigned long t0 = _CP0_GET_COUNT(); /* Used for NVMOP 6 us Delay */ /* Mask off Mask of the ExcCode Field from the Cause Register Refer to the MIPs M4K Software User's manual */ _excep_code=_CP0_GET_CAUSE() & 0x0000007C >> 2; _excep_addr=_CP0_GET_EPC(); _CP0_SET_STATUS(_CP0_GET_STATUS()&0xFFFFFFE); /* Disable Interrupts */ #ifdef WRITE_EXCEPTION_CAUSE_TO_FLASH /* Store the exception causes in program memory in case the part exhibited the problem in release mode. Gives user a place to start debugging the problem. */ NVMCON = 0x4001; /* set WREN and Word Programing mode */ NVMADDR = EXCEPTION_CAUSE; /* PM Address at which we'll store the */ /* cause register */ NVMDATA = _excep_code; /* wait at least 6 us for LVD start-up
/* This function overrides the normal _weak_ _generic_exception_handler which is defined in the C32 User's Guide. The _weak_ _generic_exception_handler just does an infinite loop. */ void _general_exception_handler(void) { unsigned long t0 = _CP0_GET_COUNT(); /* Used for NVMOP 6 us Delay */ /* Mask off Mask of the ExcCode Field from the Cause Register Refer to the MIPs M4K Software User's manual */ _excep_code=_CP0_GET_CAUSE() & 0x0000007C >> 2; _excep_addr=_CP0_GET_EPC(); _CP0_SET_STATUS(_CP0_GET_STATUS()&0xFFFFFFE); /* Disable Interrupts */ #ifdef WRITE_EXCEPTION_CAUSE_TO_FLASH /* Store the exception causes in program memory in case the part exhibited the problem in release mode. Gives user a place to start debugging the problem. */ NVMCON = 0x4001; /* set WREN and Word Programing mode */ NVMADDR = EXCEPTION_CAUSE; /* PM Address at which we'll store the */ /* cause register */ NVMDATA = _excep_code; /* wait at least 6 us for LVD start-up assume we're running at max frequency (80 MHz) so we're always safe */ { while (_CP0_GET_COUNT() - t0 < (80/2)*6); } NVMKEY = 0xAA996655; NVMKEY = 0x556699AA; /* unlock sequence */ NVMCONSET = NVMCON_WR; while(NVMCON & NVMCON_WR); /* wait on write to finish */ NVMCON = 0x4001; /* set WREN and Word Programing mode */ NVMADDR = EXCEPTION_ADDR; /* PM Address at which we'll store the */ /* exception address register */ NVMDATA = _excep_addr; /* wait at least 6 us for LVD start-up assume we're running at max frequency (80 MHz) so we're always safe */ { while (_CP0_GET_COUNT() - t0 < (80/2)*6); } NVMKEY = 0xAA996655; NVMKEY = 0x556699AA; /* unlock sequence */ NVMCONSET = NVMCON_WR; while(NVMCON & NVMCON_WR); /* Write the exception cause and address to the part can be read and the cause determined. */ NVMWriteWord((void*)EXCEPTION_CAUSE, _excep_code); NVMWriteWord((void*)EXCEPTION_ADDR, _excep_addr); #endif while (1) { /* Examine _excep_code to identify the type of exception */ /* Examine _excep_addr to find the address that caused the exception */ } }