summaryrefslogtreecommitdiff
path: root/util/nvmutil/lib/word.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/nvmutil/lib/word.c')
-rw-r--r--util/nvmutil/lib/word.c48
1 files changed, 9 insertions, 39 deletions
diff --git a/util/nvmutil/lib/word.c b/util/nvmutil/lib/word.c
index 4a8280ba..5d9220c7 100644
--- a/util/nvmutil/lib/word.c
+++ b/util/nvmutil/lib/word.c
@@ -1,48 +1,25 @@
/* SPDX-License-Identifier: MIT
- *
* Copyright (c) 2022-2026 Leah Rowe <leah@libreboot.org>
*
- * Manipulate sixteen-bit little-endian
- * words on Intel GbE NVM configurations.
+ * Manipulate Intel GbE NVM words, which are 16-bit little
+ * endian in the files (MAC address words are big endian).
*/
-#ifdef __OpenBSD__
-#include <sys/param.h>
-#endif
#include <sys/types.h>
-#include <sys/stat.h>
#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdarg.h>
#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
#include "../include/common.h"
-/*
- * GbE NVM files store 16-bit (2-byte) little-endian words.
- * We must therefore swap the order when reading or writing.
- *
- * NOTE: The MAC address words are stored big-endian in the
- * file, but we assume otherwise and adapt accordingly.
- */
-
unsigned short
nvm_word(unsigned long pos16, unsigned long p)
{
- struct xstate *x = xstatus();
- struct xfile *f;
+ struct xstate *x = xstatus(0, NULL);
+ struct xfile *f = &x->f;
unsigned long pos;
- f = &x->f;
-
check_nvm_bound(pos16, p);
pos = (pos16 << 1) + (p * GBE_PART_SIZE);
@@ -53,13 +30,11 @@ nvm_word(unsigned long pos16, unsigned long p)
void
set_nvm_word(unsigned long pos16, unsigned long p, unsigned short val16)
{
- struct xstate *x = xstatus();
- struct xfile *f;
+ struct xstate *x = xstatus(0, NULL);
+ struct xfile *f = &x->f;
unsigned long pos;
- f = &x->f;
-
check_nvm_bound(pos16, p);
pos = (pos16 << 1) + (p * GBE_PART_SIZE);
@@ -72,10 +47,8 @@ set_nvm_word(unsigned long pos16, unsigned long p, unsigned short val16)
void
set_part_modified(unsigned long p)
{
- struct xstate *x = xstatus();
- struct xfile *f;
-
- f = &x->f;
+ struct xstate *x = xstatus(0, NULL);
+ struct xfile *f = &x->f;
check_bin(p, "part number");
f->part_modified[p] = 1;
@@ -84,10 +57,7 @@ set_part_modified(unsigned long p)
void
check_nvm_bound(unsigned long c, unsigned long p)
{
- /*
- * NVM_SIZE assumed as the limit, because this
- * current design assumes that we will only
- * ever modified the NVM area.
+ /* Block out of bound NVM access
*/
check_bin(p, "part number");