Thomas Heijligen has submitted this change. ( https://review.coreboot.org/c/flashrom/+/73289 )
(
2 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: dummyflasher: Add basic WP support for opaque VARIABLE_SIZE chip ......................................................................
dummyflasher: Add basic WP support for opaque VARIABLE_SIZE chip
Since VARIABLE_SIZE emulated chips do not correspond to actual flash chip models, no active protection modes are supported: - read_wp_cfg always returns mode=disabled,range=0,0 - write_wp_cfg only accepts mode=disabled,range=0,0
However this is sufficient to support use cases where the user just needs to verify that write protection is not enabled, as is the case in some futility unit tests.
BUG=b:238694831,b:260531154 BRANCH=none TEST=none
Change-Id: I4348e0175b8c743365904f5e61fdb69e3f4f4db5 Signed-off-by: Nikolai Artemiev nartemiev@google.com Reviewed-on: https://review.coreboot.org/c/flashrom/+/73289 Reviewed-by: Edward O'Callaghan quasisec@chromium.org Reviewed-by: Thomas Heijligen src@posteo.de Tested-by: Edward O'Callaghan quasisec@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M dummyflasher.c 1 file changed, 58 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Edward O'Callaghan: Verified; Looks good to me, approved Thomas Heijligen: Looks good to me, but someone else must approve
diff --git a/dummyflasher.c b/dummyflasher.c index a68889b..fa43bcd 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -932,6 +932,33 @@ { }
+static enum flashrom_wp_result dummy_wp_read_cfg(struct flashrom_wp_cfg *cfg, struct flashctx *flash) +{ + cfg->mode = FLASHROM_WP_MODE_DISABLED; + cfg->range.start = 0; + cfg->range.len = 0; + + return FLASHROM_WP_OK; +} + +static enum flashrom_wp_result dummy_wp_write_cfg(struct flashctx *flash, const struct flashrom_wp_cfg *cfg) +{ + if (cfg->mode != FLASHROM_WP_MODE_DISABLED) + return FLASHROM_WP_ERR_MODE_UNSUPPORTED; + + if (cfg->range.start != 0 || cfg->range.len != 0) + return FLASHROM_WP_ERR_RANGE_UNSUPPORTED; + + return FLASHROM_WP_OK; +} + +static enum flashrom_wp_result dummy_wp_get_available_ranges(struct flashrom_wp_ranges **list, struct flashctx *flash) +{ + /* Not supported */ + return FLASHROM_WP_ERR_RANGE_LIST_UNAVAILABLE; +} + + static const struct spi_master spi_master_dummyflasher = { .map_flash_region = dummy_map, .unmap_flash_region = dummy_unmap, @@ -968,6 +995,9 @@ .erase = dummy_opaque_erase, .shutdown = dummy_shutdown, .delay = dummy_nop_delay, + .wp_read_cfg = dummy_wp_read_cfg, + .wp_write_cfg = dummy_wp_write_cfg, + .wp_get_ranges = dummy_wp_get_available_ranges, };
static int init_data(const struct programmer_cfg *cfg,