Brian Norris has uploaded this change for review.
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>
---
M include/libflashrom.h
M layout.c
2 files changed, 26 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/05/76005/1
diff --git a/include/libflashrom.h b/include/libflashrom.h
index 490ef03..e87776b 100644
--- a/include/libflashrom.h
+++ b/include/libflashrom.h
@@ -421,6 +421,16 @@
*/
int flashrom_layout_include_region(struct flashrom_layout *layout, const char *name);
/**
+ * @brief Mark given region as not included.
+ *
+ * @param layout The layout to alter.
+ * @param name The name of the region to exclude.
+ *
+ * @return 0 on success,
+ * 1 if the given name can't be found.
+ */
+int flashrom_layout_exclude_region(struct flashrom_layout *layout, const char *name);
+/**
* @brief Get given region's offset and length.
*
* @param[in] layout The existing layout.
diff --git a/layout.c b/layout.c
index cddd908..e46e61a 100644
--- a/layout.c
+++ b/layout.c
@@ -217,6 +217,17 @@
return 1;
}
+/* returns 0 to indicate success, 1 to indicate failure */
+static int exclude_region(struct flashrom_layout *const l, const char *name)
+{
+ struct romentry *const entry = _layout_entry_by_name(l, name);
+ if (entry) {
+ entry->included = false;
+ return 0;
+ }
+ return 1;
+}
+
/* returns -1 if an entry is not found, 0 if found. */
static int romentry_exists(struct flashrom_layout *const l, char *name, char *file)
{
@@ -441,6 +452,11 @@
return include_region(layout, name, NULL);
}
+int flashrom_layout_exclude_region(struct flashrom_layout *const layout, const char *name)
+{
+ return exclude_region(layout, name);
+}
+
int flashrom_layout_get_region_range(struct flashrom_layout *const l, const char *name,
unsigned int *start, unsigned int *len)
{
To view, visit change 76005. To unsubscribe, or for help writing mail filters, visit settings.