summaryrefslogtreecommitdiffstats
path: root/stm50flw0x0x.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-06-05 18:32:07 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-06-05 18:32:07 +0000
commit0bd2a2bdc10720776fe50b96d24d30323ec24c09 (patch)
tree1348763e5fa6f4ea9d13a5b84d63999dcf132749 /stm50flw0x0x.c
parentca8bfc6c22196e5d16c6d2625c65d6b50c04daaf (diff)
downloadast2050-flashrom-0bd2a2bdc10720776fe50b96d24d30323ec24c09.zip
ast2050-flashrom-0bd2a2bdc10720776fe50b96d24d30323ec24c09.tar.gz
Sometimes we want to read/write more than 4 bytes of chip content at once
Add chip_{read,write}n to the external flasher infrastructure which read/write n bytes at once. Fix a few places where the code used memcpy/memcmp although that is strictly impossible with external flashers. Place a FIXME in the layout.c code because usage is not totally clear and needs to be fixed to support external flashers. As a nice side benefit, we get a noticeable speedup for builtin flash reading which is now a memcpy() of the full flash area instead of a series of single-byte reads. Corresponding to flashrom svn r579. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Urja Rannikko <urjaman@gmail.com> Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Diffstat (limited to 'stm50flw0x0x.c')
-rw-r--r--stm50flw0x0x.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/stm50flw0x0x.c b/stm50flw0x0x.c
index 5ca769b..83c95bb 100644
--- a/stm50flw0x0x.c
+++ b/stm50flw0x0x.c
@@ -27,6 +27,7 @@
*/
#include <string.h>
+#include <stdlib.h>
#include "flash.h"
void protect_stm50flw0x0x(chipaddr bios)
@@ -255,7 +256,12 @@ int write_stm50flw0x0x(struct flashchip *flash, uint8_t * buf)
int total_size = flash->total_size * 1024;
int page_size = flash->page_size;
chipaddr bios = flash->virtual_memory;
+ uint8_t *tmpbuf = malloc(page_size);
+ if (!tmpbuf) {
+ printf("Could not allocate memory!\n");
+ exit(1);
+ }
printf("Programming page: \n");
for (i = 0; (i < total_size / page_size) && (rc == 0); i++) {
printf
@@ -269,8 +275,8 @@ int write_stm50flw0x0x(struct flashchip *flash, uint8_t * buf)
* are not erased and rewritten; data is retained also
* in sudden power off situations
*/
- if (!memcmp((void *)(buf + i * page_size),
- (void *)(bios + i * page_size), page_size)) {
+ chip_readn(tmpbuf, bios + i * page_size, page_size);
+ if (!memcmp((void *)(buf + i * page_size), tmpbuf, page_size)) {
printf("SKIPPED\n");
continue;
}
@@ -284,6 +290,7 @@ int write_stm50flw0x0x(struct flashchip *flash, uint8_t * buf)
}
printf("\n");
protect_stm50flw0x0x(bios);
+ free(tmpbuf);
return rc;
}
OpenPOWER on IntegriCloud