📄 xflash.c
字号:
/************************************************************* * File: xflash.c * Purpose: Program to generate self-blowing flash updates * Author: Phil Bunce (pjb@carmel.com) * Revision History: * 970604 Created * 970605 Moved writeFlash to lib/nvram.c * 970927 Added csum * 980108 Added ifdef for GHS jal indirect bug * 980406 Improved estimated time calc. * 980622 Added extern to nvInfo declaration (BSO). * 980827 Added ifdef for SWAPENDIAN. This just prints a message. */#include <mon.h>extern unsigned char dat1[];extern int dat1_size;extern Ulong dat1_csum;extern NvInfo nvInfo;char _drivername[] = "Flash update";/**************************************************************/main(){char nvmsg[40];Uchar *src;int machtype,i,sects,eta;Ulong dst,csum;Func *f;machtype = getHostType();printf("cputype: %d\n",machtype);switch (machtype) { case 4001 : case 4002 : case 4101 : nvInfo.start = 0xbfc00000; nvInfo.width = 4; nvInfo.gap = 1; nvInfo.nvbase = 0; break; case 4010 : case 4011 : case 4102 : nvInfo.start = 0xbfc00000; nvInfo.width = 1; nvInfo.gap = 1; nvInfo.nvbase = 0; break; case 4003 :printf("Self updating flashes are not currently supported on this processor\n"); exit(1,machtype); case 64364 : /* only 128KB Client memory. Not enough to even download. */ default : printf("unrecognized CPU type\n"); exit(2,machtype); }if (!nvCheck(nvmsg)) { switch (machtype) { case 4010 : case 4011 : case 4102 : nvInfo.start = 0xbfd00000; break; default : printf("%s: unrecognized nvram type, exiting.\n",nvmsg); exit(3,nvmsg); } if (!nvCheck(nvmsg)) { printf("%s: unrecognized nvram type, exiting.\n",nvmsg); exit(3,nvmsg); } }printf("flashtype: %s\n",nvmsg);src = dat1;for (csum=0,i=0;i<dat1_size;i++) csum += *src++;if (dat1_csum != csum) { printf("bad checksum: expected %08x got %08x.\n",dat1_csum,csum); exit(4,csum); }printf("checksum: ok.\n");#ifdef SWAPENDIANprintf("Don't forget to swap the flashes if you target uses more\n");printf("than one device.\n");#endifsrc = dat1;dst = nvInfo.start;sects = (dat1_size/nvInfo.type->se)+1; /* round up 980406 */eta = (3*sects)+((dat1_size*140)/(1024*1024)); /* 980406 *//* 980708 Noticed that 4101 estimate was 13.5% too small. * Changed dat1_size mult from 128 to 140 */printf("writing flash memories... (estimated time %d seconds)",eta);for (i=0;i<dat1_size;i++) writeFlash((Ulong)dst++,*src++);/* reboot */#ifdef GHSf = (Func *)0xbfc00000;(* f)();#else(* ((Func *)0xbfc00000))();#endif}do_cmd() {/* stub */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -