path: root/flash.h
diff options
authorCarl-Daniel Hailfinger <>2009-05-11 14:13:25 +0000
committerCarl-Daniel Hailfinger <>2009-05-11 14:13:25 +0000
commit1455b2baea9f4379086cabf1dcc1388c478c745c (patch)
treebfa1507d50bf32cc52f03f21f2922520061d9c3f /flash.h
parentd0fc9469fd740c2036536a3656a56c11fe0b386e (diff)
Abstract mapping/unmapping of flash regions
Flash mapping/unmapping was performed without an abstraction layer, so even the dummy flasher caused memory mappings to be set up. Add map/unmap functions to the external flasher abstraction. Fix a possible scribble-over-low-memory corner case which fortunately never triggered so far. With this patch, --programmer dummy works fine as non-root. Corresponding to flashrom svn r493. Signed-off-by: Carl-Daniel Hailfinger <> Acked-by: Uwe Hermann <>
Diffstat (limited to 'flash.h')
1 files changed, 15 insertions, 0 deletions
diff --git a/flash.h b/flash.h
index 5736516..2a11c24 100644
--- a/flash.h
+++ b/flash.h
@@ -87,6 +87,9 @@ struct programmer_entry {
int (*init) (void);
int (*shutdown) (void);
+ 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);
@@ -107,6 +110,16 @@ static inline int programmer_shutdown(void)
return programmer_table[programmer].shutdown();
+static inline void *programmer_map_flash_region(const char *descr, unsigned long phys_addr, size_t len)
+ return programmer_table[programmer].map_flash_region(descr, phys_addr, len);
+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)
programmer_table[programmer].chip_writeb(val, addr);
@@ -579,6 +592,8 @@ uint32_t internal_chip_readl(const volatile void *addr);
/* dummyflasher.c */
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);
OpenPOWER on IntegriCloud