aboutsummaryrefslogtreecommitdiffstats
path: root/printlock.c
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-11-23 22:36:53 +1100
committerEdward O'Callaghan <quasisec@chromium.org>2023-03-20 00:36:56 +0000
commit0c774d6b6a075f37f21ca9c3506141cb0d4ae34b (patch)
tree695a252de5954213b1ceeffecef302394f26c2e6 /printlock.c
parent028099dbfd92e62eb0c6227d1194ff714f55e67c (diff)
downloadflashrom-0c774d6b6a075f37f21ca9c3506141cb0d4ae34b.tar.gz
flashrom-0c774d6b6a075f37f21ca9c3506141cb0d4ae34b.tar.bz2
flashrom-0c774d6b6a075f37f21ca9c3506141cb0d4ae34b.zip
tree/: Convert unlock func ptr into enumerate values
Converting the blockprotect unlock function pointer within the flashchip struct into enum values allows for the flashchips db to be turn into pure, declarative data. A nice side-effect of this is to reduce link-time symbol space of chipdrivers and increase modularity of the spi25_statusreg.c and related implementations. BUG=none TEST=ninja test. Change-Id: Ie5c5db1b09d07e1a549990d6f5a622fae4c83233 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/69933 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Sam McNally <sammc@google.com> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Diffstat (limited to 'printlock.c')
-rw-r--r--printlock.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/printlock.c b/printlock.c
index d05251e9..f6eea7f4 100644
--- a/printlock.c
+++ b/printlock.c
@@ -186,17 +186,17 @@ static int unlock_regspace2_uniform(struct flashctx *flash, unsigned long block_
return regspace2_walk_unlockblocks(flash, blocks, &unlock_regspace2_block_generic);
}
-int unlock_regspace2_uniform_64k(struct flashctx *flash)
+static int unlock_regspace2_uniform_64k(struct flashctx *flash)
{
return unlock_regspace2_uniform(flash, 64 * 1024);
}
-int unlock_regspace2_uniform_32k(struct flashctx *flash)
+static int unlock_regspace2_uniform_32k(struct flashctx *flash)
{
return unlock_regspace2_uniform(flash, 32 * 1024);
}
-int unlock_regspace2_block_eraser_0(struct flashctx *flash)
+static int unlock_regspace2_block_eraser_0(struct flashctx *flash)
{
// FIXME: this depends on the eraseblocks not to be filled up completely (i.e. to be null-terminated).
const struct unlockblock *unlockblocks =
@@ -204,10 +204,21 @@ int unlock_regspace2_block_eraser_0(struct flashctx *flash)
return regspace2_walk_unlockblocks(flash, unlockblocks, &unlock_regspace2_block_generic);
}
-int unlock_regspace2_block_eraser_1(struct flashctx *flash)
+static int unlock_regspace2_block_eraser_1(struct flashctx *flash)
{
// FIXME: this depends on the eraseblocks not to be filled up completely (i.e. to be null-terminated).
const struct unlockblock *unlockblocks =
(const struct unlockblock *)flash->chip->block_erasers[1].eraseblocks;
return regspace2_walk_unlockblocks(flash, unlockblocks, &unlock_regspace2_block_generic);
}
+
+blockprotect_func_t *lookup_jedec_blockprotect_func_ptr(const struct flashchip *const chip)
+{
+ switch (chip->unlock) {
+ case UNLOCK_REGSPACE2_BLOCK_ERASER_0: return unlock_regspace2_block_eraser_0;
+ case UNLOCK_REGSPACE2_BLOCK_ERASER_1: return unlock_regspace2_block_eraser_1;
+ case UNLOCK_REGSPACE2_UNIFORM_32K: return unlock_regspace2_uniform_32k;
+ case UNLOCK_REGSPACE2_UNIFORM_64K: return unlock_regspace2_uniform_64k;
+ default: return NULL; /* fallthough */
+ };
+}