mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 23:22:37 +02:00
writeprotect: add WPS bit and always set it to zero
WPS bit controls use of individual block protection which is mutually exclusive with protection based on ranges. Proper support requires extension of the API as well as implementation, so here we're just making sure that range-based protection is enabled and our WP configuration is not ignored by the chip. Change-Id: I2c26ec65d64a3b6fb1f1a73690bc771415db2744 Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/60231 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
parent
dbbe1588b2
commit
bfbec45de0
3
flash.h
3
flash.h
@ -307,6 +307,9 @@ struct flashchip {
|
|||||||
|
|
||||||
/* Complement bit (CMP) */
|
/* Complement bit (CMP) */
|
||||||
struct reg_bit_info cmp;
|
struct reg_bit_info cmp;
|
||||||
|
|
||||||
|
/* Write Protect Selection (per sector protection when set) */
|
||||||
|
struct reg_bit_info wps;
|
||||||
} reg_bits;
|
} reg_bits;
|
||||||
|
|
||||||
/* Function that takes a set of WP config bits (e.g. BP, SEC, TB, etc) */
|
/* Function that takes a set of WP config bits (e.g. BP, SEC, TB, etc) */
|
||||||
|
@ -73,6 +73,8 @@ static enum flashrom_wp_result read_wp_bits(struct wp_bits *bits, struct flashct
|
|||||||
if (ret != FLASHROM_WP_OK)
|
if (ret != FLASHROM_WP_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* Note: WPS bit isn't read here, because it's not part of any range. */
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(bits->bp); i++) {
|
for (i = 0; i < ARRAY_SIZE(bits->bp); i++) {
|
||||||
if (bit_map->bp[i].reg == INVALID_REG)
|
if (bit_map->bp[i].reg == INVALID_REG)
|
||||||
break;
|
break;
|
||||||
@ -115,6 +117,8 @@ static enum flashrom_wp_result write_wp_bits(struct flashctx *flash, struct wp_b
|
|||||||
set_reg_bit(reg_values, write_masks, reg_bits->cmp, bits.cmp);
|
set_reg_bit(reg_values, write_masks, reg_bits->cmp, bits.cmp);
|
||||||
set_reg_bit(reg_values, write_masks, reg_bits->srp, bits.srp);
|
set_reg_bit(reg_values, write_masks, reg_bits->srp, bits.srp);
|
||||||
set_reg_bit(reg_values, write_masks, reg_bits->srl, bits.srl);
|
set_reg_bit(reg_values, write_masks, reg_bits->srl, bits.srl);
|
||||||
|
/* Note: always setting WPS bit to zero until its fully supported. */
|
||||||
|
set_reg_bit(reg_values, write_masks, reg_bits->wps, 0);
|
||||||
|
|
||||||
/* Write each register */
|
/* Write each register */
|
||||||
for (enum flash_reg reg = STATUS1; reg < MAX_REGISTERS; reg++) {
|
for (enum flash_reg reg = STATUS1; reg < MAX_REGISTERS; reg++) {
|
||||||
@ -253,6 +257,8 @@ static enum flashrom_wp_result get_ranges_and_wp_bits(struct flashctx *flash, st
|
|||||||
*count = 1 << bit_count;
|
*count = 1 << bit_count;
|
||||||
*ranges = calloc(*count, sizeof(struct wp_range_and_bits));
|
*ranges = calloc(*count, sizeof(struct wp_range_and_bits));
|
||||||
|
|
||||||
|
/* TODO: take WPS bit into account. */
|
||||||
|
|
||||||
for (size_t range_index = 0; range_index < *count; range_index++) {
|
for (size_t range_index = 0; range_index < *count; range_index++) {
|
||||||
/*
|
/*
|
||||||
* Extract bits from the range index and assign them to members
|
* Extract bits from the range index and assign them to members
|
||||||
|
Loading…
x
Reference in New Issue
Block a user