summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
22 hoursutil/spkmodem-recv: extensive commentingLeah Rowe
and with this, i'm now pretty much done modifying grub's crappy code. this experiment started in 2023 has now pretty much concluded. the original GNU code was poorly written, hardcoded everywhere, and not documented or commented at all. i had to learn what the code is doing through inference instead, and i'm pretty sure that these explanations cover everything. i hope? maybe the frenchman can explain anything i missed. haha. Signed-off-by: Leah Rowe <leah@libreboot.org>
23 hoursutil/spkmodem: explain what the defines areLeah Rowe
and calculate some of them instead of hard coding Signed-off-by: Leah Rowe <leah@libreboot.org>
23 hoursuseful commentsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
23 hoursutil/spkmodem-recv: also cache sep_pos in decodeLeah Rowe
yet another optimisation for weaker compilers - but some modern compilers may not optimise well for this code either. this reduces the amount of references to the struct, which is very expensive (48000 times per second) on very old CPUs. Signed-off-by: Leah Rowe <leah@libreboot.org>
23 hoursutil/spkmodem-recv: optimise decode_pulseLeah Rowe
the frame[] array is never actually used meaningfully. that setting of frame[ringpos] on the decode_state is only set here, but then the value isn't really used at all. the entire size of the annay is used for sizeof in print_stats, but then we can just declare that manually. since we also know that this value never changes, we can use a global define for the sizeof entry in print_stats, thereby simplifying operation further Signed-off-by: Leah Rowe <leah@libreboot.org>
23 hoursutil/spkmodem-recv: clean up decode_pulseLeah Rowe
make it easier to read by clearer variable naming. this change also reduces memory accesses (fewer struct dereferences - see: struct decoder_state), when using much weaker/older compilers that don't optimise properly. this, in the most active part of the code, which is called.... 48000 times a second. peanuts on modern CPUs, but on old (early 90s) CPUs it makes a big difference. Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/spkmodem-recv: byte swap on big endian CPULeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/spkmodem-recv: remove errno defineLeah Rowe
may break on modern systems (macro) Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursadd endianness check to spkmodem-recvLeah Rowe
a bit dirty. should handle this at runtime. Signed-off-by: Leah Rowe <leah@libreboot.org>
24 hoursutil/spkmodem-recv: properly handle stdin errLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
25 hoursanother correctionLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
25 hoursutil/nvmutil: fix regression on openbsdLeah Rowe
when i removed arc4random integration, i forgot to change this line back. oops! Signed-off-by: Leah Rowe <leah@libreboot.org>
25 hoursTODOLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
25 hoursTODOLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
26 hoursTODOLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
26 hoursutil/nvmutil: mitigate buggy libc i/oLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursutil/nvmutil: implement zero-byte r/w timeoutLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursTODOLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursutil/nvmutil: add some useful commentsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursutil/nvmutil: split up rw_file_exactLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
27 hoursfix indentationLeah Rowe
i was editting this in another editor Signed-off-by: Leah Rowe <leah@libreboot.org>
28 hoursutil/nvmutil: add jitter to fallback_rand entropyLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: improved entropy in fallback_randLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
29 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>
29 hoursutil/nvmutil: include time.h after types.hLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
29 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>
29 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>
29 hoursutil/nvmutil: correct install usageLeah Rowe
one for directory, then copy the binary Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: fix makefileLeah Rowe
forgot to include the binary in the path Signed-off-by: Leah Rowe <leah@libreboot.org>
29 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>
29 hoursutil/nvmutil: use install -d instead of mkdir -pLeah Rowe
-p isn't portable Signed-off-by: Leah Rowe <leah@libreboot.org>
29 hoursutil/nvmutil: fix commentLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
29 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>
29 hoursutil/nvmutil: add -m to install on MakefileLeah Rowe
also support LDFLAGS Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: simplify flags on urandomLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: fix mistake in random checkLeah Rowe
forgot this. oops Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: portable errnoLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: fix non-portable variable declarationLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 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>
30 hoursutil/nvmutil: use ECANCELED on checksum errLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
30 hoursutil/nvmutil: don't use errno for program stateLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
36 hoursutil/spkmodem-recv: code cleanupLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
38 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>
38 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>
38 hoursutil/spkmodem-recv: say what freq_sep/data areLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
38 hoursutil/spkmodem-recv: add a usage functionLeah Rowe
replace the err call in getopt Signed-off-by: Leah Rowe <leah@libreboot.org>
38 hoursutil/spkmodem-recv: tidy up the getopt loopLeah Rowe
more knf-compliant Signed-off-by: Leah Rowe <leah@libreboot.org>
38 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>
38 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>
38 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>