📄 copy.c
字号:
/************************************************************* * File: mon/copy.c * Purpose: Part of core Monitor * Author: Phil Bunce (pjb@carmel.com) * Revision History: * 970304 Start of revision history * 980406 Added blksz. */#include <mon.h>Optdesc copy_opts[] = { {"[-f] from to siz","copy memory"}, {"from","source of copy"}, {"to","destination of copy"}, {"cnt","copy cnt bytes"}, {"-f","write to flash"}, {0}};/************************************************************** copy(ac,av)* the 'copy' command */copy(ac,av)int ac;char *av[];{Ulong from, to, n;int i,fflag,blksz;char buf[100];if (!regChain) { printf("Target Description Driver not loaded\n"); return(1); }fflag = 0;for (i=1;i<ac;i++) { if (av[i][0] == '-') { if (strequ(av[i],"-f")) fflag++; else { printf("%s: bad option\n",av[i]); return(1); } } else break; }if (ac-i != 3) { printf("bad argument count\n"); return(1); }if(!get_rsa(&from,av[i]) || !get_rsa(&to,av[i+1]) || !get_rsa(&n,av[i+2])) return(1);if (fflag) {#ifdef NVRAM if (fflag < 2) { /* use 2 -f flags to skip this warning */ printf("Are you sure that you want to write to the flashes (y/n)?"); gets(buf); if (!strequ(buf,"y")) return; } blksz = nvInfo.width*nvInfo.type->se; /* 980406 */ if (to&(blksz-1)) { printf("error: flash write must start on a %dKB boundary.\n", blksz/1024); return(1); } while(n-- > 0) writeFlash(to++, read_target(XT_MEM,from++,1)); return(0);#else printf("write to NVRAM not supported with this configuration.\n"); return(1);#endif }if (to < from) while(n-- > 0) write_target(XT_MEM,to++, read_target(XT_MEM,from++,1),1);else for (from += n,to += n;n-- > 0;) write_target(XT_MEM,--to, read_target(XT_MEM,--from,1),1);return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -