diff options
author | Nikolai Artemiev <nartemiev@google.com> | 2022-02-13 22:32:59 +1100 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2022-04-05 23:47:46 +0000 |
commit | 9b20174fda038ef633af2163c9b1570f4dbf9a37 (patch) | |
tree | eb3b03cd25dc3e158c6c6de34f66bb7a79b70c99 /programmer.h | |
parent | a850fd0aa8054a1125a9231fa3317428f15900f4 (diff) | |
download | flashrom-9b20174fda038ef633af2163c9b1570f4dbf9a37.tar.gz flashrom-9b20174fda038ef633af2163c9b1570f4dbf9a37.tar.bz2 flashrom-9b20174fda038ef633af2163c9b1570f4dbf9a37.zip |
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 <non-empty> succeeds
TEST=flashrom --wp-enable --wp-range <empty> fails as expected
TEST=flashrom --wp-disable --wp-range <empty> succeeds
TEST=flashrom --wp-disable --wp-range <non-empty> fails as expected
TEST=flashrom --wp-status succeeds
Change-Id: I5c86e28cdec44bec49ba1d36f8ab62241b9b01da
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/61897
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'programmer.h')
-rw-r--r-- | programmer.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/programmer.h b/programmer.h index 0657bb1c..47d2dc31 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; }; |