/* Start here! */ UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { UInt16 err; // Called as a subroutine if (cmd == boogerPlugLaunchCmdBlowNose) { if ((err = StartApplication())) return (err); if (!(err = PickBooger((KleenexPtr)cmdPBP))) err = BlowNose((KleenexPtr)cmdPBP); StopApplication(); return (err); } // Running as an application if (cmd == boogerPlugLaunchCmdSneeze) { if ((err = StartApplication())) return (err); if (!(err = PickBooger((KleenexPtr)cmdPBP))) err = Sneeze((KleenexPtr)cmdPBP); StopApplication(); return (err); } return (sysErrParamErr); }
/** * @brief Function for application main entry. */ int main(void) { uint32_t *inst_src_addr = (uint32_t *)0x3A000; uint32_t *inst_dest_addr = (uint32_t *)0x20003000; uint32_t inst_size = 0xB00; clone_to_memory(inst_src_addr, inst_dest_addr, inst_size); StartApplication((uint32_t)inst_dest_addr); }
UInt32 PilotMain(UInt16 launchCode, MemPtr cmdPBP, UInt16 launchFlags) { Err err; if (launchCode == sysAppLaunchCmdNormalLaunch) { if ((err = StartApplication()) == 0) { EventLoop(); StopApplication(); } } return 0; }
DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags) { if (cmd == sysAppLaunchCmdNormalLaunch) { StartApplication (); FrmGotoForm (mainForm); EventLoop (); StopApplication (); } return (0); }
ULong PilotMain( UInt launchCode, Ptr cmdPBP, UInt launchFlags ) { Err err=0; if( launchCode == sysAppLaunchCmdNormalLaunch ) { if( (err=StartApplication()) == 0 ) { EventLoop(); StopApplication(); } } return err; }
/** * @brief ダブルクリックしたときに呼び出されます。 */ void CFootyView::OnMouseDouble(int x,int y) { // 宣言 CEditPosition cNowPosition; CUrlInfo cUrlInfo; RetOnUrl nRetURL; std::wstring strShellCommand; // フォーカスを合わせる ::SetFocus(m_hWnd); // 通常のエディタ領域 if (y > m_nRulerHeight && x > m_nLineCountWidth) { // キャレット位置を移動する CalcInfoFromMouse(x,y,&cNowPosition); // クリッカブル? nRetURL = IsOnUrl(&cNowPosition,&cUrlInfo); if (nRetURL == ONURL_URL) // URL { strShellCommand = cNowPosition.GetLinePointer()-> m_strLineData.substr(cUrlInfo.m_nStartPos,cUrlInfo.GetLength()); StartApplication(strShellCommand.c_str()); } else if (nRetURL == ONURL_MAIL) // メールアドレス { strShellCommand = L"mailto:"; strShellCommand += cNowPosition.GetLinePointer()-> m_strLineData.substr(cUrlInfo.m_nStartPos,cUrlInfo.GetLength()); StartApplication(strShellCommand.c_str()); } else // 何もない(単語の選択処理) { m_pDocuments->SelectWord(); Refresh(); } } }
DWord PilotMain (Word cmd, Ptr cmdPBP, Word launchFlags) { int error; if (cmd == sysAppLaunchCmdNormalLaunch) { error = StartApplication(); if (error) return error; EventLoop(); StopApplication(); } return 0; }
/* Main entry point; it is unlikely you will need to change this except to handle other launch command codes */ UInt32 PilotMain(UInt16 cmd, void *cmdPBP, UInt16 launchFlags) { UInt16 err; if (cmd == sysAppLaunchCmdNormalLaunch) { err = StartApplication(); if (err) return err; EventLoop(); StopApplication(); } else { return sysErrParamErr; } return 0; }
/* This is the main entry point for the cleaner application */ UInt32 PilotMain ( UInt16 cmd, /* SysAppLaunch Command */ MemPtr cmdPBP, /* pointer to command parameter block */ UInt16 launchFlags /* launch flag ( see SystemMgr.h for details ) */ ) { Err err; err = errNone; if ( cmd == sysAppLaunchCmdNormalLaunch ) { err = StartApplication( NULL ); if ( err != errNone ) return err; EventLoop(); StopApplication(); } return err; }
/* Main entry point; it is unlikely you will need to change this except to handle other launch command codes */ DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags) { if (cmd == sysAppLaunchCmdNormalLaunch) { Word err; err = StartApplication(); if (err) { FrmCloseAllForms(); return err; } EventLoop(); StopApplication(); } else { return sysErrParamErr; } return 0; }
/* Main entry point; it is unlikely you will need to change this except to handle other launch command codes */ UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { UInt16 err; if (cmd == sysAppLaunchCmdNormalLaunch) { err = StartApplication(); if (err) { FrmCloseAllForms(); return err; } EventLoop(); StopApplication(); } else { return sysErrParamErr; } return 0; }
BOOL CUpdaterApp::InitInstance() { CWinApp::InitInstance(); CString sCommandLine; HANDLE hMutex = CreateMutex(NULL, FALSE, _T("Updater")); switch(GetLastError()) { case ERROR_SUCCESS: // Mutes created successfully. There is no instance running break; case ERROR_ALREADY_EXISTS: // Mutes already exists so there is a running instance of our app. return FALSE; default: // Failed to create mutes by unknown reason return FALSE; } sCommandLine.Format(_T("%s"), m_lpCmdLine); StartApplication(sCommandLine); return FALSE; }
/* Main entry point; it is unlikely you will need to change this except to handle other launch command codes */ UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { UInt16 err; if (cmd != sysAppLaunchCmdNormalLaunch) return sysErrParamErr; if (!(buffer = WinCreateOffscreenWindow (160, 160, screenFormat, &err))) return err; if ((err = StartApplication()) != 0) return err; ticks = SysTicksPerSecond() / FRAME_RATE; run_game (); /* EventLoop(); */ StopApplication(); WinDeleteWindow (buffer, false); return 0; }
/********************************************************************************** * Function: PilotMain * Description: this is the function that is acctually called by the PalmOS when * application start and other events occur. we handle those system launch events * here * *******************************************************************************/ UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { Err err = 0; // request to start application normally if (cmd == sysAppLaunchCmdNormalLaunch) { #if ((defined DEBUG) && (defined HAVE_GDBHOOK)) _gdb_hook(); #endif // call StartApplication to initialize things, // go to the opening form and enter the event loop, // until end. if ((err = StartApplication ()) == 0) { FrmGotoForm (PasswordForm); EventLoop (); StopApplication (); } } return cmd; }
INT main(VOID){ StartApplication(); return EXIT_SUCCESS; }
/*********************************************************************** * main function ***********************************************************************/ UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { UInt16 error = RomVersionCompatible (MINVERSION, launchFlags); if (error) return (error); /*** * NORMAL STARTUP ****/ if ( cmd == sysAppLaunchCmdNormalLaunch ) { error = StartApplication (); if (error) { // PalmOS before 3.5 will continuously relaunch this app unless we switch to // another safe one. if (error != dmErrCorruptDatabase) { FrmCustomAlert(ALERT_debug, "Please reports this bug! Give your Palm device and PalmOS version, this BadBug(TM) should not happen.", "", ""); } StopApplication(); AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); return error; } FrmGotoForm(FORM_main); AppEventLoop (); StopApplication (); /*** * FIND ****/ /* } else if (cmd == sysAppLaunchCmdSaveData) { FrmSaveAllForms(); } else if (cmd == sysAppLaunchCmdFind) { PalmGlobalFind((FindParamsPtr)cmdPBP); */ /*** * GoTo ****/ /* } else if (cmd == sysAppLaunchCmdGoTo) { Boolean launched = launchFlags & sysAppLaunchFlagNewGlobals; if (launched) { error = StartApplication(); if (! error) { GoToItem((GoToParamsPtr)cmdPBP, launched); AppEventLoop(); StopApplication(); } } else { GoToItem((GoToParamsPtr)cmdPBP, launched); } */ /*** * BEAMING ****/ } else if (cmd == sysAppLaunchCmdSyncNotify) { // Register with the Exchange Manager ExgRegisterData(APP_CREATOR, exgRegExtensionID, "umx"); } else if (cmd == sysAppLaunchCmdExgAskUser) { // Always assume "Yes" as answer to the accept dialog since we display our // own on which the user can cancel the data ExgAskParamType *exgAskParam = (ExgAskParamType *)cmdPBP; exgAskParam->result=exgAskOk; } else if (cmd == sysAppLaunchCmdExgReceiveData) { DmOpenRef cats=NULL, dogs=NULL; // Is app active? if (launchFlags & sysAppLaunchFlagSubCall) { // Quit Forms FrmSaveAllForms(); cats = DatabaseGetRefN(DB_MAIN); dogs = DatabaseGetRefN(DB_DATA); error = BeamReceive(cats, dogs, (ExgSocketPtr) cmdPBP); CacheReset(); FrmGotoForm(FORM_main); } else { // Another app was running when we were called cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite); dogs = DmOpenDatabaseByTypeCreator(DATABASE_DATA_TYPE, APP_CREATOR, dmModeReadWrite); if (! (cats && dogs)) { FrmAlert(ALERT_beamdbfail); } else { error=BeamReceive(cats, dogs, (ExgSocketPtr)cmdPBP); } if (cats) DmCloseDatabase(cats); if (dogs) DmCloseDatabase(dogs); } /*** * ALARM ****/ } else if (cmd == sysAppLaunchCmdAlarmTriggered) { // Is app active? if (launchFlags & sysAppLaunchFlagSubCall) { AlarmTriggered(DatabaseGetRefN(DB_MAIN), (SysAlarmTriggeredParamType *)cmdPBP); } else { DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite); AlarmTriggered(cats, (SysAlarmTriggeredParamType *)cmdPBP); DmCloseDatabase(cats); } /*** * ATTENTION ****/ } else if (cmd == sysAppLaunchCmdAttention) { // Is app active? if (launchFlags & sysAppLaunchFlagSubCall) { AttentionBottleNeckProc(DatabaseGetRefN(DB_MAIN), (AttnLaunchCodeArgsType *)cmdPBP); } else { // Another app was running when we were called DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite); AttentionBottleNeckProc(cats, (AttnLaunchCodeArgsType *)cmdPBP); DmCloseDatabase(cats); } /*** * ATTENTION GOTO ****/ } else if (cmd == appLaunchCmdAlarmEventGoto) { error = StartApplication (); if (error) { // PalmOS before 3.5 will continuously relaunch this app unless we switch to // another safe one. if (error != dmErrCorruptDatabase) { FrmCustomAlert(ALERT_debug, "Please reports this bug! Give your Palm device and PalmOS version, this BadBug(TM) should not happen.", "", ""); } StopApplication(); AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); return error; } ExamSetGoto(*(UInt32 *)cmdPBP); FrmGotoForm(FORM_exams); AppEventLoop (); StopApplication (); /*** * TIME CHANGE ****/ // Launch code sent when the system time is changed. } else if (cmd == sysAppLaunchCmdTimeChange) { // reset the trigger for the next alarm to fire if (launchFlags & sysAppLaunchFlagSubCall) { AlarmReset(DatabaseGetRefN(DB_MAIN)); // Remove any "future" alarms from the attention manager queue // (ie alarms that will trigger after the new time setting) //AlarmUpdatePosted(DeviceTimeChanged); } else { // Another app was running when we were called DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite); if (cats != 0) { AlarmReset(cats); //AlarmUpdatePosted(DeviceTimeChanged); DmCloseDatabase(cats); } } /*** * RESET ****/ // This action code is sent after the system is reset. } else if (cmd == sysAppLaunchCmdSystemReset) { if (! ((SysAppLaunchCmdSystemResetType*)cmdPBP)->hardReset) { if (launchFlags & sysAppLaunchFlagSubCall) { AlarmReset(DatabaseGetRefN(DB_MAIN)); } else { // Another app was running when we were called DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite); if (cats != 0) { AlarmReset(cats); DmCloseDatabase(cats); } } } } return 0; }
void ApplicationEntryPoint() { UINT32 ComEvent; g_State.Initialize(); ComEvent = 0; if(COM_IsSerial(g_State.UsartPort) && (g_State.UsartPort != COM_NULL)) { ComEvent = SYSTEM_EVENT_FLAG_COM_IN; } #if !defined(TARGETLOCATION_RAM) g_State.WaitForActivity = (g_State.ProgramCount != 0); // is there a main app? #else g_State.WaitForActivity = FALSE; // forever #endif { UINT32 ButtonsPressed; UINT32 ButtonsReleased; char c; // clear any events present from startup while(Events_Get( SYSTEM_EVENT_FLAG_ALL )); // clear any junk from com port buffers while(DebuggerPort_Read( g_State.UsartPort, &c, sizeof(c) )); // clear any junk from button buffer while(Buttons_GetNextStateChange( ButtonsPressed, ButtonsReleased )); } { BOOL ProcessingSREC = FALSE; BOOL ProcessingXREC = FALSE; INT32 ProcessingZENFLASH = 0; INT32 Mode = 0; INT32 MenuChoice = 1; // main application location when USB not enabled BOOL MenuUpdate = TRUE; UINT32 USBEvent = 0; COM_HANDLE ReadPort = COM_NULL; int MenuOffset = 1; // no USB enabled INT64 WaitTimeout = 0; #if defined(PLATFORM_ARM_MOTE2) CPU_GPIO_SetPinState( LED1_GREEN, LED_ON ); #endif if(g_State.WaitForActivity) { WaitTimeout = HAL_Time_CurrentTime() + (INT64)g_State.WaitInterval * (10 * 1000); hal_printf( "Waiting %d.%03d second(s) for hex upload\r\n", g_State.WaitInterval / 1000, g_State.WaitInterval % 1000 ); } else { hal_printf( "Waiting forever for hex upload\r\n" ); } // checking the existence of Usb Driver, all the default values are set to no USB if( USB_DEVICE_STATE_NO_CONTROLLER != USB_GetStatus( ConvertCOM_UsbController(g_State.UsbPort) ) ) { g_State.UsingUsb = TRUE; MenuChoice = 2; MenuOffset = 2; } while(true) { if(MenuUpdate) { MenuUpdate = FALSE; LCD_Clear(); hal_fprintf( STREAM_LCD, "\f"); switch(Mode) { case 0: hal_fprintf( STREAM_LCD, " Zen Boot\r\n\r\n" ); hal_fprintf( STREAM_LCD, "%c PortBooter\r\n", MenuChoice == 0 ? '*' : ' ' ); if(g_State.UsingUsb) { hal_fprintf( STREAM_LCD, "%c FlashUSB\r\n", MenuChoice == 1 ? '*' : ' ' ); } for(int i = 0; i < g_State.ProgramCount; i++) { hal_fprintf( STREAM_LCD, "%c Prg:%08x\r\n", (i+MenuOffset) == MenuChoice ? '*' : ' ', g_State.Programs[i] ); } break; case 1: hal_printf( "PortBooter v%d.%d.%d.%d\r\n", VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION); hal_fprintf( STREAM_LCD, "Waiting forever for hex upload\r\n" ); break; case 2: hal_fprintf( STREAM_LCD, "FlashUSB\r\n" ); hal_fprintf( STREAM_LCD, "Waiting forever for hex upload\r\n" ); break; } } UINT32 Events = Events_WaitForEvents( ComEvent | SYSTEM_EVENT_FLAG_BUTTON | SYSTEM_EVENT_FLAG_USB_IN, 2000 ); if(Events & SYSTEM_EVENT_FLAG_BUTTON) { UINT32 ButtonsPressed; UINT32 ButtonsReleased; Events_Clear( SYSTEM_EVENT_FLAG_BUTTON ); while(Buttons_GetNextStateChange( ButtonsPressed, ButtonsReleased )); { if(g_State.SerialPortActive == FALSE) { //printf("%02x %02x\r\n", ButtonsPressed, ButtonsReleased); // up if(ButtonsPressed & BUTTON_UP) { switch(Mode) { case 0: MenuChoice = __max( MenuChoice-1, 0 ); break; } g_State.WaitForActivity = FALSE; MenuUpdate = TRUE; } // down if(ButtonsPressed & BUTTON_DOWN) { switch(Mode) { case 0: MenuChoice = __min( MenuChoice+1, g_State.ProgramCount + MenuOffset-1 ); break; } g_State.WaitForActivity = FALSE; MenuUpdate = TRUE; } // enter button if(ButtonsPressed & BUTTON_ENTR) { switch(Mode) { case 0: if(MenuChoice == 0) { Mode = 1; //UsingUsb = FALSE; } else if(g_State.UsingUsb && MenuChoice == 1) { Mode = 2; USB_Configure( ConvertCOM_UsbController(g_State.UsbPort), &UsbDefaultConfiguration ); USB_Initialize( ConvertCOM_UsbController(g_State.UsbPort) ); USB_OpenStream( ConvertCOM_UsbStream(g_State.UsbPort), USB_DEBUG_EP_WRITE, USB_DEBUG_EP_READ ); //UsingUsb = TRUE; } else { StartApplication( (void (*)())g_State.Programs[MenuChoice-MenuOffset] ); } break; case 1: Mode = 0; break; case 2: // USB_Uninitialize(); Mode = 0; break; } g_State.WaitForActivity = FALSE; MenuUpdate = TRUE; } if(ButtonsReleased) { MenuUpdate = TRUE; } } } } if((Events & ComEvent) || (Events & SYSTEM_EVENT_FLAG_USB_IN)) { char c; if(Events & ComEvent) { Events_Clear( ComEvent ); ReadPort = g_State.UsartPort; g_State.pStreamOutput = ReadPort; } else { USBEvent = USB_GetEvent( ConvertCOM_UsbController(g_State.UsbPort), USB_EVENT_ALL ); if( !(USBEvent & g_State.UsbEventCode) ) continue; g_State.pStreamOutput = g_State.UsbPort; ReadPort = g_State.UsbPort; } while(DebuggerPort_Read( ReadPort, &c, sizeof(c) )) { if(ProcessingSREC) { ProcessingSREC = g_SREC.Process( c ); } else if(ProcessingXREC) { ProcessingXREC = g_XREC.Process( c ); } else if(ProcessingZENFLASH) { const char Signature[] = "ZENFLASH\r"; //printf( "Got %d at %d\r\n", c, ProcessingZENFLASH ); if(Signature[ProcessingZENFLASH++] == c) { if(Signature[ProcessingZENFLASH] == 0) { SignalActivity(); ProcessingZENFLASH = 0; } } else { ProcessingZENFLASH = 0; } } else if('S' == c) { ProcessingSREC = TRUE; } else if('X' == c) { ProcessingXREC = TRUE; } else if('Z' == c) { ProcessingZENFLASH = 1; } } } if(g_State.WaitForActivity && WaitTimeout < HAL_Time_CurrentTime()) { #if defined(PLATFORM_ARM_MOTE2) CPU_GPIO_SetPinState(LED1_GREEN, LED_OFF); // Turn off Green LED for iMOTE2 #endif // we didn't see anything on serial port for wait interval (2 seconds nominally), // continue with code - just run the normal application StartApplication( (void (*)())g_State.Programs[0] ); } } } }
BOOL Process( UINT8 c ) { while(true) { switch(m_phase) { // // Setup 'address' reception. // case 0: m_ptr = (char*)&m_address; m_len = sizeof(m_address); m_phase++; break; // // Setup 'size' reception. // case 2: //printf( "Got address %08x\r\n", m_address ); m_ptr = (char*)&m_size; m_len = sizeof(m_size); m_phase++; return TRUE; // // Setup 'crc' reception. // case 4: //printf( "Got size %08x\r\n", m_size ); m_ptr = (char*)&m_crc; m_len = sizeof(m_crc); m_phase++; return TRUE; // // Setup 'data' reception or jump to entrypoint. // case 6: //printf( "Got crc %08x\r\n", m_crc ); m_crc += m_address; m_crc += m_size; if(m_size == 0) { if(m_crc != 0) { hal_fprintf( g_State.pStreamOutput, "X crc %08x %08x\r\n", m_address, m_crc ); // bad characters! realign m_phase = 0; return FALSE; } hal_fprintf( g_State.pStreamOutput, "X start %08x\r\n", m_address ); #if defined(PLATFORM_ARM_MOTE2) CPU_GPIO_SetPinState(LED1_GREEN, LED_OFF); // Turn off Green LED for iMote2 #endif StartApplication( (void (*)())m_address ); } if(m_size > sizeof(m_data) || (m_size % sizeof(FLASH_WORD)) != 0) { hal_fprintf( g_State.pStreamOutput, "X size %d\r\n", m_size ); // bad characters! realign m_phase = 0; return FALSE; } m_ptr = (char*)m_data; m_len = m_size; m_phase++; return TRUE; case 8: { FLASH_WORD* src = (FLASH_WORD*)m_data; FLASH_WORD* dst = (FLASH_WORD*)m_address; BOOL success = TRUE; int i; BlockStorageDevice * pDevice; ByteAddress WriteByteAddress ; for(i=0; i<m_size; i++) { m_crc += m_data[i]; } if(m_crc != 0) { hal_fprintf( g_State.pStreamOutput, "X crc %08x %08x\r\n", m_address, m_crc ); // bad characters! realign m_phase = 0; return FALSE; } SignalActivity(); // this slows things down to print every address, only print once per line hal_fprintf( STREAM_LCD, "WR: 0x%08x\r", (UINT32)dst ); // if it not Block Device, assume it is RAM if (BlockStorageList::FindDeviceForPhysicalAddress( & pDevice, m_address, WriteByteAddress)) { UINT32 regionIndex, rangeIndex; const BlockDeviceInfo* deviceInfo = pDevice->GetDeviceInfo() ; if(!(pDevice->FindRegionFromAddress(WriteByteAddress, regionIndex, rangeIndex))) { #if !defined(BUILD_RTM) hal_printf(" Invalid condition - Fail to find the block number from the ByteAddress %x \r\n",WriteByteAddress); #endif return FALSE; } // start from the block where the sector sits. UINT32 iRegion = regionIndex; UINT32 accessPhyAddress = (UINT32)m_address; BYTE* bufPtr = (BYTE*)src; BOOL success = TRUE; INT32 writeLenInBytes = m_size; while (writeLenInBytes > 0) { for(; iRegion < deviceInfo->NumRegions; iRegion++) { const BlockRegionInfo *pRegion = &(deviceInfo->Regions[iRegion]); ByteAddress blkAddr = pRegion->Start; while(blkAddr < accessPhyAddress) { blkAddr += pRegion->BytesPerBlock; } //writeMaxLength =the current largest number of bytes can be read from the block from the address to its block boundary. UINT32 NumOfBytes = __min(pRegion->BytesPerBlock, writeLenInBytes); if (accessPhyAddress == blkAddr && !pDevice->IsBlockErased(blkAddr, pRegion->BytesPerBlock)) { hal_fprintf( STREAM_LCD, "ER: 0x%08x\r", blkAddr ); pDevice->EraseBlock(blkAddr); blkAddr += pRegion->BytesPerBlock; } success = pDevice->Write(accessPhyAddress , NumOfBytes, (BYTE *)bufPtr, FALSE); writeLenInBytes -= NumOfBytes; if ((writeLenInBytes <=0) || (!success)) break; bufPtr += NumOfBytes; } if ((writeLenInBytes <=0) || (!success)) break; } } else { // must be RAM but don't verify, we write anyway, possibly causing a data abort if the address is bogus memcpy( dst, src, m_size ); } hal_fprintf( g_State.pStreamOutput, "X %s %08x\r\n", success ? "ack" : "nack", m_address ); m_phase = 0; return FALSE; } break; // // Read data. // case 1: case 3: case 5: case 7: *m_ptr++ = c; if(--m_len) return TRUE; m_phase++; break; } } }
BOOL Process( char c ) { switch(c) { case XON: case XOFF: // swallow these and go on break; case '\r': case '\n': { // terminate string! m_LineBuffer[m_Pos] = 0; if(ParseLine( m_LineBuffer )) { if(m_StartAddress) { if(!m_Failures) { StartApplication( (void (*)())m_StartAddress ); } else { // after getting a failed complete download, clear the error and start anew m_StartAddress = 0; m_Failures = FALSE; LCD_Clear(); hal_fprintf( STREAM_LCD, "\fFlashing...\r\n\r\n" ); } } } else { // bad characters! realign and don't exec m_Failures = TRUE; hal_fprintf( STREAM_LCD, "%12s\r\n", m_LineBuffer ); } m_Pos = 0; return FALSE; // Always align again after getting a full record. } break; default: { if(!((c < 0x80) && (c > 0x20))) { // bad characters! m_Failures = TRUE; m_Pos = 0; hal_fprintf( STREAM_LCD, "\r\nL:%d\r\n", c ); return FALSE; // Realign. } else { // if we have a non whitespace character, store it m_LineBuffer[m_Pos++] = c; // don't overrun stuff in case of bizarre failures that appear OK char by char if(m_Pos >= sizeof(m_LineBuffer)) { m_Failures = TRUE; m_Pos = 0; hal_fprintf( STREAM_LCD, "OVERFLOW\r\n" ); return FALSE; // Realign. } } } break; } return TRUE; }
void bootloader_util_app_start(uint32_t start_addr) { StartApplication(start_addr); }