# HG changeset patch # User Mychaela Falconia # Date 1613602475 0 # Node ID a75c0aafb3672681baf863e0190f47f5a6b58334 # Parent d2e800abd257a56bb202cac6848228c65ade64be plmnsel-erase command implemented diff -r d2e800abd257 -r a75c0aafb367 simtool/dispatch.c --- a/simtool/dispatch.c Wed Feb 17 22:43:18 2021 +0000 +++ b/simtool/dispatch.c Wed Feb 17 22:54:35 2021 +0000 @@ -40,6 +40,7 @@ extern int cmd_pb_update_imm(); extern int cmd_pb_update_imm_hex(); extern int cmd_plmnsel_dump(); +extern int cmd_plmnsel_erase(); extern int cmd_plmnsel_write(); extern int cmd_pnn_dump(); extern int cmd_readbin(); @@ -132,6 +133,7 @@ {"pb-update-imm", 3, 4, cmd_pb_update_imm}, {"pb-update-imm-hex", 4, 4, cmd_pb_update_imm_hex}, {"plmnsel-dump", 0, 0, cmd_plmnsel_dump}, + {"plmnsel-erase", 1, 2, cmd_plmnsel_erase}, {"plmnsel-write", 2, 2, cmd_plmnsel_write}, {"pnn-dump", 0, 0, cmd_pnn_dump}, {"quit", 0, 0, good_exit}, diff -r d2e800abd257 -r a75c0aafb367 simtool/plmnsel.c --- a/simtool/plmnsel.c Wed Feb 17 22:43:18 2021 +0000 +++ b/simtool/plmnsel.c Wed Feb 17 22:54:35 2021 +0000 @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include "simresp.h" #include "curfile.h" #include "file_id.h" @@ -110,3 +112,46 @@ return(rc); return update_bin_op(idx * 3, rec, 3); } + +cmd_plmnsel_erase(argc, argv) + char **argv; +{ + int rc; + unsigned idx, start, end, nrec; + u_char rec[3]; + + rc = select_ef_plmnsel(); + if (rc < 0) + return(rc); + nrec = curfile_total_size / 3; + start = strtoul(argv[1], 0, 0); + if (start >= nrec) { + fprintf(stderr, + "error: specified starting index is out of range\n"); + return(-1); + } + if (!argv[2]) + end = start; + else if (!strcmp(argv[2], "end")) + end = nrec - 1; + else { + end = strtoul(argv[1], 0, 0); + if (end >= nrec) { + fprintf(stderr, + "error: specified ending index is out of range\n"); + return(-1); + } + if (start > end) { + fprintf(stderr, + "error: reverse index range specified\n"); + return(-1); + } + } + memset(rec, 0xFF, 3); + for (idx = start; idx <= end; idx++) { + rc = update_bin_op(idx * 3, rec, 3); + if (rc < 0) + return(rc); + } + return(0); +}