diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-05-16 21:22:56 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-05-16 21:22:56 +0000 |
commit | 5820f42ef209cfa0d4070fa9be96c9c91123a93f (patch) | |
tree | a505b6f813fc4f7601f77e7195e479dfddc73571 /stm50flw0x0x.c | |
parent | 4059598a068f7694f2238a3811d85cbfa520a8d5 (diff) | |
download | flashrom-5820f42ef209cfa0d4070fa9be96c9c91123a93f.tar.gz flashrom-5820f42ef209cfa0d4070fa9be96c9c91123a93f.tar.bz2 flashrom-5820f42ef209cfa0d4070fa9be96c9c91123a93f.zip |
Introduce a type "chipaddr" to abstract the offsets within flash regions
Use chipaddr instead of volatile uint8_t * because when we access chips
in external flashers, they are not accessed via pointers at all.
Benefits: This allows us to differentiate between volatile machine
memory accesses and flash chip accesses. It also enforces usage
of chip_{read,write}[bwl] to access flash chips, so nobody will
unintentionally use pointers to access chips anymore. Some unneeded
casts are removed as well. Grepping for chip operations and machine
memory operations doesn't yield any false positives anymore.
Compile tested on 32 bit and 64 bit Linux.
Corresponding to flashrom svn r519.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Diffstat (limited to 'stm50flw0x0x.c')
-rw-r--r-- | stm50flw0x0x.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/stm50flw0x0x.c b/stm50flw0x0x.c index d2d82d60..0e39bce9 100644 --- a/stm50flw0x0x.c +++ b/stm50flw0x0x.c @@ -31,7 +31,7 @@ #include <stdint.h> #include "flash.h" -void protect_stm50flw0x0x(volatile uint8_t *bios) +void protect_stm50flw0x0x(chipaddr bios) { chip_writeb(0xAA, bios + 0x5555); chip_writeb(0x55, bios + 0x2AAA); @@ -42,7 +42,7 @@ void protect_stm50flw0x0x(volatile uint8_t *bios) int probe_stm50flw0x0x(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; uint32_t largeid1, largeid2; @@ -91,7 +91,7 @@ int probe_stm50flw0x0x(struct flashchip *flash) return 1; } -static void wait_stm50flw0x0x(volatile uint8_t *bios) +static void wait_stm50flw0x0x(chipaddr bios) { uint8_t id1; // id2; @@ -120,7 +120,7 @@ static void wait_stm50flw0x0x(volatile uint8_t *bios) */ int unlock_block_stm50flw0x0x(struct flashchip *flash, int offset) { - volatile uint8_t *wrprotect = flash->virtual_registers + 2; + chipaddr wrprotect = flash->virtual_registers + 2; const uint8_t unlock_sector = 0x00; int j; @@ -163,12 +163,12 @@ int unlock_block_stm50flw0x0x(struct flashchip *flash, int offset) int erase_block_stm50flw0x0x(struct flashchip *flash, int offset) { - volatile uint8_t *bios = flash->virtual_memory + offset; + chipaddr bios = flash->virtual_memory + offset; int j; // clear status register chip_writeb(0x50, bios); - printf_debug("Erase at %p\n", bios); + printf_debug("Erase at 0x%lx\n", bios); // now start it chip_writeb(0x20, bios); chip_writeb(0xd0, bios); @@ -188,11 +188,11 @@ int erase_block_stm50flw0x0x(struct flashchip *flash, int offset) return 0; } -int write_page_stm50flw0x0x(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst, int page_size) +int write_page_stm50flw0x0x(chipaddr bios, uint8_t *src, + chipaddr dst, int page_size) { int i, rc = 0; - volatile uint8_t *d = dst; + chipaddr d = dst; uint8_t *s = src; /* transfer data from source to destination */ @@ -219,8 +219,8 @@ int write_page_stm50flw0x0x(volatile uint8_t *bios, uint8_t *src, } if (rc) { - fprintf(stderr, " page %d failed!\n", - (unsigned int)(d - bios) / page_size); + fprintf(stderr, " page 0x%lx failed!\n", + (d - bios) / page_size); } return rc; @@ -234,7 +234,7 @@ int erase_stm50flw0x0x(struct flashchip *flash) int i, rc = 0; int total_size = flash->total_size * 1024; int page_size = flash->page_size; - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; printf("Erasing page:\n"); for (i = 0; (i < total_size / page_size) && (rc == 0); i++) { @@ -256,7 +256,7 @@ int write_stm50flw0x0x(struct flashchip *flash, uint8_t * buf) int i, rc = 0; int total_size = flash->total_size * 1024; int page_size = flash->page_size; - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; printf("Programming page: \n"); for (i = 0; (i < total_size / page_size) && (rc == 0); i++) { |