Flashrom assumes that the flash chip contents are available via mmap if no read function is defined. This special case is handled in lots of places all over the code.
Remove the special case and supply a jedec_read function. Not only does this allow us to fix a read bug in flashrom I recently uncovered on ICH SPI, it also allows us to add support for Paraflasher to flashrom.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-explicit_read/flash.h =================================================================== --- flashrom-explicit_read/flash.h (Revision 3808) +++ flashrom-explicit_read/flash.h (Arbeitskopie) @@ -545,6 +545,7 @@ int erase_block_jedec(volatile uint8_t *bios, unsigned int page); int write_sector_jedec(volatile uint8_t *bios, uint8_t *src, volatile uint8_t *dst, unsigned int page_size); +int read_jedec(struct flashchip *flash, uint8_t *buf);
/* m29f400bt.c */ int probe_m29f400bt(struct flashchip *flash); Index: flashrom-explicit_read/jedec.c =================================================================== --- flashrom-explicit_read/jedec.c (Revision 3808) +++ flashrom-explicit_read/jedec.c (Arbeitskopie) @@ -23,6 +23,7 @@
#include <stdio.h> #include <stdint.h> +#include <string.h> #include "flash.h"
#define MAX_REFLASH_TRIES 0x10 @@ -328,3 +329,9 @@
return 0; } + +int read_jedec(struct flashchip *flash, uint8_t *buf) +{ + memcpy(buf, (const char *)flash->virtual_memory, flash->total_size * 1024); + return 0; +} Index: flashrom-explicit_read/flashchips.c =================================================================== --- flashrom-explicit_read/flashchips.c (Revision 3808) +++ flashrom-explicit_read/flashchips.c (Arbeitskopie) @@ -39,37 +39,37 @@ {"AMD", "Am29F002(N)BB", AMD_ID, AM_29F002BB, 256, 256, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_en29f002a + probe_jedec, erase_chip_jedec, write_en29f002a, read_jedec },
{"AMD", "Am29F002(N)BT", AMD_ID, AM_29F002BT, 256, 256, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_en29f002a + probe_jedec, erase_chip_jedec, write_en29f002a, read_jedec },
{"AMD", "Am29F016D", AMD_ID, AM_29F016D, 2048, 64 * 1024, TEST_UNTESTED, - probe_29f040b, erase_29f040b, write_29f040b + probe_29f040b, erase_29f040b, write_29f040b, read_jedec },
{"AMD", "Am29F040B", AMD_ID, AM_29F040B, 512, 64 * 1024, TEST_OK_PREW, - probe_29f040b, erase_29f040b, write_29f040b + probe_29f040b, erase_29f040b, write_29f040b, read_jedec },
{"AMD", "Am29LV040B", AMD_ID, AM_29LV040B, 512, 64 * 1024, TEST_UNTESTED, - probe_29f040b, erase_29f040b, write_29f040b + probe_29f040b, erase_29f040b, write_29f040b, read_jedec },
{"ASD", "AE49F2008", ASD_ID, ASD_AE49F2008, 256, 128, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"Atmel", "AT25DF021", ATMEL_ID, AT_25DF021, @@ -173,13 +173,13 @@ {"Atmel", "AT29C020", ATMEL_ID, AT_29C020, 256, 256, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"Atmel", "AT29C040A", ATMEL_ID, AT_29C040A, 512, 256, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"Atmel", "AT45CS1282", ATMEL_ID, AT_45CS1282, @@ -239,13 +239,13 @@ {"Atmel", "AT49F002(N)", ATMEL_ID, AT_49F002N, 256, 256, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_49f002 + probe_jedec, erase_chip_jedec, write_49f002, read_jedec },
{"Atmel", "AT49F002(N)T", ATMEL_ID, AT_49F002NT, 256, 256, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_49f002 + probe_jedec, erase_chip_jedec, write_49f002, read_jedec },
{"AMIC", "A25L40P", AMIC_ID, AMIC_A25L40P, @@ -257,79 +257,79 @@ {"AMIC", "A29002B", AMIC_ID_NOPREFIX, AMIC_A29002B, 256, 64 * 1024, TEST_UNTESTED, - probe_29f002, erase_29f002, write_29f002 + probe_29f002, erase_29f002, write_29f002, read_jedec },
{"AMIC", "A29002T", AMIC_ID_NOPREFIX, AMIC_A29002T, 256, 64 * 1024, TEST_OK_PREW, - probe_29f002, erase_29f002, write_29f002 + probe_29f002, erase_29f002, write_29f002, read_jedec },
{"AMIC", "A29040B", AMIC_ID_NOPREFIX, AMIC_A29040B, 512, 64 * 1024, TEST_OK_PR, - probe_29f040b, erase_29f040b, write_29f040b + probe_29f040b, erase_29f040b, write_29f040b, read_jedec },
{"AMIC", "A49LF040A", AMIC_ID_NOPREFIX, AMIC_A49LF040A, 512, 64 * 1024, TEST_OK_PREW, - probe_49fl00x, erase_49fl00x, write_49fl00x + probe_49fl00x, erase_49fl00x, write_49fl00x, read_jedec },
{"EMST", "F49B002UA", EMST_ID, EMST_F49B002UA, 256, 4096, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_49f002 + probe_jedec, erase_chip_jedec, write_49f002, read_jedec },
{"EON", "EN29F002(A)(N)B", EON_ID, EN_29F002B, 256, 256, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_en29f002a + probe_jedec, erase_chip_jedec, write_en29f002a, read_jedec },
{"EON", "EN29F002(A)(N)T", EON_ID, EN_29F002T, 256, 256, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_en29f002a + probe_jedec, erase_chip_jedec, write_en29f002a, read_jedec },
{"Fujitsu", "MBM29F004BC", FUJITSU_ID, MBM29F004BC, 512, 64 * 1024, TEST_UNTESTED, - probe_jedec, NULL, NULL + probe_jedec, NULL, NULL, read_jedec },
{"Fujitsu", "MBM29F004TC", FUJITSU_ID, MBM29F004TC, 512, 64 * 1024, TEST_UNTESTED, - probe_jedec, NULL, NULL + probe_jedec, NULL, NULL, read_jedec },
{"Fujitsu", "MBM29F400BC", FUJITSU_ID, MBM29F400BC, 512, 64 * 1024, TEST_UNTESTED, - probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt + probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt, read_jedec },
{"Fujitsu", "MBM29F400TC", FUJITSU_ID, MBM29F400TC, 512, 64 * 1024, TEST_UNTESTED, - probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt + probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt, read_jedec },
{"Intel", "82802AB", INTEL_ID, 173, 512, 64 * 1024, TEST_OK_PREW, - probe_82802ab, erase_82802ab, write_82802ab + probe_82802ab, erase_82802ab, write_82802ab, read_jedec },
{"Intel", "82802AC", INTEL_ID, 172, 1024, 64 * 1024, TEST_OK_PREW, - probe_82802ab, erase_82802ab, write_82802ab + probe_82802ab, erase_82802ab, write_82802ab, read_jedec },
{"Macronix", "MX25L512", MX_ID, MX_25L512, @@ -383,13 +383,13 @@ {"Macronix", "MX29F002B", MX_ID, MX_29F002B, 256, 64 * 1024, TEST_UNTESTED, - probe_29f002, erase_29f002, write_29f002 + probe_29f002, erase_29f002, write_29f002, read_jedec },
{"Macronix", "MX29F002T", MX_ID, MX_29F002T, 256, 64 * 1024, TEST_UNTESTED, - probe_29f002, erase_29f002, write_29f002 + probe_29f002, erase_29f002, write_29f002, read_jedec },
{"Numonyx", "M25PE10", ST_ID, 0x8011, @@ -461,19 +461,19 @@ {"PMC", "Pm49FL002", PMC_ID_NOPREFIX, PMC_49FL002, 256, 16 * 1024, TEST_OK_PREW, - probe_49fl00x, erase_49fl00x, write_49fl00x + probe_49fl00x, erase_49fl00x, write_49fl00x, read_jedec },
{"PMC", "Pm49FL004", PMC_ID_NOPREFIX,PMC_49FL004, 512, 64 * 1024, TEST_OK_PREW, - probe_49fl00x, erase_49fl00x, write_49fl00x + probe_49fl00x, erase_49fl00x, write_49fl00x, read_jedec },
{"Sharp", "LHF00L04", SHARP_ID, SHARP_LHF00L04, 1024, 64 * 1024, TEST_UNTESTED, - probe_lhf00l04, erase_lhf00l04, write_lhf00l04 + probe_lhf00l04, erase_lhf00l04, write_lhf00l04, read_jedec },
{"Spansion", "S25FL016A", SPANSION_ID, SPANSION_S25FL016A, @@ -509,145 +509,145 @@ {"SST", "SST28SF040A", SST_ID, SST_28SF040, 512, 256, TEST_UNTESTED, - probe_28sf040, erase_28sf040, write_28sf040 + probe_28sf040, erase_28sf040, write_28sf040, read_jedec },
{"SST", "SST29EE010", SST_ID, SST_29EE010, 128, 128, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"SST", "SST29LE010", SST_ID, SST_29LE010, 128, 128, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"SST", "SST29EE020A", SST_ID, SST_29EE020A, 256, 128, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"SST", "SST29LE020", SST_ID, SST_29LE020, 256, 128, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"SST", "SST39SF010A", SST_ID, SST_39SF010, 128, 4096, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"SST", "SST39SF020A", SST_ID, SST_39SF020, 256, 4096, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"SST", "SST39SF040", SST_ID, SST_39SF040, 512, 4096, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"SST", "SST39VF512", SST_ID, SST_39VF512, 64, 4096, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"SST", "SST39VF010", SST_ID, SST_39VF010, 128, 4096, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"SST", "SST39VF020", SST_ID, SST_39VF020, 256, 4096, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"SST", "SST39VF040", SST_ID, SST_39VF040, 512, 4096, TEST_OK_PROBE, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"SST", "SST49LF002A/B", SST_ID, SST_49LF002A, 256, 16 * 1024, TEST_OK_PREW, - probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub + probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, read_jedec },
{"SST", "SST49LF003A/B", SST_ID, SST_49LF003A, 384, 64 * 1024, TEST_UNTESTED, - probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub + probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, read_jedec },
{"SST", "SST49LF004A/B", SST_ID, SST_49LF004A, 512, 64 * 1024, TEST_OK_PREW, - probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub + probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, read_jedec },
{"SST", "SST49LF004C", SST_ID, SST_49LF004C, 512, 4 * 1024, TEST_UNTESTED, - probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc + probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc, read_jedec },
{"SST", "SST49LF008A", SST_ID, SST_49LF008A, 1024, 64 * 1024, TEST_OK_PREW, - probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub + probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, read_jedec },
{"SST", "SST49LF008C", SST_ID, SST_49LF008C, 1024, 4 * 1024, TEST_UNTESTED, - probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc + probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc, read_jedec },
{"SST", "SST49LF016C", SST_ID, SST_49LF016C, 2048, 4 * 1024, TEST_OK_PREW, - probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc + probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc, read_jedec },
{"SST", "SST49LF020A", SST_ID, SST_49LF020A, 256, 16 * 1024, TEST_UNTESTED, - probe_jedec, erase_49lf040, write_49lf040 + probe_jedec, erase_49lf040, write_49lf040, read_jedec },
{"SST", "SST49LF040", SST_ID, SST_49LF040, 512, 4096, TEST_OK_PREW, - probe_jedec, erase_49lf040, write_49lf040 + probe_jedec, erase_49lf040, write_49lf040, read_jedec },
{"SST", "SST49LF040B", SST_ID, SST_49LF040B, 512, 64 * 1024, TEST_OK_PREW, - probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub + probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, read_jedec },
{"SST", "SST49LF080A", SST_ID, SST_49LF080A, 1024, 4096, TEST_OK_PREW, - probe_jedec, erase_49lf040, write_49lf040 + probe_jedec, erase_49lf040, write_49lf040, read_jedec },
{"SST", "SST49LF160C", SST_ID, SST_49LF160C, 2048, 4 * 1024, TEST_OK_PREW, - probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc + probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc, read_jedec },
{"ST", "M25P05-A", ST_ID, ST_M25P05A, @@ -713,115 +713,115 @@ {"ST", "M29F002B", ST_ID, ST_M29F002B, 256, 64 * 1024, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"ST", "M29F002T/NT", ST_ID, ST_M29F002T, 256, 64 * 1024, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"ST", "M29F040B", ST_ID, ST_M29F040B, 512, 64 * 1024, TEST_OK_PREW, - probe_29f040b, erase_29f040b, write_29f040b + probe_29f040b, erase_29f040b, write_29f040b, read_jedec },
{"ST", "M29F400BT", ST_ID, ST_M29F400BT, 512, 64 * 1024, TEST_UNTESTED, - probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt + probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt, read_jedec },
{"ST", "M29W010B", ST_ID, ST_M29W010B, 128, 16 * 1024, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"ST", "M29W040B", ST_ID, ST_M29W040B, 512, 64 * 1024, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"ST", "M50FLW040A", ST_ID, ST_M50FLW040A, 512, 64 * 1024, TEST_UNTESTED, - probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x + probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x, read_jedec },
{"ST", "M50FLW040B", ST_ID, ST_M50FLW040B, 512, 64 * 1024, TEST_UNTESTED, - probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x + probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x, read_jedec },
{"ST", "M50FLW080A", ST_ID, ST_M50FLW080A, 1024, 64 * 1024, TEST_OK_PREW, - probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x + probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x, read_jedec },
{"ST", "M50FLW080B", ST_ID, ST_M50FLW080B, 1024, 64 * 1024, TEST_UNTESTED, - probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x + probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x, read_jedec },
{"ST", "M50FW002", ST_ID, ST_M50FW002, 256, 64 * 1024, TEST_UNTESTED, - probe_49lfxxxc, NULL, NULL + probe_49lfxxxc, NULL, NULL, read_jedec },
{"ST", "M50FW016", ST_ID, ST_M50FW016, 2048, 64 * 1024, TEST_UNTESTED, - probe_82802ab, erase_82802ab, write_82802ab + probe_82802ab, erase_82802ab, write_82802ab, read_jedec },
{"ST", "M50FW040", ST_ID, ST_M50FW040, 512, 64 * 1024, TEST_OK_PREW, - probe_82802ab, erase_82802ab, write_82802ab + probe_82802ab, erase_82802ab, write_82802ab, read_jedec },
{"ST", "M50FW080", ST_ID, ST_M50FW080, 1024, 64 * 1024, TEST_UNTESTED, - probe_82802ab, erase_82802ab, write_82802ab + probe_82802ab, erase_82802ab, write_82802ab, read_jedec },
{"ST", "M50LPW116", ST_ID, ST_M50LPW116, 2048, 64 * 1024, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"SyncMOS", "S29C31004T", SYNCMOS_ID, S29C31004T, 512, 128, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_49f002 + probe_jedec, erase_chip_jedec, write_49f002, read_jedec },
{"SyncMOS", "S29C51001T", SYNCMOS_ID, S29C51001T, 128, 128, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_49f002 + probe_jedec, erase_chip_jedec, write_49f002, read_jedec },
{"SyncMOS", "S29C51002T", SYNCMOS_ID, S29C51002T, 256, 128, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_49f002 + probe_jedec, erase_chip_jedec, write_49f002, read_jedec },
{"SyncMOS", "S29C51004T", SYNCMOS_ID, S29C51004T, 512, 128, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_49f002 + probe_jedec, erase_chip_jedec, write_49f002, read_jedec },
{"Winbond", "W25x10", WINBOND_NEX_ID, W_25X10, @@ -851,121 +851,121 @@ {"Winbond", "W29C011", WINBOND_ID, W_29C011, 128, 128, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"Winbond", "W29C020C", WINBOND_ID, W_29C020C, 256, 128, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"Winbond", "W29C040P", WINBOND_ID, W_29C040P, 512, 256, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_jedec + probe_jedec, erase_chip_jedec, write_jedec, read_jedec },
{"Winbond", "W29EE011", WINBOND_ID, W_29C011, 128, 128, TEST_OK_PREW, - probe_w29ee011, erase_chip_jedec, write_jedec + probe_w29ee011, erase_chip_jedec, write_jedec, read_jedec },
{"Winbond", "W39V040A", WINBOND_ID, W_39V040A, 512, 64*1024, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"Winbond", "W39V040B", WINBOND_ID, W_39V040B, 512, 64*1024, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"Winbond", "W39V040C", WINBOND_ID, 0x50, 512, 64*1024, TEST_OK_PREW, - probe_w39v040c, erase_w39v040c, write_w39v040c + probe_w39v040c, erase_w39v040c, write_w39v040c, read_jedec },
{"Winbond", "W39V040FA", WINBOND_ID, W_39V040FA, 512, 64*1024, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"Winbond", "W39V080A", WINBOND_ID, W_39V080A, 1024, 64*1024, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_39sf020 + probe_jedec, erase_chip_jedec, write_39sf020, read_jedec },
{"Winbond", "W49F002U", WINBOND_ID, W_49F002U, 256, 128, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_49f002 + probe_jedec, erase_chip_jedec, write_49f002, read_jedec },
{"Winbond", "W49V002A", WINBOND_ID, W_49V002A, 256, 128, TEST_OK_PREW, - probe_jedec, erase_chip_jedec, write_49f002 + probe_jedec, erase_chip_jedec, write_49f002, read_jedec },
{"Winbond", "W49V002FA", WINBOND_ID, W_49V002FA, 256, 128, TEST_UNTESTED, - probe_jedec, erase_chip_jedec, write_49f002 + probe_jedec, erase_chip_jedec, write_49f002, read_jedec },
{"Winbond", "W39V080FA", WINBOND_ID, W_39V080FA, 1024, 64*1024, TEST_OK_PREW, - probe_winbond_fwhub, erase_winbond_fwhub, write_winbond_fwhub + probe_winbond_fwhub, erase_winbond_fwhub, write_winbond_fwhub, read_jedec },
{"Winbond", "W39V080FA (dual mode)", WINBOND_ID, W_39V080FA_DM, 512, 64*1024, TEST_UNTESTED, - probe_winbond_fwhub, erase_winbond_fwhub, write_winbond_fwhub + probe_winbond_fwhub, erase_winbond_fwhub, write_winbond_fwhub, read_jedec },
{"Atmel", "unknown Atmel SPI chip", ATMEL_ID, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED, - probe_spi_rdid, NULL, NULL + probe_spi_rdid, NULL, NULL, NULL },
{"EON", "unknown EON SPI chip", EON_ID_NOPREFIX, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED, - probe_spi_rdid, NULL, NULL + probe_spi_rdid, NULL, NULL, NULL },
{"Macronix", "unknown Macronix SPI chip", MX_ID, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED, - probe_spi_rdid, NULL, NULL + probe_spi_rdid, NULL, NULL, NULL },
{"PMC", "unknown PMC SPI chip", PMC_ID, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED, - probe_spi_rdid, NULL, NULL + probe_spi_rdid, NULL, NULL, NULL },
{"SST", "unknown SST SPI chip", SST_ID, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED, - probe_spi_rdid, NULL, NULL + probe_spi_rdid, NULL, NULL, NULL },
{"ST", "unknown ST SPI chip", ST_ID, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED, - probe_spi_rdid, NULL, NULL + probe_spi_rdid, NULL, NULL, NULL },
{NULL,} Index: flashrom-explicit_read/flashrom.c =================================================================== --- flashrom-explicit_read/flashrom.c (Revision 3808) +++ flashrom-explicit_read/flashrom.c (Arbeitskopie) @@ -171,9 +171,11 @@ int idx; int total_size = flash->total_size * 1024; uint8_t *buf2 = (uint8_t *) calloc(total_size, sizeof(char)); - if (flash->read == NULL) - memcpy(buf2, (const char *)flash->virtual_memory, total_size); - else + if (!flash->read) { + printf("FAILED!\n"); + fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n"); + return 1; + } else flash->read(flash, buf2);
printf("Verifying flash... "); @@ -507,9 +509,11 @@ exit(1); } printf("Force reading flash... "); - if (!flashes[0]->read) - memcpy(buf, (const char *)flashes[0]->virtual_memory, size); - else + if (!flashes[0]->read) { + printf("FAILED!\n"); + fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n"); + return 1; + } else flashes[0]->read(flashes[0], buf);
if (exclude_end_position - exclude_start_position > 0) @@ -587,9 +591,11 @@ return 1; } flash->erase(flash); - if (NULL == flash->read) - memcpy(buf, (const char *)flash->virtual_memory, size); - else + if (!flash->read) { + printf("FAILED!\n"); + fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n"); + return 1; + } else flash->read(flash, buf); for (erasedbytes = 0; erasedbytes <= size; erasedbytes++) if (0xff != buf[erasedbytes]) { @@ -606,9 +612,11 @@ exit(1); } printf("Reading flash... "); - if (flash->read == NULL) - memcpy(buf, (const char *)flash->virtual_memory, size); - else + if (!flash->read) { + printf("FAILED!\n"); + fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n"); + return 1; + } else flash->read(flash, buf);
if (exclude_end_position - exclude_start_position > 0)
OK for me. I can take that into account in my partial read patch.
Carl-Daniel Hailfinger a écrit :
Flashrom assumes that the flash chip contents are available via mmap if no read function is defined. This special case is handled in lots of places all over the code.
Remove the special case and supply a jedec_read function. Not only does this allow us to fix a read bug in flashrom I recently uncovered on ICH SPI, it also allows us to add support for Paraflasher to flashrom.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-explicit_read/flash.h
--- flashrom-explicit_read/flash.h (Revision 3808) +++ flashrom-explicit_read/flash.h (Arbeitskopie) @@ -545,6 +545,7 @@ int erase_block_jedec(volatile uint8_t *bios, unsigned int page); int write_sector_jedec(volatile uint8_t *bios, uint8_t *src, volatile uint8_t *dst, unsigned int page_size); +int read_jedec(struct flashchip *flash, uint8_t *buf);
/* m29f400bt.c */ int probe_m29f400bt(struct flashchip *flash); Index: flashrom-explicit_read/jedec.c =================================================================== --- flashrom-explicit_read/jedec.c (Revision 3808) +++ flashrom-explicit_read/jedec.c (Arbeitskopie) @@ -23,6 +23,7 @@
#include <stdio.h> #include <stdint.h> +#include <string.h> #include "flash.h"
#define MAX_REFLASH_TRIES 0x10 @@ -328,3 +329,9 @@
return 0; }
+int read_jedec(struct flashchip *flash, uint8_t *buf) +{
- memcpy(buf, (const char *)flash->virtual_memory, flash->total_size * 1024);
- return 0;
+} Index: flashrom-explicit_read/flashchips.c =================================================================== --- flashrom-explicit_read/flashchips.c (Revision 3808) +++ flashrom-explicit_read/flashchips.c (Arbeitskopie) @@ -39,37 +39,37 @@ {"AMD", "Am29F002(N)BB", AMD_ID, AM_29F002BB, 256, 256, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_en29f002a
probe_jedec, erase_chip_jedec, write_en29f002a, read_jedec
},
{"AMD", "Am29F002(N)BT", AMD_ID, AM_29F002BT, 256, 256, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_en29f002a
probe_jedec, erase_chip_jedec, write_en29f002a, read_jedec
},
{"AMD", "Am29F016D", AMD_ID, AM_29F016D, 2048, 64 * 1024, TEST_UNTESTED,
probe_29f040b, erase_29f040b, write_29f040b
probe_29f040b, erase_29f040b, write_29f040b, read_jedec
},
{"AMD", "Am29F040B", AMD_ID, AM_29F040B, 512, 64 * 1024, TEST_OK_PREW,
probe_29f040b, erase_29f040b, write_29f040b
probe_29f040b, erase_29f040b, write_29f040b, read_jedec
},
{"AMD", "Am29LV040B", AMD_ID, AM_29LV040B, 512, 64 * 1024, TEST_UNTESTED,
probe_29f040b, erase_29f040b, write_29f040b
probe_29f040b, erase_29f040b, write_29f040b, read_jedec
},
{"ASD", "AE49F2008", ASD_ID, ASD_AE49F2008, 256, 128, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"Atmel", "AT25DF021", ATMEL_ID, AT_25DF021,
@@ -173,13 +173,13 @@ {"Atmel", "AT29C020", ATMEL_ID, AT_29C020, 256, 256, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"Atmel", "AT29C040A", ATMEL_ID, AT_29C040A, 512, 256, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"Atmel", "AT45CS1282", ATMEL_ID, AT_45CS1282,
@@ -239,13 +239,13 @@ {"Atmel", "AT49F002(N)", ATMEL_ID, AT_49F002N, 256, 256, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_49f002
probe_jedec, erase_chip_jedec, write_49f002, read_jedec
},
{"Atmel", "AT49F002(N)T", ATMEL_ID, AT_49F002NT, 256, 256, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_49f002
probe_jedec, erase_chip_jedec, write_49f002, read_jedec
},
{"AMIC", "A25L40P", AMIC_ID, AMIC_A25L40P,
@@ -257,79 +257,79 @@ {"AMIC", "A29002B", AMIC_ID_NOPREFIX, AMIC_A29002B, 256, 64 * 1024, TEST_UNTESTED,
probe_29f002, erase_29f002, write_29f002
probe_29f002, erase_29f002, write_29f002, read_jedec
},
{"AMIC", "A29002T", AMIC_ID_NOPREFIX, AMIC_A29002T, 256, 64 * 1024, TEST_OK_PREW,
probe_29f002, erase_29f002, write_29f002
probe_29f002, erase_29f002, write_29f002, read_jedec
},
{"AMIC", "A29040B", AMIC_ID_NOPREFIX, AMIC_A29040B, 512, 64 * 1024, TEST_OK_PR,
probe_29f040b, erase_29f040b, write_29f040b
probe_29f040b, erase_29f040b, write_29f040b, read_jedec
},
{"AMIC", "A49LF040A", AMIC_ID_NOPREFIX, AMIC_A49LF040A, 512, 64 * 1024, TEST_OK_PREW,
probe_49fl00x, erase_49fl00x, write_49fl00x
probe_49fl00x, erase_49fl00x, write_49fl00x, read_jedec
},
{"EMST", "F49B002UA", EMST_ID, EMST_F49B002UA, 256, 4096, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_49f002
probe_jedec, erase_chip_jedec, write_49f002, read_jedec
},
{"EON", "EN29F002(A)(N)B", EON_ID, EN_29F002B, 256, 256, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_en29f002a
probe_jedec, erase_chip_jedec, write_en29f002a, read_jedec
},
{"EON", "EN29F002(A)(N)T", EON_ID, EN_29F002T, 256, 256, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_en29f002a
probe_jedec, erase_chip_jedec, write_en29f002a, read_jedec
},
{"Fujitsu", "MBM29F004BC", FUJITSU_ID, MBM29F004BC, 512, 64 * 1024, TEST_UNTESTED,
probe_jedec, NULL, NULL
probe_jedec, NULL, NULL, read_jedec
},
{"Fujitsu", "MBM29F004TC", FUJITSU_ID, MBM29F004TC, 512, 64 * 1024, TEST_UNTESTED,
probe_jedec, NULL, NULL
probe_jedec, NULL, NULL, read_jedec
},
{"Fujitsu", "MBM29F400BC", FUJITSU_ID, MBM29F400BC, 512, 64 * 1024, TEST_UNTESTED,
probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt
probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt, read_jedec
},
{"Fujitsu", "MBM29F400TC", FUJITSU_ID, MBM29F400TC, 512, 64 * 1024, TEST_UNTESTED,
probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt
probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt, read_jedec
},
{"Intel", "82802AB", INTEL_ID, 173, 512, 64 * 1024, TEST_OK_PREW,
probe_82802ab, erase_82802ab, write_82802ab
probe_82802ab, erase_82802ab, write_82802ab, read_jedec
},
{"Intel", "82802AC", INTEL_ID, 172, 1024, 64 * 1024, TEST_OK_PREW,
probe_82802ab, erase_82802ab, write_82802ab
probe_82802ab, erase_82802ab, write_82802ab, read_jedec
},
{"Macronix", "MX25L512", MX_ID, MX_25L512,
@@ -383,13 +383,13 @@ {"Macronix", "MX29F002B", MX_ID, MX_29F002B, 256, 64 * 1024, TEST_UNTESTED,
probe_29f002, erase_29f002, write_29f002
probe_29f002, erase_29f002, write_29f002, read_jedec
},
{"Macronix", "MX29F002T", MX_ID, MX_29F002T, 256, 64 * 1024, TEST_UNTESTED,
probe_29f002, erase_29f002, write_29f002
probe_29f002, erase_29f002, write_29f002, read_jedec
},
{"Numonyx", "M25PE10", ST_ID, 0x8011,
@@ -461,19 +461,19 @@ {"PMC", "Pm49FL002", PMC_ID_NOPREFIX, PMC_49FL002, 256, 16 * 1024, TEST_OK_PREW,
probe_49fl00x, erase_49fl00x, write_49fl00x
probe_49fl00x, erase_49fl00x, write_49fl00x, read_jedec
},
{"PMC", "Pm49FL004", PMC_ID_NOPREFIX,PMC_49FL004, 512, 64 * 1024, TEST_OK_PREW,
probe_49fl00x, erase_49fl00x, write_49fl00x
probe_49fl00x, erase_49fl00x, write_49fl00x, read_jedec
},
{"Sharp", "LHF00L04", SHARP_ID, SHARP_LHF00L04, 1024, 64 * 1024, TEST_UNTESTED,
probe_lhf00l04, erase_lhf00l04, write_lhf00l04
probe_lhf00l04, erase_lhf00l04, write_lhf00l04, read_jedec
},
{"Spansion", "S25FL016A", SPANSION_ID, SPANSION_S25FL016A,
@@ -509,145 +509,145 @@ {"SST", "SST28SF040A", SST_ID, SST_28SF040, 512, 256, TEST_UNTESTED,
probe_28sf040, erase_28sf040, write_28sf040
probe_28sf040, erase_28sf040, write_28sf040, read_jedec
},
{"SST", "SST29EE010", SST_ID, SST_29EE010, 128, 128, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"SST", "SST29LE010", SST_ID, SST_29LE010, 128, 128, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"SST", "SST29EE020A", SST_ID, SST_29EE020A, 256, 128, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"SST", "SST29LE020", SST_ID, SST_29LE020, 256, 128, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"SST", "SST39SF010A", SST_ID, SST_39SF010, 128, 4096, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"SST", "SST39SF020A", SST_ID, SST_39SF020, 256, 4096, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"SST", "SST39SF040", SST_ID, SST_39SF040, 512, 4096, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"SST", "SST39VF512", SST_ID, SST_39VF512, 64, 4096, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"SST", "SST39VF010", SST_ID, SST_39VF010, 128, 4096, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"SST", "SST39VF020", SST_ID, SST_39VF020, 256, 4096, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"SST", "SST39VF040", SST_ID, SST_39VF040, 512, 4096, TEST_OK_PROBE,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"SST", "SST49LF002A/B", SST_ID, SST_49LF002A, 256, 16 * 1024, TEST_OK_PREW,
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, read_jedec
},
{"SST", "SST49LF003A/B", SST_ID, SST_49LF003A, 384, 64 * 1024, TEST_UNTESTED,
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, read_jedec
},
{"SST", "SST49LF004A/B", SST_ID, SST_49LF004A, 512, 64 * 1024, TEST_OK_PREW,
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, read_jedec
},
{"SST", "SST49LF004C", SST_ID, SST_49LF004C, 512, 4 * 1024, TEST_UNTESTED,
probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc
probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc, read_jedec
},
{"SST", "SST49LF008A", SST_ID, SST_49LF008A, 1024, 64 * 1024, TEST_OK_PREW,
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, read_jedec
},
{"SST", "SST49LF008C", SST_ID, SST_49LF008C, 1024, 4 * 1024, TEST_UNTESTED,
probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc
probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc, read_jedec
},
{"SST", "SST49LF016C", SST_ID, SST_49LF016C, 2048, 4 * 1024, TEST_OK_PREW,
probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc
probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc, read_jedec
},
{"SST", "SST49LF020A", SST_ID, SST_49LF020A, 256, 16 * 1024, TEST_UNTESTED,
probe_jedec, erase_49lf040, write_49lf040
probe_jedec, erase_49lf040, write_49lf040, read_jedec
},
{"SST", "SST49LF040", SST_ID, SST_49LF040, 512, 4096, TEST_OK_PREW,
probe_jedec, erase_49lf040, write_49lf040
probe_jedec, erase_49lf040, write_49lf040, read_jedec
},
{"SST", "SST49LF040B", SST_ID, SST_49LF040B, 512, 64 * 1024, TEST_OK_PREW,
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub
probe_sst_fwhub, erase_sst_fwhub, write_sst_fwhub, read_jedec
},
{"SST", "SST49LF080A", SST_ID, SST_49LF080A, 1024, 4096, TEST_OK_PREW,
probe_jedec, erase_49lf040, write_49lf040
probe_jedec, erase_49lf040, write_49lf040, read_jedec
},
{"SST", "SST49LF160C", SST_ID, SST_49LF160C, 2048, 4 * 1024, TEST_OK_PREW,
probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc
probe_49lfxxxc, erase_49lfxxxc, write_49lfxxxc, read_jedec
},
{"ST", "M25P05-A", ST_ID, ST_M25P05A,
@@ -713,115 +713,115 @@ {"ST", "M29F002B", ST_ID, ST_M29F002B, 256, 64 * 1024, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"ST", "M29F002T/NT", ST_ID, ST_M29F002T, 256, 64 * 1024, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"ST", "M29F040B", ST_ID, ST_M29F040B, 512, 64 * 1024, TEST_OK_PREW,
probe_29f040b, erase_29f040b, write_29f040b
probe_29f040b, erase_29f040b, write_29f040b, read_jedec
},
{"ST", "M29F400BT", ST_ID, ST_M29F400BT, 512, 64 * 1024, TEST_UNTESTED,
probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt
probe_m29f400bt, erase_m29f400bt, write_coreboot_m29f400bt, read_jedec
},
{"ST", "M29W010B", ST_ID, ST_M29W010B, 128, 16 * 1024, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"ST", "M29W040B", ST_ID, ST_M29W040B, 512, 64 * 1024, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"ST", "M50FLW040A", ST_ID, ST_M50FLW040A, 512, 64 * 1024, TEST_UNTESTED,
probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x
probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x, read_jedec
},
{"ST", "M50FLW040B", ST_ID, ST_M50FLW040B, 512, 64 * 1024, TEST_UNTESTED,
probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x
probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x, read_jedec
},
{"ST", "M50FLW080A", ST_ID, ST_M50FLW080A, 1024, 64 * 1024, TEST_OK_PREW,
probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x
probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x, read_jedec
},
{"ST", "M50FLW080B", ST_ID, ST_M50FLW080B, 1024, 64 * 1024, TEST_UNTESTED,
probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x
probe_stm50flw0x0x, erase_stm50flw0x0x, write_stm50flw0x0x, read_jedec
},
{"ST", "M50FW002", ST_ID, ST_M50FW002, 256, 64 * 1024, TEST_UNTESTED,
probe_49lfxxxc, NULL, NULL
probe_49lfxxxc, NULL, NULL, read_jedec
},
{"ST", "M50FW016", ST_ID, ST_M50FW016, 2048, 64 * 1024, TEST_UNTESTED,
probe_82802ab, erase_82802ab, write_82802ab
probe_82802ab, erase_82802ab, write_82802ab, read_jedec
},
{"ST", "M50FW040", ST_ID, ST_M50FW040, 512, 64 * 1024, TEST_OK_PREW,
probe_82802ab, erase_82802ab, write_82802ab
probe_82802ab, erase_82802ab, write_82802ab, read_jedec
},
{"ST", "M50FW080", ST_ID, ST_M50FW080, 1024, 64 * 1024, TEST_UNTESTED,
probe_82802ab, erase_82802ab, write_82802ab
probe_82802ab, erase_82802ab, write_82802ab, read_jedec
},
{"ST", "M50LPW116", ST_ID, ST_M50LPW116, 2048, 64 * 1024, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"SyncMOS", "S29C31004T", SYNCMOS_ID, S29C31004T, 512, 128, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_49f002
probe_jedec, erase_chip_jedec, write_49f002, read_jedec
},
{"SyncMOS", "S29C51001T", SYNCMOS_ID, S29C51001T, 128, 128, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_49f002
probe_jedec, erase_chip_jedec, write_49f002, read_jedec
},
{"SyncMOS", "S29C51002T", SYNCMOS_ID, S29C51002T, 256, 128, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_49f002
probe_jedec, erase_chip_jedec, write_49f002, read_jedec
},
{"SyncMOS", "S29C51004T", SYNCMOS_ID, S29C51004T, 512, 128, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_49f002
probe_jedec, erase_chip_jedec, write_49f002, read_jedec
},
{"Winbond", "W25x10", WINBOND_NEX_ID, W_25X10,
@@ -851,121 +851,121 @@ {"Winbond", "W29C011", WINBOND_ID, W_29C011, 128, 128, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"Winbond", "W29C020C", WINBOND_ID, W_29C020C, 256, 128, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"Winbond", "W29C040P", WINBOND_ID, W_29C040P, 512, 256, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_jedec
probe_jedec, erase_chip_jedec, write_jedec, read_jedec
},
{"Winbond", "W29EE011", WINBOND_ID, W_29C011, 128, 128, TEST_OK_PREW,
probe_w29ee011, erase_chip_jedec, write_jedec
probe_w29ee011, erase_chip_jedec, write_jedec, read_jedec
},
{"Winbond", "W39V040A", WINBOND_ID, W_39V040A, 512, 64*1024, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"Winbond", "W39V040B", WINBOND_ID, W_39V040B, 512, 64*1024, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"Winbond", "W39V040C", WINBOND_ID, 0x50, 512, 64*1024, TEST_OK_PREW,
probe_w39v040c, erase_w39v040c, write_w39v040c
probe_w39v040c, erase_w39v040c, write_w39v040c, read_jedec
},
{"Winbond", "W39V040FA", WINBOND_ID, W_39V040FA, 512, 64*1024, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"Winbond", "W39V080A", WINBOND_ID, W_39V080A, 1024, 64*1024, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_39sf020
probe_jedec, erase_chip_jedec, write_39sf020, read_jedec
},
{"Winbond", "W49F002U", WINBOND_ID, W_49F002U, 256, 128, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_49f002
probe_jedec, erase_chip_jedec, write_49f002, read_jedec
},
{"Winbond", "W49V002A", WINBOND_ID, W_49V002A, 256, 128, TEST_OK_PREW,
probe_jedec, erase_chip_jedec, write_49f002
probe_jedec, erase_chip_jedec, write_49f002, read_jedec
},
{"Winbond", "W49V002FA", WINBOND_ID, W_49V002FA, 256, 128, TEST_UNTESTED,
probe_jedec, erase_chip_jedec, write_49f002
probe_jedec, erase_chip_jedec, write_49f002, read_jedec
},
{"Winbond", "W39V080FA", WINBOND_ID, W_39V080FA, 1024, 64*1024, TEST_OK_PREW,
probe_winbond_fwhub, erase_winbond_fwhub, write_winbond_fwhub
probe_winbond_fwhub, erase_winbond_fwhub, write_winbond_fwhub, read_jedec
},
{"Winbond", "W39V080FA (dual mode)", WINBOND_ID, W_39V080FA_DM, 512, 64*1024, TEST_UNTESTED,
probe_winbond_fwhub, erase_winbond_fwhub, write_winbond_fwhub
probe_winbond_fwhub, erase_winbond_fwhub, write_winbond_fwhub, read_jedec
},
{"Atmel", "unknown Atmel SPI chip", ATMEL_ID, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED,
probe_spi_rdid, NULL, NULL
probe_spi_rdid, NULL, NULL, NULL
},
{"EON", "unknown EON SPI chip", EON_ID_NOPREFIX, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED,
probe_spi_rdid, NULL, NULL
probe_spi_rdid, NULL, NULL, NULL
},
{"Macronix", "unknown Macronix SPI chip", MX_ID, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED,
probe_spi_rdid, NULL, NULL
probe_spi_rdid, NULL, NULL, NULL
},
{"PMC", "unknown PMC SPI chip", PMC_ID, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED,
probe_spi_rdid, NULL, NULL
probe_spi_rdid, NULL, NULL, NULL
},
{"SST", "unknown SST SPI chip", SST_ID, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED,
probe_spi_rdid, NULL, NULL
probe_spi_rdid, NULL, NULL, NULL
},
{"ST", "unknown ST SPI chip", ST_ID, GENERIC_DEVICE_ID, 0, 256, TEST_UNTESTED,
probe_spi_rdid, NULL, NULL
probe_spi_rdid, NULL, NULL, NULL
},
{NULL,}
Index: flashrom-explicit_read/flashrom.c
--- flashrom-explicit_read/flashrom.c (Revision 3808) +++ flashrom-explicit_read/flashrom.c (Arbeitskopie) @@ -171,9 +171,11 @@ int idx; int total_size = flash->total_size * 1024; uint8_t *buf2 = (uint8_t *) calloc(total_size, sizeof(char));
- if (flash->read == NULL)
memcpy(buf2, (const char *)flash->virtual_memory, total_size);
- else
if (!flash->read) {
printf("FAILED!\n");
fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n");
return 1;
} else flash->read(flash, buf2);
printf("Verifying flash... ");
@@ -507,9 +509,11 @@ exit(1); } printf("Force reading flash... ");
if (!flashes[0]->read)
memcpy(buf, (const char *)flashes[0]->virtual_memory, size);
else
if (!flashes[0]->read) {
printf("FAILED!\n");
fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n");
return 1;
} else flashes[0]->read(flashes[0], buf); if (exclude_end_position - exclude_start_position > 0)
@@ -587,9 +591,11 @@ return 1; } flash->erase(flash);
if (NULL == flash->read)
memcpy(buf, (const char *)flash->virtual_memory, size);
else
if (!flash->read) {
printf("FAILED!\n");
fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n");
return 1;
for (erasedbytes = 0; erasedbytes <= size; erasedbytes++) if (0xff != buf[erasedbytes]) {} else flash->read(flash, buf);
@@ -606,9 +612,11 @@ exit(1); } printf("Reading flash... ");
if (flash->read == NULL)
memcpy(buf, (const char *)flash->virtual_memory, size);
else
if (!flash->read) {
printf("FAILED!\n");
fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n");
return 1;
} else flash->read(flash, buf);
if (exclude_end_position - exclude_start_position > 0)
-- coreboot mailing list: coreboot@coreboot.org http://www.coreboot.org/mailman/listinfo/coreboot
Carl-Daniel Hailfinger wrote:
Flashrom assumes that the flash chip contents are available via mmap if no read function is defined. This special case is handled in lots of places all over the code.
Remove the special case and supply a jedec_read function.
This of course has absolutely nothing to do with JEDEC.
I believe Stephan already created read_flash() in flashrom.c which does exactly the same thing. Just use that. I've promised to attach his patch to a ticket against the 1.1 milestone.
Nak in short, at the very least the name and which file it's in is all wrong.
//Peter
On 10.12.2008 12:08, Peter Stuge wrote:
Carl-Daniel Hailfinger wrote:
Flashrom assumes that the flash chip contents are available via mmap if no read function is defined. This special case is handled in lots of places all over the code.
Remove the special case and supply a jedec_read function.
This of course has absolutely nothing to do with JEDEC.
I believe Stephan already created read_flash() in flashrom.c which does exactly the same thing. Just use that. I've promised to attach his patch to a ticket against the 1.1 milestone.
Sorry, I don't understand completely. Was the read_flash() already merged or is it still to be merged? If it is the latter, I'd like to get it into 1.0.
Nak in short, at the very least the name and which file it's in is all wrong.
What about calling it read_mmap()? Or maybe read_inband()? The general idea is to suggest that the flash does not need to execute a command to read (in the normal case).
We could use a flashlib.c file to store such functions in.
Regards, Carl-Daniel