summaryrefslogtreecommitdiff
path: root/util/nvmutil/lib/word.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-24 00:28:15 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-24 01:25:53 +0000
commitf2544d094ba88e1cfbb7993ad67444852cfd5efd (patch)
tree252172594a1284e59e88c73c22f0201508809022 /util/nvmutil/lib/word.c
parentafcd535816b45fd7b0e0d07c1a8580f6f462f5e4 (diff)
util/mkhtemp: new utility (hardened mktemp)
part of the same code library as nvmutil. as part of this, i renamed util/nvmutil to util/libreboot-utils/ because it is now a multi-utility codebase. this is more efficient, since i also wish to use mkhtemp (function) in nvmutil. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/lib/word.c')
-rw-r--r--util/nvmutil/lib/word.c68
1 files changed, 0 insertions, 68 deletions
diff --git a/util/nvmutil/lib/word.c b/util/nvmutil/lib/word.c
deleted file mode 100644
index f84dae6a..00000000
--- a/util/nvmutil/lib/word.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* SPDX-License-Identifier: MIT
- * Copyright (c) 2022-2026 Leah Rowe <leah@libreboot.org>
- *
- * Manipulate Intel GbE NVM words, which are 16-bit little
- * endian in the files (MAC address words are big endian).
- */
-
-#include <sys/types.h>
-
-#include <errno.h>
-#include <stddef.h>
-
-#include "../include/common.h"
-
-unsigned short
-nvm_word(size_t pos16, size_t p)
-{
- struct xstate *x = xstatus();
- struct xfile *f = &x->f;
-
- size_t pos;
-
- check_nvm_bound(pos16, p);
- pos = (pos16 << 1) + (p * GBE_PART_SIZE);
-
- return (unsigned short)f->buf[pos] |
- ((unsigned short)f->buf[pos + 1] << 8);
-}
-
-void
-set_nvm_word(size_t pos16, size_t p, unsigned short val16)
-{
- struct xstate *x = xstatus();
- struct xfile *f = &x->f;
-
- size_t pos;
-
- check_nvm_bound(pos16, p);
- pos = (pos16 << 1) + (p * GBE_PART_SIZE);
-
- f->buf[pos] = (unsigned char)(val16 & 0xff);
- f->buf[pos + 1] = (unsigned char)(val16 >> 8);
-
- set_part_modified(p);
-}
-
-void
-set_part_modified(size_t p)
-{
- struct xstate *x = xstatus();
- struct xfile *f = &x->f;
-
- check_bin(p, "part number");
- f->part_modified[p] = 1;
-}
-
-void
-check_nvm_bound(size_t c, size_t p)
-{
- /* Block out of bound NVM access
- */
-
- check_bin(p, "part number");
-
- if (c >= NVM_WORDS)
- err(ECANCELED, "check_nvm_bound: out of bounds %lu",
- (size_t)c);
-}