writeprotect: add get_wp_range() for decoding ranges
Tested: flashrom --wp-{status,range} at end of patch series
Change-Id: I5a1dfcf384166b1bac319d286306747e1dcaa000
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/59183
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/70970
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/writeprotect.c b/writeprotect.c
index 5f47bc0..a42a798 100644
--- a/writeprotect.c
+++ b/writeprotect.c
@@ -151,9 +151,17 @@
return FLASHROM_WP_OK;
}
+/** Get the range selected by a WP configuration. */
+static enum flashrom_wp_result get_wp_range(struct wp_range *range, struct flashctx *flash, const struct wp_bits *bits)
+{
+ flash->chip->decode_range(&range->start, &range->len, bits, flashrom_flash_getsize(flash));
+
+ return FLASHROM_WP_OK;
+}
+
static bool chip_supported(struct flashctx *flash)
{
- return false;
+ return (flash->chip != NULL) && (flash->chip->decode_range != NULL);
}
enum flashrom_wp_result wp_read_cfg(struct flashrom_wp_cfg *cfg, struct flashctx *flash)
@@ -167,11 +175,11 @@
if (ret == FLASHROM_WP_OK)
ret = read_wp_bits(&bits, flash);
- /* TODO: implement get_wp_range() and get_wp_mode() and call them */
- /*
if (ret == FLASHROM_WP_OK)
ret = get_wp_range(&cfg->range, flash, &bits);
+ /* TODO: implement and get_wp_mode() and call it */
+ /*
if (ret == FLASHROM_WP_OK)
ret = get_wp_mode(&cfg->mode, &bits);
*/