summaryrefslogtreecommitdiff
path: root/physmap.c
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2009-05-11 14:13:25 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2009-05-11 14:13:25 +0000
commitc2a4234f8c00507eb7bfc638da33d98e4c91de5a (patch)
treebfa1507d50bf32cc52f03f21f2922520061d9c3f /physmap.c
parent2271926c5ac271e377fa9feb55d79f46d814ed72 (diff)
downloadflashrom-c2a4234f8c00507eb7bfc638da33d98e4c91de5a.tar.gz
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. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@493 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'physmap.c')
-rw-r--r--physmap.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/physmap.c b/physmap.c
index 49e1bfc..f1a68db 100644
--- a/physmap.c
+++ b/physmap.c
@@ -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) {