summaryrefslogtreecommitdiffstats
path: root/cbtable.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-02-02 11:09:03 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-02-02 11:09:03 +0000
commitbaaffe083141823923833524f643343b8358e101 (patch)
tree2cb824d732d5628895b9256907cef0b678cbf363 /cbtable.c
parentba7c9228d32da0c080dcb74a526127efeacc137f (diff)
downloadast2050-flashrom-baaffe083141823923833524f643343b8358e101.zip
ast2050-flashrom-baaffe083141823923833524f643343b8358e101.tar.gz
Create a physical memory mapping function which requests cached readonly memory
This should take care of picky Linux kernels which do not allow uncached mappings to cached areas. Handle mapping failure gracefully (no forced exit()) if the caller specifies it. Such cached areas which can handle mapping failure are DMI tables and coreboot tables. On failure we just ignore those tables. That is not perfect, but a lot better than aborting flashrom due to an error in nonessential functionality. This should fix flashrom on a sizable number of machines where it currently aborts early. Yes, I could have exploited a Linux kernel bug to "solve" this, but relying on such bugs is not exactly the best idea. Corresponding to flashrom svn r889. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Vincent Pelletier <plr.vincent@gmail.com>
Diffstat (limited to 'cbtable.c')
-rw-r--r--cbtable.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/cbtable.c b/cbtable.c
index 2611a62..c12354c 100644
--- a/cbtable.c
+++ b/cbtable.c
@@ -6,6 +6,7 @@
* (Written by Eric Biederman <ebiederman@lnxi.com> for Linux Networx)
* Copyright (C) 2006-2009 coresystems GmbH
* (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH)
+ * Copyright (C) 2010 Carl-Daniel Hailfinger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -207,11 +208,15 @@ int coreboot_init(void)
#else
start = 0x0;
#endif
- table_area = physmap("low megabyte", start, BYTES_TO_MAP);
+ table_area = physmap_try_ro("low megabyte", start, BYTES_TO_MAP - start);
+ if (!table_area) {
+ msg_perr("Failed getting access to coreboot low tables.\n");
+ return -1;
+ }
lb_table = find_lb_table(table_area, 0x00000, 0x1000);
if (!lb_table)
- lb_table = find_lb_table(table_area, 0xf0000, BYTES_TO_MAP);
+ lb_table = find_lb_table(table_area, 0xf0000 - start, BYTES_TO_MAP - start);
if (lb_table) {
struct lb_forward *forward = (struct lb_forward *)
(((char *)lb_table) + lb_table->header_bytes);
@@ -219,7 +224,12 @@ int coreboot_init(void)
start = forward->forward;
start &= ~(getpagesize() - 1);
physunmap(table_area, BYTES_TO_MAP);
- table_area = physmap("high tables", start, BYTES_TO_MAP);
+ table_area = physmap_try_ro("high tables", start, BYTES_TO_MAP);
+ if (!table_area) {
+ msg_perr("Failed getting access to coreboot "
+ "high tables.\n");
+ return -1;
+ }
lb_table = find_lb_table(table_area, 0x00000, 0x1000);
}
}
OpenPOWER on IntegriCloud