From 9b20174fda038ef633af2163c9b1570f4dbf9a37 Mon Sep 17 00:00:00 2001 From: Nikolai Artemiev Date: Sun, 13 Feb 2022 22:32:59 +1100 Subject: libflashrom,linux_mtd: add linux_mtd writeprotect support This commit adds a generic framework to allow opaque programmers to implement writeprotect operations and uses the framework to support writeprotect operations on linux MTD device files. The generic framework comprises three new functions in `struct opaque_master` that are called from libflashrom: - wp_write_cfg() - wp_read_cfg() - wp_get_ranges() For linux_mtd, only the read/write functions are implemented. Linux's MTD interface doesn't provide a way to get available ranges, so calling get_wp_ranges() on the linux_mtd master will return FLASHROM_WP_ERR_RANGE_LIST_UNAVAILABLE. BUG=b:182223106 BRANCH=none TEST=WP ops on hana DUT (MT8173) with W25Q32DW flash TEST=flashrom --wp-enable --wp-range succeeds TEST=flashrom --wp-enable --wp-range fails as expected TEST=flashrom --wp-disable --wp-range succeeds TEST=flashrom --wp-disable --wp-range fails as expected TEST=flashrom --wp-status succeeds Change-Id: I5c86e28cdec44bec49ba1d36f8ab62241b9b01da Signed-off-by: Nikolai Artemiev Reviewed-on: https://review.coreboot.org/c/flashrom/+/61897 Tested-by: build bot (Jenkins) Reviewed-by: Anastasia Klimchuk Reviewed-by: Edward O'Callaghan --- programmer.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'programmer.h') diff --git a/programmer.h b/programmer.h index 0657bb1cf..47d2dc31b 100644 --- a/programmer.h +++ b/programmer.h @@ -403,6 +403,9 @@ struct opaque_master { int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); int (*write) (struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); int (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen); + enum flashrom_wp_result (*wp_write_cfg)(struct flashctx *, const struct flashrom_wp_cfg *); + enum flashrom_wp_result (*wp_read_cfg)(struct flashrom_wp_cfg *, struct flashctx *); + enum flashrom_wp_result (*wp_get_ranges)(struct flashrom_wp_ranges **, struct flashctx *); int (*shutdown)(void *data); void *data; }; -- cgit v1.2.3