diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-04 00:41:08 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-04 00:41:08 +0000 |
| commit | 46a0fe6b8af7ce3a516895ab8d872a43d845304b (patch) | |
| tree | e90bbd0ce2eff6d1c10f5303b8b8a69b6b36aeb8 | |
| parent | 4b424191227e5af4325f98a326e8c976ca1eee32 (diff) | |
util/nvmutil: Comments relating to NVM size limit
Part of the code currently assumes we only work on
the smaller NVM area.
I'm adding some comments to make this clear, for
when and if the code is ever expanded to support
operating on the Extended NVM area (just part the
main 128-byte NVM area).
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/nvmutil/nvmutil.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index d775f116..26659779 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -623,6 +623,20 @@ set_word(int pos16, int p, uint16_t val16) static void check_bound(int c, int p) { + /* + * NVM_SIZE assumed as the limit, because the + * current design assumes that we will only + * ever modified the NVM area. + * + * The only exception is copy/swap, but these + * do not use word/set_word and therefore do + * not cause check_bound() to be called. + * + * TODO: + * This should be adjusted in the future, if + * we ever wish to work on the Extented NVM. + */ + if ((p != 0) && (p != 1)) err(EINVAL, "check_bound: invalid partnum %d", p); if ((c < 0) || (c >= (NVM_SIZE >> 1))) @@ -655,9 +669,22 @@ write_gbe_part(int p) } } +/* + * GbE files store bytes in little-endian order. + * This function ensures big-endian host CPU support. + */ static void swap(int partnum) { + /* + * NVM_SIZE assumed as the limit; see notes in + * check_bound(). + * + * TODO: + * This should be adjusted in the future, if + * we ever wish to work on the Extended NVM. + */ + size_t w; size_t x; @@ -669,7 +696,6 @@ swap(int partnum) /* * The host CPU stores bytes in big-endian order. - * GbE files store bytes in little-endian order. * We will therefore reverse the order in memory: */ for (w = 0, x = 1; w < NVM_SIZE; w += 2, x += 2) { |
