util/nvmutil: move cmd brick to own function

fsdg20230625
Leah Rowe 2022-11-26 23:29:41 +00:00
parent eaad16edad
commit c2ed251ca6
1 changed files with 9 additions and 2 deletions

View File

@ -42,6 +42,7 @@ void cmd_dump(void);
void showmac(int partnum);
void hexdump(int partnum);
void cmd_setchecksum(void);
void cmd_brick(void);
int validChecksum(int partnum);
uint16_t word(int pos16, int partnum);
void setWord(int pos16, int partnum, uint16_t val);
@ -244,8 +245,7 @@ cmd(const char *command)
} else if (strcmp(command, "setchecksum") == 0) {
cmd_setchecksum();
} else if (strcmp(command, "brick") == 0) {
if (validChecksum(part))
setWord(0x3F, part, (word(0x3F, part)) ^ 0xFF);
cmd_brick();
} else if (strcmp(command, "swap") == 0) {
part0 = validChecksum(0);
part1 = validChecksum(1);
@ -332,6 +332,13 @@ cmd_setchecksum(void)
setWord(0x3F, part, 0xBABA - val16);
}
void
cmd_brick(void)
{
if (validChecksum(part))
setWord(0x3F, part, (word(0x3F, part)) ^ 0xFF);
}
int
validChecksum(int partnum)
{