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

tree/: Convert flashchip write func ptr to enumerate

This forges the way for flashchips.c to be pure declarative
data and lookup functions for dispatch to be pure. This
means that the flashchips data could be extracted out to
be agnostic data of the flashrom code and algorithms.

TEST='R|W|E && --flash-name' on ARM, AMD & Intel DUT's.

Change-Id: I80149de169464b204fb09f1424a86fc645b740fd
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66782
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
This commit is contained in:
Edward O'Callaghan
2022-08-16 11:48:40 +10:00
committed by Felix Singer
parent 10e7a0ebd7
commit 985ad5623f
7 changed files with 656 additions and 599 deletions

View File

@ -238,6 +238,23 @@ enum probe_func {
PROBE_SPI_ST95,
};
enum write_func {
NO_WRITE_FUNC = 0, /* 0 indicates no write function set. */
WRITE_JEDEC = 1,
WRITE_JEDEC1,
WRITE_OPAQUE,
SPI_CHIP_WRITE1,
SPI_CHIP_WRITE256,
SPI_WRITE_AAI,
SPI_WRITE_AT45DB,
WRITE_28SF040,
WRITE_82802AB,
WRITE_EN29LV640B,
EDI_CHIP_WRITE,
TEST_WRITE_INJECTOR, /* special case must come last. */
};
typedef int (write_func_t)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
struct flashchip {
const char *vendor;
const char *name;
@ -305,7 +322,7 @@ struct flashchip {
int (*printlock) (struct flashctx *flash);
int (*unlock) (struct flashctx *flash);
int (*write) (struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
enum write_func write;
int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
struct voltage {
uint16_t min;