summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2022-11-26 23:42:45 +0000
committerLeah Rowe <leah@libreboot.org>2022-11-26 23:42:45 +0000
commit82300f4f1e3062f005ffb4aad4ca7452f83a4648 (patch)
treee3aa1b62675b4e140865bc04df2512b2039aed99 /util
parentddf3b76c83eb41aa8e690c3aa6d486e397319a3a (diff)
util/nvmutil: move cmd copy to own function
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 189192cf..35a2bad2 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -44,6 +44,7 @@ void hexdump(int partnum);
void cmd_setchecksum(void);
void cmd_brick(void);
void cmd_swap(void);
+void cmd_copy(void);
int validChecksum(int partnum);
uint16_t word(int pos16, int partnum);
void setWord(int pos16, int partnum, uint16_t val);
@@ -248,9 +249,7 @@ cmd(const char *command)
} else if (strcmp(command, "swap") == 0) {
cmd_swap();
} else if (strcmp(command, "copy") == 0) {
- if (validChecksum(part))
- memcpy(gbe + ((part ^ (gbeFileModified = 1)) << 12),
- gbe + (part << 12), SIZE_4KB);
+ cmd_copy();
} else
errno = EINVAL;
}
@@ -347,6 +346,14 @@ cmd_swap(void)
}
}
+void
+cmd_copy(void)
+{
+ if (validChecksum(part))
+ memcpy(gbe + ((part ^ (gbeFileModified = 1)) << 12),
+ gbe + (part << 12), SIZE_4KB);
+}
+
int
validChecksum(int partnum)
{