aboutsummaryrefslogtreecommitdiffstats
path: root/dummyflasher.c
diff options
context:
space:
mode:
authorNikolai Artemiev <nartemiev@google.com>2023-02-27 11:34:29 +1100
committerThomas Heijligen <src@posteo.de>2023-03-02 08:41:34 +0000
commit1d6d23bee2843b4f3a2d3676a7a75f92aa8574c4 (patch)
tree90a3afe2753da456d9f49da50a91af2287ce947d /dummyflasher.c
parent119d0e5236df69702c5ac5be593c4aa683e2b35d (diff)
downloadflashrom-1d6d23bee2843b4f3a2d3676a7a75f92aa8574c4.tar.gz
flashrom-1d6d23bee2843b4f3a2d3676a7a75f92aa8574c4.tar.bz2
flashrom-1d6d23bee2843b4f3a2d3676a7a75f92aa8574c4.zip
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>
Diffstat (limited to 'dummyflasher.c')
-rw-r--r--dummyflasher.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/dummyflasher.c b/dummyflasher.c
index a68889b2..fa43bcd0 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -932,6 +932,33 @@ static void dummy_nop_delay(const struct flashctx *flash, unsigned int usecs)
{
}
+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 @@ static const struct opaque_master opaque_master_dummyflasher = {
.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,