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 | 2237dda98204032ae12004f41a99ef9286a28166 (patch) | |
tree | a505b6f813fc4f7601f77e7195e479dfddc73571 | |
parent | b79140252ae001fb1459010661b2ea8db912fc4c (diff) | |
download | flashrom-2237dda98204032ae12004f41a99ef9286a28166.zip flashrom-2237dda98204032ae12004f41a99ef9286a28166.tar.gz |
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>
-rw-r--r-- | 82802ab.c | 14 | ||||
-rw-r--r-- | am29f040b.c | 15 | ||||
-rw-r--r-- | dummyflasher.c | 24 | ||||
-rw-r--r-- | en29f002a.c | 10 | ||||
-rw-r--r-- | flash.h | 106 | ||||
-rw-r--r-- | flashrom.c | 7 | ||||
-rw-r--r-- | internal.c | 20 | ||||
-rw-r--r-- | jedec.c | 38 | ||||
-rw-r--r-- | m29f002.c | 12 | ||||
-rw-r--r-- | m29f400bt.c | 24 | ||||
-rw-r--r-- | mx29f002.c | 8 | ||||
-rw-r--r-- | nic3com.c | 8 | ||||
-rw-r--r-- | pm49fl00x.c | 6 | ||||
-rw-r--r-- | sharplhf00l04.c | 18 | ||||
-rw-r--r-- | sst28sf040.c | 16 | ||||
-rw-r--r-- | sst49lf040.c | 4 | ||||
-rw-r--r-- | sst49lfxxxc.c | 20 | ||||
-rw-r--r-- | sst_fwhub.c | 8 | ||||
-rw-r--r-- | stm50flw0x0x.c | 26 | ||||
-rw-r--r-- | w29ee011.c | 2 | ||||
-rw-r--r-- | w39v040c.c | 6 | ||||
-rw-r--r-- | w39v080fa.c | 12 | ||||
-rw-r--r-- | w49f002u.c | 2 |
23 files changed, 203 insertions, 203 deletions
@@ -45,7 +45,7 @@ void print_82802ab_status(uint8_t status) int probe_82802ab(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; #if 0 @@ -79,7 +79,7 @@ int probe_82802ab(struct flashchip *flash) return 1; } -uint8_t wait_82802ab(volatile uint8_t *bios) +uint8_t wait_82802ab(chipaddr bios) { uint8_t status; uint8_t id1, id2; @@ -109,8 +109,8 @@ uint8_t wait_82802ab(volatile uint8_t *bios) int erase_82802ab_block(struct flashchip *flash, int offset) { - volatile uint8_t *bios = flash->virtual_memory + offset; - volatile uint8_t *wrprotect = flash->virtual_registers + offset + 2; + chipaddr bios = flash->virtual_memory + offset; + chipaddr wrprotect = flash->virtual_registers + offset + 2; int j; uint8_t status; @@ -155,8 +155,8 @@ int erase_82802ab(struct flashchip *flash) return 0; } -void write_page_82802ab(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst, int page_size) +void write_page_82802ab(chipaddr bios, uint8_t *src, + chipaddr dst, int page_size) { int i; @@ -173,7 +173,7 @@ int write_82802ab(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; printf("Programming page: \n"); for (i = 0; i < total_size / page_size; i++) { diff --git a/am29f040b.c b/am29f040b.c index 87e9c70..2e70fa5 100644 --- a/am29f040b.c +++ b/am29f040b.c @@ -22,7 +22,7 @@ #include <stdint.h> #include "flash.h" -static __inline__ int erase_sector_29f040b(volatile uint8_t *bios, +static __inline__ int erase_sector_29f040b(chipaddr bios, unsigned long address) { chip_writeb(0xAA, bios + 0x555); @@ -40,17 +40,16 @@ static __inline__ int erase_sector_29f040b(volatile uint8_t *bios, return 0; } -static __inline__ int write_sector_29f040b(volatile uint8_t *bios, +static __inline__ int write_sector_29f040b(chipaddr bios, uint8_t *src, - volatile uint8_t *dst, + chipaddr dst, unsigned int page_size) { int i; for (i = 0; i < page_size; i++) { if ((i & 0xfff) == 0xfff) - printf("0x%08lx", (unsigned long)dst - - (unsigned long)bios); + printf("0x%08lx", dst - bios); chip_writeb(0xAA, bios + 0x555); chip_writeb(0x55, bios + 0x2AA); @@ -69,7 +68,7 @@ static __inline__ int write_sector_29f040b(volatile uint8_t *bios, int probe_29f040b(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; chip_writeb(0xAA, bios + 0x555); @@ -92,7 +91,7 @@ int probe_29f040b(struct flashchip *flash) int erase_29f040b(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; chip_writeb(0xAA, bios + 0x555); chip_writeb(0x55, bios + 0x2AA); @@ -112,7 +111,7 @@ int write_29f040b(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; printf("Programming page "); for (i = 0; i < total_size / page_size; i++) { diff --git a/dummyflasher.c b/dummyflasher.c index 7e671b8..bbe19bf 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -54,36 +54,36 @@ void dummy_unmap(void *virt_addr, size_t len) __func__, (unsigned long)len, virt_addr); } -void dummy_chip_writeb(uint8_t val, volatile void *addr) +void dummy_chip_writeb(uint8_t val, chipaddr addr) { - printf_debug("%s: addr=%p, val=0x%02x\n", __func__, addr, val); + printf_debug("%s: addr=0x%lx, val=0x%02x\n", __func__, addr, val); } -void dummy_chip_writew(uint16_t val, volatile void *addr) +void dummy_chip_writew(uint16_t val, chipaddr addr) { - printf_debug("%s: addr=%p, val=0x%04x\n", __func__, addr, val); + printf_debug("%s: addr=0x%lx, val=0x%04x\n", __func__, addr, val); } -void dummy_chip_writel(uint32_t val, volatile void *addr) +void dummy_chip_writel(uint32_t val, chipaddr addr) { - printf_debug("%s: addr=%p, val=0x%08x\n", __func__, addr, val); + printf_debug("%s: addr=0x%lx, val=0x%08x\n", __func__, addr, val); } -uint8_t dummy_chip_readb(const volatile void *addr) +uint8_t dummy_chip_readb(const chipaddr addr) { - printf_debug("%s: addr=%p, returning 0xff\n", __func__, addr); + printf_debug("%s: addr=0x%lx, returning 0xff\n", __func__, addr); return 0xff; } -uint16_t dummy_chip_readw(const volatile void *addr) +uint16_t dummy_chip_readw(const chipaddr addr) { - printf_debug("%s: addr=%p, returning 0xffff\n", __func__, addr); + printf_debug("%s: addr=0x%lx, returning 0xffff\n", __func__, addr); return 0xffff; } -uint32_t dummy_chip_readl(const volatile void *addr) +uint32_t dummy_chip_readl(const chipaddr addr) { - printf_debug("%s: addr=%p, returning 0xffffffff\n", __func__, addr); + printf_debug("%s: addr=0x%lx, returning 0xffffffff\n", __func__, addr); return 0xffffffff; } diff --git a/en29f002a.c b/en29f002a.c index 7a8c7f7..461ffeb 100644 --- a/en29f002a.c +++ b/en29f002a.c @@ -32,7 +32,7 @@ int probe_en29f512(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; chip_writeb(0xAA, bios + 0x555); @@ -65,7 +65,7 @@ int probe_en29f512(struct flashchip *flash) /* This does not seem to function properly for EN29F002NT. */ int probe_en29f002a(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; chip_writeb(0xAA, bios + 0x555); @@ -95,10 +95,10 @@ int write_en29f002a(struct flashchip *flash, uint8_t *buf) { int i; int total_size = flash->total_size * 1024; - volatile uint8_t *bios = flash->virtual_memory; - volatile uint8_t *dst = bios; + chipaddr bios = flash->virtual_memory; + chipaddr dst = bios; - // *bios = 0xF0; + //chip_writeb(0xF0, bios); myusec_delay(10); erase_chip_jedec(flash); @@ -77,6 +77,8 @@ #endif #endif +typedef unsigned long chipaddr; + extern int programmer; #define PROGRAMMER_INTERNAL 0x00 #define PROGRAMMER_DUMMY 0x01 @@ -92,12 +94,12 @@ struct programmer_entry { void * (*map_flash_region) (const char *descr, unsigned long phys_addr, size_t len); void (*unmap_flash_region) (void *virt_addr, size_t len); - void (*chip_writeb) (uint8_t val, volatile void *addr); - void (*chip_writew) (uint16_t val, volatile void *addr); - void (*chip_writel) (uint32_t val, volatile void *addr); - uint8_t (*chip_readb) (const volatile void *addr); - uint16_t (*chip_readw) (const volatile void *addr); - uint32_t (*chip_readl) (const volatile void *addr); + void (*chip_writeb) (uint8_t val, chipaddr addr); + void (*chip_writew) (uint16_t val, chipaddr addr); + void (*chip_writel) (uint32_t val, chipaddr addr); + uint8_t (*chip_readb) (const chipaddr addr); + uint16_t (*chip_readw) (const chipaddr addr); + uint32_t (*chip_readl) (const chipaddr addr); }; extern const struct programmer_entry programmer_table[]; @@ -122,32 +124,32 @@ static inline void programmer_unmap_flash_region(void *virt_addr, size_t len) programmer_table[programmer].unmap_flash_region(virt_addr, len); } -static inline void chip_writeb(uint8_t val, volatile void *addr) +static inline void chip_writeb(uint8_t val, chipaddr addr) { programmer_table[programmer].chip_writeb(val, addr); } -static inline void chip_writew(uint16_t val, volatile void *addr) +static inline void chip_writew(uint16_t val, chipaddr addr) { programmer_table[programmer].chip_writew(val, addr); } -static inline void chip_writel(uint32_t val, volatile void *addr) +static inline void chip_writel(uint32_t val, chipaddr addr) { programmer_table[programmer].chip_writel(val, addr); } -static inline uint8_t chip_readb(const volatile void *addr) +static inline uint8_t chip_readb(const chipaddr addr) { return programmer_table[programmer].chip_readb(addr); } -static inline uint16_t chip_readw(const volatile void *addr) +static inline uint16_t chip_readw(const chipaddr addr) { return programmer_table[programmer].chip_readw(addr); } -static inline uint32_t chip_readl(const volatile void *addr) +static inline uint32_t chip_readl(const chipaddr addr) { return programmer_table[programmer].chip_readl(addr); } @@ -180,8 +182,8 @@ struct flashchip { int (*read) (struct flashchip *flash, uint8_t *buf); /* Some flash devices have an additional register space. */ - volatile uint8_t *virtual_memory; - volatile uint8_t *virtual_registers; + chipaddr virtual_memory; + chipaddr virtual_registers; }; #define TEST_UNTESTED 0 @@ -605,16 +607,16 @@ void physunmap(void *virt_addr, size_t len); void get_io_perms(void); int internal_init(void); int internal_shutdown(void); -void internal_chip_writeb(uint8_t val, volatile void *addr); -void internal_chip_writew(uint16_t val, volatile void *addr); -void internal_chip_writel(uint32_t val, volatile void *addr); -uint8_t internal_chip_readb(const volatile void *addr); -uint16_t internal_chip_readw(const volatile void *addr); -uint32_t internal_chip_readl(const volatile void *addr); -void fallback_chip_writew(uint16_t val, volatile void *addr); -void fallback_chip_writel(uint32_t val, volatile void *addr); -uint16_t fallback_chip_readw(const volatile void *addr); -uint32_t fallback_chip_readl(const volatile void *addr); +void internal_chip_writeb(uint8_t val, chipaddr addr); +void internal_chip_writew(uint16_t val, chipaddr addr); +void internal_chip_writel(uint32_t val, chipaddr addr); +uint8_t internal_chip_readb(const chipaddr addr); +uint16_t internal_chip_readw(const chipaddr addr); +uint32_t internal_chip_readl(const chipaddr addr); +void fallback_chip_writew(uint16_t val, chipaddr addr); +void fallback_chip_writel(uint32_t val, chipaddr addr); +uint16_t fallback_chip_readw(const chipaddr addr); +uint32_t fallback_chip_readl(const chipaddr addr); #if defined(__FreeBSD__) || defined(__DragonFly__) extern int io_fd; #endif @@ -624,12 +626,12 @@ int dummy_init(void); int dummy_shutdown(void); void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); void dummy_unmap(void *virt_addr, size_t len); -void dummy_chip_writeb(uint8_t val, volatile void *addr); -void dummy_chip_writew(uint16_t val, volatile void *addr); -void dummy_chip_writel(uint32_t val, volatile void *addr); -uint8_t dummy_chip_readb(const volatile void *addr); -uint16_t dummy_chip_readw(const volatile void *addr); -uint32_t dummy_chip_readl(const volatile void *addr); +void dummy_chip_writeb(uint8_t val, chipaddr addr); +void dummy_chip_writew(uint16_t val, chipaddr addr); +void dummy_chip_writel(uint32_t val, chipaddr addr); +uint8_t dummy_chip_readb(const chipaddr addr); +uint16_t dummy_chip_readw(const chipaddr addr); +uint32_t dummy_chip_readl(const chipaddr addr); int dummy_spi_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); @@ -638,8 +640,8 @@ int nic3com_init(void); int nic3com_shutdown(void); void *nic3com_map(const char *descr, unsigned long phys_addr, size_t len); void nic3com_unmap(void *virt_addr, size_t len); -void nic3com_chip_writeb(uint8_t val, volatile void *addr); -uint8_t nic3com_chip_readb(const volatile void *addr); +void nic3com_chip_writeb(uint8_t val, chipaddr addr); +uint8_t nic3com_chip_readb(const chipaddr addr); extern struct pcidev_status nics_3com[]; /* flashrom.c */ @@ -725,19 +727,19 @@ extern uint8_t volatile *sb600_spibar; /* jedec.c */ uint8_t oddparity(uint8_t val); -void toggle_ready_jedec(volatile uint8_t *dst); -void data_polling_jedec(volatile uint8_t *dst, uint8_t data); -void unprotect_jedec(volatile uint8_t *bios); -void protect_jedec(volatile uint8_t *bios); -int write_byte_program_jedec(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst); +void toggle_ready_jedec(chipaddr dst); +void data_polling_jedec(chipaddr dst, uint8_t data); +void unprotect_jedec(chipaddr bios); +void protect_jedec(chipaddr bios); +int write_byte_program_jedec(chipaddr bios, uint8_t *src, + chipaddr dst); int probe_jedec(struct flashchip *flash); int erase_chip_jedec(struct flashchip *flash); int write_jedec(struct flashchip *flash, uint8_t *buf); -int erase_sector_jedec(volatile uint8_t *bios, unsigned int page); -int erase_block_jedec(volatile uint8_t *bios, unsigned int page); -int write_sector_jedec(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst, unsigned int page_size); +int erase_sector_jedec(chipaddr bios, unsigned int page); +int erase_block_jedec(chipaddr bios, unsigned int page); +int write_sector_jedec(chipaddr bios, uint8_t *src, + chipaddr dst, unsigned int page_size); /* m29f002.c */ int erase_m29f002(struct flashchip *flash); @@ -747,15 +749,15 @@ int write_m29f002b(struct flashchip *flash, uint8_t *buf); /* m29f400bt.c */ int probe_m29f400bt(struct flashchip *flash); int erase_m29f400bt(struct flashchip *flash); -int block_erase_m29f400bt(volatile uint8_t *bios, - volatile uint8_t *dst); +int block_erase_m29f400bt(chipaddr bios, + chipaddr dst); int write_m29f400bt(struct flashchip *flash, uint8_t *buf); int write_coreboot_m29f400bt(struct flashchip *flash, uint8_t *buf); -void toggle_ready_m29f400bt(volatile uint8_t *dst); -void data_polling_m29f400bt(volatile uint8_t *dst, uint8_t data); -void protect_m29f400bt(volatile uint8_t *bios); -void write_page_m29f400bt(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst, int page_size); +void toggle_ready_m29f400bt(chipaddr dst); +void data_polling_m29f400bt(chipaddr dst, uint8_t data); +void protect_m29f400bt(chipaddr bios); +void write_page_m29f400bt(chipaddr bios, uint8_t *src, + chipaddr dst, int page_size); /* mx29f002.c */ int probe_29f002(struct flashchip *flash); @@ -771,9 +773,9 @@ int write_49fl00x(struct flashchip *flash, uint8_t *buf); int probe_lhf00l04(struct flashchip *flash); int erase_lhf00l04(struct flashchip *flash); int write_lhf00l04(struct flashchip *flash, uint8_t *buf); -void toggle_ready_lhf00l04(volatile uint8_t *dst); -void data_polling_lhf00l04(volatile uint8_t *dst, uint8_t data); -void protect_lhf00l04(volatile uint8_t *bios); +void toggle_ready_lhf00l04(chipaddr dst); +void data_polling_lhf00l04(chipaddr dst, uint8_t data); +void protect_lhf00l04(chipaddr bios); /* sst28sf040.c */ int probe_28sf040(struct flashchip *flash); @@ -83,7 +83,7 @@ void map_flash_registers(struct flashchip *flash) { size_t size = flash->total_size * 1024; /* Flash registers live 4 MByte below the flash. */ - flash->virtual_registers = programmer_map_flash_region("flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size); + flash->virtual_registers = (chipaddr)programmer_map_flash_region("flash chip registers", (0xFFFFFFFF - 0x400000 - size + 1), size); } int read_memmapped(struct flashchip *flash, uint8_t *buf) @@ -116,7 +116,7 @@ struct flashchip *probe_flash(struct flashchip *first_flash, int force) size = flash->total_size * 1024; base = flashbase ? flashbase : (0xffffffff - size + 1); - flash->virtual_memory = programmer_map_flash_region("flash chip", base, size); + flash->virtual_memory = (chipaddr)programmer_map_flash_region("flash chip", base, size); if (force) break; @@ -129,8 +129,7 @@ struct flashchip *probe_flash(struct flashchip *first_flash, int force) break; notfound: - /* The intermediate cast to unsigned long works around a gcc warning bug. */ - programmer_unmap_flash_region((void *)(unsigned long)flash->virtual_memory, size); + programmer_unmap_flash_region((void *)flash->virtual_memory, size); } if (!flash || !flash->name) @@ -138,45 +138,45 @@ int internal_shutdown(void) return 0; } -void internal_chip_writeb(uint8_t val, volatile void *addr) +void internal_chip_writeb(uint8_t val, chipaddr addr) { *(volatile uint8_t *) addr = val; } -void internal_chip_writew(uint16_t val, volatile void *addr) +void internal_chip_writew(uint16_t val, chipaddr addr) { *(volatile uint16_t *) addr = val; } -void internal_chip_writel(uint32_t val, volatile void *addr) +void internal_chip_writel(uint32_t val, chipaddr addr) { *(volatile uint32_t *) addr = val; } -uint8_t internal_chip_readb(const volatile void *addr) +uint8_t internal_chip_readb(const chipaddr addr) { return *(volatile uint8_t *) addr; } -uint16_t internal_chip_readw(const volatile void *addr) +uint16_t internal_chip_readw(const chipaddr addr) { return *(volatile uint16_t *) addr; } -uint32_t internal_chip_readl(const volatile void *addr) +uint32_t internal_chip_readl(const chipaddr addr) { return *(volatile uint32_t *) addr; } /* Little-endian fallback for drivers not supporting 16 bit accesses */ -void fallback_chip_writew(uint16_t val, volatile void *addr) +void fallback_chip_writew(uint16_t val, chipaddr addr) { chip_writeb(val & 0xff, addr); chip_writeb((val >> 8) & 0xff, addr + 1); } /* Little-endian fallback for drivers not supporting 16 bit accesses */ -uint16_t fallback_chip_readw(const volatile void *addr) +uint16_t fallback_chip_readw(const chipaddr addr) { uint16_t val; val = chip_readb(addr); @@ -185,14 +185,14 @@ uint16_t fallback_chip_readw(const volatile void *addr) } /* Little-endian fallback for drivers not supporting 32 bit accesses */ -void fallback_chip_writel(uint32_t val, volatile void *addr) +void fallback_chip_writel(uint32_t val, chipaddr addr) { chip_writew(val & 0xffff, addr); chip_writew((val >> 16) & 0xffff, addr + 2); } /* Little-endian fallback for drivers not supporting 32 bit accesses */ -uint32_t fallback_chip_readl(const volatile void *addr) +uint32_t fallback_chip_readl(const chipaddr addr) { uint32_t val; val = chip_readw(addr); @@ -35,7 +35,7 @@ uint8_t oddparity(uint8_t val) return (val ^ (val >> 1)) & 0x1; } -void toggle_ready_jedec(volatile uint8_t *dst) +void toggle_ready_jedec(chipaddr dst) { unsigned int i = 0; uint8_t tmp1, tmp2; @@ -51,7 +51,7 @@ void toggle_ready_jedec(volatile uint8_t *dst) } } -void data_polling_jedec(volatile uint8_t *dst, uint8_t data) +void data_polling_jedec(chipaddr dst, uint8_t data) { unsigned int i = 0; uint8_t tmp; @@ -66,7 +66,7 @@ void data_polling_jedec(volatile uint8_t *dst, uint8_t data) } } -void unprotect_jedec(volatile uint8_t *bios) +void unprotect_jedec(chipaddr bios) { chip_writeb(0xAA, bios + 0x5555); chip_writeb(0x55, bios + 0x2AAA); @@ -78,7 +78,7 @@ void unprotect_jedec(volatile uint8_t *bios) usleep(200); } -void protect_jedec(volatile uint8_t *bios) +void protect_jedec(chipaddr bios) { chip_writeb(0xAA, bios + 0x5555); chip_writeb(0x55, bios + 0x2AAA); @@ -89,7 +89,7 @@ void protect_jedec(volatile uint8_t *bios) int probe_jedec(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; uint32_t largeid1, largeid2; uint32_t flashcontent1, flashcontent2; @@ -161,7 +161,7 @@ int probe_jedec(struct flashchip *flash) return 0; } -int erase_sector_jedec(volatile uint8_t *bios, unsigned int page) +int erase_sector_jedec(chipaddr bios, unsigned int page) { /* Issue the Sector Erase command */ chip_writeb(0xAA, bios + 0x5555); @@ -184,7 +184,7 @@ int erase_sector_jedec(volatile uint8_t *bios, unsigned int page) return 0; } -int erase_block_jedec(volatile uint8_t *bios, unsigned int block) +int erase_block_jedec(chipaddr bios, unsigned int block) { /* Issue the Sector Erase command */ chip_writeb(0xAA, bios + 0x5555); @@ -209,7 +209,7 @@ int erase_block_jedec(volatile uint8_t *bios, unsigned int block) int erase_chip_jedec(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; /* Issue the JEDEC Chip Erase command */ chip_writeb(0xAA, bios + 0x5555); @@ -231,11 +231,11 @@ int erase_chip_jedec(struct flashchip *flash) return 0; } -int write_page_write_jedec(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst, int page_size) +int write_page_write_jedec(chipaddr bios, uint8_t *src, + chipaddr dst, int page_size) { int i, tried = 0, start_index = 0, ok; - volatile uint8_t *d = dst; + chipaddr d = dst; uint8_t *s = src; retry: @@ -272,14 +272,14 @@ retry: goto retry; } if (!ok) { - fprintf(stderr, " page %d failed!\n", - (unsigned int)(d - bios) / page_size); + fprintf(stderr, " page 0x%lx failed!\n", + (d - bios) / page_size); } return !ok; } -int write_byte_program_jedec(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst) +int write_byte_program_jedec(chipaddr bios, uint8_t *src, + chipaddr dst) { int tried = 0, ok = 1; @@ -308,8 +308,8 @@ retry: return !ok; } -int write_sector_jedec(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst, unsigned int page_size) +int write_sector_jedec(chipaddr bios, uint8_t *src, + chipaddr dst, unsigned int page_size) { int i; @@ -326,12 +326,12 @@ int write_jedec(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; erase_chip_jedec(flash); // dumb check if erase was successful. for (i = 0; i < total_size; i++) { - if (chip_readb(bios + i) != (uint8_t) 0xff) { + if (chip_readb(bios + i) != 0xff) { printf("ERASE FAILED @%d, val %02x!\n", i, chip_readb(bios + i)); return -1; } @@ -22,7 +22,7 @@ int erase_m29f002(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; chip_writeb(0xaa, bios + 0x555); chip_writeb(0x55, bios + 0xaaa); chip_writeb(0x80, bios + 0x555); @@ -34,8 +34,8 @@ int erase_m29f002(struct flashchip *flash) return 0; } -static void rewrite_block(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst, int size) +static void rewrite_block(chipaddr bios, uint8_t *src, + chipaddr dst, int size) { /* erase */ chip_writeb(0xaa, bios + 0x555); @@ -59,7 +59,7 @@ static void rewrite_block(volatile uint8_t *bios, uint8_t *src, } } -static void do_block(volatile uint8_t *bios, uint8_t *src, int i, +static void do_block(chipaddr bios, uint8_t *src, int i, unsigned long start, int size) { printf("%d at address: 0x%08lx", i, start); @@ -70,7 +70,7 @@ static void do_block(volatile uint8_t *bios, uint8_t *src, int i, int write_m29f002t(struct flashchip *flash, uint8_t *buf) { int i, page_size = flash->page_size; - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; /* M29F002(N)T has 7 blocks. From bottom to top their sizes are: * 64k 64k 64k 32k 8k 8k 16k @@ -92,7 +92,7 @@ int write_m29f002t(struct flashchip *flash, uint8_t *buf) int write_m29f002b(struct flashchip *flash, uint8_t *buf) { int i = 0, page_size = flash->page_size; - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; /* M29F002B has 7 blocks. From bottom to top their sizes are: * 16k 8k 8k 32k 64k 64k 64k diff --git a/m29f400bt.c b/m29f400bt.c index cb55d76..7d63d58 100644 --- a/m29f400bt.c +++ b/m29f400bt.c @@ -20,7 +20,7 @@ #include "flash.h" -void protect_m29f400bt(volatile uint8_t *bios) +void protect_m29f400bt(chipaddr bios) { chip_writeb(0xAA, bios + 0xAAA); chip_writeb(0x55, bios + 0x555); @@ -29,8 +29,8 @@ void protect_m29f400bt(volatile uint8_t *bios) usleep(200); } -void write_page_m29f400bt(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst, int page_size) +void write_page_m29f400bt(chipaddr bios, uint8_t *src, + chipaddr dst, int page_size) { int i; @@ -41,12 +41,12 @@ void write_page_m29f400bt(volatile uint8_t *bios, uint8_t *src, /* transfer data from source to destination */ chip_writeb(*src, dst); - //*(volatile char *) (bios) = 0xF0; + //chip_writeb(0xF0, bios); //usleep(5); toggle_ready_jedec(dst); printf - ("Value in the flash at address %p = %#x, want %#x\n", - (uint8_t *) (dst - bios), chip_readb(dst), *src); + ("Value in the flash at address 0x%lx = %#x, want %#x\n", + (dst - bios), chip_readb(dst), *src); dst++; src++; } @@ -54,7 +54,7 @@ void write_page_m29f400bt(volatile uint8_t *bios, uint8_t *src, int probe_m29f400bt(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; chip_writeb(0xAA, bios + 0xAAA); @@ -85,7 +85,7 @@ int probe_m29f400bt(struct flashchip *flash) int erase_m29f400bt(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; chip_writeb(0xAA, bios + 0xAAA); chip_writeb(0x55, bios + 0x555); @@ -101,7 +101,7 @@ int erase_m29f400bt(struct flashchip *flash) return 0; } -int block_erase_m29f400bt(volatile uint8_t *bios, volatile uint8_t *dst) +int block_erase_m29f400bt(chipaddr bios, chipaddr dst) { chip_writeb(0xAA, bios + 0xAAA); @@ -110,7 +110,7 @@ int block_erase_m29f400bt(volatile uint8_t *bios, volatile uint8_t *dst) chip_writeb(0xAA, bios + 0xAAA); chip_writeb(0x55, bios + 0x555); - //*(volatile uint8_t *) (bios + 0xAAA) = 0x10; + //chip_writeb(0x10, bios + 0xAAA); chip_writeb(0x30, dst); myusec_delay(10); @@ -124,7 +124,7 @@ int write_m29f400bt(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; //erase_m29f400bt (flash); printf("Programming page:\n "); @@ -176,7 +176,7 @@ int write_m29f400bt(struct flashchip *flash, uint8_t *buf) int write_coreboot_m29f400bt(struct flashchip *flash, uint8_t *buf) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; printf("Programming page:\n "); /********************************* @@ -24,7 +24,7 @@ int probe_29f002(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; chip_writeb(0xAA, bios + 0x5555); @@ -47,7 +47,7 @@ int probe_29f002(struct flashchip *flash) int erase_29f002(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; chip_writeb(0xF0, bios + 0x555); chip_writeb(0xAA, bios + 0x555); @@ -80,8 +80,8 @@ int write_29f002(struct flashchip *flash, uint8_t *buf) { int i; int total_size = flash->total_size * 1024; - volatile uint8_t *bios = flash->virtual_memory; - volatile uint8_t *dst = bios; + chipaddr bios = flash->virtual_memory; + chipaddr dst = bios; chip_writeb(0xF0, bios); myusec_delay(10); @@ -87,17 +87,17 @@ void nic3com_unmap(void *virt_addr, size_t len) { } -void nic3com_chip_writeb(uint8_t val, volatile void *addr) +void nic3com_chip_writeb(uint8_t val, chipaddr addr) { - OUTL((uint32_t)(intptr_t)addr, io_base_addr + BIOS_ROM_ADDR); + OUTL((uint32_t)addr, io_base_addr + BIOS_ROM_ADDR); OUTB(val, io_base_addr + BIOS_ROM_DATA); } -uint8_t nic3com_chip_readb(const volatile void *addr) +uint8_t nic3com_chip_readb(const chipaddr addr) { uint8_t val; - OUTL((uint32_t)(intptr_t)addr, io_base_addr + BIOS_ROM_ADDR); + OUTL((uint32_t)addr, io_base_addr + BIOS_ROM_ADDR); val = INB(io_base_addr + BIOS_ROM_DATA); return val; diff --git a/pm49fl00x.c b/pm49fl00x.c index 86f3497..5e96ddc 100644 --- a/pm49fl00x.c +++ b/pm49fl00x.c @@ -25,7 +25,7 @@ extern int exclude_start_page, exclude_end_page; -void write_lockbits_49fl00x(volatile uint8_t *bios, int size, +void write_lockbits_49fl00x(chipaddr bios, int size, unsigned char bits, int block_size) { int i, left = size; @@ -54,7 +54,7 @@ int erase_49fl00x(struct flashchip *flash) 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; /* unprotected */ write_lockbits_49fl00x(flash->virtual_registers, @@ -89,7 +89,7 @@ int write_49fl00x(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; /* unprotected */ write_lockbits_49fl00x(flash->virtual_registers, total_size, 0, diff --git a/sharplhf00l04.c b/sharplhf00l04.c index 52071e6..c59203d 100644 --- a/sharplhf00l04.c +++ b/sharplhf00l04.c @@ -36,7 +36,7 @@ void print_lhf00l04_status(uint8_t status) int probe_lhf00l04(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; #if 0 @@ -71,7 +71,7 @@ int probe_lhf00l04(struct flashchip *flash) return 1; } -uint8_t wait_lhf00l04(volatile uint8_t *bios) +uint8_t wait_lhf00l04(chipaddr bios) { uint8_t status; uint8_t id1, id2; @@ -101,17 +101,17 @@ uint8_t wait_lhf00l04(volatile uint8_t *bios) int erase_lhf00l04_block(struct flashchip *flash, int offset) { - volatile uint8_t *bios = flash->virtual_memory + offset; - volatile uint8_t *wrprotect = flash->virtual_registers + offset + 2; + chipaddr bios = flash->virtual_memory + offset; + chipaddr wrprotect = flash->virtual_registers + offset + 2; uint8_t status; // clear status register chip_writeb(0x50, bios); - printf("Erase at %p\n", bios); + printf("Erase at 0x%lx\n", bios); status = wait_lhf00l04(flash->virtual_memory); print_lhf00l04_status(status); // clear write protect - printf("write protect is at %p\n", (wrprotect)); + printf("write protect is at 0x%lx\n", (wrprotect)); printf("write protect is 0x%x\n", chip_readb(wrprotect)); chip_writeb(0, wrprotect); printf("write protect is 0x%x\n", chip_readb(wrprotect)); @@ -142,8 +142,8 @@ int erase_lhf00l04(struct flashchip *flash) return 0; } -void write_page_lhf00l04(volatile uint8_t *bios, uint8_t *src, - volatile uint8_t *dst, int page_size) +void write_page_lhf00l04(chipaddr bios, uint8_t *src, + chipaddr dst, int page_size) { int i; @@ -160,7 +160,7 @@ int write_lhf00l04(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; erase_lhf00l04(flash); if (chip_readb(bios) != 0xff) { diff --git a/sst28sf040.c b/sst28sf040.c index 282b369..afa4191 100644 --- a/sst28sf040.c +++ b/sst28sf040.c @@ -30,7 +30,7 @@ #define RESET 0xFF #define READ_ID 0x90 -static __inline__ void protect_28sf040(volatile uint8_t *bios) +static __inline__ void protect_28sf040(chipaddr bios) { uint8_t tmp; @@ -43,7 +43,7 @@ static __inline__ void protect_28sf040(volatile uint8_t *bios) tmp = chip_readb(bios + 0x040A); } -static __inline__ void unprotect_28sf040(volatile uint8_t *bios) +static __inline__ void unprotect_28sf040(chipaddr bios) { uint8_t tmp; @@ -56,7 +56,7 @@ static __inline__ void unprotect_28sf040(volatile uint8_t *bios) tmp = chip_readb(bios + 0x041A); } -static __inline__ int erase_sector_28sf040(volatile uint8_t *bios, +static __inline__ int erase_sector_28sf040(chipaddr bios, unsigned long address) { chip_writeb(AUTO_PG_ERASE1, bios); @@ -68,9 +68,9 @@ static __inline__ int erase_sector_28sf040(volatile uint8_t *bios, return 0; } -static __inline__ int write_sector_28sf040(volatile uint8_t *bios, +static __inline__ int write_sector_28sf040(chipaddr bios, uint8_t *src, - volatile uint8_t *dst, + chipaddr dst, unsigned int page_size) { int i; @@ -95,7 +95,7 @@ static __inline__ int write_sector_28sf040(volatile uint8_t *bios, int probe_28sf040(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; chip_writeb(RESET, bios); @@ -119,7 +119,7 @@ int probe_28sf040(struct flashchip *flash) int erase_28sf040(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; unprotect_28sf040(bios); chip_writeb(CHIP_ERASE, bios); @@ -137,7 +137,7 @@ int write_28sf040(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; unprotect_28sf040(bios); diff --git a/sst49lf040.c b/sst49lf040.c index 10452bf..a610092 100644 --- a/sst49lf040.c +++ b/sst49lf040.c @@ -26,7 +26,7 @@ int erase_49lf040(struct flashchip *flash) 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; for (i = 0; i < total_size / page_size; i++) { /* Chip erase only works in parallel programming mode @@ -42,7 +42,7 @@ int write_49lf040(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; printf("Programming page: "); for (i = 0; i < total_size / page_size; i++) { 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: "); diff --git a/sst_fwhub.c b/sst_fwhub.c index 3b74a95..6abff0c 100644 --- a/sst_fwhub.c +++ b/sst_fwhub.c @@ -37,7 +37,7 @@ void print_sst_fwhub_status(uint8_t status) int check_sst_fwhub_block_lock(struct flashchip *flash, int offset) { - volatile uint8_t *registers = flash->virtual_registers; + chipaddr registers = flash->virtual_registers; uint8_t blockstatus; blockstatus = chip_readb(registers + offset + 2); @@ -63,7 +63,7 @@ int check_sst_fwhub_block_lock(struct flashchip *flash, int offset) int clear_sst_fwhub_block_lock(struct flashchip *flash, int offset) { - volatile uint8_t *registers = flash->virtual_registers; + chipaddr registers = flash->virtual_registers; uint8_t blockstatus; blockstatus = check_sst_fwhub_block_lock(flash, offset); @@ -115,7 +115,7 @@ int erase_sst_fwhub(struct flashchip *flash) { int i; unsigned int total_size = flash->total_size * 1024; - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; for (i = 0; i < total_size; i += flash->page_size) erase_sst_fwhub_block(flash, i); @@ -136,7 +136,7 @@ int write_sst_fwhub(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; uint8_t blockstatus; // FIXME: We want block wide erase instead of ironing the whole chip diff --git a/stm50flw0x0x.c b/stm50flw0x0x.c index d2d82d6..0e39bce 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++) { @@ -23,7 +23,7 @@ int probe_w29ee011(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2; extern char *chip_to_probe; @@ -23,7 +23,7 @@ int probe_w39v040c(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t id1, id2, lock; chip_writeb(0xAA, bios + 0x5555); @@ -61,7 +61,7 @@ int erase_w39v040c(struct flashchip *flash) { int i; unsigned int total_size = flash->total_size * 1024; - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; for (i = 0; i < total_size; i += flash->page_size) erase_sector_jedec(flash->virtual_memory, i); @@ -80,7 +80,7 @@ int write_w39v040c(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; if (flash->erase(flash)) return -1; diff --git a/w39v080fa.c b/w39v080fa.c index 7b827f8..8ebd263 100644 --- a/w39v080fa.c +++ b/w39v080fa.c @@ -23,7 +23,7 @@ int probe_winbond_fwhub(struct flashchip *flash) { - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t vid, did; /* Product Identification Entry */ @@ -54,7 +54,7 @@ int probe_winbond_fwhub(struct flashchip *flash) static int unlock_block_winbond_fwhub(struct flashchip *flash, int offset) { - volatile uint8_t *wrprotect = flash->virtual_registers + offset + 2; + chipaddr wrprotect = flash->virtual_registers + offset + 2; uint8_t locking; printf_debug("Trying to unlock block @0x%08x = 0x%02x\n", offset, @@ -98,7 +98,7 @@ static int unlock_block_winbond_fwhub(struct flashchip *flash, int offset) int unlock_winbond_fwhub(struct flashchip *flash) { int i, total_size = flash->total_size * 1024; - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; uint8_t locking; /* Are there any hardware restrictions that we can't overcome? @@ -143,7 +143,7 @@ int unlock_winbond_fwhub(struct flashchip *flash) return 0; } -static int erase_sector_winbond_fwhub(volatile uint8_t *bios, +static int erase_sector_winbond_fwhub(chipaddr bios, unsigned int sector) { /* Remember: too much sleep can waste your day. */ @@ -168,7 +168,7 @@ static int erase_sector_winbond_fwhub(volatile uint8_t *bios, int erase_winbond_fwhub(struct flashchip *flash) { int i, total_size = flash->total_size * 1024; - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; unlock_winbond_fwhub(flash); @@ -193,7 +193,7 @@ int write_winbond_fwhub(struct flashchip *flash, uint8_t *buf) { int i; int total_size = flash->total_size * 1024; - volatile uint8_t *bios = flash->virtual_memory; + chipaddr bios = flash->virtual_memory; if (erase_winbond_fwhub(flash)) return -1; @@ -26,7 +26,7 @@ int write_49f002(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; erase_chip_jedec(flash); |