1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 06:01:16 +02:00

tests/erase: record the opcode for each erase

This allows tests to verify that the correct opcode is used when
erasing, which is required to unit-test the fix to issue #525 where in
some situations an incorrect erase opcode will be used.

BUG=https://ticket.coreboot.org/issues/525

Change-Id: I3983fe42c2e7f06668a1bd20d2db7fafa93b8043
Signed-off-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/82251
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
Peter Marheine
2024-05-10 17:06:50 +10:00
parent 9a9ccdb6e6
commit 510ef74653
5 changed files with 157 additions and 58 deletions

View File

@ -266,10 +266,16 @@ enum write_func {
WRITE_82802AB,
WRITE_EN29LV640B,
EDI_CHIP_WRITE,
#ifdef FLASHROM_TEST
TEST_WRITE_INJECTOR, /* special case must come last. */
#endif
};
typedef int (write_func_t)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
#ifdef FLASHROM_TEST
extern write_func_t *g_test_write_injector;
#endif
enum read_func {
NO_READ_FUNC = 0, /* 0 indicates no read function set. */
SPI_CHIP_READ = 1,
@ -278,11 +284,17 @@ enum read_func {
EDI_CHIP_READ,
SPI_READ_AT45DB,
SPI_READ_AT45DB_E8,
#ifdef FLASHROM_TEST
TEST_READ_INJECTOR, /* special case must come last. */
#endif
};
typedef int (read_func_t)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
int read_flash(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
#ifdef FLASHROM_TEST
extern read_func_t *g_test_read_injector;
#endif
enum block_erase_func {
NO_BLOCK_ERASE_FUNC = 0, /* 0 indicates no block erase function set. */
SPI_BLOCK_ERASE_EMULATION = 1,
@ -319,9 +331,21 @@ enum block_erase_func {
ERASE_SECTOR_49LFXXXC,
STM50_SECTOR_ERASE,
EDI_CHIP_BLOCK_ERASE,
TEST_ERASE_INJECTOR, /* special case must come last. */
#ifdef FLASHROM_TEST
/* special cases must come last. */
TEST_ERASE_INJECTOR_1,
TEST_ERASE_INJECTOR_2,
TEST_ERASE_INJECTOR_3,
TEST_ERASE_INJECTOR_4,
TEST_ERASE_INJECTOR_5,
#endif
};
#ifdef FLASHROM_TEST
#define NUM_TEST_ERASE_INJECTORS 5
extern erasefunc_t *g_test_erase_injector[NUM_TEST_ERASE_INJECTORS];
#endif
enum blockprotect_func {
NO_BLOCKPROTECT_FUNC = 0, /* 0 indicates no unlock function set. */
SPI_DISABLE_BLOCKPROTECT,