From f630a1623f84b452873e3fc69d608925d90fd85b Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Mon, 16 May 2022 15:38:18 +1000 Subject: writeprotect.c: Allow opaque masters to hook {read,write}_register() Allow specialisation in opaque masters, such as ichspi hwseq, to write to status registers. Also update the dispatch logic in libflashrom to call wp code when status register access functions are provided by an opaque master. BUG=none BRANCH=none TEST=flashrom --wp-status on AMD and Intel DUTs Change-Id: I3ab0d7f5f48338c8ecb118a69651c203fbc516ac Signed-off-by: Edward O'Callaghan Signed-off-by: Nikolai Artemiev Co-Authored-by: Nikolai Artemiev Reviewed-on: https://review.coreboot.org/c/flashrom/+/64375 Reviewed-by: Anastasia Klimchuk Tested-by: build bot (Jenkins) --- include/programmer.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/programmer.h') diff --git a/include/programmer.h b/include/programmer.h index 5fb06260..eaf4a983 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -402,6 +402,14 @@ 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); + /* + * Callbacks for accessing flash registers. An opaque programmer must + * provide these functions for writeprotect operations to be available, + * unless it provides custom wp operations instead. + */ + int (*read_register)(const struct flashctx *flash, enum flash_reg reg, uint8_t *value); + int (*write_register)(const struct flashctx *flash, enum flash_reg reg, uint8_t value); + /* Callbacks for overiding default writeprotect operations with custom ones. */ 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 *); -- cgit v1.2.3