summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2014-05-26 00:36:24 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2014-05-26 00:36:24 +0000
commit6455dff07b06e3b870f75e88652e0501810bd104 (patch)
tree0ec4cf1c51ffbd549717d6c030422e37cddddca7
parentffb0cf649c1c66c85441314434cd1cd57f89fe02 (diff)
downloadflashrom-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>
-rw-r--r--flash.h59
-rw-r--r--flashchips.c4
-rw-r--r--flashrom.c53
-rw-r--r--print.c24
-rw-r--r--print_wiki.c44
5 files changed, 113 insertions, 71 deletions
diff --git a/flash.h b/flash.h
index 2951c4d3d..d0b4fd9d7 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
diff --git a/flashchips.c b/flashchips.c
index dee7d9ebd..027b99613 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -2189,7 +2189,7 @@ const struct flashchip flashchips[] = {
.model_id = ATMEL_AT26F004,
.total_size = 512,
.page_size = 256,
- .tested = TEST_BAD_WRITE,
+ .tested = {.probe = NT, .read = NT, .erase = NT, .write = BAD },
.feature_bits = FEATURE_WRSR_WREN,
.probe = probe_spi_rdid,
.probe_timing = TIMING_ZERO,
@@ -5915,7 +5915,7 @@ const struct flashchip flashchips[] = {
.model_id = MACRONIX_MX23L3254,
.total_size = 4096,
.page_size = 256,
- .tested = TEST_OK_PR | TEST_BAD_EW,
+ .tested = {.probe = OK, .read = OK, .erase = NA, .write = NA},
.probe = probe_spi_rdid,
.probe_timing = TIMING_ZERO,
.write = NULL, /* MX23L3254 is a mask ROM, so it is read-only */
diff --git a/flashrom.c b/flashrom.c
index b3661c13d..a2851afbc 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -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;
diff --git a/print.c b/print.c
index fd4b2a7fa..8ca99d58f 100644
--- a/print.c
+++ b/print.c
@@ -249,38 +249,46 @@ static int print_supported_chips(void)
for (i = curdevlen; i < maxchiplen; i++)
msg_ginfo(" ");
- if ((chip->tested & TEST_OK_PROBE))
+ if (chip->tested.probe == OK)
msg_ginfo("P");
+ else if (chip->tested.probe == NA)
+ msg_ginfo("-");
else
msg_ginfo(" ");
- if ((chip->tested & TEST_OK_READ))
+ if (chip->tested.read == OK)
msg_ginfo("R");
+ else if (chip->tested.read == NA)
+ msg_ginfo("-");
else
msg_ginfo(" ");
- if ((chip->tested & TEST_OK_ERASE))
+ if (chip->tested.erase == OK)
msg_ginfo("E");
+ else if (chip->tested.erase == NA)
+ msg_ginfo("-");
else
msg_ginfo(" ");
- if ((chip->tested & TEST_OK_WRITE))
+ if (chip->tested.write == OK)
msg_ginfo("W");
+ else if (chip->tested.write == NA)
+ msg_ginfo("-");
else
msg_ginfo(" ");
for (i = 0; i < border; i++)
msg_ginfo(" ");
- if ((chip->tested & TEST_BAD_PROBE))
+ if (chip->tested.probe == BAD)
msg_ginfo("P");
else
msg_ginfo(" ");
- if ((chip->tested & TEST_BAD_READ))
+ if (chip->tested.read == BAD)
msg_ginfo("R");
else
msg_ginfo(" ");
- if ((chip->tested & TEST_BAD_ERASE))
+ if (chip->tested.erase == BAD)
msg_ginfo("E");
else
msg_ginfo(" ");
- if ((chip->tested & TEST_BAD_WRITE))
+ if (chip->tested.write == BAD)
msg_ginfo("W");
else
msg_ginfo(" ");
diff --git a/print_wiki.c b/print_wiki.c
index 5dcc4b6dc..cad6fef44 100644
--- a/print_wiki.c
+++ b/print_wiki.c
@@ -249,7 +249,6 @@ static void print_supported_boards_wiki(void)
static void print_supported_chips_wiki(int cols)
{
unsigned int lines_per_col;
- uint32_t t;
char *s;
char vmax[6];
char vmin[6];
@@ -287,7 +286,35 @@ static void print_supported_chips_wiki(int cols)
c = !c;
old = f;
- t = f->tested;
+ const char *probe, *read, *write, *erase;
+ switch (f->tested.probe) {
+ case OK: probe = "OK"; break;
+ case BAD: probe = "No"; break;
+ case NA: probe = "NA"; break;
+ case DEP: probe = "Dep"; break;
+ default: probe = "?3"; break;
+ }
+ switch (f->tested.read) {
+ case OK: read = "OK"; break;
+ case BAD: read = "No"; break;
+ case NA: read = "NA"; break;
+ case DEP: read = "Dep"; break;
+ default: read = "?3"; break;
+ }
+ switch (f->tested.erase) {
+ case OK: erase = "OK"; break;
+ case BAD: erase = "No"; break;
+ case NA: erase = "NA"; break;
+ case DEP: erase = "Dep"; break;
+ default: erase = "?3"; break;
+ }
+ switch (f->tested.write) {
+ case OK: write = "OK"; break;
+ case BAD: write = "No"; break;
+ case NA: write = "NA"; break;
+ case DEP: write = "Dep"; break;
+ default: write = "?3"; break;
+ }
s = flashbuses_to_text(f->bustype);
sprintf(vmin, "%0.03f", f->voltage.min / (double)1000);
sprintf(vmax, "%0.03f", f->voltage.max / (double)1000);
@@ -298,16 +325,9 @@ static void print_supported_chips_wiki(int cols)
"|| %s || %s \n",
(c == 1) ? "eeeeee" : "dddddd", f->vendor, f->name,
f->total_size, s,
- (t & TEST_OK_PROBE) ? "OK" :
- (t & TEST_BAD_PROBE) ? "No" : "?3",
- (t & TEST_OK_READ) ? "OK" :
- (t & TEST_BAD_READ) ? "No" : "?3",
- (t & TEST_OK_ERASE) ? "OK" :
- (t & TEST_BAD_ERASE) ? "No" : "?3",
- (t & TEST_OK_WRITE) ? "OK" :
- (t & TEST_BAD_WRITE) ? "No" : "?3",
- f->voltage.min ? vmin : "N/A",
- f->voltage.min ? vmax : "N/A");
+ probe, read, erase, write,
+ f->voltage.min ? vmin : "?",
+ f->voltage.max ? vmax : "?");
free(s);
if (((i % lines_per_col) + 1) == lines_per_col)