diff options
| author | Leah Rowe <leah@libreboot.org> | 2025-01-03 01:36:20 +0000 | 
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2025-01-03 01:36:44 +0000 | 
| commit | 033e4cd9d50767b3e9d8d9d950c622c2f075a878 (patch) | |
| tree | ed482db3c4eeda63bbd4daa667fab967470138a1 | |
| parent | 874317c4e591bc5485ac2b248b4e82b8f7646027 (diff) | |
util/nvmutil: Make the GbE checksum a define
This makes the code easier to understand.
All 2-byte words, stored in little endian order within
the 128-byte GbE NVM area, must add up to 0xBABA.
If it doesn't, then software is supposed to reject that
GbE config. The nvmutil software works on that basis.
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/nvmutil/nvmutil.c | 5 | 
1 files changed, 3 insertions, 2 deletions
| diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 33cea8e6..950fc2e8 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -24,6 +24,7 @@ uint8_t hextonum(char chs), rhex(void);  #define MAC_ADDRESS argv[3]  #define PARTN argv[3]  #define SIZE_4KB 0x1000 +#define NVM_CHECKSUM 0xbaba  uint16_t buf16[SIZE_4KB], mac[3] = {0, 0, 0};  uint8_t *buf = (uint8_t *) &buf16; @@ -235,7 +236,7 @@ cmd_setchecksum(void)  	uint16_t val16 = 0;  	for (int c = 0; c < 0x3F; c++)  		val16 += word(c, part); -	setWord(0x3F, part, 0xBABA - val16); +	setWord(0x3F, part, NVM_CHECKSUM - val16);  }  void @@ -258,7 +259,7 @@ goodChecksum(int partnum)  	uint16_t total = 0;  	for(int w = 0; w <= 0x3F; w++)  		total += word(w, partnum); -	if (total == 0xBABA) +	if (total == NVM_CHECKSUM)  		return 1;  	fprintf(stderr, "WARNING: BAD checksum in part %d\n", partnum);  	return (errno = ECANCELED) & 0; | 
