diff options
author | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2014-05-26 00:36:24 +0000 |
---|---|---|
committer | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2014-05-26 00:36:24 +0000 |
commit | 6455dff07b06e3b870f75e88652e0501810bd104 (patch) | |
tree | 0ec4cf1c51ffbd549717d6c030422e37cddddca7 /flashrom.c | |
parent | ffb0cf649c1c66c85441314434cd1cd57f89fe02 (diff) | |
download | flashrom-6455dff07b06e3b870f75e88652e0501810bd104.tar.gz flashrom-6455dff07b06e3b870f75e88652e0501810bd104.tar.bz2 flashrom-6455dff07b06e3b870f75e88652e0501810bd104.zip |
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 <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'flashrom.c')
-rw-r--r-- | flashrom.c | 53 |
1 files changed, 36 insertions, 17 deletions
@@ -1791,32 +1791,43 @@ void check_chip_supported(const struct flashchip *chip) "clone the contents of this chip (see man page for " "details).\n"); } - if (TEST_OK_MASK != (chip->tested & TEST_OK_MASK)) { + + if ((chip->tested.erase == NA) && (chip->tested.write == NA)) { + msg_cdbg("This chip's main memory can not be erased/written by design.\n"); + } + + if ((chip->tested.probe == BAD) || (chip->tested.probe == NT) || + (chip->tested.read == BAD) || (chip->tested.read == NT) || + (chip->tested.erase == BAD) || (chip->tested.erase == NT) || + (chip->tested.write == BAD) || (chip->tested.write == NT)){ msg_cinfo("===\n"); - if (chip->tested & TEST_BAD_MASK) { + if ((chip->tested.probe == BAD) || + (chip->tested.read == BAD) || + (chip->tested.erase == BAD) || + (chip->tested.write == BAD)) { msg_cinfo("This flash part has status NOT WORKING for operations:"); - if (chip->tested & TEST_BAD_PROBE) + if (chip->tested.probe == BAD) msg_cinfo(" PROBE"); - if (chip->tested & TEST_BAD_READ) + if (chip->tested.read == BAD) msg_cinfo(" READ"); - if (chip->tested & TEST_BAD_ERASE) + if (chip->tested.erase == BAD) msg_cinfo(" ERASE"); - if (chip->tested & TEST_BAD_WRITE) + if (chip->tested.write == BAD) msg_cinfo(" WRITE"); msg_cinfo("\n"); } - if ((!(chip->tested & TEST_BAD_PROBE) && !(chip->tested & TEST_OK_PROBE)) || - (!(chip->tested & TEST_BAD_READ) && !(chip->tested & TEST_OK_READ)) || - (!(chip->tested & TEST_BAD_ERASE) && !(chip->tested & TEST_OK_ERASE)) || - (!(chip->tested & TEST_BAD_WRITE) && !(chip->tested & TEST_OK_WRITE))) { + if ((chip->tested.probe == NT) || + (chip->tested.read == NT) || + (chip->tested.erase == NT) || + (chip->tested.write == NT)) { msg_cinfo("This flash part has status UNTESTED for operations:"); - if (!(chip->tested & TEST_BAD_PROBE) && !(chip->tested & TEST_OK_PROBE)) + if (chip->tested.probe == NT) msg_cinfo(" PROBE"); - if (!(chip->tested & TEST_BAD_READ) && !(chip->tested & TEST_OK_READ)) + if (chip->tested.read == NT) msg_cinfo(" READ"); - if (!(chip->tested & TEST_BAD_ERASE) && !(chip->tested & TEST_OK_ERASE)) + if (chip->tested.erase == NT) msg_cinfo(" ERASE"); - if (!(chip->tested & TEST_BAD_WRITE) && !(chip->tested & TEST_OK_WRITE)) + if (chip->tested.write == NT) msg_cinfo(" WRITE"); msg_cinfo("\n"); } @@ -1859,7 +1870,7 @@ int chip_safety_check(const struct flashctx *flash, int force, int read_it, int if (read_it || erase_it || write_it || verify_it) { /* Everything needs read. */ - if (chip->tested & TEST_BAD_READ) { + if (chip->tested.read == BAD) { msg_cerr("Read is not working on this chip. "); if (!force) return 1; @@ -1873,7 +1884,11 @@ int chip_safety_check(const struct flashctx *flash, int force, int read_it, int } if (erase_it || write_it) { /* Write needs erase. */ - if (chip->tested & TEST_BAD_ERASE) { + if (chip->tested.erase == NA) { + msg_cerr("Erase is not possible on this chip.\n"); + return 1; + } + if (chip->tested.erase == BAD) { msg_cerr("Erase is not working on this chip. "); if (!force) return 1; @@ -1886,7 +1901,11 @@ int chip_safety_check(const struct flashctx *flash, int force, int read_it, int } } if (write_it) { - if (chip->tested & TEST_BAD_WRITE) { + if (chip->tested.write == NA) { + msg_cerr("Write is not possible on this chip.\n"); + return 1; + } + if (chip->tested.write == BAD) { msg_cerr("Write is not working on this chip. "); if (!force) return 1; |