summaryrefslogtreecommitdiff
path: root/util
AgeCommit message (Collapse)Author
2023-06-01util/nvmutil: remove unnecessary parenthesesLeah Rowe
2023-06-01util/nvmutil: simplify setWord() with word() macroLeah Rowe
There is nothing cooler than a macro. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-06-01util/nvmutil: do xor swap in a macroLeah Rowe
eventually, everything will be a macro! Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-06-01util/nvmutil pledge,unveil: use correct err stringLeah Rowe
2023-06-01util/nvmutil: ensure that errno is set on err()Leah Rowe
When err() is called, it is intended that nvmutil will always exit with non-zero status, but with errno as the return value. Ensure that errno is *not* zero. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-06-01util/nvmutil: minor code cleanupLeah Rowe
Make word() a macro, simplify err_if(). Could also make setWord() a macro if I forego certain optimisations, but I'll leave it as-is. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-31util/nvmutil: simplified error handling in mainLeah Rowe
This change also reduces code indentation. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-31util/nvmutil: Use unveil, and harden pledgesLeah Rowe
After /dev/urandom (for MAC address randomisation) and the GbE file have been handled, unveil them. Unveil is a system call provided by OpenBSD that, when called, restricts access only to the files and/or directories specified, each given specific permissions. You can learn more about unveil here: https://man.openbsd.org/unveil.2 An ifdef rule makes nvmutil only use unveil on OpenBSD, because it's not available anywhere else. This is the same as with the pledge() system call. Where invalid arguments are given, and no action performed, pledge promises are also reduced to just stdio, preventing any writes to files, or reads from files. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-31util/nvmutil: Harden pledge promisesLeah Rowe
After reading a file, remove rpath. When removing rpath, also remove wpath if flags are not to O_RDONLY (read-only disk operation). When wpath is permitted, and a file was successfully written, remove wpath. In order to permit /dev/urandom access in rhex(), I call it as a void just before re-calling pledge. The rhex() function has been written in such a way that /dev/urandom only needs to be read *once*. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-31util/nvmutil: Simplify use of pledge (on OpenBSD)Leah Rowe
Define xpledge which calls pledge and handles errors. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-30util/nvmutil: Use correct pledge promise (OpenBSD)Leah Rowe
I assumed wpath was all that's needed, but this simply allows writes. rpath must be specified alongside wpath, for reads. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-30util/*: Properly detect OpenBSD for pledge() callLeah Rowe
The utils that are pledged checked HAVE_PLEDGE which was bogus. OpenBSD defines __OpenBSD__, which you can check for in ifdef. This change makes nvmutil and spkmodem-recv *actually* use pledge, when the utils are compiled on OpenBSD. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-29util/e6400-flash-unlock: clean up commented codeLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Use pledge but only on OpenBSDLeah Rowe
It will only be used on OpenBSD. Other operating systems will behave in the same way. Pledge is feature specific to OpenBSD that restricts system operations, for security: https://man.openbsd.org/pledge.2 Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Add -u flag (no line buffer)Leah Rowe
printf outputs to stdout, which is line buffered by default. Adding a -u option to disable buffering. Exit when a non-support flag is given, but adhere to current behaviour when no flag is given. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Tidy up global variablesLeah Rowe
They do not need to be initialised zero, because global variables are always zero by default, unless set differently by the programmer. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Make pulse variable globalLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Use parentheses on comparisonsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Move global variable: pulseLeah Rowe
It is only used by a single function. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Purge unused global: amplitudeLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Remove unused variable: posLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Re-order functions for clarityLeah Rowe
print_char() is referenced last, so declare it last. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Handle output in new functionLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Re-order prototypesLeah Rowe
Put them in the same order as declared. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Rename functions for clarityLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Return errno in mainLeah Rowe
This is a good general practise, to catch errors. Any errors found can then be handled in code. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Use correct printf specifierLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Add error handlingLeah Rowe
There was literally no error handling before. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Move logic out of mainLeah Rowe
Main should only be a skeletal structure. Actual logic should always be handled externally. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Rename variable for clarityLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Remove use of static keywordLeah Rowe
It is entirely superfluous in this program. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Rename variable for clarityLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Remove space in function callsLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Say frame in EnglishLeah Rowe
Source code should be written in English. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Top-down logic (main on top)Leah Rowe
Add the appropriate prototype. Top-down function order is easier to read. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: simplified pulse checkLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Define argc/argv in mainLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Reduced indentation in loopLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Use tabs for indentationLeah Rowe
The GNU indentation style is hard to read. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Add clean to the MakefileLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Define CC in the MakefileLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Add strict CFLAGSLeah Rowe
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-05-16util/spkmodem_recv: Import from corebootLeah Rowe
Imported from util/spkmodem_recv at coreboot revision: e70bc423f9a2e1d13827f2703efe1f9c72549f20 This is a client for spkmodem, to allow serial console via PC speaker. I've decided to import it in lbmk, because I heavily modified it. The patches will be applied next. Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-04-30util/e6400-flash-unlock: do void on ec_fdo_commandLeah Rowe
the return value was never used
2023-04-24don't force console mode in grubLeah Rowe
the deleted patch (in this commit) was written to fix an issue theoretically; it hasn't been fully tested, and some people have reported strange issues since this patch was merged - there is no proof that this patch causes them, but removing this patch is the correct thing to do regardless
2023-04-19util/e6400-flash-unlock: restore READMENicholas Chin
when nicholas added this, he removed the README because it's going on libreboot.org instead. however, i merged a WIP version of his page for now because i want to get the e6400 going in libreboot sooner. so, temp-readding this README. will just link to this on codeberg or something, from the lb docs NOTE: I didn't write this README, hence author field set in the commit. Nicholas wrote it, but I (Leah Rowe) am just adding it. so, git author set to nicholas, not me
2023-04-19Add E6400 flash unlock utilityNicholas Chin
Adding it to lbmk for now as it is not yet in coreboot. If it is merged into coreboot we can just reference the one there. The original README will be incorporated into a new page on lbwww, so README.md just points to a placeholder URL that should match the new page.
2023-04-15util/nvmutil: sort includes alphabeticallyLeah Rowe
small nitpick, but i try to use openbsd style since i like that style. upon further reading of their style guidelines today, it was revealed to me that for includes, they: * sort sys/ includes alphabetically, at the top * after sys/ includes, have an empty line * includes for networking-related headers below that * empty space below networking headers if there * after that, have the rest of the includes, sorted alphabetically at least, that is my understanding. i have to admit, it does look cleaner not really that critical but why not do it?
2023-04-11util/nvmutil: don't display errant whitespaceLeah Rowe
At the end of each line is an errant space. Fix that.
2023-04-08add ich9utils back to utilsLeah Rowe
don't download it. keep it in lbmk. libreboot moved to codeberg for git hosting, and i didn't want to keep lugging around an extra git repo just for one tiny project.