util/nvmutil swap(): Only handle the nvm area
The 128-byte nvm area is all that we need to handle, since that is the only thing we actually work on in nvmutil, based on checksum verification; the latter implies that bytes must be in the correct order. The swap() function previously worked on the entire block, e.g. 4KB on 8KB files, 8KB on 16KB files and 64KB on 128KB files, and it did this twice, so it would have operated on anywhere between 8KB to 128KB of data. It now only operates on 256 bytes at a maximum, or 128 bytes if only handling one block. This is a significant performance optimisation, on big endian host CPUs. Signed-off-by: Leah Rowe <leah@libreboot.org>master
parent
47d7283462
commit
d176b56c58
|
@ -437,6 +437,6 @@ swap(int partnum) /* swaps bytes in words, not pointers. */
|
||||||
size_t w, x;
|
size_t w, x;
|
||||||
uint8_t *n = (uint8_t *) gbe[partnum];
|
uint8_t *n = (uint8_t *) gbe[partnum];
|
||||||
|
|
||||||
for (w = nf * ((uint8_t *) &e)[0], x = 1; w < nf; w += 2, x += 2)
|
for (w = nf * ((uint8_t *) &e)[0], x = 1; w < 128; w += 2, x += 2)
|
||||||
n[w] ^= n[x], n[x] ^= n[w], n[w] ^= n[x];
|
n[w] ^= n[x], n[x] ^= n[w], n[w] ^= n[x];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue