void HARD_Breakpoint_Handler( UINT32 *registers, UINT32 sp, UINT32 lr ) { #if !defined(ABORTS_REDUCESIZE) if(1 == ++ABORT_recursion_counter) { GLOBAL_LOCK(irq); //Verify_RAMConstants((void *) FALSE); ABORT_HandlerDisplay(registers, sp, lr, 4, "", TRUE); CPU_Halt(); } #else CPU_Reset(); #endif // !defined(ABORTS_REDUCESIZE) }
void ApplicationEntryPoint() { CLR_SETTINGS clrSettings; InitCRuntime(); CPU_Initialize(); Time_Initialize(); HAL_Initialize(); // CLR entry point memset(&clrSettings, 0, sizeof(CLR_SETTINGS)); clrSettings.MaxContextSwitches = 50; clrSettings.WaitForDebugger = false; clrSettings.EnterDebuggerLoopAfterExit = true; ClrStartup( clrSettings ); HAL_Uninitialize(); Time_Uninitialize(); #if !defined(BUILD_RTM) debug_printf( "Exiting.\r\n" ); CPU_Halt(); #else CPU_Reset(); #endif }
//************************************************************************************* //Panic button thread quits to the menu when pressed //************************************************************************************* static int PanicThread( SceSize args, void * argp ) { const u32 MASK = PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER | PSP_CTRL_START; u32 count = 0; //Loop 4 ever while(1) { SceCtrlData pad; sceCtrlPeekBufferPositive(&pad, 1); if( (pad.Buttons & MASK) == MASK ) { if(++count > 5) //If button press for more that 2sec we return to main menu { count = 0; CGraphicsContext::Get()->ClearAllSurfaces(); CPU_Halt("Panic"); ThreadSleepMs(2000); } } else count = 0; //Idle here, only check button 3 times/sec not to hog CPU time from EMU ThreadSleepMs(300); } return 0; }
static void RuntimeFault( int szText ) { lcd_printf("\014ERROR:\r\n%d\r\n", szText ); debug_printf( "ERROR: %d\r\n", szText ); // let watchdog take over CPU_Halt(); }
//***************************************************************************** // //***************************************************************************** void CSynchroniser::HandleOutOfSynch( const char * msg ) { char message[ 512 ]; sprintf( message, "Synchronisation Failed at 0x%08x: %s", gCPUState.CurrentPC, msg ); gCPUState.Dump(); CPU_Halt( message ); Destroy(); }
void HARD_Breakpoint_Handler(UINT32 *registers) { #if !defined(BUILD_RTM) GLOBAL_LOCK(irq); FAULT_HandlerDisplay(registers, 0); CPU_Halt(); #else CPU_Reset(); #endif // !defined(BUILD_RTM) }
void FAULT_Handler( UINT32* registers, UINT32 exception ) { ASSERT_IRQ_MUST_BE_OFF(); #if !defined(BUILD_RTM) FAULT_HandlerDisplay(registers, exception); CPU_Halt(); #else CPU_Reset(); #endif // !defined(BUILD_RTM) }
void StackOverflow( UINT32 sp ) { ASSERT_IRQ_MUST_BE_OFF(); #if !defined(ABORTS_REDUCESIZE) && !defined(PLATFORM_ARM_OS_PORT) lcd_printf("\fSTACK OVERFLOW\r\nsp=0x%08x\r\nStackBottom:\r\n0x%08x", sp, (UINT32)&StackBottom); CPU_Halt(); #else CPU_Reset(); #endif // !defined(ABORTS_REDUCESIZE) }
void ABORTD_Handler( UINT32* registers, UINT32 sp, UINT32 lr ) { ASSERT_IRQ_MUST_BE_OFF(); #if !defined(ABORTS_REDUCESIZE) Verify_RAMConstants((void *) FALSE); ABORT_HandlerDisplay(registers, sp, lr, 8, "ABORT Data", TRUE); CPU_Halt(); #else CPU_Reset(); #endif // !defined(ABORTS_REDUCESIZE) }
void NULL_Pointer_Write() { GLOBAL_LOCK(irq); UINT32* ResetVector = 0; lcd_printf("\fERROR:\r\nNULL Pointer write\r\nRESET vector modified to 0x%08x\r\n", *ResetVector); monitor_debug_printf("ERROR: vector area modified\r\n"); // dump many words for(int i = 0; i < 0x100; i++) { monitor_debug_printf("0x%08x=0x%08x\r\n", (UINT32) ResetVector, *ResetVector); } CPU_Halt(); }
static void HandleSaveStateOperationOnVerticalBlank() { DAEDALUS_ASSERT(gCPURunning, "Expecting the CPU to be running at this point"); if( gSaveStateOperation == SSO_NONE ) return; MutexLock lock( &gSaveStateMutex ); // // Handle the save state // switch( gSaveStateOperation ) { case SSO_NONE: DAEDALUS_ERROR( "Unreachable" ); break; case SSO_SAVE: DBGConsole_Msg(0, "Saving '%s'\n", gSaveStateFilename.c_str()); SaveState_SaveToFile( gSaveStateFilename.c_str() ); gSaveStateOperation = SSO_NONE; break; case SSO_LOAD: DBGConsole_Msg(0, "Loading '%s'\n", gSaveStateFilename.c_str()); // Try to load the savestate immediately. If this fails, it // usually means that we're running the correct rom (we should have a // separate return code to check this case). In that case we // stop the cpu and handle the load in // HandleSaveStateOperationOnCPUStopRunning. if (SaveState_LoadFromFile( gSaveStateFilename.c_str() )) { CPU_ResetFragmentCache(); gSaveStateOperation = SSO_NONE; } else { // Halt the CPU so that we can swap the rom safely and load the savesate. CPU_Halt("Load SaveSate"); // NB: return without clearing gSaveStateOperation } break; } }
void CBatchTestEventHandler::Terminate( ETerminationReason reason ) { mTerminationReason = reason; CPU_Halt( "End of batch run" ); }
void ABORT_HandlerDisplay( UINT32 *registers_const, UINT32 sp, UINT32 lr, UINT32 pc_offset, const char *Title, BOOL SerialOutput ) { UINT32 cpsr; UINT32 pc; int i; int j; #if !defined(PLATFORM_ARM_OS_PORT) UINT8* stackbytes; const UINT32* const stackwords = (UINT32 *)sp; #endif int page; UINT32* registers; #if defined(PLATFORM_ARM_MC9328) UINT32 URXDn_X; MC9328MXL_USART& USART = MC9328MXL::USART( ConvertCOM_ComPort(USART_DEFAULT_PORT) ); #else // TODO ??? #endif ++ABORT_recursion_counter; dump_again: page = 0; registers = registers_const; cpsr = *registers++; pc = (*registers++) - pc_offset; if(SerialOutput) { // unprotect the GPIO pins for USART, allowing USART output USART_Initialize( ConvertCOM_ComPort(USART_DEFAULT_PORT), USART_DEFAULT_BAUDRATE, USART_PARITY_NONE, 8, USART_STOP_BITS_ONE, USART_FLOW_NONE ); monitor_debug_printf("ERROR: %s\r\n", Title); monitor_debug_printf(" cpsr=0x%08x\r\n", cpsr); monitor_debug_printf(" pc =0x%08x\r\n", pc); monitor_debug_printf(" lr =0x%08x\r\n", lr); for(i = 0; i <= 12; i++) { monitor_debug_printf(" r%d=0x%08x\r\n", i, registers[i]); } monitor_debug_printf(" sp =0x%08x\r\n", sp); RegisterDump(); } // don't let the screen go away if the watchdog was enabled. Watchdog_Disable(); //Flash_ChipReadOnly(TRUE); // first dump stuff to the com port, then go interactive with the buttons and LCD if(SerialOutput) { monitor_debug_printf("ERROR: %s\r\n", Title); monitor_debug_printf(" cpsr=0x%08x\r\n", cpsr); monitor_debug_printf(" pc =0x%08x\r\n", pc); monitor_debug_printf(" lr =0x%08x\r\n", lr); for(i = 0; i <= 12; i++) { monitor_debug_printf(" r%d=0x%08x\r\n", i, registers[i]); } monitor_debug_printf(" sp =0x%08x\r\n", sp); #if !defined(PLATFORM_ARM_OS_PORT) stackbytes = (UINT8 *)sp; for(i = 0; i < 16; i++) { monitor_debug_printf("[0x%08x] :", (UINT32)&stackbytes[i*16]); for(j = 0; j < 16; j++) { // don't cause a data abort here! if((UINT32) &stackbytes[i*16 + j] < (UINT32) &StackTop) { monitor_debug_printf(" %02x", stackbytes[i*16 + j]); } else { monitor_debug_printf(" "); } } monitor_debug_printf(" "); for(j = 0; j < 16; j++) { if((UINT32) &stackbytes[i*16 + j] < (UINT32) &StackTop) { monitor_debug_printf("%c", (stackbytes[i*16 + j] >= ' ') ? stackbytes[i*16 + j] : '.'); } } monitor_debug_printf("\r\n"); } #endif } //--// // make sure USART is ready to go (clock enabled, pins set active) regardless of charger state, idem potent call if it was already on CPU_ProtectCommunicationGPIOs( FALSE ); #if defined(PLATFORM_ARM_MC9328) while(USART.URXDn_X[0] & MC9328MXL_USART::URXDn__CHARRDY); #else // TODO ??? #endif //--// // go interactive with the buttons and LCD while(true) { UINT32 CurrentButtonsState; lcd_printf("\f"); switch(page) { case 0: lcd_printf("%-12s \r\n\r\n", Title); lcd_printf("Build Date:\r\n"); lcd_printf("%-12s \r\n" , __DATE__); lcd_printf("%-12s \r\n" , __TIME__); lcd_printf("\r\n"); lcd_printf("cps=0x%08x\r\n", cpsr); lcd_printf("pc =0x%08x\r\n", pc); lcd_printf("lr =0x%08x\r\n", lr); lcd_printf("sp =0x%08x\r\n", sp); break; case 1: lcd_printf("Registers 1\r\n\r\n"); for(i = 0; i < 10; i++) { lcd_printf("r%1d =0x%08x\r\n", i, registers[i]); } break; case 2: lcd_printf("Registers 2\r\n\r\n"); for(i = 10; i < 13; i++) { lcd_printf("r%2d=0x%08x\r\n", i, registers[i]); } break; case 3: default: { #if !defined(PLATFORM_ARM_OS_PORT) UINT32 index = (page-3)*10; lcd_printf("Stack %08x\r\n\r\n", (UINT32)&stackwords[index]); for(i = 0; i < 10; i++) { stackbytes = (UINT8 *)&stackwords[index+i]; // don't cause a data abort displaying past the end of the stack! if((UINT32) &stackwords[index+i] < (UINT32) &StackTop) { lcd_printf("%08x %c%c%c%c\r\n", stackwords[index+i], (stackbytes[0] >= ' ') ? stackbytes[0] : '.', (stackbytes[1] >= ' ') ? stackbytes[1] : '.', (stackbytes[2] >= ' ') ? stackbytes[2] : '.', (stackbytes[3] >= ' ') ? stackbytes[3] : '.' ); } else { lcd_printf(" \r\n"); } } #endif } break; } // wait for a button press while(0 == (CurrentButtonsState = Buttons_CurrentHWState())) { #if defined(PLATFORM_ARM_MC9328) if(USART.URXDn_X[0] & MC9328MXL_USART::URXDn__CHARRDY) { goto StartMonitorMode; } #else // TODO ??? #endif } // wait for 10 mSec HAL_Time_Sleep_MicroSeconds(10000/64); // wait for it to release while(0 == (CurrentButtonsState ^ Buttons_CurrentHWState())); // wait for 10 mSec HAL_Time_Sleep_MicroSeconds(10000/64); if(CurrentButtonsState & BUTTON_B5) { page = (page + 1); // no limit of stack pages LCD_Clear(); } if(CurrentButtonsState & BUTTON_B2) { page = (page > 0) ? page - 1 : 0; LCD_Clear(); } if((CurrentButtonsState & BUTTON_B4) || (CurrentButtonsState & BUTTON_B0)) { goto dump_again; } continue; #if defined(PLATFORM_ARM_MC9328) StartMonitorMode: #endif { char data[16]; UINT32 pos = 0; LCD_Clear(); lcd_printf("\fMONITOR MODE\r\n"); HAL_Time_Sleep_MicroSeconds(10000); while(1) { #if defined(PLATFORM_ARM_MC9328) URXDn_X = USART.URXDn_X[0]; if(URXDn_X & MC9328MXL_USART::URXDn__CHARRDY) { data[pos++] = (char)(URXDn_X & MC9328MXL_USART::URXDn__DATA_mask); #else if(false) { // TODO ??? #endif switch(data[0]) { case 'L': monitor_debug_printf("rb=0x%08x\r\n", HalSystemConfig.RAM1.Base ); monitor_debug_printf("rs=0x%08x\r\n", HalSystemConfig.RAM1.Size ); monitor_debug_printf("fb=0x%08x\r\n", HalSystemConfig.FLASH.Base); monitor_debug_printf("fs=0x%08x\r\n", HalSystemConfig.FLASH.Size); break; case 'M': if(pos < 12) continue; { UINT8* start = *(UINT8**)&data[4]; UINT8* end = *(UINT8**)&data[8]; lcd_printf( "\f\r\n\r\nREAD:\r\n %08x\r\n %08x", (UINT32)start, (UINT32)end ); if(AbortHandler_CheckMemoryRange( start, end )) { while(start < end) { monitor_debug_printf("[0x%08x]", (UINT32)start); for(j = 0; j < 128; j++) { monitor_debug_printf("%02x", *start++); if(start == end) break; } monitor_debug_printf("\r\n"); } } else { monitor_debug_printf("ERROR: invalid range: %08x-%08x\r\n", (UINT32)start, (UINT32)end ); } } break; case 'R': for(i = 0; i <= 12; i++) { monitor_debug_printf("r%d=%08x\r\n", i, registers[i]); } monitor_debug_printf("sp=%08x\r\n", sp); monitor_debug_printf("lr=%08x\r\n", lr); monitor_debug_printf("pc=%08x\r\n", pc); monitor_debug_printf("cpsr=%08x\r\n", cpsr); #if defined(PLATFORM_ARM_MC9328) monitor_debug_printf("BWA=%08x\r\n", 0); monitor_debug_printf("BWC=%08x\r\n", 0); #else // TODO ??? #endif break; case '\r': case '\n': case ' ': break; default: monitor_debug_printf("ERROR: unknown command %c\r\n", data[0] ); break; } pos = 0; } else if(Buttons_CurrentHWState()) { // wait for it to release while (Buttons_CurrentHWState()); LCD_Clear(); break; } } } } } #endif // !defined(ABORTS_REDUCESIZE) extern "C" { void UNDEF_Handler( UINT32* registers, UINT32 sp, UINT32 lr ) { ASSERT_IRQ_MUST_BE_OFF(); #if !defined(ABORTS_REDUCESIZE) Verify_RAMConstants((void *) FALSE); ABORT_HandlerDisplay(registers, sp, lr, 4, "Undef Instr", TRUE); CPU_Halt(); #else CPU_Reset(); #endif // !defined(ABORTS_REDUCESIZE) }
int main(void) { #if PLATFORM_ARM_OS_PORT ClrThreadId = osThreadGetId(); #endif BootstrapCode_GPIO(); HAL_Time_Initialize(); HAL_Initialize(); #if !defined(BUILD_RTM) DEBUG_TRACE4( STREAM_LCD, ".NetMF v%d.%d.%d.%d\r\n", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION); DEBUG_TRACE3(TRACE_ALWAYS, "%s, Build Date:\r\n\t%s %s\r\n", HalName, __DATE__, __TIME__); #if defined(__GNUC__) DEBUG_TRACE1(TRACE_ALWAYS, "GNU Compiler version %d\r\n", __GNUC__); #else DEBUG_TRACE1(TRACE_ALWAYS, "ARM Compiler version %d\r\n", __ARMCC_VERSION); #endif UINT8* BaseAddress; UINT32 SizeInBytes; HeapLocation( BaseAddress, SizeInBytes ); memset ( BaseAddress, 0, SizeInBytes ); debug_printf("\f"); debug_printf("%-15s\r\n", HalName); debug_printf("%-15s\r\n", "Build Date:"); debug_printf(" %-13s\r\n", __DATE__); debug_printf(" %-13s\r\n", __TIME__); #endif // !defined(BUILD_RTM) /***********************************************************************************/ { #if defined(FIQ_SAMPLING_PROFILER) FIQ_Profiler_Init(); #endif } // the runtime is by default using a watchdog Watchdog_GetSetTimeout ( WATCHDOG_TIMEOUT , TRUE ); Watchdog_GetSetBehavior( WATCHDOG_BEHAVIOR, TRUE ); Watchdog_GetSetEnabled ( WATCHDOG_ENABLE, TRUE ); // HAL initialization completed. Interrupts are enabled. Jump to the Application routine ApplicationEntryPoint(); debug_printf("main exited!!???. Halting CPU\r\n"); #if defined(BUILD_RTM) CPU_Reset(); #else CPU_Halt(); #endif return -1; }