1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-06-30 21:52:36 +02:00

tree/: Change chip restore data type from uint8_t to void ptr

Chip restore callbacks currently are used by
- spi25_statusreg.c unlock functions to restore status register 1.
- s25f.c to restore config register 3.

Both of these cases only need to save a single uint8_t value to restore
the original chip state, however storing a void pointer will allow more
flexible chip restore behaviour. In particular, it will allow
flashrom_wp_cfg objects to be saved and restored, enabling
writeprotect-based unlocking.

BUG=b:237485865,b:247421511
BRANCH=none
TEST=Tested on grunt DUT (prog: sb600spi, flash: W25Q128.W):
     `flashrom --wp-range 0x0,0x1000000 \
      flashrom --wp-status     # Result: range=0x0,0x1000000 \
      flashrom -w random.bin   # Result: success \
      flashrom -v random.bin   # Result: success \
      flashrom --wp-status     # Result: range=0x0,0x1000000`

Change-Id: I311b468a4b0349f4da9584c12b36af6ec2394527
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/70349
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
Nikolai Artemiev
2022-12-05 12:49:14 +11:00
committed by Edward O'Callaghan
parent 7cab790a46
commit 673cb357d4
4 changed files with 32 additions and 10 deletions

View File

@ -94,7 +94,7 @@ int register_shutdown(int (*function) (void *data), void *data)
}
int register_chip_restore(chip_restore_fn_cb_t func,
struct flashctx *flash, uint8_t status)
struct flashctx *flash, void *data)
{
if (flash->chip_restore_fn_count >= MAX_CHIP_RESTORE_FUNCTIONS) {
msg_perr("Tried to register more than %i chip restore"
@ -102,7 +102,7 @@ int register_chip_restore(chip_restore_fn_cb_t func,
return 1;
}
flash->chip_restore_fn[flash->chip_restore_fn_count].func = func;
flash->chip_restore_fn[flash->chip_restore_fn_count].status = status;
flash->chip_restore_fn[flash->chip_restore_fn_count].data = data;
flash->chip_restore_fn_count++;
return 0;
@ -115,7 +115,7 @@ static int deregister_chip_restore(struct flashctx *flash)
while (flash->chip_restore_fn_count > 0) {
int i = --flash->chip_restore_fn_count;
rc |= flash->chip_restore_fn[i].func(
flash, flash->chip_restore_fn[i].status);
flash, flash->chip_restore_fn[i].data);
}
return rc;