If a programmer has untested or non-working write/erase code, but probing/reading works, it makes sense to protect the user against write/erase accidents. This feature will be used by the Nvidia MCP SPI code, and it also might make sense for the gfxnvidia driver which has non-working write/erase.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-programmer_may_write/flash.h =================================================================== --- flashrom-programmer_may_write/flash.h (Revision 1065) +++ flashrom-programmer_may_write/flash.h (Arbeitskopie) @@ -569,6 +569,7 @@ uint32_t spi; }; extern struct decode_sizes max_rom_decode; +extern int programmer_may_write; extern char *programmer_param; extern unsigned long flashbase; extern int verbose; Index: flashrom-programmer_may_write/flashrom.c =================================================================== --- flashrom-programmer_may_write/flashrom.c (Revision 1065) +++ flashrom-programmer_may_write/flashrom.c (Arbeitskopie) @@ -109,6 +109,9 @@ .spi = 0xffffffff };
+/* Is writing allowed with this programmer? */ +int programmer_may_write = 1; + const struct programmer_entry programmer_table[] = { #if CONFIG_INTERNAL == 1 { @@ -1360,6 +1363,21 @@ size = flash->total_size * 1024; buf = (uint8_t *) calloc(size, sizeof(char));
+ if (!programmer_may_write && (write_it || erase_it)) { + msg_perr("Write/erase is not working yet on your programmer in " + "its current configuration.\n"); + /* --force is the wrong approach, but it's the best we can do + * until the generic programmer parameter parser is merged. + */ + if (!force) { + msg_perr("Aborting.\n"); + programmer_shutdown(); + return 1; + } else { + msg_cerr("Continuing anyway.\n"); + } + } + if (erase_it) { if (flash->tested & TEST_BAD_ERASE) { msg_cerr("Erase is not working on this chip. ");