summaryrefslogtreecommitdiff
path: root/util
AgeCommit message (Collapse)Author
21 hoursutil/nvmutil: implement zero-byte r/w timeoutLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
22 hoursTODOLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
22 hoursutil/nvmutil: add some useful commentsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
22 hoursutil/nvmutil: split up rw_file_exactLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
22 hoursfix indentationLeah Rowe
i was editting this in another editor Signed-off-by: Leah Rowe <leah@libreboot.org>
23 hoursutil/nvmutil: add jitter to fallback_rand entropyLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
23 hoursutil/nvmutil: improved entropy in fallback_randLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
23 hoursutil/nvmutil: remove /dev/random fallbackLeah Rowe
only use the old fallback, or /dev/urandom /dev/random blocks on some older unix machines, or in embedded environments that may never have enough entropy, causing the code to hang. urandom is most certainly expected to exist on pretty much anything since the mid 90s. i could probably re-add the arc4random setup for BSDs. i'll think about it. gotta do that portably too. Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: include time.h after types.hLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: mitigate fast calls to randLeah Rowe
if someone calls rhex fast enough, the timestamp may not change. this mitigates that by adding a counter value to the mix Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: fallback randomiserLeah Rowe
used when a random device isn't available, on old unix, or on certain chroot environments. Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: correct install usageLeah Rowe
one for directory, then copy the binary Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: fix makefileLeah Rowe
forgot to include the binary in the path Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: remove errno externLeah Rowe
may break modern systems. and all old systems that i care about will handle errno just fine. Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: use install -d instead of mkdir -pLeah Rowe
-p isn't portable Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: fix commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: use chmod instead, in MakefileLeah Rowe
yeah, why not use a tool that's been around since the 80s? Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: add -m to install on MakefileLeah Rowe
also support LDFLAGS Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: simplify flags on urandomLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: fix mistake in random checkLeah Rowe
forgot this. oops Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: portable errnoLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: fix non-portable variable declarationLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/nvmutil: disable urandom if not foundLeah Rowe
disable random mac address generation on really old operating systems. Signed-off-by: Leah Rowe <leah@libreboot.org>
25 hoursutil/nvmutil: use ECANCELED on checksum errLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
25 hoursutil/nvmutil: don't use errno for program stateLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
31 hoursutil/spkmodem-recv: code cleanupLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
32 hoursutil/spkmodem-recv: optimise pulse checkLeah Rowe
the last change was good, but this code, again, has to do these calculations 48,000 times a second. trivial on new computers. but now try it on a computer from 1992. we should try to make this as fast as possible :) older compilers especially don't optimise these checks. this patch shifts it to one subtraction and one unsigned comparison, rather than checking less than or greater than both. often used in... literally exactly this type of program. on a good compiler this will compile to an add, cmp and conditional jump. less readable, but the results (set 1 or 0) make it pretty obvious what it does, after a few seconds. Signed-off-by: Leah Rowe <leah@libreboot.org>
32 hoursutil/spkmodem-recv: clearer pulse decodingLeah Rowe
i turned this into abs() call earlier, but this isn't obviously readable by some people. make it absolutely clear what this does. also reduces use of syscalls. Signed-off-by: Leah Rowe <leah@libreboot.org>
32 hoursutil/spkmodem-recv: say what freq_sep/data areLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
32 hoursutil/spkmodem-recv: add a usage functionLeah Rowe
replace the err call in getopt Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: tidy up the getopt loopLeah Rowe
more knf-compliant Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: allow short sample readsLeah Rowe
fread() may return short reads, whereas the current code assumes either EOF or a full read. change if to a while. really, it's that simple. just loop until it's done. i probably b0rked this myself when refactoring the GNU code. Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: don't exit in print_statsLeah Rowe
i treated ftell errors as fatal, but if fttell fails with ESPIPE, and someone's using -d, the program may exit immediately, even though there's no problem. instead, skip printing the offset (basically no debug). this fixes a bug that i introduced myself, when i forked this code, because i added that error check; the GNU code didn't have any check whatsoever. Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: buffer calls to fread()Leah Rowe
we currently read small amounts of data with fread, repeatedly, which is quite taxing on the CPU, on very old systems. 48khz audio. 48000 calls to fread() per second? yeah. let's optimise this. performance now should be roughly O(1) in practise. this and the other recent changes means no modulo or division, reduced branching, memory memory roads, and lots of buffering. the buffering here is quite conservative, so the human won't notice any difference. we're cutting the number of times we call fread by a factor of several thousand, but you'll still see text scrolling down pretty quick, with minimal lag. the old GNU code i forked was terrible at this. Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: make new pulse calculation clearerLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: tidy up pulse decodingLeah Rowe
make it clearer about next/old, in the loop. this also improves performance on older systems (cache the values first, don't re-calculate) again, this is GNU code. but you wouldn't know it, in my current version. i forked this from GRUB several years ago and started cleaning it for fun. Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: split up handle_audio()Leah Rowe
the signal check should be its own function, for clearer understanding Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: tidy up handle_audioLeah Rowe
frame handling, error checks, pulse decoding and character decoding are all jumbled up. this patch separates them a bit, making it clearer. should also help codegen. this tool is dealing with high bandwidth text, which on slower computers may be cumbersome. every optimisation counts. not really relevant on newer systems. Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: optimise ring buffer pos calcLeah Rowe
instead of computing next every time, just advance two indexes. another performance optimisation on older machines, especially old compilers, because it reduces the amount of logical branching. the old code was pretty much just advancing two indexes in lockstep, when getting the next pulse, but recalculating one of them based on the other, each time. this is yet another hangover from the old GNU code that i forked three years ago. Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: don't use modulus on decodeLeah Rowe
it's slow on older compilers/systems that don't optimise. instead, we branch (cheaper) and just do an above or equal comparison), resetting appropriately or subtracting. should yield an actually useful performance gain, on older systems. a bit theoretical on modern systems, which optimise well (modern compilers will produce assembly code much like what the new C code is doing) Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursspkmodemrecv makefile: add -c to installLeah Rowe
a bit pedantic. but that's my intention. for backwards compatibility with older systems. this flag means: create the directory. on modern versions on all systems, it's the default behaviour. Signed-off-by: Leah Rowe <leah@libreboot.org>
33 hoursutil/spkmodem-recv: further portability / cleanupLeah Rowe
i used a bunch of global variables. that's gone. added proper externs, including for errno. lots of old unix systems require this. this version should be perfectly polished and portable now. all status is now handled in a struct, making the code a bit easier to understand, because the variables now are clearly pertinent to the state of the decoder, rather than being seemingly random. some indentation reduced. also cleaned up ftell/feof usage again. the new code is a bit more robust when dealing with piped input(which is literally what this program takes, exclusively) i started my cleanup of this tool from GNU GRUB in 2023. i finished it today. also the Openbsd pledge is more portable now (code made to compile on pre-pledge openbsd as well) Signed-off-by: Leah Rowe <leah@libreboot.org>
38 hoursutil/nvmutil: further clean up decode_pulse()Leah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
38 hoursutil/spkmodem-recv: tidy up frame decodingLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
38 hoursutil/spkmodem-recv: handle fread errorsLeah Rowe
also handle EOF condition and exit cleanly. don't use dirty feof. Signed-off-by: Leah Rowe <leah@libreboot.org>
38 hoursutil/spkmodem-recv: fix getopt prototypeLeah Rowe
i use -pedantic and std=c90 also add the define Signed-off-by: Leah Rowe <leah@libreboot.org>
39 hoursremoved some unnecessary thingsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
39 hoursanother fixLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
39 hourstiny fixLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
39 hoursutil/spkmodem-recv: portability and code cleanupLeah Rowe
borrowing recent improvements from nvmutil Signed-off-by: Leah Rowe <leah@libreboot.org>