summaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorPeter Stuge <peter@stuge.se>2009-01-23 05:23:06 +0000
committerPeter Stuge <peter@stuge.se>2009-01-23 05:23:06 +0000
commitccf8c6c79444108b45ed82d96b18cbdb6a8d2cff (patch)
treeb7417fb2e24f15ed90e8102301ff365a71852878 /flashrom.c
parent72c9668b9535bfe40d3e321faa26cfe5bb9a44b3 (diff)
downloadast2050-flashrom-ccf8c6c79444108b45ed82d96b18cbdb6a8d2cff.zip
ast2050-flashrom-ccf8c6c79444108b45ed82d96b18cbdb6a8d2cff.tar.gz
Check all mmap() calls and print helpful Linux error message
Corresponding to flashrom svn r386 and coreboot v2 svn r3890. Signed-off-by: Peter Stuge <peter@stuge.se> Acked-by: Peter Stuge <peter@stuge.se>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/flashrom.c b/flashrom.c
index 7e52fbc..26585fb 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -84,6 +84,17 @@ struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
return NULL;
}
+void mmap_errmsg()
+{
+ if (EINVAL == errno) {
+ fprintf(stderr, "In Linux this error can be caused by the CONFIG_NONPROMISC_DEVMEM (<2.6.27),\n");
+ fprintf(stderr, "CONFIG_STRICT_DEVMEM (>=2.6.27) and CONFIG_X86_PAT kernel options.\n");
+ fprintf(stderr, "Please check if either is enabled in your kernel before reporting a failure.\n");
+ fprintf(stderr, "You can override CONFIG_X86_PAT at boot with the nopat kernel parameter but\n");
+ fprintf(stderr, "disabling the other option unfortunately requires a kernel recompile. Sorry!\n");
+ }
+}
+
int map_flash_registers(struct flashchip *flash)
{
volatile uint8_t *registers;
@@ -94,6 +105,7 @@ int map_flash_registers(struct flashchip *flash)
if (registers == MAP_FAILED) {
perror("Can't mmap registers using " MEM_DEV);
+ mmap_errmsg();
exit(1);
}
flash->virtual_registers = registers;
@@ -139,13 +151,7 @@ struct flashchip *probe_flash(struct flashchip *first_flash, int force)
fd_mem, (off_t) base);
if (bios == MAP_FAILED) {
perror("Can't mmap memory using " MEM_DEV);
- if (EINVAL == errno) {
- fprintf(stderr, "In Linux this error can be caused by the CONFIG_NONPROMISC_DEVMEM (<2.6.27),\n");
- fprintf(stderr, "CONFIG_STRICT_DEVMEM (>=2.6.27) and CONFIG_X86_PAT kernel options.\n");
- fprintf(stderr, "Please check if either is enabled in your kernel before reporting a failure.\n");
- fprintf(stderr, "You can override CONFIG_X86_PAT at boot with the nopat kernel parameter but\n");
- fprintf(stderr, "disabling the other option unfortunately requires a kernel recompile. Sorry!\n");
- }
+ mmap_errmsg();
exit(1);
}
flash->virtual_memory = bios;
OpenPOWER on IntegriCloud