diff options
author | Edward O'Callaghan <quasisec@google.com> | 2022-08-16 18:23:33 +1000 |
---|---|---|
committer | Felix Singer <felixsinger@posteo.net> | 2022-11-01 01:16:26 +0000 |
commit | 594d3357b6a4d883b6b87295bf4b9b6400777d18 (patch) | |
tree | 765d729f5ce7b2e54e176f29e0cb6a2eb75a8ad6 /include | |
parent | 985ad5623f8c2695ffc07d4bdbacbf2d85d4c11a (diff) | |
download | flashrom-594d3357b6a4d883b6b87295bf4b9b6400777d18.tar.gz flashrom-594d3357b6a4d883b6b87295bf4b9b6400777d18.tar.bz2 flashrom-594d3357b6a4d883b6b87295bf4b9b6400777d18.zip |
tree/: Convert flashchip read 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: I612d46fefedf2b69e7e2064aa857fa0756efb4e7
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66788
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/flash.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/include/flash.h b/include/flash.h index b61b7eae..2ba235db 100644 --- a/include/flash.h +++ b/include/flash.h @@ -255,6 +255,19 @@ enum write_func { }; typedef int (write_func_t)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); +enum read_func { + NO_READ_FUNC = 0, /* 0 indicates no read function set. */ + SPI_CHIP_READ = 1, + READ_OPAQUE, + READ_MEMMAPPED, + EDI_CHIP_READ, + SPI_READ_AT45DB, + SPI_READ_AT45DB_E8, + TEST_READ_INJECTOR, /* special case must come last. */ +}; +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); + struct flashchip { const char *vendor; const char *name; @@ -323,7 +336,7 @@ struct flashchip { int (*printlock) (struct flashctx *flash); int (*unlock) (struct flashctx *flash); enum write_func write; - int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); + enum read_func read; struct voltage { uint16_t min; uint16_t max; |