mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-22 14:36:31 +02:00
util/nvmutil: make the MAC shifting easier to read
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+14
-3
@@ -414,9 +414,20 @@ set_mac_nib(int mac_pos, int nib)
|
|||||||
(mac[mac_pos + nib] == 'X'))) /* random */
|
(mac[mac_pos + nib] == 'X'))) /* random */
|
||||||
h = (h & 0xE) | 2; /* local, unicast */
|
h = (h & 0xE) | 2; /* local, unicast */
|
||||||
|
|
||||||
/* Store the new nibble as part of the new MAC address */
|
/*
|
||||||
macbuf[byte >> 1] |= (uint16_t)h <<
|
* The word is stored big-endian in the file.
|
||||||
(((byte & 1) << 3) + (4 * (nib ^ 1)));
|
* Logically in C, it is stored little-endian,
|
||||||
|
* because of how we load in read_gbe(), so
|
||||||
|
* we store the MAC address in reverse order
|
||||||
|
* per 2-byte word (there are 3 of these).
|
||||||
|
*/
|
||||||
|
int shift = (byte & 1) << 3; /* left or right byte? */
|
||||||
|
shift |= (nib ^ 1) << 2; /* left or right nib? */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now we can shift properly, OR'ing the result:
|
||||||
|
*/
|
||||||
|
macbuf[byte >> 1] |= (uint16_t)h << shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t
|
static uint8_t
|
||||||
|
|||||||
Reference in New Issue
Block a user