Changeset 579 for trunk/82802ab.c


Ignore:
Timestamp:
Jun 5, 2009 8:32:07 PM (4 years ago)
Author:
hailfinger
Message:

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@…>
Acked-by: Urja Rannikko <urjaman@…>
Acked-by: Uwe Hermann <uwe@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/82802ab.c

    r578 r579  
    2828 
    2929#include <string.h> 
     30#include <stdlib.h> 
    3031#include "flash.h" 
    3132 
     
    173174        int page_size = flash->page_size; 
    174175        chipaddr bios = flash->virtual_memory; 
    175  
     176        uint8_t *tmpbuf = malloc(page_size); 
     177 
     178        if (!tmpbuf) { 
     179                printf("Could not allocate memory!\n"); 
     180                exit(1); 
     181        } 
    176182        printf("Programming page: \n"); 
    177183        for (i = 0; i < total_size / page_size; i++) { 
     
    187193                 * sudden power off situations 
    188194                 */ 
    189                 if (!memcmp((void *)(buf + i * page_size), 
    190                             (void *)(bios + i * page_size), page_size)) { 
     195                chip_readn(tmpbuf, bios + i * page_size, page_size); 
     196                if (!memcmp((void *)(buf + i * page_size), tmpbuf, page_size)) { 
    191197                        printf("SKIPPED\n"); 
    192198                        continue; 
     
    200206        printf("\n"); 
    201207        protect_jedec(bios); 
     208        free(tmpbuf); 
    202209 
    203210        return 0; 
Note: See TracChangeset for help on using the changeset viewer.