summaryrefslogtreecommitdiff
path: root/82802ab.c
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2009-06-05 18:32:07 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2009-06-05 18:32:07 +0000
commita75816168d7324124fc5c585623fca71dd8b3fba (patch)
tree1348763e5fa6f4ea9d13a5b84d63999dcf132749 /82802ab.c
parent993783e7475f00da6f9df12cc159077588552b1b (diff)
downloadflashrom-a75816168d7324124fc5c585623fca71dd8b3fba.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. 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> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@579 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to '82802ab.c')
-rw-r--r--82802ab.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/82802ab.c b/82802ab.c
index c5cf52f..1dc997f 100644
--- a/82802ab.c
+++ b/82802ab.c
@@ -27,6 +27,7 @@
*/
#include <string.h>
+#include <stdlib.h>
#include "flash.h"
// I need that Berkeley bit-map printer
@@ -172,7 +173,12 @@ int write_82802ab(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; i++) {
printf
@@ -186,8 +192,8 @@ int write_82802ab(struct flashchip *flash, uint8_t *buf)
* or not erased and rewritten; their 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;
}
@@ -199,6 +205,7 @@ int write_82802ab(struct flashchip *flash, uint8_t *buf)
}
printf("\n");
protect_jedec(bios);
+ free(tmpbuf);
return 0;
}