diff options
author | Evan Benn <evanbenn@chromium.org> | 2023-01-16 16:12:44 +1100 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2023-02-06 00:33:11 +0000 |
commit | 72e62750c8734bcf2d99da2dc3b5dc1d0cb38b5a (patch) | |
tree | 59b62901955fd84ac670e65db5e4d669ca0a2c2c /util/flashrom_tester/flashrom/src/lib.rs | |
parent | 69bbe7986c17111015034871da63f2ceea6ad45b (diff) | |
download | flashrom-72e62750c8734bcf2d99da2dc3b5dc1d0cb38b5a.tar.gz flashrom-72e62750c8734bcf2d99da2dc3b5dc1d0cb38b5a.tar.bz2 flashrom-72e62750c8734bcf2d99da2dc3b5dc1d0cb38b5a.zip |
flashrom_tester: Rewrite IOOpts to support more operations
flashrom cli supports include regions for all of read write and verify,
as well as omitting the read/write/verify file if an include region with
file is specified. Use an enum to allow only one operation at a time.
Unify the read and write region implementations.
BUG=b:235916336
BRANCH=None
TEST=None
Change-Id: I1cb46bb1b26949fd9c19949c43708a8b652e00da
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/71973
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.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 | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/util/flashrom_tester/flashrom/src/lib.rs b/util/flashrom_tester/flashrom/src/lib.rs index 6b0cca36e..7c8664983 100644 --- a/util/flashrom_tester/flashrom/src/lib.rs +++ b/util/flashrom_tester/flashrom/src/lib.rs @@ -107,12 +107,6 @@ where } } -pub struct ROMWriteSpecifics<'a> { - pub layout_file: Option<&'a Path>, - pub write_file: Option<&'a Path>, - pub name_file: Option<&'a str>, -} - pub trait Flashrom { /// Returns the size of the flash in bytes. fn get_size(&self) -> Result<i64, FlashromError>; @@ -120,9 +114,6 @@ pub trait Flashrom { /// Returns the vendor name and the flash name. fn name(&self) -> Result<(String, String), FlashromError>; - /// Write only a region of the flash. - fn write_file_with_layout(&self, rws: &ROMWriteSpecifics) -> Result<bool, FlashromError>; - /// Set write protect status and range. fn wp_range(&self, range: (i64, i64), wp_enable: bool) -> Result<bool, FlashromError>; @@ -148,6 +139,16 @@ pub trait Flashrom { /// Write the whole flash to the file specified by `path`. fn write_from_file(&self, path: &Path) -> Result<(), FlashromError>; + /// Write only a region of the flash. + /// `path` is a file of the size of the whole flash. + /// The `region` name corresponds to a region name in the `layout` file, not the flash. + fn write_from_file_region( + &self, + path: &Path, + region: &str, + layout: &Path, + ) -> Result<bool, FlashromError>; + /// Verify the whole flash against the file specified by `path`. fn verify_from_file(&self, path: &Path) -> Result<(), FlashromError>; |