mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-01 22:21:16 +02:00
libflashrom: Add layout "exclude" API
Layouts can be expensive to derive (reading from flash), so we might want to reuse a layout for different purposes. Today, it's not possible to undo a flashrom_layout_include_region() operation (to, say, operate on a different region). Add such an API. Change-Id: I7ea3e0674f25e34bf2cfc8f464ae7ca1c1a3fbfd Signed-off-by: Brian Norris <briannorris@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/76005 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
This commit is contained in:

committed by
Edward O'Callaghan

parent
91aa2d8526
commit
e08899fcf4
@ -879,6 +879,32 @@ impl Layout {
|
||||
}
|
||||
}
|
||||
|
||||
/// Exclude a region
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// This function will return an error if the region is not a valid CString,
|
||||
/// or if libflashrom returns an error.
|
||||
pub fn exclude_region(&mut self, region: &str) -> std::result::Result<(), RegionError> {
|
||||
let err = {
|
||||
let region = CString::new(region)?;
|
||||
unsafe {
|
||||
libflashrom_sys::flashrom_layout_exclude_region(
|
||||
self.layout.as_mut(),
|
||||
region.as_ptr(),
|
||||
)
|
||||
}
|
||||
};
|
||||
if err != 0 {
|
||||
Err(RegionError::ErrorCode(ErrorCode {
|
||||
function: "flashrom_layout_exclude_region",
|
||||
code: err,
|
||||
}))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the [`Range`] for the given region
|
||||
///
|
||||
/// # Errors
|
||||
|
Reference in New Issue
Block a user