Nikolai Artemiev has uploaded this change for review.

View Change

dummyflasher: Add basic WP support for opaque VARIABLE_SIZE chip

Allow WP operations to be used with VARIABLE_SIZE emulated chips.

No active protection modes are supported, i.e.
- read_wp_cfg always returns mode=disabled, range=0,0 config
- write_wp_cfg only accepts a mode=disabled, range=0,0 config

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>
---
M dummyflasher.c
1 file changed, 54 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/89/73289/1
diff --git a/dummyflasher.c b/dummyflasher.c
index 0897332..9623c8d 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,
@@ -969,6 +996,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,

To view, visit change 73289. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I4348e0175b8c743365904f5e61fdb69e3f4f4db5
Gerrit-Change-Number: 73289
Gerrit-PatchSet: 1
Gerrit-Owner: Nikolai Artemiev <nartemiev@google.com>
Gerrit-MessageType: newchange