Author: rminnich Date: 2009-05-17 01:05:20 +0200 (Sun, 17 May 2009) New Revision: 4290
Modified: trunk/coreboot-v2/util/cbfstool/cbfstool.h trunk/coreboot-v2/util/cbfstool/util.c Log: This patch implements a "flash friendly" value for initialized areas of flash. It makes the write part of flashrom dramatically faster with small payloads like filo; and it also eliminates unnecessary wear on flash by not writing zeros (it's unlikely this really matters; let me know next time you flash a BIOS flash 100,000 times!).
More importantly, it allows for future partial flash upgrades with cbfs.
Note that uninitialized_flash_value is a global that can, if we ever need it, be set by an argument in main. Assuming we ever see a flash where the "erased" value is 0, not 0xff.
At the same time, "erased" value has been "1" on every EEPROM or FLASH I've used for some time now.
Signed-off-by: Ronald G. Minnich rminnich@gmail.com Acked-by: Peter Stuge peter@stuge.se
Modified: trunk/coreboot-v2/util/cbfstool/cbfstool.h =================================================================== --- trunk/coreboot-v2/util/cbfstool/cbfstool.h 2009-05-15 18:02:25 UTC (rev 4289) +++ trunk/coreboot-v2/util/cbfstool/cbfstool.h 2009-05-16 23:05:20 UTC (rev 4290) @@ -56,6 +56,7 @@ /* Function prototypes */
/* util.c */ +void flashinit(void *ptr, size_t len); int open_rom(struct rom *rom, const char *filename); int create_rom(struct rom *rom, const unsigned char *filename, int size, const char *bootblockname, int bootblocksize,
Modified: trunk/coreboot-v2/util/cbfstool/util.c =================================================================== --- trunk/coreboot-v2/util/cbfstool/util.c 2009-05-15 18:02:25 UTC (rev 4289) +++ trunk/coreboot-v2/util/cbfstool/util.c 2009-05-16 23:05:20 UTC (rev 4290) @@ -25,6 +25,13 @@ #include <sys/mman.h> #include "cbfstool.h"
+int uninitialized_flash_value = 0xff; + +void flashinit(void *ptr, size_t len) +{ + memset(ptr, uninitialized_flash_value, len); +} + int get_size(const char *size) { char *next; @@ -203,6 +210,9 @@ return -1; }
+ /* mmap'ed pages are by default zero-filled. Fix that. */ + flashinit(rom->ptr, romsize); + /* This is a pointer to the header for easy access */ rom->header = (struct cbfs_header *) ROM_PTR(rom, rom->size - 16 - bootblocksize - sizeof(struct cbfs_header));