summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-06-01 08:25:55 +0100
committerLeah Rowe <leah@libreboot.org>2023-06-01 08:25:55 +0100
commit5d6af06a73e96217c229d4074a28f6d310b33fab (patch)
tree22fd0602f4a779edddfef88cc39546482d14b08d /util/nvmutil
parenta2136933af50988978aaf96919e9d013b1901f8f (diff)
util/nvmutil: move non-functions to nvmutil.h
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c49
-rw-r--r--util/nvmutil/nvmutil.h67
2 files changed, 68 insertions, 48 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 0b3cce7a..f3ea1a66 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -21,11 +21,6 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/*
- * This file is part of Libreboot. See:
- * https://libreboot.org/docs/install/nvmutil.html
- */
-
#include <sys/stat.h>
#include <dirent.h>
@@ -38,49 +33,7 @@
#include <string.h>
#include <unistd.h>
-void readGbeFile(int *fd, const char *path, int flags,
- size_t nr);
-void cmd_setmac(const char *strMac);
-int invalidMacAddress(const char *strMac, uint16_t *mac);
-uint8_t hextonum(char chs);
-uint8_t rhex(void);
-void cmd_dump(void);
-void showmac(int partnum);
-void hexdump(int partnum);
-void cmd_setchecksum(void);
-void cmd_brick(void);
-void cmd_swap(void);
-void cmd_copy(void);
-int validChecksum(int partnum);
-void setWord(int pos16, int partnum, uint16_t val16);
-void xorswap_buf(int n, int partnum);
-void writeGbeFile(int *fd, const char *filename, size_t nw);
-void xpledge(const char *promises, const char *execpromises);
-void xunveil(const char *path, const char *permissions);
-
-#define FILENAME argv[1]
-#define COMMAND argv[2]
-#define MAC_ADDRESS argv[3]
-#define PARTNUM argv[3]
-#define SIZE_4KB 0x1000
-#define SIZE_8KB 0x2000
-
-uint16_t buf16[SIZE_4KB];
-uint8_t *buf;
-size_t gbe[2];
-uint8_t skipread[2] = {0, 0};
-
-int part, gbeFileModified = 0;
-uint8_t nvmPartModified[2] = {0, 0};
-
-uint16_t test;
-uint8_t big_endian;
-
-#define word(pos16, partnum) buf16[pos16 + (partnum << 11)]
-#define ERR() errno = errno ? errno : ECANCELED
-#define xorswap(x, y) x ^= y, y ^= x, x ^= y
-#define xopen(fd, loc, p) if ((fd = open(loc, p)) == -1) err(ERR(), "%s", loc)
-#define err_if(x) if (x) err(ERR(), NULL)
+#include "nvmutil.h"
int
main(int argc, char *argv[])
diff --git a/util/nvmutil/nvmutil.h b/util/nvmutil/nvmutil.h
new file mode 100644
index 00000000..1411266c
--- /dev/null
+++ b/util/nvmutil/nvmutil.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2022, 2023 Leah Rowe <info@minifree.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+void readGbeFile(int *fd, const char *path, int flags,
+ size_t nr);
+void cmd_setmac(const char *strMac);
+int invalidMacAddress(const char *strMac, uint16_t *mac);
+uint8_t hextonum(char chs);
+uint8_t rhex(void);
+void cmd_dump(void);
+void showmac(int partnum);
+void hexdump(int partnum);
+void cmd_setchecksum(void);
+void cmd_brick(void);
+void cmd_swap(void);
+void cmd_copy(void);
+int validChecksum(int partnum);
+void setWord(int pos16, int partnum, uint16_t val16);
+void xorswap_buf(int n, int partnum);
+void writeGbeFile(int *fd, const char *filename, size_t nw);
+void xpledge(const char *promises, const char *execpromises);
+void xunveil(const char *path, const char *permissions);
+
+#define FILENAME argv[1]
+#define COMMAND argv[2]
+#define MAC_ADDRESS argv[3]
+#define PARTNUM argv[3]
+#define SIZE_4KB 0x1000
+#define SIZE_8KB 0x2000
+
+uint16_t buf16[SIZE_4KB];
+uint8_t *buf;
+size_t gbe[2];
+uint8_t skipread[2] = {0, 0};
+
+int part, gbeFileModified = 0;
+uint8_t nvmPartModified[2] = {0, 0};
+
+uint16_t test;
+uint8_t big_endian;
+
+#define word(pos16, partnum) buf16[pos16 + (partnum << 11)]
+#define ERR() errno = errno ? errno : ECANCELED
+#define xorswap(x, y) x ^= y, y ^= x, x ^= y
+#define xopen(fd, loc, p) if ((fd = open(loc, p)) == -1) err(ERR(), "%s", loc)
+#define err_if(x) if (x) err(ERR(), NULL)
+