Nikolai Artemiev has uploaded this change for review.
[RFC] writeprotect: implement wp_set_range()
BUG=b:195381327,b:153800563
TEST=flashrom --wp-range
BRANCH=none
Change-Id: I7d26f43fb05c5828b9839bb57a28fa1088dcd9a0
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
---
M writeprotect.c
1 file changed, 33 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/82/58482/1
diff --git a/writeprotect.c b/writeprotect.c
index 884e4d6..ea10047 100644
--- a/writeprotect.c
+++ b/writeprotect.c
@@ -152,7 +152,6 @@
}
return 0;
}
-void *suppress_unused_warning_for_write_wp_chip_state = write_wp_chip_state;
struct wp_range_wpst_pair {
struct wp_range range;
@@ -276,8 +275,39 @@
int wp_set_range(struct flashctx *flash, const struct wp_range range)
{
- /* TODO */
- return 1;
+ struct wp_range_wpst_pair *ranges;
+ size_t range_count;
+
+ int ret = get_available_ranges(flash, &ranges, &range_count);
+ if (ret)
+ return ret;
+
+ /* Search for matching range */
+ struct wp_chip_state wpst;
+ bool found = false;
+ for (size_t i = 0; i < range_count; i++) {
+ struct wp_range *range_i = &ranges[i].range;
+ if (range_i->start == range.start && range_i->len == range.len) {
+ wpst = ranges[i].wpst;
+ found = true;
+ break;
+ }
+ }
+
+ free(ranges);
+
+ if (!found) {
+ msg_gerr("The chip does not support the requested range.\n");
+ return 1;
+ }
+
+ ret = write_wp_chip_state(flash, &wpst);
+
+ if (!ret) {
+ msg_ginfo("Sucessfully set the requested protection range.\n");
+ }
+
+ return ret;
}
int wp_get_mode(struct flashctx *flash, enum wp_mode *mode)
To view, visit change 58482. To unsubscribe, or for help writing mail filters, visit settings.