summaryrefslogtreecommitdiff
path: root/util/nvmutil/lib/word.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-18 19:30:32 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-19 04:25:43 +0000
commit2ed8db3adc19dd922e31082634146e159f65af2e (patch)
treedd242e1f7a178ee0c925cd080d61bac22fd681f5 /util/nvmutil/lib/word.c
parent6ccd54635fdec85f44a9960b93c52fde89c07f41 (diff)
util/nvmutil: major cleanup
handle init in xstatus() it's now a singleton design also tidied up some other code also removed todo.c. bloat. will do all those anyway. too much change. i just kept touching the code until it looked good Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/lib/word.c')
-rw-r--r--util/nvmutil/lib/word.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/util/nvmutil/lib/word.c b/util/nvmutil/lib/word.c
index 4a8280ba..4647c1f4 100644
--- a/util/nvmutil/lib/word.c
+++ b/util/nvmutil/lib/word.c
@@ -29,20 +29,17 @@
* 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.
+ * NOTE: The MAC address words are stored big-endian in-file.
*/
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 +50,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 +67,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 +77,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");