From 6455dff07b06e3b870f75e88652e0501810bd104 Mon Sep 17 00:00:00 2001 From: Stefan Tauner Date: Mon, 26 May 2014 00:36:24 +0000 Subject: Add two new states to enum test_state and use it for flashchips The new enum test_state looks like this: enum test_state { OK = 0, NT = 1, /* Not tested */ BAD, /* Known to not work */ DEP, /* Support depends on configuration (e.g. Intel flash descriptor) */ NA, /* Not applicable (e.g. write support on ROM chips) */ }; The second new state 'NA' is introduced, among other things, to indicate the erase and write states of real ROMs correctly. This is also implemented by this patch and required to exchange the previous bit mask in struct flashchip with a new struct containing an enum test_state for each operation. The -L output is changed accordingly to print '-' in the case of an N/A state and the wiki output uses a new template producing a greyed out cell. Previous users of enum test_state are not affected by this change (yet). Corresponding to flashrom svn r1798. Signed-off-by: Stefan Tauner Acked-by: Carl-Daniel Hailfinger --- flash.h | 59 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) (limited to 'flash.h') diff --git a/flash.h b/flash.h index 2951c4d..d0b4fd9 100644 --- a/flash.h +++ b/flash.h @@ -120,6 +120,26 @@ enum write_granularity { #define FEATURE_OTP (1 << 8) #define FEATURE_QPI (1 << 9) +enum test_state { + OK = 0, + NT = 1, /* Not tested */ + BAD, /* Known to not work */ + DEP, /* Support depends on configuration (e.g. Intel flash descriptor) */ + NA, /* Not applicable (e.g. write support on ROM chips) */ +}; + +#define TEST_UNTESTED (struct tested){ .probe = NT, .read = NT, .erase = NT, .write = NT } + +#define TEST_OK_PROBE (struct tested){ .probe = OK, .read = NT, .erase = NT, .write = NT } +#define TEST_OK_PR (struct tested){ .probe = OK, .read = OK, .erase = NT, .write = NT } +#define TEST_OK_PRE (struct tested){ .probe = OK, .read = OK, .erase = OK, .write = NT } +#define TEST_OK_PREW (struct tested){ .probe = OK, .read = OK, .erase = OK, .write = OK } + +#define TEST_BAD_PROBE (struct tested){ .probe = BAD, .read = NT, .erase = NT, .write = NT } +#define TEST_BAD_PR (struct tested){ .probe = BAD, .read = BAD, .erase = NT, .write = NT } +#define TEST_BAD_PRE (struct tested){ .probe = BAD, .read = BAD, .erase = BAD, .write = NT } +#define TEST_BAD_PREW (struct tested){ .probe = BAD, .read = BAD, .erase = BAD, .write = BAD } + struct flashctx; typedef int (erasefunc_t)(struct flashctx *flash, unsigned int addr, unsigned int blocklen); @@ -143,11 +163,13 @@ struct flashchip { unsigned int page_size; int feature_bits; - /* - * Indicate if flashrom has been tested with this flash chip and if - * everything worked correctly. - */ - uint32_t tested; + /* Indicate how well flashrom supports different operations of this flash chip. */ + struct tested { + enum test_state probe; + enum test_state read; + enum test_state erase; + enum test_state write; + } tested; int (*probe) (struct flashctx *flash); @@ -192,27 +214,6 @@ struct flashctx { struct registered_programmer *pgm; }; -#define TEST_UNTESTED 0 - -#define TEST_OK_PROBE (1 << 0) -#define TEST_OK_READ (1 << 1) -#define TEST_OK_ERASE (1 << 2) -#define TEST_OK_WRITE (1 << 3) -#define TEST_OK_PR (TEST_OK_PROBE | TEST_OK_READ) -#define TEST_OK_PRE (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE) -#define TEST_OK_PRW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_WRITE) -#define TEST_OK_PREW (TEST_OK_PROBE | TEST_OK_READ | TEST_OK_ERASE | TEST_OK_WRITE) -#define TEST_OK_MASK 0x0f - -#define TEST_BAD_PROBE (1 << 4) -#define TEST_BAD_READ (1 << 5) -#define TEST_BAD_ERASE (1 << 6) -#define TEST_BAD_WRITE (1 << 7) -#define TEST_BAD_EW (TEST_BAD_ERASE | TEST_BAD_WRITE) -#define TEST_BAD_REW (TEST_BAD_READ | TEST_BAD_ERASE | TEST_BAD_WRITE) -#define TEST_BAD_PREW (TEST_BAD_PROBE | TEST_BAD_READ | TEST_BAD_ERASE | TEST_BAD_WRITE) -#define TEST_BAD_MASK 0xf0 - /* Timing used in probe routines. ZERO is -2 to differentiate between an unset * field and zero delay. * @@ -265,12 +266,6 @@ int doit(struct flashctx *flash, int force, const char *filename, int read_it, i int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename); int write_buf_to_file(const unsigned char *buf, unsigned long size, const char *filename); -enum test_state { - OK = 0, - NT = 1, /* Not tested */ - BAD -}; - /* Something happened that shouldn't happen, but we can go on. */ #define ERROR_NONFATAL 0x100 -- cgit v1.1