Edward O'Callaghan submitted this change.

View Change


Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, but someone else must approve Edward O'Callaghan: Looks good to me, approved
libflashrom: Add flags to skip unreadable and unwritable regions

Add flags to allow libflashrom users to configure how operations that
include unreadable or unwritable regions should be behave.

If the flags are set to true, a read/write operation will just skip the
inaccessible region and will still be executed in other regions.

If the flags are set to false, the inaccessible region will cause the
entire operation to fail.

BUG=b:260440773
BRANCH=none
TEST=builds

Change-Id: I9b96fb04b863625d2c9f9a00b97c35b3ddb0871b
CoAuthored-by: Edward O'Callaghan <quasisec@google.com>
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/70128
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
---
M include/flash.h
M include/libflashrom.h
M libflashrom.c
3 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/include/flash.h b/include/flash.h
index aabc785..2ea9c86 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -530,6 +530,8 @@
bool force_boardmismatch;
bool verify_after_write;
bool verify_whole_chip;
+ bool skip_unreadable_regions;
+ bool skip_unwritable_regions;
} flags;
/* We cache the state of the extended address register (highest byte
* of a 4BA for 3BA instructions) and the state of the 4BA mode here.
diff --git a/include/libflashrom.h b/include/libflashrom.h
index bac76c2..490ef03 100644
--- a/include/libflashrom.h
+++ b/include/libflashrom.h
@@ -251,6 +251,8 @@
FLASHROM_FLAG_FORCE_BOARDMISMATCH,
FLASHROM_FLAG_VERIFY_AFTER_WRITE,
FLASHROM_FLAG_VERIFY_WHOLE_CHIP,
+ FLASHROM_FLAG_SKIP_UNREADABLE_REGIONS,
+ FLASHROM_FLAG_SKIP_UNWRITABLE_REGIONS,
};

/**
diff --git a/libflashrom.c b/libflashrom.c
index 44f297f..2e89fe5 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -265,21 +265,25 @@
const enum flashrom_flag flag, const bool value)
{
switch (flag) {
- case FLASHROM_FLAG_FORCE: flashctx->flags.force = value; break;
- case FLASHROM_FLAG_FORCE_BOARDMISMATCH: flashctx->flags.force_boardmismatch = value; break;
- case FLASHROM_FLAG_VERIFY_AFTER_WRITE: flashctx->flags.verify_after_write = value; break;
- case FLASHROM_FLAG_VERIFY_WHOLE_CHIP: flashctx->flags.verify_whole_chip = value; break;
+ case FLASHROM_FLAG_FORCE: flashctx->flags.force = value; break;
+ case FLASHROM_FLAG_FORCE_BOARDMISMATCH: flashctx->flags.force_boardmismatch = value; break;
+ case FLASHROM_FLAG_VERIFY_AFTER_WRITE: flashctx->flags.verify_after_write = value; break;
+ case FLASHROM_FLAG_VERIFY_WHOLE_CHIP: flashctx->flags.verify_whole_chip = value; break;
+ case FLASHROM_FLAG_SKIP_UNREADABLE_REGIONS: flashctx->flags.skip_unreadable_regions = value; break;
+ case FLASHROM_FLAG_SKIP_UNWRITABLE_REGIONS: flashctx->flags.skip_unwritable_regions = value; break;
}
}

bool flashrom_flag_get(const struct flashrom_flashctx *const flashctx, const enum flashrom_flag flag)
{
switch (flag) {
- case FLASHROM_FLAG_FORCE: return flashctx->flags.force;
- case FLASHROM_FLAG_FORCE_BOARDMISMATCH: return flashctx->flags.force_boardmismatch;
- case FLASHROM_FLAG_VERIFY_AFTER_WRITE: return flashctx->flags.verify_after_write;
- case FLASHROM_FLAG_VERIFY_WHOLE_CHIP: return flashctx->flags.verify_whole_chip;
- default: return false;
+ case FLASHROM_FLAG_FORCE: return flashctx->flags.force;
+ case FLASHROM_FLAG_FORCE_BOARDMISMATCH: return flashctx->flags.force_boardmismatch;
+ case FLASHROM_FLAG_VERIFY_AFTER_WRITE: return flashctx->flags.verify_after_write;
+ case FLASHROM_FLAG_VERIFY_WHOLE_CHIP: return flashctx->flags.verify_whole_chip;
+ case FLASHROM_FLAG_SKIP_UNREADABLE_REGIONS: return flashctx->flags.skip_unreadable_regions;
+ case FLASHROM_FLAG_SKIP_UNWRITABLE_REGIONS: return flashctx->flags.skip_unwritable_regions;
+ default: return false;
}
}


To view, visit change 70128. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I9b96fb04b863625d2c9f9a00b97c35b3ddb0871b
Gerrit-Change-Number: 70128
Gerrit-PatchSet: 24
Gerrit-Owner: Nikolai Artemiev <nartemiev@google.com>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged