1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

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>
This commit is contained in:
Nikolai Artemiev 2022-12-09 15:03:35 +11:00 committed by Edward O'Callaghan
parent 6cb1bd6fe3
commit a018234400
3 changed files with 17 additions and 9 deletions

View File

@ -530,6 +530,8 @@ struct flashrom_flashctx {
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.

View File

@ -251,6 +251,8 @@ enum flashrom_flag {
FLASHROM_FLAG_FORCE_BOARDMISMATCH,
FLASHROM_FLAG_VERIFY_AFTER_WRITE,
FLASHROM_FLAG_VERIFY_WHOLE_CHIP,
FLASHROM_FLAG_SKIP_UNREADABLE_REGIONS,
FLASHROM_FLAG_SKIP_UNWRITABLE_REGIONS,
};
/**

View File

@ -265,21 +265,25 @@ void flashrom_flag_set(struct flashrom_flashctx *const flashctx,
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;
}
}