diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-05-11 14:13:25 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2009-05-11 14:13:25 +0000 |
commit | 1455b2baea9f4379086cabf1dcc1388c478c745c (patch) | |
tree | bfa1507d50bf32cc52f03f21f2922520061d9c3f /physmap.c | |
parent | d0fc9469fd740c2036536a3656a56c11fe0b386e (diff) | |
download | ast2050-flashrom-1455b2baea9f4379086cabf1dcc1388c478c745c.zip ast2050-flashrom-1455b2baea9f4379086cabf1dcc1388c478c745c.tar.gz |
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 <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
Diffstat (limited to 'physmap.c')
-rw-r--r-- | physmap.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -69,12 +69,33 @@ void *sys_physmap(unsigned long phys_addr, size_t len) void physunmap(void *virt_addr, size_t len) { + if (len == 0) { + printf_debug("Not unmapping zero size at %p\n", virt_addr); + return; + } + munmap(virt_addr, len); } #endif void *physmap(const char *descr, unsigned long phys_addr, size_t len) { + if (len == 0) { + printf_debug("Not mapping %s, zero size at 0x%08lx\n", + descr, phys_addr); + return NULL; + } + + if ((getpagesize() - 1) & len) { + fprintf(stderr, "Mapping %s at 0x%08lx, unaligned size 0x%lx\n", + descr, phys_addr, (unsigned long)len); + } + + if ((getpagesize() - 1) & phys_addr) { + fprintf(stderr, "Mapping %s, 0x%lx bytes at unaligned 0x%08lx\n", + descr, (unsigned long)len, phys_addr); + } + void *virt_addr = sys_physmap(phys_addr, len); if (NULL == virt_addr) { |