From cbf563cbde925dae6971c7df305493a638de51c6 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Tue, 16 Jun 2009 08:55:44 +0000 Subject: Support reads of arbitrary range That means you can tell flashrom to read exactly bytes 12345-56789 (start 12345, length 44445) and it will not fetch a single byte more. Uwe tested this on one LPC, one SPI, and one parallel flash board. Corresponding to flashrom svn r596. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Uwe Hermann --- flashrom.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'flashrom.c') diff --git a/flashrom.c b/flashrom.c index fe5826f..5821371 100644 --- a/flashrom.c +++ b/flashrom.c @@ -194,9 +194,9 @@ void map_flash_registers(struct flashchip *flash) flash->virtual_registers = (chipaddr)programmer_map_flash_region("flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size); } -int read_memmapped(struct flashchip *flash, uint8_t *buf) +int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len) { - chip_readn(buf, flash->virtual_memory, flash->total_size * 1024); + chip_readn(buf, flash->virtual_memory + start, len); return 0; } @@ -393,7 +393,7 @@ int verify_flash(struct flashchip *flash, uint8_t *buf) fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n"); return 1; } else - flash->read(flash, buf2); + flash->read(flash, buf2, 0, total_size); printf("Verifying flash... "); @@ -446,7 +446,7 @@ int read_flash(struct flashchip *flash, char *filename, unsigned int exclude_sta fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n"); return 1; } else - flash->read(flash, buf); + flash->read(flash, buf, 0, size); if (exclude_end_position - exclude_start_position > 0) memset(buf + exclude_start_position, 0, @@ -482,7 +482,7 @@ int erase_flash(struct flashchip *flash) fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n"); return 1; } else - flash->read(flash, buf); + flash->read(flash, buf, 0, size); for (erasedbytes = 0; erasedbytes < size; erasedbytes++) if (0xff != buf[erasedbytes]) { @@ -915,6 +915,7 @@ int main(int argc, char *argv[]) * 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, -- cgit v1.1