David Hendricks has uploaded this change for review.

View Change

layout: Add a function to check if numeric range is included

This adds a helper function to iterate thru ranges to check if a
specified numeric range is marked as included in the layout.

If no include -i arguments were used to specify included regions,
then all any range will return true.

Change-Id: I096410ea957fe204affa67734e7589a6e4424a26
Signed-off-by: David Hendricks <dhendricks@fb.com>
---
M layout.c
M layout.h
2 files changed, 26 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/69/20569/1
diff --git a/layout.c b/layout.c
index 9bf0b03..a35a72c 100644
--- a/layout.c
+++ b/layout.c
@@ -225,3 +225,27 @@

return ret;
}
+
+/* returns 1 if any offset within [base, base+len) is included in layout */
+int range_is_included(chipoff_t start, chipoff_t end)
+{
+ int i;
+
+ if (num_include_args == 0)
+ return 1;
+
+ for (i = 0; i < layout.num_entries; i++) {
+ struct romentry entry = layout.entries[i];
+
+ if (!entry.included)
+ continue;
+ if (end < entry.start)
+ continue;
+ if (start > entry.end)
+ continue;
+
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/layout.h b/layout.h
index c93d754..6fc4e2e 100644
--- a/layout.h
+++ b/layout.h
@@ -66,4 +66,6 @@

int process_include_args(struct flashrom_layout *);

+int range_is_included(chipoff_t start, chipoff_t end);
+
#endif /* !__LAYOUT_H__ */

To view, visit change 20569. To unsubscribe, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: staging
Gerrit-MessageType: newchange
Gerrit-Change-Id: I096410ea957fe204affa67734e7589a6e4424a26
Gerrit-Change-Number: 20569
Gerrit-PatchSet: 1
Gerrit-Owner: David Hendricks <david.hendricks@gmail.com>