summaryrefslogtreecommitdiffstats
path: root/sst49lfxxxc.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-05-16 21:22:56 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-05-16 21:22:56 +0000
commit5820f42ef209cfa0d4070fa9be96c9c91123a93f (patch)
treea505b6f813fc4f7601f77e7195e479dfddc73571 /sst49lfxxxc.c
parent4059598a068f7694f2238a3811d85cbfa520a8d5 (diff)
downloadast2050-flashrom-5820f42ef209cfa0d4070fa9be96c9c91123a93f.zip
ast2050-flashrom-5820f42ef209cfa0d4070fa9be96c9c91123a93f.tar.gz
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 'sst49lfxxxc.c')
-rw-r--r--sst49lfxxxc.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/sst49lfxxxc.c b/sst49lfxxxc.c
index 54897cc..d744cca 100644
--- a/sst49lfxxxc.c
+++ b/sst49lfxxxc.c
@@ -41,7 +41,7 @@
#define STATUS_ESS (1 << 6)
#define STATUS_WSMS (1 << 7)
-static __inline__ int write_lockbits_49lfxxxc(volatile uint8_t *bios, int size,
+static __inline__ int write_lockbits_49lfxxxc(chipaddr bios, int size,
unsigned char bits)
{
int i, left = size;
@@ -68,7 +68,7 @@ static __inline__ int write_lockbits_49lfxxxc(volatile uint8_t *bios, int size,
return 0;
}
-static __inline__ int erase_sector_49lfxxxc(volatile uint8_t *bios,
+static __inline__ int erase_sector_49lfxxxc(chipaddr bios,
unsigned long address)
{
unsigned char status;
@@ -79,7 +79,7 @@ static __inline__ int erase_sector_49lfxxxc(volatile uint8_t *bios,
do {
status = chip_readb(bios);
if (status & (STATUS_ESS | STATUS_BPS)) {
- printf("sector erase FAILED at address=0x%08lx status=0x%01x\n", (unsigned long)bios + address, status);
+ printf("sector erase FAILED at address=0x%08lx status=0x%01x\n", bios + address, status);
chip_writeb(CLEAR_STATUS, bios);
return (-1);
}
@@ -88,9 +88,9 @@ static __inline__ int erase_sector_49lfxxxc(volatile uint8_t *bios,
return 0;
}
-static __inline__ int write_sector_49lfxxxc(volatile uint8_t *bios,
+static __inline__ int write_sector_49lfxxxc(chipaddr bios,
uint8_t *src,
- volatile uint8_t *dst,
+ chipaddr dst,
unsigned int page_size)
{
int i;
@@ -111,7 +111,7 @@ static __inline__ int write_sector_49lfxxxc(volatile uint8_t *bios,
do {
status = chip_readb(bios);
if (status & (STATUS_ESS | STATUS_BPS)) {
- printf("sector write FAILED at address=0x%08lx status=0x%01x\n", (unsigned long)dst, status);
+ printf("sector write FAILED at address=0x%08lx status=0x%01x\n", dst, status);
chip_writeb(CLEAR_STATUS, bios);
return (-1);
}
@@ -123,7 +123,7 @@ static __inline__ int write_sector_49lfxxxc(volatile uint8_t *bios,
int probe_49lfxxxc(struct flashchip *flash)
{
- volatile uint8_t *bios = flash->virtual_memory;
+ chipaddr bios = flash->virtual_memory;
uint8_t id1, id2;
@@ -147,8 +147,8 @@ int probe_49lfxxxc(struct flashchip *flash)
int erase_49lfxxxc(struct flashchip *flash)
{
- volatile uint8_t *bios = flash->virtual_memory;
- volatile uint8_t *registers = flash->virtual_registers;
+ chipaddr bios = flash->virtual_memory;
+ chipaddr registers = flash->virtual_registers;
int i;
unsigned int total_size = flash->total_size * 1024;
@@ -167,7 +167,7 @@ int write_49lfxxxc(struct flashchip *flash, uint8_t *buf)
int i;
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;
write_lockbits_49lfxxxc(flash->virtual_registers, total_size, 0);
printf("Programming page: ");
OpenPOWER on IntegriCloud