- Apr 10, 2023
-
-
Leah Rowe authored
At the end of each line is an errant space. Fix that.
-
- Apr 07, 2023
- Apr 06, 2023
-
-
Leah Rowe authored
also removed some unnecessary checks fixed the check of pwrite's return value (it should check for -1)
-
Leah Rowe authored
-
Leah Rowe authored
added a few that were more useful deleted a few obnoxious ones
-
Leah Rowe authored
the byteswap() function is used for big endian host compatibility, but it can also be used to swap words in the stored mac address
-
Leah Rowe authored
-
Leah Rowe authored
-
Leah Rowe authored
these were put in when i was testing the feature to limit read/written bytes in loading/saving of files
-
Leah Rowe authored
the code is smaller
-
- Apr 05, 2023
-
-
Leah Rowe authored
-
Leah Rowe authored
word/setWord no longer mitigates endianness. instead, all bytes are swapped after reading and before writing the file, and only if the host is big endian this improves performance on little endian hosts, which is most machines, and the code is much simpler, so it's more robust and less likely to break mac address endianness made more clear in code, including with a comment that explains it (the nvm section contains little endian words, *except* the mac address whose words are stored big endian)
-
Leah Rowe authored
it was resetting the total for each nibble. absolute epic fail on my part. fixed now.
-
Leah Rowe authored
-
Leah Rowe authored
-
- Mar 06, 2023
-
-
Leah Rowe authored
reduce the number of calls to read() by using bit shifts. when rnum is zero, read again. in most cases, a nibble will not be zero, so this will usually result in about 13-15 of of 16 nibbles being used. this is in comparison to 8 nibbles being used before, which means that the number of calls to read() are roughly halved. at the same time, the extra amount of logic is minimal (and probably less) when compiled, outside of calls to read(), because shifting is better optimised (on 64-bit machines, the uint64_t will be shifted with just a single instruction, if the compiler is decent), whereas the alternative would be to always precisely use exactly 16 nibbles by counting up to 16, which would involve the use of an and mask and still need a shift, plus... you get the point. this is probably the most efficient code ever written, for generating random numbers between the value of 0 and 15
-
- Jan 28, 2023
-
-
Leah Rowe authored
-
Leah Rowe authored
-
Leah Rowe authored
the way nvmutil is designed, setWord() is only ever called under non-error conditions. however, if one part is valid but the other one isn't, and a command is run that touches both parts, errno is non-zero write writeGbeFile is called in situations where one part is valid, but the other isn't, AND the writes to gbe (in memory) results in a non-change, writeGbeFile is not called; in this situation, errno is not being reset, despite non-error condition this patch fixed the bug, resulting in zero status upon exit under such conditions
-
Leah Rowe authored
-
Leah Rowe authored
the current code writes part 1 first, and part 0 next, on the disk, due to the way the swap works. with this change, swap still swaps the two parts of the file, on disk, but writes the new file sequentially. this change might speed up i/o on the file system, on HDDs. on SSDs, this change likely makes no difference at all.
-
Leah Rowe authored
-
Leah Rowe authored
-
Leah Rowe authored
don't use malloc(). instead, just load random bytes into a uint64_t
-
- Jan 27, 2023
-
-
Leah Rowe authored
this will make the code more flexible, if (when) i add changes that allow multiple commands to be used in a single run, on any given number of files
-
Leah Rowe authored
-
Leah Rowe authored
-
Leah Rowe authored
-
Leah Rowe authored
only read the required number of bytes, per command
-
Leah Rowe authored
On many Lenovo GbE regions (in factory firmware), part 0 is invalid but part 1 is valid. This change means part 1 is checked first. If part 1 is valid, part 0 won't be checked at all (due to how most C compilers optimise). Most people are just going to extract the factory GbE file, modify it and re-insert it into the ROM image, so this causes a nice speedup.
-
Leah Rowe authored
don't constantly open/close the file: /dev/urandom only read 12 bytes at a time because of this change, the readFromFile() function now only handles gbe files
-
Leah Rowe authored
-
- Jan 17, 2023