double getFlashProcTime() { DWORD processId; HANDLE process; FILETIME createTime, exitTime, kernelTime, userTime; processId=FindFlash(); if (!processId) return 0; process=OpenProcess( PROCESS_QUERY_INFORMATION, FALSE, processId ); if (!process) { ErrorExit(_T("OpenProcess")); } if (!GetProcessTimes( process, &createTime, &exitTime, &kernelTime, &userTime )) { ErrorExit(_T("GetProcessTimes")); } // ? http://www.codeproject.com/KB/threads/getprocesstimes.aspx return (*((__int64 *)&kernelTime)/1e7)+(*((__int64 *)&userTime)/1e7); }
static int BURNT_action(int argc, char *argv[]) { UINT i; UINT32 src_addr=0x100000; UINT32 dest_addr=FLASH_BASE; UINT32 src,dest; UINT32 fileSize=0; UINT32 blockSize=0; INT flash_type; if( !_net_init ) { if( Net_Init(_dhcp) < 0 ) { uprintf("ERROR: Network initialization failed!\n"); return -1; } _net_init=1; } uprintf("Waiting for download ...\n"); if( TFTP_Download((UCHAR *)src_addr,(ULONG *)&fileSize,_dhcp)==0 ) { uprintf("\nFlash programming "); if( _net_init )DisableIRQ(); flash_type=FindFlash(); if( _net_init )EnableIRQ(); if( flash_type < 0 ) { uprintf("ERROR: Un-supported flash type !!\n"); return -1; } // Write program if( (fileSize&0x3) )fileSize=((fileSize&(~0x3))+4);//word-aligment i=fileSize; src=src_addr; dest=dest_addr; while(i) { blockSize=flash[flash_type].BlockSize(dest); if( _net_init )DisableIRQ(); flash[flash_type].BlockErase(dest, blockSize); if( i < blockSize ) { flash[flash_type].BlockWrite(dest, (UCHAR *)src, i); blockSize=i; } else { flash[flash_type].BlockWrite(dest, (UCHAR *)src, blockSize); } if( _net_init )EnableIRQ(); src+=blockSize; dest+=blockSize; i-=blockSize; uprintf("."); } uprintf(" OK!\n"); } else { uprintf("\nDownload error!\n"); return -1; } // verify data uprintf("Write data verifing "); for(i=0;i<fileSize;i+=4) { if( (i&0xFFFF)== 0x0 )uprintf("."); if( *((volatile unsigned int *)(src_addr+i))!=*((volatile unsigned int *)(dest_addr+i)) ) { uprintf("ERROR: Data failed @ 0x%08x \n", dest_addr+i); return -1; } } uprintf(" OK!\n"); return 0; }