aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNikolai Artemiev <nartemiev@google.com>2022-11-21 19:29:57 +1100
committerEdward O'Callaghan <quasisec@chromium.org>2023-03-03 05:52:20 +0000
commit29a3a09f9155e5de69d6d2a4bf582a9e09b8e0a4 (patch)
treecb0b381aa39c16acd78446f8d9f24c5d141250bc /include
parent1d6d23bee2843b4f3a2d3676a7a75f92aa8574c4 (diff)
downloadflashrom-29a3a09f9155e5de69d6d2a4bf582a9e09b8e0a4.tar.gz
flashrom-29a3a09f9155e5de69d6d2a4bf582a9e09b8e0a4.tar.bz2
flashrom-29a3a09f9155e5de69d6d2a4bf582a9e09b8e0a4.zip
writeprotect: Add function to get register values and WP bit masks
Add a new wp_cfg_to_reg_values() function that takes a generic wp_cfg instance and returns the chip-specific values that need to be written to the chip's registers to enable the specified protection range/mode. The function returns three values for each chip register: - reg_values[reg] - Value writeprotect will write to reg - bit_masks[reg] - Bit mask for WP-related bits in reg - write_masks[reg] - Bit mask for writable WP-related bits in reg (i.e. the ones writeprotect will try to write) BUG=b:260019525,b:259013033,260020006 BRANCH=none TEST=ninja test Change-Id: Ib2a47153b230c9f82bb4eca357c335f2abbacc20 Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/69847 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Diffstat (limited to 'include')
-rw-r--r--include/writeprotect.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/writeprotect.h b/include/writeprotect.h
index 12926c4d..7ceed079 100644
--- a/include/writeprotect.h
+++ b/include/writeprotect.h
@@ -89,4 +89,10 @@ enum flashrom_wp_result wp_get_available_ranges(struct flashrom_wp_ranges **, st
/* Checks if writeprotect functions can be used with the current flash/programmer */
bool wp_operations_available(struct flashrom_flashctx *);
+/*
+ * Converts a writeprotect config to register values and masks that indicate which register bits affect WP state.
+ * reg_values, bit_masks, and write_masks must all have length of at least MAX_REGISTERS.
+ */
+enum flashrom_wp_result wp_cfg_to_reg_values(uint8_t *reg_values, uint8_t *bit_masks, uint8_t *write_masks, struct flashrom_flashctx *, const struct flashrom_wp_cfg *);
+
#endif /* !__WRITEPROTECT_H__ */