[coreboot] [PATCH] flashrom: Partial read support
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Sat Jun 13 01:48:24 CEST 2009
With this patch it is possible to read arbitarary chip ranges on a byte
boundary.
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.
(This is also what quite a few of my previous patches were preparing for.)
The SPI read refactoring patch (which is waiting for an Ack) is needed
to make this work for SPI.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Index: flashrom-partial_read/flash.h
===================================================================
--- flashrom-partial_read/flash.h (Revision 588)
+++ flashrom-partial_read/flash.h (Arbeitskopie)
@@ -166,7 +166,7 @@
int probe_timing;
int (*erase) (struct flashchip *flash);
int (*write) (struct flashchip *flash, uint8_t *buf);
- int (*read) (struct flashchip *flash, uint8_t *buf);
+ int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len);
/* Some flash devices have an additional register space. */
chipaddr virtual_memory;
@@ -720,7 +720,7 @@
extern int verbose;
#define printf_debug(x...) { if (verbose) printf(x); }
void map_flash_registers(struct flashchip *flash);
-int read_memmapped(struct flashchip *flash, uint8_t *buf);
+int read_memmapped(struct flashchip *flash, uint8_t *buf, int start, int len);
extern char *pcidev_bdf;
/* layout.c */
@@ -762,7 +762,7 @@
int spi_block_erase_d8(const struct flashchip *flash, unsigned long addr);
int spi_chip_write_1(struct flashchip *flash, uint8_t *buf);
int spi_chip_write_256(struct flashchip *flash, uint8_t *buf);
-int spi_chip_read(struct flashchip *flash, uint8_t *buf);
+int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
uint8_t spi_read_status_register(void);
int spi_disable_blockprotect(void);
void spi_byte_program(int address, uint8_t byte);
@@ -790,7 +790,7 @@
int ich_init_opcodes(void);
int ich_spi_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
-int ich_spi_read(struct flashchip *flash, uint8_t * buf);
+int ich_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
int ich_spi_write_256(struct flashchip *flash, uint8_t * buf);
/* it87spi.c */
@@ -801,14 +801,14 @@
int it87xx_probe_spi_flash(const char *name);
int it8716f_spi_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
-int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf);
+int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len);
int it8716f_spi_chip_write_1(struct flashchip *flash, uint8_t *buf);
int it8716f_spi_chip_write_256(struct flashchip *flash, uint8_t *buf);
/* sb600spi.c */
int sb600_spi_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
-int sb600_spi_read(struct flashchip *flash, uint8_t *buf);
+int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
int sb600_spi_write_1(struct flashchip *flash, uint8_t *buf);
uint8_t sb600_read_status_register(void);
extern uint8_t *sb600_spibar;
@@ -908,7 +908,7 @@
int wbsio_check_for_spi(const char *name);
int wbsio_spi_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
-int wbsio_spi_read(struct flashchip *flash, uint8_t *buf);
+int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
int wbsio_spi_write_1(struct flashchip *flash, uint8_t *buf);
/* stm50flw0x0x.c */
Index: flashrom-partial_read/it87spi.c
===================================================================
--- flashrom-partial_read/it87spi.c (Revision 588)
+++ flashrom-partial_read/it87spi.c (Arbeitskopie)
@@ -257,7 +257,7 @@
* IT8716F only allows maximum of 512 kb SPI mapped to LPC memory cycles
* Need to read this big flash using firmware cycles 3 byte at a time.
*/
-int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf)
+int it8716f_spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len)
{
int total_size = 1024 * flash->total_size;
int i;
Index: flashrom-partial_read/spi.c
===================================================================
--- flashrom-partial_read/spi.c (Revision 588)
+++ flashrom-partial_read/spi.c (Arbeitskopie)
@@ -673,19 +673,19 @@
return spi_command(sizeof(cmd), len, cmd, bytes);
}
-int spi_chip_read(struct flashchip *flash, uint8_t *buf)
+int spi_chip_read(struct flashchip *flash, uint8_t *buf, int start, int len)
{
switch (spi_controller) {
case SPI_CONTROLLER_IT87XX:
- return it8716f_spi_chip_read(flash, buf);
+ return it8716f_spi_chip_read(flash, buf, start, len);
case SPI_CONTROLLER_SB600:
- return sb600_spi_read(flash, buf);
+ return sb600_spi_read(flash, buf, start, len);
case SPI_CONTROLLER_ICH7:
case SPI_CONTROLLER_ICH9:
case SPI_CONTROLLER_VIA:
- return ich_spi_read(flash, buf);
+ return ich_spi_read(flash, buf, start, len);
case SPI_CONTROLLER_WBSIO:
- return wbsio_spi_read(flash, buf);
+ return wbsio_spi_read(flash, buf, start, len);
default:
printf_debug
("%s called, but no SPI chipset/strapping detected\n",
Index: flashrom-partial_read/wbsio_spi.c
===================================================================
--- flashrom-partial_read/wbsio_spi.c (Revision 588)
+++ flashrom-partial_read/wbsio_spi.c (Arbeitskopie)
@@ -173,7 +173,7 @@
return 0;
}
-int wbsio_spi_read(struct flashchip *flash, uint8_t *buf)
+int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
{
int size = flash->total_size * 1024;
Index: flashrom-partial_read/sb600spi.c
===================================================================
--- flashrom-partial_read/sb600spi.c (Revision 588)
+++ flashrom-partial_read/sb600spi.c (Arbeitskopie)
@@ -39,7 +39,7 @@
struct sb600_spi_controller *spi_bar = NULL;
uint8_t *sb600_spibar;
-int sb600_spi_read(struct flashchip *flash, uint8_t *buf)
+int sb600_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
{
int rc = 0, i;
int total_size = flash->total_size * 1024;
Index: flashrom-partial_read/flashrom.c
===================================================================
--- flashrom-partial_read/flashrom.c (Revision 588)
+++ flashrom-partial_read/flashrom.c (Arbeitskopie)
@@ -193,9 +193,9 @@
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;
}
@@ -302,7 +302,7 @@
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... ");
@@ -355,7 +355,7 @@
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,
@@ -388,7 +388,7 @@
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]) {
Index: flashrom-partial_read/ichspi.c
===================================================================
--- flashrom-partial_read/ichspi.c (Revision 588)
+++ flashrom-partial_read/ichspi.c (Arbeitskopie)
@@ -681,7 +681,7 @@
return 0;
}
-int ich_spi_read(struct flashchip *flash, uint8_t * buf)
+int ich_spi_read(struct flashchip *flash, uint8_t * buf, int start, int len)
{
int i, rc = 0;
int total_size = flash->total_size * 1024;
--
http://www.hailfinger.org/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: flashrom_partial_read.diff
URL: <http://www.coreboot.org/pipermail/coreboot/attachments/20090613/90bd760d/attachment.ksh>
More information about the coreboot
mailing list