summaryrefslogtreecommitdiff
path: root/util/flashrom/flashrom.c
diff options
context:
space:
mode:
authorSegher Boessenkool <segher@kernel.crashing.org>2008-08-12 11:58:00 +0000
committerSegher Boessenkool <segher@kernel.crashing.org>2008-08-12 11:58:00 +0000
commit716c7204685b65707f83956bbae8bd3e338f9286 (patch)
tree6ac3da5a7105d70a9853eee9827e2ae2fc5c8b39 /util/flashrom/flashrom.c
parentd133d9a23077e30f57014ab84633b7a0c4dc2518 (diff)
downloadcoreboot-716c7204685b65707f83956bbae8bd3e338f9286.tar.xz
flashrom: Fix error -EINVAL on mmap()
Don't calculate "flash_baseaddr" until the final value of "size" is known, otherwise we end up trying to map a page right after the end of memory. Fixes #112. Signed-off-by: Segher Boessenkool <segher@kernel.crashing.org> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3502 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/flashrom/flashrom.c')
-rw-r--r--util/flashrom/flashrom.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/util/flashrom/flashrom.c b/util/flashrom/flashrom.c
index 4fd509c3b1..03a8eeb651 100644
--- a/util/flashrom/flashrom.c
+++ b/util/flashrom/flashrom.c
@@ -116,14 +116,6 @@ struct flashchip *probe_flash(struct flashchip *flash, int force)
size = flash->total_size * 1024;
-#ifdef TS5300
- // FIXME: Wrong place for this decision
- // FIXME: This should be autodetected. It is trivial.
- flash_baseaddr = 0x9400000;
-#else
- flash_baseaddr = (0xffffffff - size + 1);
-#endif
-
/* If getpagesize() > size ->
* "Can't mmap memory using /dev/mem: Invalid argument"
* This should never happen as we don't support any flash chips
@@ -139,6 +131,14 @@ struct flashchip *probe_flash(struct flashchip *flash, int force)
size = getpagesize();
}
+#ifdef TS5300
+ // FIXME: Wrong place for this decision
+ // FIXME: This should be autodetected. It is trivial.
+ flash_baseaddr = 0x9400000;
+#else
+ flash_baseaddr = (0xffffffff - size + 1);
+#endif
+
bios = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
fd_mem, (off_t) flash_baseaddr);
if (bios == MAP_FAILED) {