Firmware: added copy and compare commands (#13 and #14)

Change-Id: I22e55b860c8daf2a580760e41232be9ff9ede91a
This commit is contained in:
David Banks 2019-11-13 15:37:55 +00:00
parent bfb4f531fe
commit 1bf2358b55
2 changed files with 50 additions and 1 deletions

View File

@ -49,6 +49,8 @@ char *cmdStrings[] = {
"flush", "flush",
"fill", "fill",
"crc", "crc",
"copy",
"compare",
"mem", "mem",
"rdm", "rdm",
"wrm", "wrm",
@ -93,6 +95,8 @@ void (*cmdFuncs[])(char *params) = {
doCmdFlush, doCmdFlush,
doCmdFill, doCmdFill,
doCmdCrc, doCmdCrc,
doCmdCopy,
doCmdCompare,
doCmdMem, doCmdMem,
doCmdReadMem, doCmdReadMem,
doCmdWriteMem, doCmdWriteMem,
@ -645,7 +649,7 @@ void log_char(uint8_t c) {
void log_addr_data(addr_t a, data_t d) { void log_addr_data(addr_t a, data_t d) {
logc(' '); logc(' ');
loghex4(a); loghex4(a);
logstr(" = "); logc(':');
loghex2(d); loghex2(d);
logstr(" "); logstr(" ");
log_char(d); log_char(d);
@ -1289,6 +1293,49 @@ void doCmdCrc(char *params) {
logc('\n'); logc('\n');
} }
void doCmdCopy(char *params) {
uint16_t i;
addr_t start;
addr_t end;
addr_t to;
data_t data;
params = parsehex4(params, &start);
params = parsehex4(params, &end);
params = parsehex4(params, &to);
for (i = 0; i <= end - start; i++) {
loadAddr(start + i);
data = readMemByte();
loadData(data);
loadAddr(to + i);
writeMemByte();
}
}
void doCmdCompare(char *params) {
uint16_t i;
addr_t start;
addr_t end;
addr_t with;
data_t data1;
data_t data2;
params = parsehex4(params, &start);
params = parsehex4(params, &end);
params = parsehex4(params, &with);
for (i = 0; i <= end - start; i++) {
loadAddr(start + i);
data1 = readMemByte();
loadAddr(with + i);
data2 = readMemByte();
if (data1 != data2) {
logstr("Compare failed:");
log_addr_data(start + i, data1);
logstr(" /=");
log_addr_data(with + i, data2);
logc('\n');
}
}
}
void doCmdMem(char *params) { void doCmdMem(char *params) {
genericDump(params, readMemByteInc); genericDump(params, readMemByteInc);
} }

View File

@ -48,7 +48,9 @@ void doCmdBreakRdMem(char *params);
void doCmdBreakWrIO(char *params); void doCmdBreakWrIO(char *params);
void doCmdBreakWrMem(char *params); void doCmdBreakWrMem(char *params);
void doCmdClear(char *params); void doCmdClear(char *params);
void doCmdCompare(char *params);
void doCmdContinue(char *params); void doCmdContinue(char *params);
void doCmdCopy(char *params);
void doCmdCrc(char *params); void doCmdCrc(char *params);
void doCmdDis(char *params); void doCmdDis(char *params);
void doCmdFlush(char *params); void doCmdFlush(char *params);