diff options
author | Evan Benn <evanbenn@chromium.org> | 2022-06-01 12:45:01 +1000 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2022-08-26 05:07:09 +0000 |
commit | f6d9a2847e6b66a8f1415e04dc2bd13cc1d7e555 (patch) | |
tree | 857f5cd26ecdd05007114228d95284031fca4bd4 /util/flashrom_tester/flashrom/src/lib.rs | |
parent | b41bb5622c08edb33cd83aa05973513db3869af0 (diff) | |
download | flashrom-f6d9a2847e6b66a8f1415e04dc2bd13cc1d7e555.tar.gz flashrom-f6d9a2847e6b66a8f1415e04dc2bd13cc1d7e555.tar.bz2 flashrom-f6d9a2847e6b66a8f1415e04dc2bd13cc1d7e555.zip |
flashrom_tester: Add an implementation using libflashrom
flashrom_tester 'flashrom' crate was implemented using the flashrom
commandline. Add a second implementation using the libflashrom interface
via the libflashrom and libflashrom-sys rust bindings.
BUG=b:230545739
BRANCH=None
TEST=cargo test
TEST=on grunt (AMD)
TEST=/usr/bin/flashrom_tester --libflashrom host
TEST=/usr/bin/flashrom_tester --flashrom_binary /usr/sbin/flashrom host
Change-Id: Ic4db6c829d7e8dc707a10c10e1ca0d9b8abccdec
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65282
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'util/flashrom_tester/flashrom/src/lib.rs')
-rw-r--r-- | util/flashrom_tester/flashrom/src/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/util/flashrom_tester/flashrom/src/lib.rs b/util/flashrom_tester/flashrom/src/lib.rs index 5f168b529..7326391e1 100644 --- a/util/flashrom_tester/flashrom/src/lib.rs +++ b/util/flashrom_tester/flashrom/src/lib.rs @@ -37,10 +37,17 @@ extern crate log; mod cmd; +mod flashromlib; use std::{error, fmt}; pub use cmd::{dut_ctrl_toggle_wp, FlashromCmd}; +pub use flashromlib::FlashromLib; + +pub use libflashrom::{ + flashrom_log_level, FLASHROM_MSG_DEBUG, FLASHROM_MSG_DEBUG2, FLASHROM_MSG_ERROR, + FLASHROM_MSG_INFO, FLASHROM_MSG_SPEW, FLASHROM_MSG_WARN, +}; #[derive(Copy, Clone, PartialEq, Debug)] pub enum FlashChip { @@ -71,6 +78,13 @@ impl FlashChip { return r; } + /// Return the programmer string and optional programmer options + pub fn to_split(fc: FlashChip) -> (&'static str, Option<&'static str>) { + let programmer = FlashChip::to(fc); + let mut bits = programmer.splitn(2, ':'); + (bits.next().unwrap(), bits.next()) + } + /// Return whether the hardware write protect signal can be controlled. /// /// Servo and dediprog adapters are assumed to always have hardware write protect |