[coreboot] r3502 - trunk/util/flashrom

svn at coreboot.org svn at coreboot.org
Tue Aug 12 13:58:01 CEST 2008


Author: segher
Date: 2008-08-12 13:58:00 +0200 (Tue, 12 Aug 2008)
New Revision: 3502

Modified:
   trunk/util/flashrom/flashrom.c
Log:
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 at kernel.crashing.org>
Acked-by: Stefan Reinauer <stepan at coresystems.de>


Modified: trunk/util/flashrom/flashrom.c
===================================================================
--- trunk/util/flashrom/flashrom.c	2008-08-11 20:35:32 UTC (rev 3501)
+++ trunk/util/flashrom/flashrom.c	2008-08-12 11:58:00 UTC (rev 3502)
@@ -116,14 +116,6 @@
 
 		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 @@
 			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) {





More information about the coreboot mailing list