[coreboot] [PATCH] flashrom: Kill obsolete exclude range feature
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Tue Jun 16 14:10:56 CEST 2009
Kill obsolete exclude range feature. It is ignored by almost every chip
and does not work for external flashers. Plus, it gives the user a false
sense of security in some corner cases.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Index: flashrom-kill_exclude_range/flashrom.8
===================================================================
--- flashrom-kill_exclude_range/flashrom.8 (Revision 597)
+++ flashrom-kill_exclude_range/flashrom.8 (Arbeitskopie)
@@ -50,9 +50,6 @@
.TP
.B "\-c, \-\-chip" <chipname>
Probe only for specified flash ROM chip.
-.TP
-.B "\-s, \-\-estart" <addr>
-Exclude start position (obsolete).
.sp
flashrom supports ROM layouts. This allows you to flash certain parts of
the flash chip only. A ROM layout file looks like follows:
@@ -81,9 +78,6 @@
flexible and they should lead to a ROM update file format with the
ROM layout and the ROM image in one file (cpio, zip or something?).
.TP
-.B "\-e, \-\-eend" <addr>
-Exclude end postion (obsolete).
-.TP
.B "\-m, \-\-mainboard" <[vendor:]part>
Override mainboard settings.
.sp
Index: flashrom-kill_exclude_range/pm49fl00x.c
===================================================================
--- flashrom-kill_exclude_range/pm49fl00x.c (Revision 597)
+++ flashrom-kill_exclude_range/pm49fl00x.c (Arbeitskopie)
@@ -22,8 +22,6 @@
#include "flash.h"
-extern int exclude_start_page, exclude_end_page;
-
void write_lockbits_49fl00x(chipaddr bios, int size,
unsigned char bits, int block_size)
{
@@ -64,9 +62,6 @@
*/
printf("Erasing page: ");
for (i = 0; i < total_size / page_size; i++) {
- if ((i >= exclude_start_page) && (i < exclude_end_page))
- continue;
-
/* erase the page */
if (erase_block_jedec(flash, i * page_size, page_size)) {
fprintf(stderr, "ERASE FAILED!\n");
@@ -98,9 +93,6 @@
printf("Programming page: ");
for (i = 0; i < total_size / page_size; i++) {
- if ((i >= exclude_start_page) && (i < exclude_end_page))
- continue;
-
/* erase the page before programming */
if (erase_block_jedec(flash, i * page_size, page_size)) {
fprintf(stderr, "ERASE FAILED!\n");
Index: flashrom-kill_exclude_range/flashrom.c
===================================================================
--- flashrom-kill_exclude_range/flashrom.c (Revision 597)
+++ flashrom-kill_exclude_range/flashrom.c (Arbeitskopie)
@@ -31,7 +31,6 @@
#include "flashchips.h"
char *chip_to_probe = NULL;
-int exclude_start_page, exclude_end_page;
int verbose = 0;
int programmer = PROGRAMMER_INTERNAL;
@@ -425,7 +424,7 @@
return 0;
}
-int read_flash(struct flashchip *flash, char *filename, unsigned int exclude_start_position, unsigned int exclude_end_position)
+int read_flash(struct flashchip *flash, char *filename)
{
unsigned long numbytes;
FILE *image;
@@ -448,10 +447,6 @@
} else
flash->read(flash, buf, 0, size);
- if (exclude_end_position - exclude_start_position > 0)
- memset(buf + exclude_start_position, 0,
- exclude_end_position - exclude_start_position);
-
numbytes = fwrite(buf, 1, size, image);
fclose(image);
free(buf);
@@ -581,8 +576,6 @@
" -E | --erase: erase flash device\n"
" -V | --verbose: more verbose output\n"
" -c | --chip <chipname>: probe only for specified flash chip\n"
- " -s | --estart <addr>: exclude start position\n"
- " -e | --eend <addr>: exclude end postion\n"
" -m | --mainboard <[vendor:]part>: override mainboard settings\n"
" -f | --force: force write without checking image\n"
" -l | --layout <file.layout>: read ROM layout from file\n"
@@ -640,7 +633,6 @@
char *filename = NULL;
- unsigned int exclude_start_position = 0, exclude_end_position = 0; // [x,y)
char *tempstr = NULL, *tempstr2 = NULL;
print_version();
@@ -695,14 +687,6 @@
}
erase_it = 1;
break;
- case 's':
- tempstr = strdup(optarg);
- sscanf(tempstr, "%x", &exclude_start_position);
- break;
- case 'e':
- tempstr = strdup(optarg);
- sscanf(tempstr, "%x", &exclude_end_position);
- break;
case 'm':
tempstr = strdup(optarg);
strtok(tempstr, ":");
@@ -817,7 +801,7 @@
printf("Run flashrom -L to view the hardware supported in this flashrom version.\n");
exit(1);
}
- return read_flash(flashes[0], filename, exclude_start_position, exclude_end_position);
+ return read_flash(flashes[0], filename);
}
// FIXME: flash writes stay enabled!
exit(1);
@@ -881,7 +865,7 @@
if (erase_flash(flash))
return 1;
} else if (read_it) {
- if (read_flash(flash, filename, exclude_start_position, exclude_end_position))
+ if (read_flash(flash, filename))
return 1;
} else {
struct stat image_stat;
@@ -908,27 +892,6 @@
}
}
- /* exclude range stuff. Nice idea, but at the moment it is only
- * supported in hardware by the pm49fl004 chips.
- * Instead of implementing this for all chips I suggest advancing
- * it to the rom layout feature below and drop exclude range
- * completely once all flash chips can do rom layouts. stepan
- */
-
- /* FIXME: This code is totally broken. It treats exclude ranges as include ranges. */
- // ////////////////////////////////////////////////////////////
- if (exclude_end_position - exclude_start_position > 0)
- chip_readn(buf + exclude_start_position,
- flash->virtual_memory + exclude_start_position,
- exclude_end_position - exclude_start_position);
-
- exclude_start_page = exclude_start_position / flash->page_size;
- if ((exclude_start_position % flash->page_size) != 0) {
- exclude_start_page++;
- }
- exclude_end_page = exclude_end_position / flash->page_size;
- // ////////////////////////////////////////////////////////////
-
// This should be moved into each flash part's code to do it
// cleanly. This does the job.
/* FIXME: Adapt to the external flasher infrastructure. */
--
http://www.hailfinger.org/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: flashrom_kill_exclude_range.diff
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20090616/f4ddf898/attachment.ksh>
More information about the coreboot
mailing list